Skip to content

markdown: extend h2 heading underline across full title - #44

Merged
achille-roussel merged 1 commit into
mainfrom
fix-markdown-titles
May 27, 2026
Merged

markdown: extend h2 heading underline across full title#44
achille-roussel merged 1 commit into
mainfrom
fix-markdown-titles

Conversation

@achille-roussel

Copy link
Copy Markdown
Contributor

Summary

Multi-word level-2 headings rendered with a short underline that stopped part-way through the title (e.g. The data model had only The data underlined). Root cause:

  • Goldmark splits multi-word headings at the last space into two Text nodes ("The data" + " model").
  • Lipgloss emits the parameterless reset \x1b[m (shorthand for \x1b[0m) between styled segments.
  • The post-processing in renderHeading that re-asserts \x1b[4m after every reset only matched the explicit \x1b[0m form, so the middle reset cleared the underline and the trailing word rendered without it.

Fix is one extra strings.ReplaceAll for \x1b[m, plus a regression test that asserts the underline-off SGR sits after the last visible character of the heading (covers both ATX ## ... and setext --- underline forms).

Test plan

  • go test ./markdown/... (full package suite passes)
  • New TestMarkdownH2UnderlineSpansFullHeading fails on main and passes with the fix
  • go test ./... (full repo)

🤖 Generated with Claude Code

Goldmark splits multi-word headings at the last space into two Text
nodes, and lipgloss emits the parameterless reset "\x1b[m" between the
styled segments. The post-processing that re-asserts the underline SGR
after every reset only matched "\x1b[0m", so the middle reset cleared
the underline and the trailing word rendered without it — visible as a
short underline that stops part-way through the heading.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@achille-roussel
achille-roussel merged commit e833cf6 into main May 27, 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.

1 participant