-
Notifications
You must be signed in to change notification settings - Fork 61
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
π©βπ» Improve HTML processing #680
Conversation
{ | ||
type: 'html', | ||
value: '<hr>', | ||
}, | ||
{ | ||
type: 'html', | ||
value: '<br>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-closing HTML values are now correctly added.
selectAll('paragraph > htmlParsed', tree).forEach((parsed) => { | ||
const node = parsed as GenericParent; | ||
if (node?.children?.length === 1 && node.children[0].type === 'paragraph') { | ||
node.children = node.children[0].children as GenericNode[]; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTML is by default added into a paragraph, if it is already contained in one -- this strips it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - Any implications of pulling in the reconstructHtmlPlugin
to the default behaviour? Probably not - it will just make the htmlPlugin
better π. Other than that, this PR adds: β
more custom handling of html, β
better self closing tags, and β
small paragraph nesting tweak. Looks good!
This improves a lot of the functionality around HTML processing to get it into the AST before any other transformations. We can now have things like
<figure><img src=""><figcaption>The caption</figcaption></figure>
which will be processed into the correct container. This can also work with HTML links directly to that caption, which will be processed as normal.The IDs are required to be on the
figure
, not theimage
, but that seems reasonable.cc @dellaert who is motivated by having HTML that works in google collab, but also works with MyST for LaTeX export.
@fwkoch there are probably a number of other changes incoming for the HTML processing along these lines, but I think we can get them in iteratively.
Fixes: