Repository navigation
fix(comark): add support for collapsible sections and improve handling of <details> blocks - #236
arashsheyda wants to merge 4 commits into
Conversation
…g of <details> blocks
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
comark
@comark/ansi
@comark/html
@comark/nuxt
@comark/react
@comark/svelte
@comark/vue
commit: |
| /** | ||
| * Check whether an html_block token opens a `<details>` without closing it. | ||
| * CommonMark type-6 blocks terminate on blank lines, so `<details>` followed | ||
| * by a blank line splits into separate tokens and the body content ends up | ||
| * outside the element. | ||
| */ | ||
| function isUnclosedDetailsBlock(content: string): boolean { | ||
| const trimmed = content.trim() | ||
| return /^<details[\s>]/i.test(trimmed) && !/<\/details\s*>/i.test(trimmed) | ||
| } |
There was a problem hiding this comment.
Why does this need to be so special-cased? Why can’t this be solved in a way that works with any type-6 block?
There was a problem hiding this comment.
It seems like all type-6 blocks containing blank lines parse incorrectly according to the specification:
compare commonmark demo (see the HTML tab) with the same code in the comark editor.
<details>
<summary>Original summary in English</summary>
xxx
</details>
<div class=foo">
*Markdown*
</div>This should be parsed as a single div wrapping the *Markdown*, not a div closed by a blank line
|
@farnabaz any chance you can review this? (I can resolve conflicts after) |
|
@arashsheyda Honestly this PR was really specific for details tag, I took some time and drop #401 to fix the general issue of html handling. It's almost ready, but still in WIP. I would appreciate your pov on it and possibly if would help to have more SPEC on it 🙏 |

🔗 Linked issue
resolves #235
❓ Type of change
📚 Description
📝 Checklist
pnpm verifyand it passes.