jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
219 stars 64 forks source link

Expose raw html / `allowDangerousHtml` to the MyST CLI #1040

Open choldgraf opened 8 months ago

choldgraf commented 8 months ago

In the MyST parser library, there's an option called allowDangerousHtml that allows the parser to include "raw" HTML that isn't a formal MyST node. This is mentioned on this page:

https://mystmd.org/guide/commonmark#valid-html

CleanShot 2024-03-29 at 09 01 17@2x

However, it is unclear in the documentation how to set allowDangerousHtml, and I think it is actually not possible from a MyST configuration + CLI system, but only at the command line.

It would be useful if this could be exposed to users so that they can embed their own HTML, JS, CSS, etc. This is useful if you want to do things like:

Where is this implemented?

This is an educated guess, but I believe that the myst-transform that builds the HTML outputs doesn't use this parameter and thus this functionality is not exposed to users:

https://github.com/executablebooks/mystmd/blob/ffb239a921ee90aa8e55c067e243e4213767c6fe/packages/myst-transforms/src/html.ts#L160-L180

Or could it be done with a {raw:html} directive

In this PR we added support for {raw:typst} and {raw:latex} directives:

Could that be extended to allow for {raw:html}?

lorenzo-rovigatti commented 7 months ago

I'd love to have this feature, as I currently cannot use myst for my project because I cannot find a way of adding raw HTML to the page :(

choldgraf commented 3 months ago

Could this be done with a {raw:html} directive?

In this PR we added support for {raw:typst} and {raw:latex} directives:

Could that be extended to allow for {raw:html}?