diff --git a/lib/Note.lib.php b/lib/Note.lib.php index f6a6931..bb51a8a 100644 --- a/lib/Note.lib.php +++ b/lib/Note.lib.php @@ -192,10 +192,11 @@ class Note { */ public function getCleanTitle(): string { $title = $this->getTitle(); - $title = str_replace("*", "", $title); - $title = str_replace("#", "", $title); - $title = str_replace("_", "", $title); - $title = str_replace("`", "", $title); + $title = str_replace(["*", "#", "_", "`"], "", $title); + $title = preg_replace([ + "/^- \[ \] /m", + "/^- \[x\] /m" + ], "", $title); return trim($title); } @@ -333,15 +334,15 @@ class Note { $text = explode("\n", $this->getText()); $item = trim(str_replace("\n", "", $item)); for ($i = 0; $i < count($text); $i++) { - if (!preg_match("/^- \[[Xx ]\] .*/", $text[$i])) { + if (!preg_match("/^- \[[x ]\] .*/", $text[$i])) { continue; } - $linecleaned = trim(preg_replace("/^- \[[Xx ]\] /", "", $text[$i])); + $linecleaned = trim(preg_replace("/^- \[[x ]\] /", "", $text[$i])); if ($item != $linecleaned) { continue; } - if (preg_match("/^- \[[Xx]\] .*/", $text[$i])) { - $text[$i] = preg_replace("/^- \[[Xx]\] /", "- [ ] ", $text[$i]); + if (preg_match("/^- \[[x]\] .*/", $text[$i])) { + $text[$i] = preg_replace("/^- \[[x]\] /", "- [ ] ", $text[$i]); } else if (preg_match("/^- \[ \] .*/", $text[$i])) { $text[$i] = preg_replace("/^- \[ \] /", "- [x] ", $text[$i]); }