Tolerate spaces after language in markdown fences.

See #2357.  We now support `~~~ .py ` with that trailing space.

Note that the test coverage is Python-side only due to
bugdown_matches_marked being set to false, since we don't yet
support language syntax on the client side.

(imported from commit ccd5fcb0eee01478d349161400103480678d7486)
This commit is contained in:
Steve Howell 2014-03-05 18:05:49 -05:00
parent 91fb286b0d
commit 8f37c3f5fd
3 changed files with 4 additions and 2 deletions

View File

@ -15,6 +15,7 @@ var fencestr = "^(~{3,}|`{3,})" + // Opening Fence
"\\{?\\.?" +
"([a-zA-Z0-9_+-]*)" + // Language
"\\}?" +
"[ ]*" + // Spaces
")$";
var fence_re = new RegExp(fencestr);

View File

@ -2,7 +2,7 @@
"regular_tests": [
{
"name": "codeblock_hilite",
"input": "Hamlet said:\n~~~~.python\ndef speak(self):\n x = 1\n~~~~",
"input": "Hamlet said:\n~~~~.python \ndef speak(self):\n x = 1\n~~~~",
"expected_output": "<p>Hamlet said:</p>\n<div class=\"codehilite\"><pre><span class=\"k\">def</span> <span class=\"nf\">speak</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n <span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>",
"bugdown_matches_marked": false
},
@ -574,4 +574,4 @@
"http://generate.quora.net/render?width=700&amp;from=-4hours&amp;until=now&amp;height=400&amp;bgcolor=black&amp;lineMode=connected&amp;title=arb%20hint%20status&amp;target=alias(ans.hintland.hand.arb.enhint_rate%2C%22enhint%20rate%22)&amp;target=alias(ans.hintland.hand.arb.unhint_rate%2C%22unhint%20rate%22)&amp;target=alias(ans.hintland.hand.arb.size%2C%22hint%20size%22)&amp;target=alias(scale(ans.vagabond.dingarb_cube_count%2C10000)%2C%22cube%20count%20x%2010K%22)&amp;target=alias(scale(hnumbers.time.ding.gegevens.query.count%2C10)%2C%22ding%20gegevens%20query%20count%20x%2010%22)&amp;fgcolor=white&amp;uniq=0.44046106841415167"
]
]
}
}

View File

@ -83,6 +83,7 @@ FENCE_RE = re.compile(r"""
) # "py" or "javascript"
\}?
) # language, like ".py" or "{javascript}"
[ ]* # spaces
$
""", re.VERBOSE)