Skip to content

fix(render): escape line-start markers only before whitespace - #46

Merged
chaliy merged 1 commit into
mainfrom
claude/project-thread-ulbh3z
Oct 27, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/project-thread-ulbh3z

Conversation

@chaliy

@chaliy chaliy commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

Text that only looks like a block marker at the start of a line is no longer backslash-escaped. #, + and ordered markers (1., 1)) are escaped only when followed by whitespace or the end of the text run (where the next node could supply the space). >, - and = stay always escaped (quotes, thematic breaks, setext underlines).

Why

Regression from #23 found by the eval: 4.6 out of 5 stars rendered as 4\.6 out of 5 stars. The backslash is noise for text consumers, and 4.6 can never open a list.

Before / After

Input text Before After
4.6 out of 5 stars 4\.6 out of 5 stars 4.6 out of 5 stars
#hashtag \#hashtag #hashtag
+1 for this \+1 for this +1 for this
1. li 1\. li 1\. li (unchanged)
# then node h \# h \# h (unchanged)

New tests in tests/output_safety.rs: line_start_marker_lookalikes_render_verbatim (failed before the fix) and line_start_marker_at_run_end_stays_escaped. The pulldown-cmark oracle still sees exactly one paragraph for every case. cargo test --workspace passes.

Risk

  • Low
  • Narrows escaping only where CommonMark cannot open a block; run-end case stays escaped so split text nodes cannot combine into a marker.

Checklist

  • Tests added or updated
  • Backward compatibility considered (output-only change; CHANGELOG Fixed, threat model T1 and eval gap note updated)

Generated by Claude Code

4.6 out of 5 rendered as 4\.6. #, + and ordered markers open a block only
when followed by whitespace, so escape them only then (or at the end of the
text run, where the next node may supply it).
@chaliy
chaliy force-pushed the claude/project-thread-ulbh3z branch from b4feb99 to 344cafb Compare October 27, 2026 02:48
@chaliy
chaliy merged commit 16b3014 into main Oct 27, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant