# 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

\n

line3 line4

\n

line5

\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 = """

This is a H1

This is a H2

""" assert md_to_html(md) == html end fun test_blocks_headings_2 is test do var md = """ # This is a H1 ## This is a H2 ###### This is a H6 """ var html = """

This is a H1

This is a H2

This is a H6
""" assert md_to_html(md) == html end fun test_blocks_headings_3 is test do var md = """ # This is a H1 # ## This is a H2 ## ### This is a H3 ###### """ var html = """

This is a H1

This is a H2

This is a H3

""" assert md_to_html(md) == html end fun test_blocks_hr1 is test do var md = """ * * * *** ***** - - - --------------------------------------- """ var html = "
\n
\n
\n
\n
\n" assert md_to_html(md) == html end fun test_blocks_bquote1 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.

""" 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.

""" 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 = """

This is the first level of quoting.

This is nested blockquote.

Back to the first level.

""" assert md_to_html(md) == html end fun test_blocks_list1 is test do var md = """ * Red * Green * Blue """ var html = """ """ assert md_to_html(md) == html end fun test_blocks_list2 is test do var md = """ + Red + Green + Blue """ var html = """ """ assert md_to_html(md) == html end fun test_blocks_list3 is test do var md = """ - Red - Green - Blue """ var html = """ """ assert md_to_html(md) == html end fun test_blocks_list4 is test do var md = """ 1. Bird 2. McHale 3. Parish """ var html = """
  1. Bird
  2. McHale
  3. Parish
""" assert md_to_html(md) == html end fun test_blocks_list5 is test do var md = """ 3. Bird 1. McHale 8. Parish """ var html = """
  1. Bird
  2. McHale
  3. Parish
""" assert md_to_html(md) == html end fun test_blocks_list6 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 = """ """ assert md_to_html(md) == html end fun test_blocks_list7 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 = """ """ assert md_to_html(md) == html end fun test_blocks_list8 is test do var md = """ * Bird * Magic """ var html = """ """ assert md_to_html(md) == html end fun test_blocks_list9 is test do var md = """ 1. 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. 2. Suspendisse id sem consectetuer libero luctus adipiscing. """ var html = """
  1. 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.

  2. Suspendisse id sem consectetuer libero luctus adipiscing.

""" assert md_to_html(md) == html end fun test_blocks_list10 is test do var md = """ * 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. """ var html = """ """ assert md_to_html(md) == html end fun test_blocks_list_ext is test do var md = """ This is a paragraph * and this is a list """ var html = """

This is a paragraph

""" assert md_to_html(md) == html end fun test_blocks_indented_code1 is test do var md = """ This is a normal paragraph: This is a code block. """ var html = """

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">
    &copy; 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">
    &copy; 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">
    &copy; 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 = """

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");
""" 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 = """ """ assert md_to_html(md) == html end fun test_blocks_nesting3 is test do var md = """ * A list item with a code block: """ var html = """ """ assert md_to_html(md) == html end fun test_blocks_nesting4 is test do var md = """ * Tab * Tab * Tab """ var html = """ """ assert md_to_html(md) == html end fun test_blocks_nesting5 is test do var md = """ * this * sub that """ var html = """ """ assert md_to_html(md) == html end end