cripslock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit bbaaaa358e463574942aad2d400ca0238a29cc49
parent 6484345a0eec47265d1b056036510e152be343bb
Author: Daniel Barlow <dan@telent.net>
Date:   Tue,  5 Aug 2025 18:03:01 +0100

textile: don't emph underscore in middle of word

emph pattern can only occur at the start of the string or after
whitespace

Diffstat:
Mtextile.fnl | 18+++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/textile.fnl b/textile.fnl @@ -152,6 +152,7 @@ la (let [{ : P : V : C : B : Cp : Ct : S} lpeg special (S "_*\"@-") except (fn [x] (^ (- (P 1) x) 1)) + start-or-space (+ (B loc.space) (- (B (P 1)))) recurse #(merge-strings (inline-parser:match $1))] (P { 1 :elements @@ -165,7 +166,8 @@ la (V :del) (C special)) - :emph (* (P "_") + :emph (* start-or-space + (P "_") (/ (except (P "_")) #(prepend :em (recurse $1))) (P "_")) @@ -196,6 +198,7 @@ la (expect= (inline-markup "") []) (expect= (inline-markup "foo") ["foo"]) + (expect= (inline-markup "_emph_") [[:em "emph"] ]) (expect= (inline-markup "foo _emph_") ["foo " [:em "emph"] ]) (expect= (inline-markup "foo -struck-") ["foo " [:del "struck"] ]) (expect= (inline-markup "foo @1+2+3@") ["foo " [:code "1+2+3"] ]) @@ -364,6 +367,19 @@ filesystem. "]) (define-tests :parse-stream + (expect= (parse-string "h1. Hi") [[:h1 "Hi\n"]]) + (expect= (parse-string +"kernel about the size of sigset_t; given that the kernel puts its idea +ofa sigset_t onto my stack, it seems a trifle unsporting to arrange +headers so that i only get access to the glibc version - especially" +) + [["p" + "kernel about the size of sigset_t; given that the kernel puts its idea +ofa sigset_t onto my stack, it seems a trifle unsporting to arrange +headers so that i only get access to the glibc version - especially +"]]) + + (fn convert [name] (with-open [f (assert (io.open name :r))] (with-open [out (assert (io.tmpfile))]