From 4037070fc49a550e56c122aabdd01793210ccf60 Mon Sep 17 00:00:00 2001 From: Ruben Berenguel Montoro Date: Sat, 9 Nov 2024 10:26:18 +0100 Subject: [PATCH] Additional project feature --- .vscode/ltex.disabledRules.en-US.txt | 1 + lib/common.js | 1 + lib/taskUtils.js | 27 ++++++++++++++++++--------- style.css | 6 +++--- 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 .vscode/ltex.disabledRules.en-US.txt diff --git a/.vscode/ltex.disabledRules.en-US.txt b/.vscode/ltex.disabledRules.en-US.txt new file mode 100644 index 0000000..100d541 --- /dev/null +++ b/.vscode/ltex.disabledRules.en-US.txt @@ -0,0 +1 @@ +COMMA_PARENTHESIS_WHITESPACE diff --git a/lib/common.js b/lib/common.js index 308a347..43254ad 100644 --- a/lib/common.js +++ b/lib/common.js @@ -21,6 +21,7 @@ const numMojis = [ ]; const linkRegex = /\[(.*?)\]\((.*?)\)/; +const linkPlusRegex = /\[(.*?)\]\((.*?)\)\s+(.*)/; function toTop(div) { const allDivs = document.querySelectorAll("div"); diff --git a/lib/taskUtils.js b/lib/taskUtils.js index a05c714..715d318 100644 --- a/lib/taskUtils.js +++ b/lib/taskUtils.js @@ -131,9 +131,10 @@ function textToTaskObject(text) { obj.done = true; cleaned = cleaned.slice(3); } - const linkMatch = cleaned.match(linkRegex); + const linkMatch = cleaned.match(linkPlusRegex); if (linkMatch) { - obj.text = linkMatch[1]; + console.log(linkMatch); + obj.text = linkMatch[1] + (linkMatch[3] ?? ""); obj.link = linkMatch[2]; } else { obj.text = cleaned; @@ -231,7 +232,7 @@ function tasksFromMarkdown(paths, cb) { tasks.push(obj); } return tasks; - }) + }), ); }); @@ -327,7 +328,7 @@ function addTasksToDiv(_tasks, targetDivId) { const taskExtra = d(); taskText.classList.add("taskText"); const taskTitle = d(); - taskText.appendChild(taskTitle) + taskText.appendChild(taskTitle); taskExtra.classList.add("taskExtra"); let text = task.text.replace("#kr", "✨ #kr"); const extra = task.extra ? task.extra : ""; @@ -352,12 +353,20 @@ function addTasksToDiv(_tasks, targetDivId) { pproj = [_p]; } const color = colors[i % colors.length]; + for (let proj of pproj) { + const full = `.${proj}`; const adjColor = `color-mix(in srgb, var(${color}) 98%, var(--light) 2%)`; - text = text.replace( - proj, - `${proj}` - ); + console.log(text); + if (text.endsWith(full)) { + text = text.replace(full, ""); + text = `${text}`; + } else { + text = text.replace( + proj, + `${proj}`, + ); + } } } taskTitle.innerHTML = text; @@ -382,7 +391,7 @@ function addTasksToDiv(_tasks, targetDivId) { } const allHighlights = allRows.filter((r) => - r.classList.contains("highlight") + r.classList.contains("highlight"), ); if (allHighlights.length == 0) { diff --git a/style.css b/style.css index 15ebefe..02750e8 100644 --- a/style.css +++ b/style.css @@ -162,7 +162,7 @@ iframe { margin-right: 1em; } -.taskText > strong { +.taskText > div > strong { text-shadow: -0.06em -0.06em 0; } @@ -224,7 +224,7 @@ span[data-title]:hover::after { .taskRow.highlight { padding-left: 2em; - filter: saturate(1.2) brightness(1.2);; + filter: saturate(1.2) brightness(1.2); } .taskRow.dim { @@ -276,7 +276,7 @@ span[data-title]:hover::after { color: var(--light-grey-trans) !important; } -.done .taskText > strong { +.done .taskText > div > strong { color: var(--light-grey-trans) !important; text-shadow: none !important; }