Skip to content

Commit

Permalink
Merge pull request #2450 from vibe-d/markdown_fix
Browse files Browse the repository at this point in the history
Fix HTML escaping rules within Markdown emphasis.
  • Loading branch information
s-ludwig authored Jun 9, 2020
2 parents 1bc9bfe + 2e4da15 commit 7eaaf70
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion textfilter/vibe/textfilter/markdown.d
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ private void writeMarkdownEscaped(R)(ref R dst, string ln, in LinkRef[string] li
string text;
if (auto em = parseEmphasis(ln, text)) {
dst.put(em == 1 ? "<em>" : em == 2 ? "<strong>" : "<strong><em>");
filterHTMLEscape(dst, text, HTMLEscapeFlags.escapeMinimal);
dst.put(text);
dst.put(em == 1 ? "</em>" : em == 2 ? "</strong>": "</em></strong>");
} else {
dst.put(ln[0]);
Expand Down Expand Up @@ -1685,3 +1685,9 @@ private struct Link {
assert (filterMarkdown("- foo\n- %%%", MarkdownFlags.figures) == "<ul>\n<li>foo\n</li>\n</ul>\n<figure></figure>\n");
assert (filterMarkdown("- foo\n\n- %%%", MarkdownFlags.figures) == "<ul>\n<li>foo\n</li>\n</ul>\n<figure></figure>\n");
}

@safe unittest { // HTML entities
assert(filterMarkdown("&nbsp;") == "<p>&nbsp;\n</p>\n");
assert(filterMarkdown("*&nbsp;*") == "<p><em>&nbsp;</em>\n</p>\n");
assert(filterMarkdown("`&nbsp;`") == "<p><code class=\"prettyprint\">&amp;nbsp;</code>\n</p>\n");
}

0 comments on commit 7eaaf70

Please sign in to comment.