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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
defmodule Test.Acceptance.Ast.Lists.ComplexHeadTest do
use Support.AcceptanceTestCase
import Support.AstHelpers, only: [ast_from_md: 1, ast_with_errors: 1]
describe "Headers become one junk of text" do
test "at end of input" do
markdown = """
* First
Second
"""
expected = [ul(li(["First", pre_code(" Second")]))]
assert ast_from_md(markdown) == expected
end
test "before end of list" do
markdown = """
* Primo
Secondo
# Ciao
"""
expected = [ul(li(["Primo", pre_code(" Secondo")])), tag("h1", "Ciao")]
assert ast_from_md(markdown) == expected
end
test "before and of list item" do
markdown = """
* первый
второй
* Привет
"""
expected = [ul([li(["первый", pre_code(" второй")]), li("Привет")])]
assert ast_from_md(markdown) == expected
end
test "before body" do
markdown = """
* uma
duas
Olá
"""
expected = [ul(li([p("uma\n duas"), p("Olá")]))]
assert ast_from_md(markdown) == expected
end
end
describe "Headers contain block data" do
test "blockquote at the beginning" do
markdown = """
* > σπουδαίος
"""
expected = [ul(blockquote("σπουδαίος"))]
assert ast_from_md(markdown) == expected
end
test "blockquote in the middle" do
markdown = """
* banale
> important
"""
expected = [ul(li(["banale", blockquote("important")]))]
assert ast_from_md(markdown) == expected
end
end
describe "Ending Headers" do
test "by a blank line" do
markdown = """
* Rien à voir, circulez
Text
"""
expected = [ul(["Rien à voir, circulez"]), p("Text")]
assert ast_from_md(markdown) == expected
end
end
describe "cmark-gfm compliance - and what we do with it" do
test "parse blocks in headers if they are indented _correctly_" do
markdown = """
- a
> b
> c
"""
expected = [ul(li(["a", pre_code("> b"), blockquote("c")]))]
assert ast_from_md(markdown) == expected
end
test "parse headlines in headers if they are indented _correctly_" do
markdown = """
- a
# b
# c
"""
expected = [ul(li(["a", pre_code("# b"), tag("h1", "c")]))]
assert ast_from_md(markdown) == expected
end
test "blocks with negative indent stop the list/item, but text does not" do
markdown = """
- a
> b
c
> d
"""
expected = [
ul(li(["a", blockquote("b\nc\nd")]))
]
assert ast_from_md(markdown) == expected
end
test "headline with negative indent stop the list/item definitely, but we need to align correctly" do
markdown = """
- a
## b
c
# d
"""
expected = [
ul(li(["a\n ## b\nc", tag("h1", "d")]))
]
assert ast_from_md(markdown) == expected
end
test "headline with negative indent stop the list/item definitely, if aligned correctly" do
markdown = """
- a
## b
c
# d
"""
expected = [
ul("a\n ## b\nc"),
tag("h1", "d")
]
assert ast_from_md(markdown) == expected
end
test "negatively indexed outside of a block element is still part of the item" do
markdown = """
- a
c
"""
expected = [
ul(li("a\nc"))
]
assert ast_from_md(markdown) == expected
end
test "negatively indexed outside of a block element is not part of the item after a header" do
markdown = """
- a
# b
c
"""
expected = [
ul(li(["a", tag("h1", "b"), "c"]))
]
assert ast_from_md(markdown) == expected
end
test "negatively indexed outside of a block element is not part of the item after text" do
markdown = """
- a
# b
c
"""
expected = [
ul(li(["a", tag("h1", "b"), "c"]))
]
assert ast_from_md(markdown) == expected
end
test "negatively indexed outside of a block element is again part of the item after an indented header" do
markdown = """
- a
# b
c
"""
expected = [ul(li(["a", pre_code("# b"), "c"]))]
assert ast_from_md(markdown) == expected
end
test "block element negatively indexed ends the list" do
markdown = """
- a
> b
"""
expected = [ul(li(["a", blockquote("b")]))]
assert ast_from_md(markdown) == expected
end
test "header element negatively indexed ends the list" do
markdown = """
- a
# b
"""
expected = [ul("a"), tag("h1", "b")]
assert ast_from_md(markdown) == expected
end
test "code element negatively indexed ends the list, but not for us" do
markdown = """
- a
```
b
```
"""
expected = [ul(li(["a", pre_code("b")]))]
assert ast_from_md(markdown) == expected
end
end
describe "pending inline code" do
test "simplest possible case" do
markdown = """
- a `
"""
expected = {[ul("a `")], [{:warning, 1, "Closing unclosed backquotes ` at end of input"}]}
assert ast_with_errors(markdown) == expected
end
end
end
# SPDX-License-Identifier: Apache-2.0
|