antfu / markdown-it-mdc

MDC (Markdown Components) syntax for markdown-it.
MIT License
101 stars 3 forks source link

mdc breaks with inline attributes in the slot #10

Closed QuentinRoy closed 3 months ago

QuentinRoy commented 4 months ago

Describe the bug

::insert
  Some sentence with ` `. A [link](./something.tar){download} with inline attribute (`{download}`). Another sentence with ` `.
::

is actually rendered:

<insert>Some&nbsp;sentence&nbsp;with&nbsp;<code>&amp;nbsp;</code>. A <a href="./something.tar.html" download="true">link</a> with inline attribute. Another&amp;nbsp;sentence&amp;nbsp;with&amp;nbsp;<code>&amp;nbsp;</code>.</insert>

Notice all & that followed the inline props were escaped to &amp;.

In my specific case (I'm using this with vitepress), it crashes altogether with the following error: [plugin:vitepress] inline rule didn't increment state.pos.

Reproduction

PR #9

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 124.70 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 8.15.1 - ~/Workspace/markdown-it-mdc/node_modules/.bin/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 123.0.6312.107
    Safari: 17.4.1

Used Package Manager

pnpm

Validations