aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2025-02-04 10:26:28 -0500
committerGravatar Peter McGoron 2025-02-04 10:26:28 -0500
commitcbb20bcbeb3be06ddfa880bf826f345a9df950c5 (patch)
tree39722dc5773a3d26c6d250fde23a10d34baea92d
parentChange handling of paragraph breaks, compress tests (diff)
Rewrite tests to conform to greedy behavior for paragraph breaksHEADmaster
Paragraph breaks will be associated with the deepest child that will accept them. These paragraph breaks can be moved around in a post-processing pass over the tree (which must happen anyways to parse inline syntax). This also allows for child-type-dependent processing of paragraph breaks.
-rw-r--r--market/blocks.scm7
-rw-r--r--tests/run.scm15
2 files changed, 15 insertions, 7 deletions
diff --git a/market/blocks.scm b/market/blocks.scm
index a065ab4..894e824 100644
--- a/market/blocks.scm
+++ b/market/blocks.scm
@@ -100,6 +100,13 @@
;; Check if `line` continues `child`. If not, check if `line` is
;; allowed inside this node. If not, check if line is a paragraph
;; break. If not, add the line as a paragraph.
+ ;;
+ ;; Note that in cases where lazy paragraph breaks are allowed (i.e. in
+ ;; list elements), all paragraph breaks at the end of a block are
+ ;; associated with the block, and not with the parent node, which is
+ ;; where the breaks should occur. Although semantically incorrect,
+ ;; this can be fixed in another pass (which must be done anyways to
+ ;; parse inline syntax).
(cond
((continues active-child line) => (cut parse-line-to-node! active-child <>))
((allowed-inside node line) first-arg => (cut parse-line-to-node! <...>))
diff --git a/tests/run.scm b/tests/run.scm
index d903454..bbfba4c 100644
--- a/tests/run.scm
+++ b/tests/run.scm
@@ -349,15 +349,15 @@
(test-parse->document "* hello,")
(test-parse->document "" _)
(test-parse->document "world" _)
- (test-node-list "document children" 3 _)
+ (test-node-list "document children" 2 _)
(fork
"list item"
_
(chain-lambda (test-child "list item" unordered-list-item? 0 _)
- (test-node-list "items" 1 _)
- (test-child-string "xstring?" 0 "hello,\n" _)))
- (test-paragraph-break "break" 1 _)
- (test-child-string "paragraph" 2 "world\n" _))
+ (test-node-list "items" 2 _)
+ (test-child-string "xstring?" 0 "hello,\n" _)
+ (test-paragraph-break "break" 1 _)))
+ (test-child-string "paragraph" 1 "world\n" _))
(with-test-chain "multiple list elements"
(test-parse->document "* h")
(test-parse->document " el" _)
@@ -456,7 +456,7 @@
_
(chain-lambda (test-child "unordered list?" unordered-list-item? 0 _)
(test-node-list "children" 1 _)
- (test-child-string "xstring?" 0 "hello\n")))
+ (test-child-string "xstring?" 0 "hello\n" _)))
(fork
"thematic break"
_
@@ -465,7 +465,8 @@
"third list item"
_
(chain-lambda (test-child "unordered list?" unordered-list-item? 2 _)
- (test-node-list "children" 1 "world\n" _))))
+ (test-node-list "children" 1 _)
+ (test-child-string "xstring?" 0 "world\n" _))))
(with-test-chain "interrupt paragraph"
(test-parse->document "hello")
(test-parse->document "***" _)