[Repo Assist] Improve CommonMark ATX heading compliance#1028
Merged
Conversation
- Reject ATX headings with no space after '#' (e.g. '#NoSpace' → paragraph) - Reject ATX headings with more than 6 '#' characters (→ paragraph) - Support 0–3 optional leading spaces before the opening '#' sequence - Fix empty heading body when entire content is a closing '###' sequence - Enable additional passing CommonMark spec sections: Blank lines, Inlines, Soft line breaks, Textual content, ATX headings (26 new test cases) - Update test expectations and reference HTML files to match CommonMark spec Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
14 tasks
Contributor
|
@nojaf I'm OK with this. The code is not particularly pretty but if it's passing all tests plus the added tests I'm OK with it |
dsyme
approved these changes
Feb 26, 2026
Collaborator
|
/repo-assist I have nitpicks on the tests. You changed the outcome of the existing test without adding a new one for properly formatted headers. There should be a tests for something like I would also like a rename of the test @dsyme , can't help myself, life is too short not to nitpick. |
- Rename 'Transform header 1 correctly' to 'ATX heading without space after hash is treated as paragraph' to better reflect what is being tested - Add new test 'ATX heading with space after hash is transformed to heading element' to verify that properly formatted ATX headings (e.g. '# Header 1', '## Header 2') produce heading elements Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Commit pushed:
|
nojaf
approved these changes
Feb 26, 2026
This was referenced Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is a pull request created by Repo Assist, an automated AI assistant.
Closes #191
Summary
This PR improves CommonMark compliance for ATX headings in the Markdown parser. The changes fix four specific deviations from the [CommonMark spec for ATX headings]((spec.commonmark.org/redacted)
Changes to
MarkdownParser.fsThe
(|Heading|_|)active pattern's ATX heading case is rewritten to strictly follow CommonMark:#sequence —#NoSpaceand##Tagare now correctly rendered as paragraphs instead of headings.#characters —####### foo(7 hashes) is now a paragraph as required by the spec.## foo(up to 3 leading spaces) is now correctly recognised as a heading.### ###now correctly produces an empty<h3>rather than<h3>###</h3>.Enabled CommonMark spec sections (
CommonMarkSpecTest.fs)Five additional spec sections that were already 100% passing are now enabled, adding 26 new passing test cases:
ATX headings(19 tests)Blank lines(1 test)Inlines(1 test)Soft line breaks(2 tests)Textual content(3 tests)Updated tests
Markdown.fs: UpdatedTransform header 1 correctlyandTransform header 2 correctlyto reflect the correct CommonMark behavior (headings without a space after#are paragraphs).Tight blocks.html,line-endings-*.html): Updated to reflect that#Header/##Headerwithout a space are paragraphs rather than headings.Test Status
✅ All 220 Markdown tests pass (26 new, 194 pre-existing — 0 failures).
✅ All 101 Literate tests pass.
✅ Build succeeds.