1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
defmodule Acceptance.Ast.Lists.ListAndInlineCodeTest do
use Support.AcceptanceTestCase
describe "List parsing running into EOI inside inline code" do
test "simple case" do
markdown = """
* And
`Hello
* World
"""
ast = ul(tag("li", "And\n`Hello\n* World"))
messages = [{:warning, 2, "Closing unclosed backquotes ` at end of input"}]
assert as_ast(markdown) == {:error, [ast], messages}
end
test "link with title" do
markdown = ~s(* And\n* `Hello\n* World)
ast = tag("ul", [tag("li", "And"), tag("li", "`Hello\n* World")])
messages = [{:warning, 2, "Closing unclosed backquotes ` at end of input"}]
assert as_ast(markdown) == {:error, [ast], messages}
end
test "error in spaced part" do
markdown = ~s(* And\n `Hello\n * World)
ast = tag("ul", tag("li", "And\n`Hello\n * World"))
messages = [{:warning, 2, "Closing unclosed backquotes ` at end of input"}]
assert as_ast(markdown) == {:error, [ast], messages}
end
test "error in doubly spaced part" do
markdown = """
* And
`Hello
* World
"""
ast = ul(li(tags("p", ["And", "`Hello\n * World"])))
messages = [{:warning, 3, "Closing unclosed backquotes ` at end of input"}]
assert as_ast(markdown) == {:error, [ast], messages}
end
test "even more complex spaced example (checking for one offs)" do
markdown = """
Prefix1
* And
Prefix2
`Hello
* World
"""
ast = [p("Prefix1"), tag("ul", tag("li", ["And\nPrefix2\n`Hello\n * World"]))]
messages = [{:warning, 4, "Closing unclosed backquotes ` at end of input"}]
assert as_ast(markdown) == {:error, ast, messages}
end
end
describe "indentation of code (was regtest #85)" do
test "losing some indent" do
markdown = "1. one\n\n ```elixir\n defmodule```\n"
html = "<ol>\n<li><p>one</p>\n<pre><code class=\"elixir\"> defmodule```</code></pre>\n</li>\n</ol>\n"
ast = parse_html(html)
messages = [{:error, 3, "Fenced Code Block opened with ``` not closed at end of input"}]
assert as_ast(markdown) == {:error, ast, messages}
end
test "less aligned fence is not part of the inline code block" do
markdown = "1. one\n\n ~~~elixir\n defmodule\n ~~~"
ast = [tag("ol", tag("li", [p("one"), tag("pre", tag("code", " defmodule", class: "elixir"))])), pre_code("")]
messages = [
{:error, 3, "Fenced Code Block opened with ~~~ not closed at end of input"},
{:error, 5, "Fenced Code Block opened with ~~~ not closed at end of input"}
]
assert as_ast(markdown) == {:error, ast, messages}
end
test "more aligned fence is part of the inline code block" do
markdown = " 1. one\n ~~~elixir\n defmodule\n ~~~"
ast = [tag("ol", tag("li", ["one", tag("pre", tag("code", ["defmodule"], [{"class", "elixir"}]))]))]
messages = []
assert as_ast(markdown) == {:ok, ast, messages}
end
end
end
|