lib/markdown: fix multiple fence in the same comment
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 11 May 2015 17:31:26 +0000 (13:31 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 10 Jun 2015 22:22:35 +0000 (18:22 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/markdown/markdown.nit
lib/markdown/test_markdown.nit

index 0d264cb..8ac0b6e 100644 (file)
@@ -1703,6 +1703,7 @@ class LineFence
                else
                        block = v.current_block.split(v.current_block.last_line.as(not null))
                end
+               block.remove_surrounding_empty_lines
                var meta = block.first_line.value.meta_from_fence
                block.kind = new BlockFence(block, meta)
                block.first_line.clear
index e4bd177..6f8519c 100644 (file)
@@ -578,6 +578,44 @@ print "Hello World!"
                assert res == exp
        end
 
+       fun test_process_code_ext6 do
+               var test = """
+~~~
+print "Hello"
+~~~
+~~~
+print "World"
+~~~
+"""
+               var exp = """
+<pre><code>print "Hello"
+</code></pre>
+<pre><code>print "World"
+</code></pre>
+"""
+               var res = test.md_to_html.write_to_string
+               assert res == exp
+       end
+
+       fun test_process_code_ext7 do
+               var test = """
+~~~
+print "Hello"
+~~~
+~~~
+print "World"
+~~~
+"""
+               var exp = """
+<pre><code>print "Hello"
+</code></pre>
+<pre><code>print "World"
+</code></pre>
+"""
+               var res = test.md_to_html.write_to_string
+               assert res == exp
+       end
+
        fun test_process_nesting1 do
                var test = """
 > ## This is a header.
@@ -2619,6 +2657,8 @@ class TestLine
                assert v.line_kind(subject) isa LineFence
                subject = new MDLine(loc, "  ```")
                assert v.line_kind(subject) isa LineFence
+               subject = new MDLine(loc, "~~~raw")
+               assert v.line_kind(subject) isa LineFence
        end
 
        fun test_count_chars do