2019-03-11 12:39:21 +01:00
|
|
|
using Mustache
|
|
|
|
|
|
|
|
# Test parsing
|
2019-03-06 21:27:47 +01:00
|
|
|
|
|
|
|
doc = """
|
|
|
|
|
|
|
|
! println("Something")
|
|
|
|
|
|
|
|
Some markdown with inline stuff and `j code`
|
|
|
|
|
|
|
|
! Not julia code but `j show("is")`
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2020-05-15 16:51:52 +02:00
|
|
|
ms = collect(eachmatch(Weave.INLINE_REGEXES, doc))
|
2019-03-06 21:27:47 +01:00
|
|
|
@test ms[1][2] == "println(\"Something\")"
|
|
|
|
@test ms[2][1] == "code"
|
|
|
|
@test ms[3][1] == "show(\"is\")"
|
|
|
|
|
2020-05-16 12:52:24 +02:00
|
|
|
let
|
|
|
|
_, chunks = Weave.parse_markdown(doc)
|
|
|
|
chunk = first(chunks)
|
2019-03-06 21:27:47 +01:00
|
|
|
@test length(chunk.content) == 7
|
|
|
|
@test chunk.content[2].content == ms[1][2]
|
|
|
|
@test chunk.content[4].content == ms[2][1]
|
|
|
|
@test chunk.content[6].content == ms[3][1]
|
2020-05-16 12:52:24 +02:00
|
|
|
end
|
2019-03-06 21:27:47 +01:00
|
|
|
|
2020-05-16 12:52:24 +02:00
|
|
|
let
|
|
|
|
_, chunks = Weave.parse_markdown(doc)
|
|
|
|
chunk = first(chunks)
|
|
|
|
@test all([chunk.content[i].content == chunk.content[i].content for i in 1:7])
|
|
|
|
end
|
2019-03-11 12:39:21 +01:00
|
|
|
|
|
|
|
# Test with document
|
|
|
|
|
|
|
|
tpl = mt"""
|
|
|
|
{{{ :body }}}
|
|
|
|
"""
|
|
|
|
|
|
|
|
out = weave(joinpath(@__DIR__, "documents", "markdown_beamer.jmd"), doctype="md2html", template=tpl)
|
|
|
|
@test read(out, String) == read(out*".ref", String)
|
|
|
|
rm(out)
|
|
|
|
|
|
|
|
out = weave(joinpath(@__DIR__, "documents", "markdown_beamer.jmd"), doctype="md2tex", template=tpl)
|
|
|
|
@test read(out, String) == read(out*".ref", String)
|
|
|
|
rm(out)
|