Weave.jl/src/pandoc.jl

33 lines
894 B
Julia
Raw Normal View History

"""
`pandoc2html(formatted::AbstractString)`
Convert output from pandoc markdown to html using Weave.jl template
"""
function pandoc2html(formatted::AbstractString, doc::WeaveDoc)
html_template = joinpath(Pkg.dir("Weave"), "templates/pandoc_skeleton.html")
css_template = joinpath(Pkg.dir("Weave"), "templates/pandoc_skeleton.css")
path, wsource = splitdir(abspath(doc.source))
wversion = string(Pkg.installed("Weave"))
wtime = Date(now())
#Change path for pandoc
old_wd = pwd()
cd(doc.cwd)
2016-04-20 16:04:38 +02:00
html =""
2016-04-20 16:04:38 +02:00
try
html = readall(pipeline(`echo $formatted` ,
`pandoc -R -s --mathjax --self-contained --template
2016-04-20 15:58:38 +02:00
$html_template --include-in-header=$css_template -V wversion=$wversion -V wtime=$wtime -V wsource=$wsource`)
)
2016-04-20 16:04:38 +02:00
catch
cd(old_wd)
error("Unable to convert to html, check that you have pandoc installed and in your path")
end
return(html)
end