commit f8e35511ea77434317517ab32b07dfe454889c34
parent b9c3ac6a07bceae9c1136a47f871085f313830b1
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 21 Jul 2025 14:12:06 +0100
textile: recognise inline markup only when adjacent to words
this is -strikethrough- here
this - however - is not
Diffstat:
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/textile.fnl b/textile.fnl
@@ -105,18 +105,19 @@
})
(local inline-token-pattern
- (.. "(["
+ (.. "%f[%g](["
(accumulate [chrs ""
c _ (pairs inline-tokens)]
(.. "%" (string.sub c 1 1) chrs))
- "])"))
+ "])%g"))
(fn inline-markup [str]
(if (or (not str) (= str ""))
nil
(case (string.find str inline-token-pattern)
- (start end tok)
- (let [(during after)
+ (start _end tok)
+ (let [end (+ start -1 (# tok))
+ (during after)
((. inline-tokens tok) inline-markup (string.sub str end))
marked-after (or (inline-markup after) [])]
(if (> start 1)
@@ -142,7 +143,11 @@
;; markup in code blocks is ignored
(expect= (inline-markup "foo @1+_2_+3@") ["foo " [:code "1+_2_+3"] ])
- (expect= (inline-markup "foo@example.com") ["foo" "@example.com" ])
+ (expect= (inline-markup "I have - and this is an aside - no strikethrough")
+ ["I have - and this is an aside - no strikethrough"])
+
+ (expect= (inline-markup "foo@example.com") ["foo@example.com" ])
+ (expect= (inline-markup "foo @ example.com") ["foo @ example.com" ])
(expect= (inline-markup "say \"hello\" to my friend")
["say " "\"hello\" to my friend"])