Commit Diff
Diff:
efb35fc6373ee692ad40c6b1d64210513de03df9
588b55fbdbdb143bad22870345f7d91d8e7b7bf5
Commit:
588b55fbdbdb143bad22870345f7d91d8e7b7bf5
Tree:
a5f56abe911792c7b71018db4770cf9a990ce514
Author:
Omar Polo <op@omarpolo.com>
Date:
Mon Jan 17 09:14:15 2022 UTC
Message:
Handle gracefully invalid link lines

`=>` without other fields is not a valid link line, so let's handle it
by parsing it as a paragraph with the "=>" text in it.
commit - efb35fc6373ee692ad40c6b1d64210513de03df9
commit + 588b55fbdbdb143bad22870345f7d91d8e7b7bf5
blob - 8f7ef80c7d9ea7898c1a60b309b76b2d1c4c6c45
blob + 564a9499b29181fc2547d366882a4af7c680f7a7
--- gemtext.lisp
+++ gemtext.lisp
@@ -44,7 +44,10 @@
:text (strim s 2)))
((prefix-p "#" s) (make-instance 'title :level 1
:text (strim s 1)))
- ((prefix-p "=>" s) (parse-link (strim s 2)))
+ ((prefix-p "=>" s) (let ((s (strim s 2)))
+ (if (string-equal s "")
+ (make-instance 'paragraph :text "=>")
+ (parse-link s))))
((prefix-p "* " s) (make-instance 'item :text (strim s 1)))
((prefix-p ">" s) (make-instance 'blockquote :text (strim s 1)))
(t (make-instance 'paragraph :text (strim s 0))))))
blob - 11c6d0387a8ca0645c1dba062371db92eb4432dd
blob + 3a463a0593a373047b354add2c06b13dd0c2c74f
--- t/gemtext-tests.lisp
+++ t/gemtext-tests.lisp
@@ -22,6 +22,9 @@
("###title" . ,(make-instance 'gemtext:title
:text "title"
:level 3))
+ ;; handle gracefully invalid link lines
+ ("=>" . ,(make-instance 'gemtext:paragraph
+ :text "=>"))
("=>/foo" . ,(make-instance 'gemtext:link
:url (quri:uri "/foo")))
("=> /foo bar" . ,(make-instance 'gemtext:link
Omar Polo