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.
assert res == exp
end
+ fun test_process_xml4 do
+ var test = """
+<p>This is an example of a block element that should be escaped.</p>
+<p>Idem for the second paragraph.</p>
+"""
+ var exp = test
+ var res = test.md_to_html.write_to_string
+ assert res == exp
+ end
+
+ fun test_process_xml5 do
+ var test = """
+# Some more XML tests
+
+<p>This is an example of a block element that should be escaped.</p>
+<p>Idem for the second paragraph.</p>
+
+With a *md paragraph*!
+"""
+ var exp = """
+<h1 id="Some_more_XML_tests">Some more XML tests</h1>
+<p>This is an example of a block element that should be escaped.</p>
+<p>Idem for the second paragraph.</p>
+<p>With a <em>md paragraph</em>!</p>
+"""
+ var res = test.md_to_html.write_to_string
+ print res
+ assert res == exp
+ end
+
fun test_process_span_code1 do
var test = "Use the `printf()` function."
var exp = "<p>Use the <code>printf()</code> function.</p>\n"
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
"TokenLink at 4,1--4,1"]
(new TestTokenProcessor(stack)).process(string)
end
+
+ fun test_token_location4 do
+ var string = "**Hello**\n\n`World`"
+ var stack = [
+ "TokenStrongStar at 1,1--1,1",
+ "TokenStrongStar at 1,8--1,8",
+ "TokenCodeSingle at 3,1--3,1",
+ "TokenCodeSingle at 3,7--3,7"]
+ (new TestTokenProcessor(stack)).process(string)
+ end
+
+ fun test_token_location5 do
+ var string = "# *Title1*\n\n# *Title2*"
+ var stack = [
+ "TokenEmStar at 1,3--1,3",
+ "TokenEmStar at 1,10--1,10",
+ "TokenEmStar at 3,3--3,3",
+ "TokenEmStar at 3,10--3,10"]
+ (new TestTokenProcessor(stack)).process(string)
+ end
end
class TestTokenProcessor
redef fun token_at(input, pos) do
var token = super
if token isa TokenNone then return token
- var res = "{token.class_name} at {token.location}"
- print res
+ var res = "{token.class_name} at {token.location or else "?"}"
var exp = test_stack.shift
+ print ""
+ print "EXP {exp}"
+ print "RES {res}"
assert exp == res
return token
end
proc.emitter.decorator = new TestBlockDecorator(stack)
proc.process(string)
end
+
+ fun test_block_location3 do
+ var stack = [
+ "BlockHeadline: 1,1--1,8",
+ "BlockHeadline: 3,1--3,10"]
+ var string ="""# Title\n\n## Title 2"""
+ proc.emitter.decorator = new TestBlockDecorator(stack)
+ proc.process(string)
+ end
end
class TestBlockDecorator