Fix parsing of as |...| block params in markdown component invocations#2095
Fix parsing of as |...| block params in markdown component invocations#2095
as |...| block params in markdown component invocations#2095Conversation
|
|
Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
The `unescapeComponentsOutsideCode` function only unescaped PascalCase
component tags containing `@` (for component args). Tags with Glimmer
block parameter syntax like `<Tabs as |Tab|>` were not unescaped because
`|` chars prevent micromark from recognizing them as HTML blocks.
Add `content.includes('as |')` condition to also unescape these tags.
Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
as |...| block params in markdown component invocations
|
@copilot you have a lint error in ci |
Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
Footnotes
|
|
@copilot when trying this out locally, I get this error: (using the code snippet from the issue report) (requires this diff to test tho) (and installing |
Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
... Fixed in 69814b2. The root cause: because The fix strips those spurious |
| `); | ||
| }); | ||
|
|
||
| it('allows component with block params (as |...|) invocation', async () => { |
There was a problem hiding this comment.
@copilot add another test with more lines like the original issue report -- something still isn't working (still have the mismatched p tag error)
There was a problem hiding this comment.
Added the more realistic test in d32b42b. The root issue was that when <Tabs as |Tab|> and <Tab @title="First"> appear on consecutive lines (no blank line between them), the markdown parser puts both into the SAME <p> block: <p><Tabs as |Tab|>\n<Tab @title="First"></p>. The previous regex only handled the case where the <p> contained only the opening block-param tag.
Fixed by switching to a tempered greedy token (?:(?!</p>)[\s\S])* that correctly matches content within a single <p> without crossing into adjacent paragraphs. The new test covers the realistic case from the issue report (h1 + text + <Tabs as |Tab|> with nested <Tab> components).
…separator Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
<Tabs as |Tab|>in markdown content is entity-encoded to<Tabs as |Tab|>because:|characters inas |Tab|make micromark not recognize<Tabs as |Tab|>as a valid HTML tagunescapeComponentsOutsideCodeonly unescapes tags containing@, notas |...|patternsunescapeComponentsOutsideCodeinparse.jsto also unescape tags withas |...|block parameter syntaxas |...|invocations in markdownparse.test.ts(CI lint failure)<p>wrappers around block-param component opening tags(?:(?!</p>)[\s\S])*to prevent merging adjacent paragraphs when stripping<p>wrappers<Tabs as |Tab|>with nested<Tab>components)Original prompt
asinvocations in markdown with live content #2094✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.