# This file is part of NIT ( http://www.nitlanguage.org ). # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either htmlress or implied. # See the License for the specific language governing permissions and # limitations under the License. # Test for markdown blocks parsing module test_markdown_blocks is test import test_markdown class TestMarkdownBlocks super TestMarkdownHtml test fun test_blocks_empty is test do var md = "" var html = "" assert md_to_html(md) == html end fun test_blocks_tabs is test do var md = """\tsome code\n""" var html = """
some code\n
\n"""
assert md_to_html(md) == html
end
fun test_blocks_pagraph1 is test do
var md = "test\n"
var html = "test
\n" assert md_to_html(md) == html end fun test_blocks_pagraph2 is test do var md = """line1\nline2\n\nline3 line4\n\nline5\n""" var html = """line1\nline2
\nline3 line4
\nline5
\n""" assert md_to_html(md) == html end fun test_blocks_pagraph3 is test do var md = """ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. """ var html = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.
""" assert md_to_html(md) == html end fun test_blocks_headings_1 is test do var md = """ This is a H1 ============= This is a H2 ------------- """ var html = """""" assert md_to_html(md) == html end fun test_blocks_bquote2 is test do var md = """ > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. """ var html = """This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.
This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
""" assert md_to_html(md) == html end fun test_blocks_bquote3 is test do var md = """ > This is the first level of quoting. > > > This is nested blockquote. > > Back to the first level. """ var html = """Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.
""" assert md_to_html(md) == html end fun test_blocks_list1 is test do var md = """ * Red * Green * Blue """ var html = """This is the first level of quoting.
This is nested blockquote.
Back to the first level.
Bird
Magic
This is a list item with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
Suspendisse id sem consectetuer libero luctus adipiscing.
This is a list item with two paragraphs.
This is the second paragraph in the list item. You're only required to indent the first line. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Another item in the same list.
This is a paragraph
This is a normal paragraph:
This is a code block.
"""
assert md_to_html(md) == html
end
fun test_blocks_indented_code2 is test do
var md = """
Here is an example of AppleScript:
tell application "Foo"
beep
end tell
"""
var html = """
Here is an example of AppleScript:
tell application "Foo"
beep
end tell
<div class="footer">
© 2004 Foo Corporation
</div>
"""
assert md_to_html(md) == html
end
fun test_blocks_indented_code3 is test do
var md = """
Here is an example of AppleScript:
beep
"""
var html = """
Here is an example of AppleScript:
beep
"""
assert md_to_html(md) == html
end
fun test_blocks_fenced_code1 is test do
var md = """
Here is an example of AppleScript:
~~~
tell application "Foo"
beep
end tell
~~~
"""
var html = """
Here is an example of AppleScript:
tell application "Foo"
beep
end tell
<div class="footer">
© 2004 Foo Corporation
</div>
"""
assert md_to_html(md) == html
end
fun test_blocks_fenced_code2 is test do
var md = """
Here is an example of AppleScript:
```
tell application "Foo"
beep
end tell
```
"""
var html = """
Here is an example of AppleScript:
tell application "Foo"
beep
end tell
<div class="footer">
© 2004 Foo Corporation
</div>
"""
assert md_to_html(md) == html
end
fun test_blocks_fenced_code3 is test do
var md = """
```nit
print "Hello World!"
```
"""
var html = """
print "Hello World!"
"""
assert md_to_html(md) == html
end
fun test_blocks_fenced_code4 is test do
var md = """
~~~
print "Hello"
~~~
~~~
print "World"
~~~
"""
var html = """
print "Hello"
print "World"
"""
assert md_to_html(md) == html
end
fun test_blocks_fenced_code5 is test do
var md = """
~~~
print "Hello"
~~~
~~~
print "World"
~~~
"""
var html = """
print "Hello"
print "World"
"""
assert md_to_html(md) == html
end
fun test_blocks_nesting1 is test do
var md = """
> ## This is a header.
>
> 1. This is the first list item.
> 2. This is the second list item.
>
> Here's some example code:
>
> return shell_exec("echo $input | $markdown_script");
"""
var html = """
""" assert md_to_html(md) == html end fun test_blocks_nesting2 is test do var md = """ * A list item with a blockquote: > This is a blockquote > inside a list item. """ var html = """This is a header.
- This is the first list item.
- This is the second list item.
Here's some example code:
return shell_exec("echo $input | $markdown_script");
A list item with a blockquote:
This is a blockquote inside a list item.
"""
var html = """
-
A list item with a code block:
<code goes here>
"""
assert md_to_html(md) == html
end
fun test_blocks_nesting4 is test do
var md = """
* Tab
* Tab
* Tab
"""
var html = """
- Tab
- Tab
- Tab
"""
assert md_to_html(md) == html
end
fun test_blocks_nesting5 is test do
var md = """
* this
* sub
that
"""
var html = """
-
this
-
sub
that
"""
assert md_to_html(md) == html
end
end