# 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.
# Tests for markdown inline constructs
module test_markdown_inlines is test
import test_markdown
class TestMarkdownInlines
super TestMarkdownHtml
test
fun test_inlines_emph1 is test do
var md = """
*single asterisks*
_single underscores_
**double asterisks**
__double underscores__
"""
var html = """
single asterisks
single underscores
double asterisks
double underscores
"""
assert md_to_html(md) == html
end
fun test_inlines_emph2 is test do
var md = "un*frigging*believable"
var html = "unfriggingbelievable
\n"
assert md_to_html(md) == html
end
fun test_inlines_emph3 is test do
var md = "Con _cat_ this"
var html = "Con cat this
\n"
assert md_to_html(md) == html
end
fun test_inlines_emph_ext is test do
var md = "Con_cat_this"
var html = "Con_cat_this
\n"
assert md_to_html(md) == html
end
fun test_inlines_xml1 is test do
var md = """
This is a regular paragraph.
This is another regular paragraph.
"""
var html = """
This is a regular paragraph.
This is another regular paragraph.
"""
assert md_to_html(md) == html
end
fun test_inlines_xml2 is test do
var md = """
This is an image in a regular paragraph.
"""
var html = """
This is an image in a regular paragraph.
"""
assert md_to_html(md) == html
end
fun test_inlines_xml3 is test do
var md = """
"""
var html = """
"""
assert md_to_html(md) == html
end
fun test_inlines_xml4 is test do
var md = """
This is an example of a block element that should be escaped.
Idem for the second paragraph.
"""
assert md_to_html(md) == md
end
fun test_inlines_xml5 is test do
var md = """
# Some more XML tests
This is an example of a block element that should be escaped.
Idem for the second paragraph.
With a *md paragraph*!
"""
var html = """
Some more XML tests
This is an example of a block element that should be escaped.
Idem for the second paragraph.
With a md paragraph!
"""
assert md_to_html(md) == html
end
fun test_escape_bad_html is test do
var md = "-1 if < , +1 if > and 0 otherwise"
var html = "-1 if < , +1 if > and 0 otherwise
\n"
assert md_to_html(md) == html
end
fun test_inlines_span_code1 is test do
var md = "Use the `printf()` function."
var html = "Use the printf()
function.
\n"
assert md_to_html(md) == html
end
fun test_inlines_span_code2 is test do
var md = "``There is a literal backtick (`) here.``"
var html = "There is a literal backtick (`) here.
\n"
assert md_to_html(md) == html
end
fun test_inlines_span_code3 is test do
var md = """
A single backtick in a code span: `` ` ``
A backtick-delimited string in a code span: `` `foo` ``
"""
var html = """
A single backtick in a code span: `
A backtick-delimited string in a code span: `foo`
"""
assert md_to_html(md) == html
end
fun test_inlines_span_code4 is test do
var md = "Please don't use any `