cripslock

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

commit 0d1debaa161e3a846ccca80fbe1da6d220758e08
parent 9ada974c1098f268ac61bebca906bf3770d9d698
Author: Daniel Barlow <dan@telent.net>
Date:   Tue,  5 Aug 2025 18:25:01 +0100

textile: fix whitespace-related bugs

* we have to treat \r as a space
* use the `whitespace` match instead of a literal " " in more places

Diffstat:
Mtextile.fnl | 21+++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/textile.fnl b/textile.fnl @@ -152,7 +152,8 @@ 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)))) + whitespace (+ loc.space (P "\r")) + start-or-space (+ (B whitespace) (- (B (P 1)))) recurse #(merge-strings (inline-parser:match $1))] (P { 1 :elements @@ -168,20 +169,20 @@ la :emph (* start-or-space (P "_") - (/ (except (P "_")) #(prepend :em (recurse $1))) - (P "_")) + (/ (except (P "_")) #(prepend :em (recurse $1))) + (P "_")) :strong (* (P "*") (/ (except (P "*")) #(prepend :strong (recurse $1))) (P "*")) - :del (* (B loc.space) + :del (* start-or-space (P "-") - (/ (* (- (P 1) (S " -")) (except (P "-"))) + (/ (* (- (P 1) (+ whitespace " ")) (except (P "-"))) #(prepend :del (recurse $1))) (P "-")) - :code (* (B (S " (")) + :code (* (B (+ whitespace "(")) (P "@") (/ (except (P "@")) #[:code $1]) (P "@")) @@ -381,7 +382,15 @@ headers so that i only get access to the glibc version - especially" 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 "]]) + (expect= (parse-string +"was immensely cheered to find that none of the other interviewees -\r +interesting people, great hackers and luminaries among them - were\r +") + [["p" + "was immensely cheered to find that none of the other interviewees -\r +interesting people, great hackers and luminaries among them - were\r +"]]) (fn convert [name] (with-open [f (assert (io.open name :r))]