mirror of https://github.com/zulip/zulip.git
bugdown: Fix handling of nested fenced math blocks.
Change any fence delimiters (backticks and tildes) to be interpreted literally inside of math fenced_code blocks. Fixes #5190.
This commit is contained in:
parent
01885cdedc
commit
0449dc8b8a
|
@ -107,7 +107,7 @@ exports.process_fenced_code = function (content) {
|
|||
if (line === fence) {
|
||||
this.done();
|
||||
} else {
|
||||
consume_line(lines, line);
|
||||
lines.push(line);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -56,6 +56,12 @@
|
|||
"marked_expected_output": "<p>I heard about this second hand...</p>\n<blockquote>\n<p>He said:</p>\n<blockquote>\n<p>The customer is complaining.</p>\n<p>They looked at this code:</p>\n<div class=\"codehilite\"><pre><span></span>def hello(): print 'hello\n</pre></div>\n\n\n<p>They would prefer:</p>\n</blockquote>\n<p>def hello()<br>\n puts 'hello'<br>\nend</p>\n</blockquote>\n<p>Please advise.</p>\n<div class=\"codehilite\"><pre><span></span>\nShe said:\n~~~ quote\nJust send them this:\n```\necho "hello\n"\n```\n</pre></div>",
|
||||
"text_content": "I heard about this second hand...\n\nHe said:\n\nThe customer is complaining.\nThey looked at this code:\ndef hello(): print 'hello\n\n\n\nThey would prefer:\n\ndef hello()\n puts 'hello'\nend\n\nPlease advise.\nShe said:\n~~~ quote\nJust send them this:\n```\necho \"hello\n\"\n```\n"
|
||||
},
|
||||
{
|
||||
"name": "fenced_quotes_inside_mathblock",
|
||||
"input": "```math\n````js\nvar x;\n````\n```",
|
||||
"expected_output": "<p><span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math><semantics><mrow><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi>j</mi><mi>s</mi><mi>v</mi><mi>a</mi><mi>r</mi><mi>x</mi><mo separator=\"true\">;</mo><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi></mrow><annotation encoding=\"application/x-tex\">````js\nvar x;\n````</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"strut\" style=\"height:0.69444em;\"></span><span class=\"strut bottom\" style=\"height:0.8888799999999999em;vertical-align:-0.19444em;\"></span><span class=\"base displaystyle textstyle uncramped\"><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathit\" style=\"margin-right:0.05724em;\">j</span><span class=\"mord mathit\">s</span><span class=\"mord mathit\" style=\"margin-right:0.03588em;\">v</span><span class=\"mord mathit\">a</span><span class=\"mord mathit\" style=\"margin-right:0.02778em;\">r</span><span class=\"mord mathit\">x</span><span class=\"mpunct\">;</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span></span></span></span></span></p>",
|
||||
"marked_expected_output": "<span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-mathml\"><math><semantics><mrow><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi>j</mi><mi>s</mi><mi>v</mi><mi>a</mi><mi>r</mi><mi>x</mi><mo separator=\"true\">;</mo><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi><mi mathvariant=\"normal\">‘</mi></mrow><annotation encoding=\"application/x-tex\">````js\nvar x;\n````</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"strut\" style=\"height:0.69444em;\"></span><span class=\"strut bottom\" style=\"height:0.8888799999999999em;vertical-align:-0.19444em;\"></span><span class=\"base displaystyle textstyle uncramped\"><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathit\" style=\"margin-right:0.05724em;\">j</span><span class=\"mord mathit\">s</span><span class=\"mord mathit\" style=\"margin-right:0.03588em;\">v</span><span class=\"mord mathit\">a</span><span class=\"mord mathit\" style=\"margin-right:0.02778em;\">r</span><span class=\"mord mathit\">x</span><span class=\"mpunct\">;</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span><span class=\"mord mathrm\">‘</span></span></span></span></span>"
|
||||
},
|
||||
{
|
||||
"name": "empty_single_blockquote",
|
||||
"input": ">",
|
||||
|
|
|
@ -255,7 +255,7 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
|
|||
if line.rstrip() == self.fence:
|
||||
self.done()
|
||||
else:
|
||||
check_for_new_fence(self.lines, line)
|
||||
self.lines.append(line)
|
||||
|
||||
def done(self):
|
||||
# type: () -> None
|
||||
|
|
Loading…
Reference in New Issue