Repository navigation
Parse multi-line tag openings inside blockquotes - #642
Conversation
The block rule sliced a tag's text straight out of the raw source, from the opening on the first line to the closing on a later one. Inside a blockquote that slice included the "> " markers of the continuation lines, so the tag grammar rejected it and the tag became an error node. Read the tag's lines through state.getLines, which returns them with container markers already stripped, and take what lies between the opening and closing delimiters. Fixes #641
joelzwarrington
left a comment
There was a problem hiding this comment.
Overall, changes look good to me, but would love to see a few more test cases that might catch some other issues. Let me know what you think!
There was a problem hiding this comment.
Do you mind adding a few more test cases here? I'm thinking we might want to test the following scenarios to confirm:
- List-item containers work with multi-line tags
- {% test #foo .bar
baz=1 %}
This is a test
{% /test %}- Nested containers with multi-line tags, can do either blockquotes → list item or vice-versa
> - {% test #foo .bar
> baz=1 %}
> This is a test
> {% /test %}- Parsing after a multi-line tag within a blockquote works as expected
> {% test #foo .bar
> baz=1 %}
> This is a test
> {% /test %}
After the blockquote- A single-line tag inside a blockquote works as expected
> {% test #foo .bar baz=1 %}
> This is a test
> {% /test %}There was a problem hiding this comment.
@joelzwarrington good ideas, just added these 4 tests, should be ready for ur review
Cover list items, blockquote + list nesting, content following a blockquote, and single-line tags in a blockquote.
Thanks for the quick review @joelzwarrington! Since this is approved now, any chance you could merge it, and then cut a patch release that includes both this and #640? I'm hoping to bump Keystatic's Markdoc dependency to pick up both blockquote fixes, since its editor writes files with format(), and the last published version (0.5.9) predates both. Happy to help if there's anything else needed to get a release out. |
Fixes #641: a tag opening that spans several lines parses everywhere except inside a blockquote, where the
>markers of the continuation lines end up inside the tag text and the grammar rejects it.This isn't just a hand-written edge case.
format()wraps any tag opening longer thanmaxTagOpeningWidth, so a tool that formats on save (Keystatic, for one) turns a long callout inside a quote into an error node on the next parse.Fix: read the tag's lines through
state.getLines, which strips container markers the same way markdown-it's own block rules do. Single-line tags are unaffected. Test added beside the existing multi-line tag tests; it fails onmain.Independent of #640, which fixes the formatter side of the same round trip.