Skip to content

Split emphasis markers at paragraph breaks, merge heading lines#110

Merged
xijo merged 1 commit intomasterfrom
fix-emphasis-across-breaks
Jan 20, 2026
Merged

Split emphasis markers at paragraph breaks, merge heading lines#110
xijo merged 1 commit intomasterfrom
fix-emphasis-across-breaks

Conversation

@xijo
Copy link
Owner

@xijo xijo commented Jan 20, 2026

Summary

Two related fixes for markdown rendering issues when line breaks occur inside formatting tags:

Emphasis (strong/em) with paragraph breaks

When <br><br> occurs inside <strong> or <em>, markers must be split so they don't span across paragraph breaks.

Before: <strong>hello<br><br>world</strong> → **hello  \n  \nworld** (broken rendering)
After:  <strong>hello<br><br>world</strong> → **hello**  \n  \n**world** (correct)

Headings with line breaks

Markdown headings can't span multiple lines, so content is merged into a single line.

Before: <h1>foo<br>bar</h1> → # foo  \nbar (bar loses heading)
After:  <h1>foo<br>bar</h1> → # foo bar (all content in heading)

Implementation

  • Added wrap_with_markers helper in Base class for splitting emphasis at paragraph breaks
  • Updated H converter to merge lines with spaces

Test plan

  • Added specs for strong, em, and h converters
  • All 212 tests pass
  • Verified roundtrip with Redcarpet renders correctly

Fixes #95

🤖 Generated with Claude Code

When <br><br> (or other paragraph breaks) occur inside <strong> or <em>,
the markdown markers must be split so they don't span across breaks.
Otherwise, markdown renderers fail to apply the formatting.

Before: <strong>hello<br><br>world</strong> → **hello  \n  \nworld**
After:  <strong>hello<br><br>world</strong> → **hello**  \n  \n**world**

For headings, line breaks are merged into a single line since markdown
headings can't span multiple lines.

Before: <h1>foo<br>bar</h1> → # foo  \nbar (bar loses heading)
After:  <h1>foo<br>bar</h1> → # foo bar (all content in heading)

Added wrap_with_markers helper in Base class for reuse.

Fixes #95

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@xijo xijo merged commit 3136bb7 into master Jan 20, 2026
7 checks passed
@xijo xijo deleted the fix-emphasis-across-breaks branch January 20, 2026 11:10
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.

Doesn't handle <br><br> within <strong></strong>

1 participant