Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose raw html / allowDangerousHtml to the MyST CLI #1040

Open
choldgraf opened this issue Mar 29, 2024 · 2 comments
Open

Expose raw html / allowDangerousHtml to the MyST CLI #1040

choldgraf opened this issue Mar 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@choldgraf
Copy link
Collaborator

choldgraf commented Mar 29, 2024

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:

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

@choldgraf choldgraf added the enhancement New feature or request label Mar 29, 2024
@lorenzo-rovigatti
Copy link

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
Copy link
Collaborator Author

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}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants