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

Add "allowHTML" option for Markdoc with HTML parsing/processing #7597

Merged
merged 17 commits into from
Jul 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changeset/stupid-poets-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@astrojs/markdoc': minor
alex-sherwin marked this conversation as resolved.
Show resolved Hide resolved
---

Adds an "allowHTML" Markdoc integration option.

When enabled, all Markdoc markup is processed via the htmlparser2 library to detect
HTML elements and creating a modified set of markdown-it tokens which seamlessly interleave
HTML markup elements with any Markdoc tags and nodes.

This is a potential XSS vector as HTML in Markdoc markup will be rendered as real HTML nodes
once this is enabled (it should be noted this is already the case for Markdoc and MDX integrations
alex-sherwin marked this conversation as resolved.
Show resolved Hide resolved
as-is, by default.)

Example of enabling this feature:
alex-sherwin marked this conversation as resolved.
Show resolved Hide resolved

```js
alex-sherwin marked this conversation as resolved.
Show resolved Hide resolved
export default defineConfig({
integrations: [markdoc({ allowHTML: true })],
});
```