Normalize known self-closing HTML elements #66
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For normalize known self-closing HTML elements, we will apply multi-pass filtering to HTML renderer. When markdown-it's
xhtmlOut
option istrue
, the whitelisted HTML elements would be normalized.Motivation
I'm trying to enhance Marp's collaboration with well-known JavaScript framework: React, Vue, and so on.
I have already tried using Incremental DOM via my markdown-it-incremental-dom plugin, and it works well at Marp Web built on Preact. However, these are not very well known although great modules. To spread Marp ecosystem widely, I'm thinking that we should provide a better experience into frequently used JS frameworks in general.
So I have tried creating React component at my CodeSandbox: https://codesandbox.io/s/v6v4rzx4jl. It has succeeded to render slides with minimum diff by converting rendered HTML into virtual DOM (using htm, he, and style-to-object).
The problem was caused by the whitelisted
<br>
HTML element. htm parser requires the strict syntax to self-closing element, so user-written<br>
will raise error. Thus, we have to normalize self-closing element.