cripslock

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

commit 249e6c335b5a67b1d498bd819861ea1bf0d4b075
parent 2d7b92b23ba794d90cf8e3e785df461311a691cd
Author: Daniel Barlow <dan@telent.net>
Date:   Sat,  9 Aug 2025 19:45:40 +0100

textile: accept \r\n as line terminator when splitting paras

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

diff --git a/textile.fnl b/textile.fnl @@ -13,6 +13,7 @@ (fn extract-blocks [doc] (let [{ : P : C : Ct : V } lpeg eof (- (P 1)) + end-para (^ (+ (P "\r\n") (P "\n")) 2) p (P { 1 :doc :doc (* (^ (P "\n") 0) (/ (^ (V :block) 1) #[$...])) @@ -24,8 +25,9 @@ :pre-body (/ (^ (- (P 1) (P "</pre>")) 1) #(.. "pre. " $1)) - :para (* (/ (^ (- (P 1) (P "\n\n")) 1) #(.. $1 "\n")) - (+ (^ (P "\n") 2) eof)) + :para (* (/ (^ (- (P 1) end-para) 1) #(.. $1 "\n")) + (+ end-para + eof)) })] (p:match doc))) @@ -46,6 +48,8 @@ (expect= (. paras 2) "this is\nalso a paragraph\n"))) (expect= (extract-blocks "\n\n\nfirst para after some blank lines\n") ["first para after some blank lines\n\n"]) + (expect= (extract-blocks "first line\r\nsecond line\r\n\r\nsecond para\r\n") + ["first line\r\nsecond line\n" "second para\r\n\n"]) (expect= (extract-blocks "a para <pre>