Remove todo list markup from clean title

master
Skylar Ittner 5 years ago
parent 18bc8b1f4b
commit 6cb23163bf

@ -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]);
}

Loading…
Cancel
Save