Skip to content

Commit

Permalink
Add tests for Github code blocks, passing on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
jasononeil committed Sep 29, 2012
1 parent 93bf673 commit 6d46bc3
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions test/MarkdownTest.hx
Expand Up @@ -997,5 +997,83 @@ Pretty **cool** hey!
Assert.areEqual(expected, result);
}

@Test
public function testGithubCodeBlock_noLanguage():Void
{
var input =
'```
for (i in array)
{
trace (i);
}
```';
var expected = '<pre><code class=\'\'>for (i in array)
{
trace (i);
}
</code></pre>';
Markdown.setFilters(filters.GithubCodeBlocks);
var result = Markdown.convert(input);
Assert.areEqual(expected, result);
}

@Test
public function testGithubCodeBlock_markdownNotParse():Void
{
var input =
'```
In here this gh *code should* not become Markdown
==============================================
```

And with an indented code block:

In here this *code should* not become Markdown
==============================================

';
var expected = '<pre><code class=\'\'>In here this gh *code should* not become Markdown
==============================================
</code></pre>

<p>And with an indented code block:</p>

<pre><code>In here this *code should* not become Markdown
==============================================
</code></pre>';
Markdown.setFilters(filters.GithubCodeBlocks);
var result = Markdown.convert(input);
Assert.areEqual(expected, result);
}

@Test
public function testGithubCodeBlock_htmlEscaped():Void
{
var input =
'```
This is <b>Bold</b> and <i>Italic</i> and <script>Dangerous</script>
====================================================================
```

And with an indented code block:

This is <b>Bold</b> and <i>Italic</i> and <script>Dangerous</script>
====================================================================

';
var expected = '<pre><code class=\'\'>This is &lt;b&gt;Bold&lt;/b&gt; and &lt;i&gt;Italic&lt;/i&gt; and &lt;script&gt;Dangerous&lt;/script&gt;
====================================================================
</code></pre>

<p>And with an indented code block:</p>

<pre><code>This is &lt;b&gt;Bold&lt;/b&gt; and &lt;i&gt;Italic&lt;/i&gt; and &lt;script&gt;Dangerous&lt;/script&gt;
====================================================================
</code></pre>';
Markdown.setFilters(filters.GithubCodeBlocks);
var result = Markdown.convert(input);
Assert.areEqual(expected, result);
}


}

0 comments on commit 6d46bc3

Please sign in to comment.