mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

Expose raw html / `allowDangerousHtml` to the MyST CLI

Open choldgraf opened this issue 1 year ago • 2 comments

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:

  • Embed your own styles on a page
  • Embed the HTML embed code of a widget from some other service
  • Generate some custom structure that you don't know how to accomplish with MyST
  • Add some JavaScript to give the page custom behavior.

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:

  • https://github.com/jupyter-book/mystmd/pull/1442

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

choldgraf avatar Mar 29 '24 16:03 choldgraf

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 :(

lorenzo-rovigatti avatar Apr 04 '24 16:04 lorenzo-rovigatti

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

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

  • https://github.com/jupyter-book/mystmd/pull/1442

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

choldgraf avatar Aug 10 '24 06:08 choldgraf