🚧 WIP: add six extended formats to the task lists

This commit is contained in:
Cell
2024-11-01 15:02:01 +08:00
parent 867984fda2
commit 8fa3538725
3 changed files with 57 additions and 8 deletions
+3 -1
View File
@@ -1,7 +1,7 @@
:root {
// Note: Custom variable values only support SassScript inside `#{}`.
// Theme colors varibles
// Theme colors variables
@each $color, $value in $theme-colors {
--#{$prefix}#{$color}: #{$value};
}
@@ -22,6 +22,8 @@
--#{$prefix}scrollbar-track-color: transparent;
--#{$prefix}scrollbar-width: thin;
--#{$prefix}scrollbar-width-legacy: 12px;
// TODO migrate SCSS variables to CSS variables
}
// Dark theme
+32
View File
@@ -230,6 +230,38 @@
ul {
list-style-type: disc;
// Task lists
li[data-task] {
list-style: none;
margin-left: -1.5rem;
}
}
// Task lists
li[data-task] {
color: var(--#{$prefix}task-color);
.checkbox-icon {
margin-right: 0.25em;
color: var(--#{$prefix}checkbox-color);
}
}
li[data-task='x'],
li[data-task='-'] {
--#{$prefix}task-color: var(--#{$prefix}secondary);
text-decoration: line-through;
}
li[data-task='x'] {
--#{$prefix}checkbox-color: var(--#{$prefix}primary);
}
li[data-task='/'] {
--#{$prefix}task-color: var(--#{$prefix}success);
}
li[data-task='!'] {
--#{$prefix}checkbox-color: var(--#{$prefix}danger);
}
li[data-task='?'] {
--#{$prefix}checkbox-color: var(--#{$prefix}warning);
}
dl {
+22 -7
View File
@@ -4,14 +4,20 @@
{{- $iconMap := dict
" " "fa-regular fa-square"
"x" "fa-solid fa-check-square"
">" "fa-solid fa-calendar"
"<" "fa-solid fa-calendar-check"
"/" "fa-regular fa-square"
"-" "fa-solid fa-square-xmark"
"<" "fa-regular fa-calendar-plus"
">" "fa-regular fa-calendar-minus"
"!" "fa-solid fa-circle-exclamation"
"\\?" "fa-regular fa-circle-question"
-}}
{{- $extendedSigns := slice -}}
{{- range $sign, $icon := $iconMap -}}
{{- $extendedSigns = $extendedSigns | append $sign -}}
{{- end -}}
{{- /* TODO merge from config */ -}}
{{- /*
The basic syntax is compatible with GitHub, Obsidian, and Typora.
The basic format is as follows:
@@ -19,20 +25,29 @@
- [x] Checked
*/ -}}
{{- $icon := dict "Class" (add "checkbox-icon fa-fw " (index $iconMap " ")) | partial "plugin/icon.html" -}}
{{- $content := replaceRE `<li><input disabled="" type="checkbox"> (.+?)</li>` (printf `<li data-task=" ">%s $1</li>` $icon) . -}}
{{- $label := T (printf "taskList.%v" " ") -}}
{{- $content := replaceRE `<li><input disabled="" type="checkbox"> (.+?)</li>` (printf `<li data-task=" " title=%q>%s$1</li>` $label $icon) . -}}
{{- $label := T (printf "taskList.%v" "x") -}}
{{- $icon := dict "Class" (add "checkbox-icon fa-fw " (index $iconMap "x")) | partial "plugin/icon.html" -}}
{{- $content = replaceRE `<li><input checked="" disabled="" type="checkbox"> (.+?)</li>` (printf `<li data-task="x">%s $1</li>` $icon) $content -}}
{{- $content = replaceRE `<li><input checked="" disabled="" type="checkbox"> (.+?)</li>` (printf `<li data-task="x" title=%q>%s$1</li>` $label $icon) $content -}}
{{- /*
The extended syntax is compatible with Obsidian.
The extended format is as follows:
- [>] Scheduled
- [<] Rescheduled
- [-] Cancelled
- [/] In Progress
- [<] Scheduled
- [>] Rescheduled
- [!] Important
- [?] Question
*/ -}}
{{- range $extendedSigns -}}
{{- $class := index $iconMap . | default "fa-solid fa-check-square" -}}
{{- $icon := dict "Class" (add "checkbox-icon fa-fw " $class) | partial "plugin/icon.html" -}}
{{- $content = replaceRE (printf `<li>\[%s\] (.+?)</li>` (htmlEscape .)) (printf `<li data-task="%s">%s $1</li>` . $icon) $content -}}
{{- $sign := htmlEscape . -}}
{{- $originSign := replace . "\\" "" -}}
{{- $label := (T (printf "taskList.%v" $originSign)) | default (T (printf "taskList.%v" " ")) -}}
{{- $content = replaceRE (printf `<li>\[%s\] (.+?)</li>` $sign) (printf `<li data-task=%q title=%q>%s$1</li>` $originSign $label $icon) $content -}}
{{- end -}}
{{- return $content -}}