summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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