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

Preserve HTML comments within html block #282

Merged
merged 4 commits into from
Jan 23, 2022
Merged

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Jan 23, 2022

Marp Core HTML sanitizer has no longer stripped HTML comments written within HTML block. When allowed HTML by html constructor option, Marp Core will keep HTML comment(s) if wrapped by the HTML tag.

This behavior is helpful for user-side script usage. By wrapping JS by HTML comment, users can prevent escaping special characters in the script into HTML entities (Reported in marp-team/marp#250).

<script>
<!--
if (1 < 2) console.log(true)
-->
</script>

For safety, we have not taken the approach of recognizing script context to switch whether escape or not. Users who want to use the raw inline script always must wrap the script in HTML comment.

When HTML block is consisted by only a single HTML comment, it will be collected as the presenter note by Marpit framework.

@yhatt yhatt changed the title Preserve comments within html block Preserve HTML comments within html block Jan 23, 2022
@yhatt yhatt merged commit d9bc9c7 into main Jan 23, 2022
@yhatt yhatt deleted the preserve-comments-in-html-block branch January 23, 2022 04:33
yhatt added a commit that referenced this pull request Jan 23, 2022
yhatt added a commit that referenced this pull request Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant