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 PR updates the Commonmark renderer to support documents containing unicode emspaces (
\u2003
). There are two relevant changes:When rendering Paragraphs, we were stripping all leading and trailing whitespace characters from their text to prevent the possibility of these characters being interpreted as markdown symbols, as leading spaces might be interpreted as an indented code block and trailing spaces might be interpreted as a line break. We were being overzealous in this stripping, as MD only considers certain whitespace characters as meaningful in this way. We obtained a narrower set of characters to strip by considering the chars which are matched by
[\s]
,[ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]
, and checking which of these are meaningful to markdown.Secondly, we need to encode unicode whitespace characters as html entities in the rendered output, as otherwise many markdown parsers (including Markdown-it) will ignore them. This PR does that for emspace characters only, but other unicode whitespace characters can be added as needed in subsequent PRs.