Skip to content

fix: handle HTML void elements in markdown attribute processing#126

Merged
osteele merged 1 commit into
mainfrom
fix-66-void-elements
Feb 26, 2026
Merged

fix: handle HTML void elements in markdown attribute processing#126
osteele merged 1 commit into
mainfrom
fix-66-void-elements

Conversation

@osteele
Copy link
Copy Markdown
Owner

@osteele osteele commented Feb 26, 2026

Summary

Fixes #66<br> tags (and other HTML void elements) inside markdown="1" blocks caused an "unexpected EOF" error.

Root cause: The HTML tokenizer depth tracker in processInnerMarkdown and copyContent incremented depth on every StartTagToken, but void elements (<br>, <hr>, <img>, etc.) never produce a matching EndTagToken. This caused the depth counter to never reach 0, resulting in EOF when the tokenizer ran out of input.

Fix: Skip depth increment for HTML void elements. Both <br> (HTML5) and <br/> (XHTML) forms are handled correctly.

Test plan

  • go test ./... passes
  • Added tests for <br>, <hr>, <img> inside markdown="1" and markdown="0" blocks
  • CI passes

<br>, <hr>, <img>, and other HTML void elements inside markdown="1"
blocks caused an "unexpected EOF" error because the HTML tokenizer
depth tracker incremented on their start tags but never saw matching
end tags. Skip depth increment for void elements.
@osteele osteele merged commit 3b2985d into main Feb 26, 2026
6 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.

Fix parsing error with <br> tags in markdown files

1 participant