Skip to content

Fix thematic breaks not interrupting paragraphs (#41)#51

Merged
llimllib merged 2 commits intomainfrom
fix-thematic-breaks
Mar 14, 2026
Merged

Fix thematic breaks not interrupting paragraphs (#41)#51
llimllib merged 2 commits intomainfrom
fix-thematic-breaks

Conversation

@llimllib
Copy link
Copy Markdown
Owner

Summary

Fixes #41. Per GFM spec §4.1, thematic breaks can interrupt a paragraph. Previously, handle_in_paragraph() did not check for thematic breaks, so lines like ***, ___, and * * * were treated as inline emphasis markers instead.

Changes

src/lib.rs

Added a thematic break check in handle_in_paragraph(), after the setext heading underline check (so --- still becomes a setext heading as the spec requires) but before the code fence check. When a thematic break is detected:

  1. The current paragraph is emitted
  2. The formatted horizontal rule is emitted
  3. The parser returns to the Ready state

tests/fixtures/blocks/horizontal_rule_interrupts_paragraph.toml

Added a conformance test covering all three thematic break variants (***, ___, * * *) interrupting paragraphs, verifying that:

  • The paragraph is emitted when the thematic break line arrives
  • The thematic break is emitted in the same chunk
  • Subsequent text starts a new paragraph

Session transcript

Claude Code session transcript

Per GFM spec §4.1, thematic breaks can interrupt a paragraph.
Previously, handle_in_paragraph() did not check for thematic breaks,
so lines like ***, ___, and * * * were treated as inline emphasis
markers instead.

Added a thematic break check in handle_in_paragraph() after the
setext heading underline check (so --- still becomes a setext heading)
but before the code fence check. When detected, the paragraph is
emitted followed by the horizontal rule.

Added conformance test covering ***, ___, and * * * variants
interrupting paragraphs.
@llimllib llimllib merged commit 9e51c1b into main Mar 14, 2026
3 checks passed
@llimllib llimllib deleted the fix-thematic-breaks branch March 14, 2026 02:22
llimllib added a commit that referenced this pull request Mar 14, 2026
Fixes #43. Per GFM spec §5.1, block quotes can interrupt paragraphs. Previously, `handle_in_paragraph()` did not check for blockquote markers, so lines like `> bar` were treated as literal text within the paragraph.

## Changes

### `src/lib.rs`
Added a `parse_blockquote_marker()` check in `handle_in_paragraph()`, after the code fence check. When a blockquote marker (`>`) is detected while in a paragraph:
1. The current paragraph is emitted
2. The parser transitions to `InBlockquote` state
3. The blockquote content starts buffering

This follows the same pattern as the ATX heading interrupt (#52) and thematic break interrupt (#51).

### `tests/fixtures/blocks/blockquote_interrupts_paragraph.toml`
Added a conformance test covering:
- A single-line blockquote interrupting a paragraph (GFM spec Example 222)
- A multi-line blockquote interrupting a paragraph
- Verifies the paragraph is emitted when the blockquote line arrives, and the blockquote is emitted on the subsequent blank line

## Session transcript
[Claude Code session transcript](https://github.com/llimllib/mdriver/blob/fix-blockquote-interrupt/transcripts/43-fix-blockquote-interrupt.html)
llimllib added a commit that referenced this pull request Mar 14, 2026
Fixes #44. Per GFM spec §5.3, lists can interrupt paragraphs. Previously, `handle_in_paragraph()` did not check for list items, so lines like `- bar` were treated as literal text within the paragraph.

## Changes

### `src/lib.rs`
Added a `parse_list_item()` check in `handle_in_paragraph()`, after the blockquote marker check and before the table delimiter row check. When a list item is detected while in a paragraph:
1. The current paragraph is emitted
2. The parser transitions to `InList` state
3. The list starts buffering items

Per the GFM spec §5.3, ordered lists can only interrupt paragraphs if they start with `1`. Ordered lists starting with other numbers (like `14.`) are treated as continuation paragraph text.

This follows the same pattern as the blockquote interrupt (#53), ATX heading interrupt (#52), and thematic break interrupt (#51).

### `tests/fixtures/blocks/list_interrupts_paragraph.toml`
Added a conformance test covering:
- Unordered list interrupting a paragraph (GFM spec Example 283)
- Ordered list starting with 1 interrupting a paragraph
- Ordered list NOT starting with 1 cannot interrupt a paragraph (GFM spec Example 284)

## Session transcript
[Claude Code session transcript](https://github.com/llimllib/mdriver/blob/list-interrupt/transcripts/54-fix-list-interrupt.html)
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.

Thematic breaks don't interrupt paragraphs

1 participant