fix: more tweaks to improve remark/rehype compatibility #109
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.
This does a few things to improve compatibility with remark/rehype:
Start inserting line breaks at the end of
heading
tags. Looks like the original implementation simply forgot to include the\n
at the end. Then there are some test changes to respond to this.Allow
width
ontd
tags. This is specified in thetables.md
fixture, but was being sanitized in the output.Manually insert
rel="noopener noreferrer"
intotables.md
fixture and output.Marked
parses this entire thing with atoken.type
ofhtml
, and so the overriddenlink
function in our renderer does not get invoked here. Rather than try to fix this programmatically, I thought it would be easier to just fix the test.The reason why this is necessary is because https://github.com/rehypejs/rehype-raw will convert the raw html into an AST. And then later on https://github.com/rehypejs/rehype-external-links will deal with the external links.
People probably shouldn't be inserting giant raw anchor tags into their markdown, so I suspect this won't impact people. Additionally, not having this attribute is a slight security concern, so people should be doing it anyway.
Add some basic tests covering
anchor
tags.A special hack to change how lists live inside summary tags. There's a more detailed comment in
mod.ts
and you can see the fixture result changes to not have the extra line (in addition to removing whitespace at the start). Again, this is necessary due to https://github.com/rehypejs/rehype-raw converting raw html into an AST. Perhaps this warrants some extra tests aroundsummary
tags?