You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to replace markdown-it with Magicdoc, and I'm running into compatibility issues with markdown generated by other editors for custom container types.
Most other clients in this ecosystem use markdown-it and a custom container to generate spoiler blocks. I've implemented a custom renderer for this in Magicdoc, and it works, but it's not compatible with markdown generated elsewhere due to the fact Magicdoc doesn't allow a space between the container tag and the type.
Example:
This works in MagicDoc:
:::spoiler Title
This is spoiler text that will be inside a details/summary block.
:::
This does not work:
::: spoiler Title
This is spoiler text that will be inside a details/summary block.
:::
The space between the ::: and type causes the type to not be picked up. I can deal with this on my end, but it has to interact with markdown generated by other clients which all utilize a space between the container tag and the type.
I haven't built this patch into my project yet, but simulating it with RegExr shows allowing an optional space between the ::: and (?type<>... should allow both ::: type and :::type formats:
It was completely blocking usage since spoiler tags are widely used, but I've worked around this by pre-processing the source input to replace ::: spoiler with :::spoiler. Seems to work. Unsure, though, how to change the severity level in the GH issue.
This is merged. For reference, the way I implemented it, only a single space is allowed, otherwise it won't parse. This will be released in the next version.
Describe the bug
I'm trying to replace
markdown-it
with Magicdoc, and I'm running into compatibility issues with markdown generated by other editors for custom container types.Most other clients in this ecosystem use
markdown-it
and a custom container to generate spoiler blocks. I've implemented a custom renderer for this in Magicdoc, and it works, but it's not compatible with markdown generated elsewhere due to the fact Magicdoc doesn't allow a space between the container tag and the type.Example:
This works in MagicDoc:
This does not work:
The space between the
:::
and type causes the type to not be picked up. I can deal with this on my end, but it has to interact with markdown generated by other clients which all utilize a space between the container tag and the type.Looking at /packages/plugins/svelte-marked/src/lib/markdown/extensions/container.ts, there's a regex rule for detecting the container tags.
const rule = /^:::(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n|$)/i
I haven't built this patch into my project yet, but simulating it with RegExr shows allowing an optional space between the
:::
and(?type<>...
should allow both::: type
and:::type
formats:const rule = /^::: ?(?<type>[a-z0-9-]+)(?<options>.*)?\n(?<content>(?:.|\n)*)\n:::(?:\n|$)/i
Would there be any issue to update the container rule regex to account for an optional space?
Reproduction
Basically make an extension using the container extension and put a space between the container tag (
:::
) and the container type.Logs
No response
System Info
Severity
Blocking all usage of Magidoc
The text was updated successfully, but these errors were encountered: