You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix lone marker line wrongly starting a block in significantNewlines mode (#180)
In significantNewlines mode, a hard-wrapped prose line beginning with
-, *, +, > or | was unconditionally treated as a list/blockquote/table,
turning arithmetic and comparison expressions into spurious blocks:
Die Frage ist, wann ist x = 5
* 3 + 17 wahr.
became a paragraph followed by a bullet list. The bullet, blockquote
and table branches of startsNewBlockSignificant() had no "is this a
real block?" guard, unlike the ordered-list branch which already
restricts interruption to "1." (so 5. / 1985. stay prose).
Add a bounded one-line lookahead, threaded only into the paragraph
collector (the other startsNewBlock() call sites keep their previous
behavior via the null default). A lone bullet/blockquote/table marker
now interrupts a paragraph only when it forms a real block: two or
more consecutive markers, an indented continuation, or a preceding
blank line. Headings and code/comment/div fences are unambiguous and
still interrupt on a single line.
This is a deliberate behavior change in significantNewlines mode:
single-item lists and single-line blockquotes no longer interrupt a
paragraph without a blank line. Documented in parser-options.md;
affected tests updated and regression tests added.
Copy file name to clipboardExpand all lines: docs/guide/parser-options.md
+30-6Lines changed: 30 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,22 +170,46 @@ Output:
170
170
171
171
Note: Soft break rendering is controlled separately via `SoftBreakMode` - see the [Soft Break Modes](#soft-break-modes) section above.
172
172
173
+
#### Lone marker lines are not blocks
174
+
175
+
Hard-wrapped prose frequently starts a line with `-`, `*`, `+`, `>` or `|` as an
176
+
arithmetic/comparison operator or pipe rather than a list/quote/table marker:
177
+
178
+
```text
179
+
Die Frage ist, wann ist x = 5
180
+
* 3 + 17 wahr.
181
+
```
182
+
183
+
To avoid turning these into spurious lists, a **single** marker line followed by
184
+
ordinary prose does *not* interrupt a paragraph. A bullet/blockquote/table
185
+
marker only interrupts when it forms a *real* block:
186
+
187
+
- two or more consecutive marker lines (`- a` / `- b`, or `> a` / `> b`), **or**
188
+
- a marker line with an indented continuation (`- item` / ` more`), **or**
189
+
- it is preceded by a blank line (then any single marker starts a block).
190
+
191
+
This mirrors the existing rule that only `1.` (not `5.` or `1985.`) interrupts
192
+
a paragraph as an ordered list. Headings (`#`) and code/comment/div fences are
193
+
unambiguous and still interrupt on a single line.
194
+
173
195
### Preventing Block Interruption with Escaping
174
196
175
197
In significant newlines mode, if you want to include literal block markers without triggering block parsing, escape the first character with a backslash:
0 commit comments