Skip to content

Preserve literal trailing hashes in ATX headings - #321

Open
bug-origin wants to merge 1 commit into
matthewwithanm:developfrom
bug-origin:fix/atx-heading-trailing-hashes
Open

bug-origin wants to merge 1 commit into
matthewwithanm:developfrom
bug-origin:fix/atx-heading-trailing-hashes

Conversation

@bug-origin

Copy link
Copy Markdown

An HTML heading ending in a standalone hash loses that character when its Markdown is rendered. For example, <h3>Issue #</h3> becomes ### Issue #, which CommonMark renders as “Issue”.

Escape the first hash in a trailing run where it would be read as an ATX closing sequence. This also preserves headings made entirely of hashes. The tests cover both of these cases, a word ending in a hash (C#), and the explicitly closed ATX style.

Verified on Python 3.13 with the full pytest suite (96 passed), flake8 and the README lint. Also checked the rendered headings with markdown-it-py.

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