Skip to content

Preserve HTML comments within html block#282

Merged
yhatt merged 4 commits into
mainfrom
preserve-comments-in-html-block
Jan 23, 2022
Merged

Preserve HTML comments within html block#282
yhatt merged 4 commits into
mainfrom
preserve-comments-in-html-block

Conversation

@yhatt

@yhatt yhatt commented Jan 23, 2022

Copy link
Copy Markdown
Member

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