summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-04-15 13:54:53 +0100
committerArun Isaac2023-04-15 13:54:53 +0100
commit254c966d8c809b57e420fdee29876e0439a29a53 (patch)
tree2bec9c4d2d9f84af30e0701d33257de479143417
parentec825e7abc430c2389f9af46cccdfc2be585a90a (diff)
downloadtissue-254c966d8c809b57e420fdee29876e0439a29a53.tar.gz
tissue-254c966d8c809b57e420fdee29876e0439a29a53.tar.lz
tissue-254c966d8c809b57e420fdee29876e0439a29a53.zip
issue: Ignore preformatted blocks.
* tissue/issue.scm (file-details): Ignore preformatted blocks. * tests/issue.scm ("Ignore preformatted block"): New test. * issues/ignore-preformatted-blocks-in-gemtext-parser.gmi: Close issue.
-rw-r--r--issues/ignore-preformatted-blocks-in-gemtext-parser.gmi2
-rw-r--r--tests/issue.scm7
-rw-r--r--tissue/issue.scm8
3 files changed, 16 insertions, 1 deletions
diff --git a/issues/ignore-preformatted-blocks-in-gemtext-parser.gmi b/issues/ignore-preformatted-blocks-in-gemtext-parser.gmi
index 6ff78e3..ce05091 100644
--- a/issues/ignore-preformatted-blocks-in-gemtext-parser.gmi
+++ b/issues/ignore-preformatted-blocks-in-gemtext-parser.gmi
@@ -4,3 +4,5 @@
Our gemtext parser does not ignore preformatted blocks. Case in point is the parser wrongly identifying the issue allow-checkboxes-without-a-space.gmi as having a task list.
=> allow-checkboxes-without-a-space
+
+* closed
diff --git a/tests/issue.scm b/tests/issue.scm
index 53d908f..97541a0 100644
--- a/tests/issue.scm
+++ b/tests/issue.scm
@@ -98,4 +98,11 @@ strings."
(call-with-input-string "* [] foo"
(compose hashtable->alist file-details)))
+(test-equal "Ignore preformatted block"
+ '()
+ (call-with-input-string "```
+# foo
+```"
+ (compose hashtable->alist file-details)))
+
(test-end "issue")
diff --git a/tissue/issue.scm b/tissue/issue.scm
index fd4a852..14bd75f 100644
--- a/tissue/issue.scm
+++ b/tissue/issue.scm
@@ -214,9 +214,15 @@ return #f."
(define (file-details port)
"Return a hashtable of details extracted from input PORT reading a
gemtext file."
- (let ((result (make-eq-hashtable)))
+ (let ((result (make-eq-hashtable))
+ (in-preformatted #f))
(port-transduce (tmap (lambda (line)
(cond
+ ;; Toggle preformatted state.
+ ((string=? "```" line)
+ (set! in-preformatted (not in-preformatted)))
+ ;; Ignore preformatted blocks.
+ (in-preformatted #t)
;; Checkbox lists are tasks. If the
;; checkbox has any character other
;; than space in it, the task is