aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-01-27 06:59:37 -0500
committerGravatar Peter McGoron 2025-01-27 06:59:37 -0500
commitdb3c450a9279f54229775fb27512a032cd959a54 (patch)
treeb1863dcc6fde1a32c21fbc9fde6a622b166b2577
parentexpand starts and continues by adding current node as argument (diff)
fix spurious newlines
-rw-r--r--market/blocks.scm2
-rw-r--r--market/default.scm2
-rw-r--r--tests/run.scm20
3 files changed, 20 insertions, 4 deletions
diff --git a/market/blocks.scm b/market/blocks.scm
index 91319ce..0d0b7d2 100644
--- a/market/blocks.scm
+++ b/market/blocks.scm
@@ -126,5 +126,5 @@
((get-active-child node)
=> (cut process-active-child node line <>))
((allowed-inside node line) first-arg => parse-line-to-node!)
- (else (add-new-paragraph node line))))
+ ((not (empty-line? line)) (add-new-paragraph node line))))
diff --git a/market/default.scm b/market/default.scm
index 85a1e53..9ea1fa1 100644
--- a/market/default.scm
+++ b/market/default.scm
@@ -145,7 +145,7 @@
(list-queue (line->xstring line))
#f)))
(add-new-child! node new-node #f)
- (values node line)))
+ (values node (empty-line))))
(let detect ((line line)
(indent 0))
(cond
diff --git a/tests/run.scm b/tests/run.scm
index 4e8c8ae..87cbfa3 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -79,7 +79,7 @@
(list-ref _ 0)
(xstring->string _))))
(test-equal "two lines" str "hello,\nworld\n"))
- (test-group "multiple paragraphs"
+ (test-group "multiple paragraphs in block quote"
(let ((lst (chain (parse->document "> hello")
(parse->document "> " _)
(parse->document "> world" _)
@@ -94,13 +94,29 @@
(test-equal "second paragraph"
(xstring->string (list-ref lst 1))
"world\n")))
+ (test-group "interrupted by paragraph break"
+ (let ((lst (chain (parse->document "> hello,")
+ (parse->document "" _)
+ (parse->document "world" _)
+ (node-children _)
+ (list-queue-list _))))
+ (test-assert "first is block quote" (block-quote? (list-ref lst 0)))
+ (let ((quote-par (chain (list-ref lst 0)
+ (node-children _)
+ (list-queue-list _)
+ (list-ref _ 0)
+ (xstring->string _))))
+ (test-equal "quote text" "hello,\n" quote-par))
+ (let ((text (chain (list-ref lst 1)
+ (xstring->string _))))
+ (test-equal "paragraph text" "world\n" text))))
(test-group "interrupted"
(let ((lst (chain (parse->document "> hello, world")
(parse->document "outside of a block quote" _)
(node-children _)
(list-queue-list _))))
(test-assert "first is block quote"
- (block-node? (list-ref lst 0)))
+ (block-quote? (list-ref lst 0)))
(let ((quote-paragraph (chain (list-ref lst 0)
(node-children _)
(list-queue-list _)