Skip to content

Commit

Permalink
test(inputter): Initiate markdown inputter busted testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Aug 14, 2022
1 parent 12ba2f5 commit b2329cc
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions inputters/markdown_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
SILE = require("core.sile")
SILE.backend = "dummy"
SILE.init()
SILE.utilities.error = error

local astToSil = require("core.ast").astToSil

describe("#Markdown #inputter", function ()
local inputter = SILE.inputters.markdown()

describe("should parse", function ()
it("header", function()
local tree = inputter:parse("# Header\n")
local sil = astToSil(tree)
assert.is.equal([[\begin[class="markdown"]{document}
\markdown:internal:header[level="1"]{Header}
\end{document}
]], sil)
end)
it("header with attributes", function()
local tree = inputter:parse("## Header {#hash - lang=en}\n")
local sil = astToSil(tree)
assert.is.equal([[\begin[class="markdown"]{document}
\markdown:internal:header[class="unnumbered", id="hash", lang="en", level="2"]{Header}
\end{document}
]], sil)
end)
it("basic inline markup", function()
local tree = inputter:parse("normal **bold** _italic_ `code`")
local sil = astToSil(tree)
assert.is.equal([[\begin[class="markdown"]{document}
normal \strong{bold} \em{italic} \code{code}
\end{document}
]], sil)
end)
it("horizontal rule", function()
local tree = inputter:parse("---\n\n")
local sil = astToSil(tree)
assert.is.equal([[\begin[class="markdown"]{document}
\fullrule{}
\end{document}
]], sil)
end)
end)
it("span in paragraph", function()
local tree = inputter:parse("[underlined]{.underline}\n\n")
local sil = astToSil(tree)
assert.is.equal([[\begin[class="markdown"]{document}
\markdown:internal:paragraph{\markdown:internal:span[class="underline"]{underlined}}
\end{document}
]], sil)
end)
it("bullet list", function()
local tree = inputter:parse("- Item1\n- Item2\n")
local sil = astToSil(tree)
assert.is.equal([[\begin[class="markdown"]{document}
\itemize{\item{Item1}\item{Item2}}
\end{document}
]], sil)
end)
end)

0 comments on commit b2329cc

Please sign in to comment.