FIX: pre-hoist code blocks & spans

This commit is contained in:
Régis Hanol
2015-03-09 12:32:37 +01:00
parent 5b1ee3fedf
commit 70f00e31df
7 changed files with 120 additions and 31 deletions
+30 -8
View File
@@ -216,15 +216,33 @@ test("Mentions", function() {
"<p><a href=\"https://twitter.com/codinghorror\">@codinghorror</a></p>",
"it doesn't do link mentions within links");
cooked("Hello @EvilTrout", "<p>Hello <span class=\"mention\">@EvilTrout</span></p>", "adds a mention class");
cooked("robin@email.host", "<p>robin@email.host</p>", "won't add mention class to an email address");
cooked("hanzo55@yahoo.com", "<p>hanzo55@yahoo.com</p>", "won't be affected by email addresses that have a number before the @ symbol");
cooked("@EvilTrout yo", "<p><span class=\"mention\">@EvilTrout</span> yo</p>", "it handles mentions at the beginning of a string");
cooked("yo\n@EvilTrout", "<p>yo<br/><span class=\"mention\">@EvilTrout</span></p>", "it handles mentions at the beginning of a new line");
cooked("Hello @EvilTrout",
"<p>Hello <span class=\"mention\">@EvilTrout</span></p>",
"adds a mention class");
cooked("robin@email.host",
"<p>robin@email.host</p>",
"won't add mention class to an email address");
cooked("hanzo55@yahoo.com",
"<p>hanzo55@yahoo.com</p>",
"won't be affected by email addresses that have a number before the @ symbol");
cooked("@EvilTrout yo",
"<p><span class=\"mention\">@EvilTrout</span> yo</p>",
"it handles mentions at the beginning of a string");
cooked("yo\n@EvilTrout",
"<p>yo<br/><span class=\"mention\">@EvilTrout</span></p>",
"it handles mentions at the beginning of a new line");
cooked("`evil` @EvilTrout `trout`",
"<p><code>evil</code> <span class=\"mention\">@EvilTrout</span> <code>trout</code></p>",
"deals correctly with multiple <code> blocks");
cooked("```\na @test\n```", "<p><pre><code class=\"lang-auto\">a @test</code></pre></p>", "should not do mentions within a code block.");
cooked("```\na @test\n```",
"<p><pre><code class=\"lang-auto\">a @test</code></pre></p>",
"should not do mentions within a code block.");
cooked("> foo bar baz @eviltrout",
"<blockquote><p>foo bar baz <span class=\"mention\">@eviltrout</span></p></blockquote>",
@@ -357,7 +375,9 @@ test("Code Blocks", function() {
"<p><pre><code class=\"lang-ruby\">&lt;header&gt;hello&lt;/header&gt;</code></pre></p>",
"it escapes code in the code block");
cooked("```text\ntext\n```", "<p><pre><code class=\"lang-nohighlight\">text</code></pre></p>", "handles text by adding nohighlight");
cooked("```text\ntext\n```",
"<p><pre><code class=\"lang-nohighlight\">text</code></pre></p>",
"handles text by adding nohighlight");
cooked("```ruby\n# cool\n```",
"<p><pre><code class=\"lang-ruby\"># cool</code></pre></p>",
@@ -403,7 +423,9 @@ test("Code Blocks", function() {
"<pre><code>[quote]test[/quote]</code></pre>",
"it does not parse other block types in markdown code blocks");
cooked("## a\nb\n```\nc\n```", "<h2>a</h2>\n\n<p><pre><code class=\"lang-auto\">c</code></pre></p>", "it handles headings with code blocks after them.");
cooked("## a\nb\n```\nc\n```",
"<h2>a</h2>\n\n<p><pre><code class=\"lang-auto\">c</code></pre></p>",
"it handles headings with code blocks after them.");
});
test("sanitize", function() {
@@ -73,7 +73,7 @@ Nor should these, which occur in code spans:
Backslash: `\\`
Backtick: `` \` ``
Backtick: `\``
Asterisk: `\*`
@@ -113,7 +113,7 @@ other Markdown constructs:
\`backticks\`
This is a code span with a literal backslash-backtick sequence: `` \` ``
This is a code span with a literal backslash-backtick sequence: `\``
This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.
@@ -2,4 +2,4 @@
Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
Here's how you put `` `backticks` `` in a code span.
Here's how you put `` `backticks` `` in a code span.
@@ -86,7 +86,7 @@ Multiple paragraphs:
1. Item 1, graf one.
Item 2. graf two. The quick brown fox jumped over the lazy dog's
Item 1. graf two. The quick brown fox jumped over the lazy dog's
back.
2. Item 2.
@@ -91,7 +91,7 @@
<ol>
<li><p>Item 1, graf one.</p>
<p>Item 2. graf two. The quick brown fox jumped over the lazy dog's
<p>Item 1. graf two. The quick brown fox jumped over the lazy dog's
back.</p></li>
<li><p>Item 2.</p></li>
<li><p>Item 3.</p></li>