From 707916075efadc55ce432095c333b3025cd01321 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 23 Jul 2024 18:19:26 +0300 Subject: (single) Implemented reaodnly task lists --- demo/src/index.md | 2 ++ single.awk | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/demo/src/index.md b/demo/src/index.md index 7b37979..2032b72 100644 --- a/demo/src/index.md +++ b/demo/src/index.md @@ -101,3 +101,5 @@ Lorem `ipsum` dolor tiada ad;l ``kfj `skigj`` jjsa ![](https://syndamia.com/favicon.ico) ![](https://syndamia.com/favicon.ico "Hello") ![World](https://syndamia.com/favicon.ico) ![Hello](https://syndamia.com/favicon.ico "World") +- [ ] *A* +- [x] **B** diff --git a/single.awk b/single.awk index ac2eb7a..415e042 100644 --- a/single.awk +++ b/single.awk @@ -27,7 +27,7 @@ # [x] Superscript ^...^ # [x] Subscript ~...~ # [ ] Footnote [^...] (with user customizations) -# [ ] Task list - [ ] +# [x] Task list - [ ] (readonly) # [.] Definition lists # [x] Single line # [ ] Multi-line @@ -187,6 +187,14 @@ function autoinsert(arrname, isbefore) { /^( |\t)[ \t]*/ { } +# Check boxes +/^[ \t]*- \[[ x]\][ \t]/ { + match($0, /- \[[ x]\][ \t]/) + if (substr($0, RSTART + 3, 1) == "x") checked = " checked=\"checked\"" + else checked = "" + $0 = "" substr($0, RSTART + RLENGTH) "
" +} + # Unordered lists function abs(x) { return ((x < 0) ? -x : x) } !blankline && lengthStack("list-level") > 0 { -- cgit v1.3.1-26-gb76a