Skip to content

Normalize list marker spacing to avoid accidental code blocks - #66

Merged
patakuti merged 1 commit into
mainfrom
fix/list-marker-spacing
Aug 1, 2026
Merged

Normalize list marker spacing to avoid accidental code blocks#66
patakuti merged 1 commit into
mainfrom
fix/list-marker-spacing

Conversation

@patakuti

@patakuti patakuti commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes Ordered list items with extra spacing after the marker render as a code block #65: a list marker followed by 5+ spaces (e.g. 1. a) currently renders as an indented code block instead of a normal list item, per strict CommonMark/GFM rules. This is an easy mistake to make (e.g. padding markers for visual alignment) and the result is a silent, confusing rendering change.
  • Adds PreprocessListMarkers(), which always normalizes the whitespace after a list marker to a single space before parsing, skipping content inside fenced code blocks.
  • This is an intentional deviation from GitHub's rendering, favoring predictability over strict spec compliance. Documented under "Known Limitations" in README.md.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./...
  • Added TestPreprocessListMarkers covering ordered/bullet markers, nested lists, fenced code blocks (skipped), indented code blocks (skipped), blockquote-prefixed lists, and thematic-break edge cases
  • Manually verified 1. a now renders as <li>a</li> instead of a <pre><code> block

🤖 Generated with Claude Code

Under strict CommonMark/GFM, a list marker followed by 5+ spaces turns
the rest of the line into an indented code block instead of plain
text (e.g. "1.     a" renders as a code block). This is an easy
mistake to make when padding markers for visual alignment, and the
resulting rendering change is silent and confusing.

Add PreprocessListMarkers, which always collapses the whitespace
after a list marker to a single space before parsing, skipping fenced
code blocks. This is an intentional deviation from GitHub's rendering
in favor of predictability.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@patakuti
patakuti merged commit 55f99a6 into main Aug 1, 2026
1 check 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.

Ordered list items with extra spacing after the marker render as a code block

1 participant