mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
56 lines
2.2 KiB
HTML
56 lines
2.2 KiB
HTML
{{- /* Task lists rendering */ -}}
|
|
{{- /* If Hugo supports the list rendering hook, refactor this snippet. */ -}}
|
|
|
|
{{- $iconMap := dict
|
|
" " "fa-regular fa-square"
|
|
"x" "fa-solid fa-check-square"
|
|
"/" "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"
|
|
-}}
|
|
{{- /* Custom Task lists */ -}}
|
|
{{- $iconMap = site.Params.taskList | merge $iconMap -}}
|
|
|
|
{{- /* Get the extended signs */ -}}
|
|
{{- $extendedSigns := slice -}}
|
|
{{- range $sign, $icon := $iconMap -}}
|
|
{{- $extendedSigns = $extendedSigns | append $sign -}}
|
|
{{- end -}}
|
|
|
|
{{- /*
|
|
The basic syntax is compatible with GitHub, Obsidian, and Typora.
|
|
The basic format is as follows:
|
|
- [ ] Unchecked
|
|
- [x] Checked
|
|
*/ -}}
|
|
{{- $icon := dict "Class" (index $iconMap " ") | partial "plugin/icon.html" -}}
|
|
{{- $label := T (printf "taskList.%v" " ") -}}
|
|
{{- $content := replaceRE `(?s)<li>((\n<p>)*)<input disabled="" type="checkbox">\s?([\s\S]*?)(<ul|<ol|</li>)` (printf `<li data-task=" ">$1%s<span title=%q>$3</span>$4` $icon $label) . -}}
|
|
{{- $label := T (printf "taskList.%v" "x") -}}
|
|
{{- $icon := dict "Class" (index $iconMap "x") | partial "plugin/icon.html" -}}
|
|
{{- $content = replaceRE `(?s)<li>((\n<p>)*)<input checked="" disabled="" type="checkbox">\s?([\s\S]*?)(<ul|<ol|</li>)` (printf `<li data-task="x">$1%s<span title=%q>$3</span>$4` $icon $label) $content -}}
|
|
|
|
{{- /*
|
|
The extended syntax is compatible with Obsidian.
|
|
The extended format is as follows:
|
|
- [-] Cancelled
|
|
- [/] In Progress
|
|
- [<] Scheduled
|
|
- [>] Rescheduled
|
|
- [!] Important
|
|
- [?] Question
|
|
*/ -}}
|
|
{{- range $extendedSigns -}}
|
|
{{- $class := index $iconMap . | default "fa-solid fa-check-square" -}}
|
|
{{- $icon := dict "Class" $class | partial "plugin/icon.html" -}}
|
|
{{- $sign := htmlEscape . -}}
|
|
{{- $originSign := replace . "\\" "" -}}
|
|
{{- $label := (T (printf "taskList.%v" $originSign)) | default (T (printf "taskList.%v" " ")) -}}
|
|
{{- $content = replaceRE (printf `(?s)<li>((\n<p>)*)\[%s\]\s?([\s\S]*?)(<ul|<ol|</li>)` $sign) (printf `<li data-task=%q>$1%s<span title=%q>$3</span>$4` $originSign $icon $label) $content -}}
|
|
{{- end -}}
|
|
|
|
{{- return $content -}}
|