Skip to content

Split tables parsing into Maddy-style or CommonMark-style. - #96

Open
luciansmith wants to merge 17 commits into
progsource:masterfrom
luciansmith:make-tables-conformant
Open

Split tables parsing into Maddy-style or CommonMark-style.#96
luciansmith wants to merge 17 commits into
progsource:masterfrom
luciansmith:make-tables-conformant

Conversation

@luciansmith

Copy link
Copy Markdown
Contributor

Maddy's parsing of tables is a one-off, and works for both the body and the footer of tables. CommonMark doesn't support table footers at all. However, if you're using maddy as part of a system that needs to round-trip HTML through MD and back again, the table format that a CommonMark-style exporter creates won't be parsed by Maddy.

So, this update splits table parsing into two forms: the form Maddy invented, and the form CommonMark/GFM expects. This can be set using a new MADDY_SPECIFIC_PARSER flag, and by default, it parses its own invented format. When turned off, the parser instead parses GFM-style tables.

All of this code is just Claude, though all the design was me.

I was getting failures where URLs with underscores were getting <em> blocks thrown in them, creating invalid HTML.
Most don't pass (and are disabled), but should. Unfortunately, adding a word boundary (\b) to the strong regex works for these tests, but somehow the full parser then breaks. The regex that I believed should work is added as a comment, for anyone wishing to make things work going forward.
Addresses comments from ages ago (sorry!) and also does the correct behavior with unbalanced underscores.
Made with help from Claude, but checked and updated a lot.
Maddy's parsing of tables is a one-off, and works for both the body and the footer of tables. CommonMark doesn't support table footers at all. However, if you're using maddy as part of a system that needs to round-trip HTML through MD and back again, the table format that a CommonMark-style exporter creates won't be parsed by Maddy.
So, this update splits table parsing into two forms: the form Maddy invented, and the form CommonMark/GFM expects. This can be set using a new MADDY_SPECIFIC_PARSER flag, and by default, it parses its own invented format. When turned off, the parser instead parses GFM-style tables.
All of this code is just Claude, though all the design was me.
@luciansmith

Copy link
Copy Markdown
ContributorAuthor

I'm afraid this might have gotten merged with the emphasis fix, despite my best efforts to keep them apart. Let me know if you need them divided again.

Sign up for freeto 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

@luciansmith