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

Normalize known self-closing HTML elements #66

Merged
merged 4 commits into from
Feb 3, 2019

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Feb 2, 2019

For normalize known self-closing HTML elements, we will apply multi-pass filtering to HTML renderer. When markdown-it's xhtmlOut option is true, 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.

@yhatt yhatt merged commit 8f3b15f into master Feb 3, 2019
@yhatt yhatt deleted the normalize-self-closing-html branch February 3, 2019 07:06
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