mirror of https://github.com/mpastell/Weave.jl
Make md2pdf use Julia markdown
parent
db2de48133
commit
8a6aac0129
|
@ -89,13 +89,16 @@ function weave(source ; doctype = :auto, plotlib=:auto,
|
|||
write(io, formatted)
|
||||
end
|
||||
|
||||
#Convert using pandoc
|
||||
#Special for that need external programs
|
||||
if doc.doctype == "pandoc2html"
|
||||
outname = get_outname(out_path, doc, ext = "html")
|
||||
pandoc2html(formatted, doc, outname)
|
||||
elseif doc.doctype == "md2pdf"
|
||||
elseif doc.doctype == "pandoc2pdf"
|
||||
outname = get_outname(out_path, doc, ext = "pdf")
|
||||
pandoc2pdf(formatted, doc, outname)
|
||||
elseif doc.doctype == "md2pdf"
|
||||
xelatex(doc, outname)
|
||||
outname = get_outname(out_path, doc, ext = "pdf")
|
||||
end
|
||||
|
||||
doc.cwd == pwd() && (outname = basename(outname))
|
||||
|
|
|
@ -69,20 +69,6 @@ const pdoc2html = Pandoc("Markdown to HTML (requires Pandoc)",
|
|||
"text/html", "text/markdown", "text/plain"],
|
||||
:doctype=> "md2html"))
|
||||
|
||||
const md2pdf = Pandoc("Markdown to pdf (requires Pandoc and xelatex)",
|
||||
Dict{Symbol,Any}(
|
||||
:codestart => "````julia",
|
||||
:codeend=> "````\n\n",
|
||||
:outputstart=> "````",
|
||||
:outputend=> "````\n\n",
|
||||
:fig_ext=> ".pdf",
|
||||
:extension=> "md",
|
||||
:mimetypes => ["application/pdf", "image/png", "image/jpg",
|
||||
"text/latex", "text/plain"],
|
||||
:doctype=> "md2pdf"))
|
||||
|
||||
|
||||
|
||||
type Markdown
|
||||
description::AbstractString
|
||||
formatdict::Dict{Symbol,Any}
|
||||
|
@ -432,7 +418,7 @@ const formats = Dict{AbstractString, Any}("tex" => tex,
|
|||
"texminted" => texminted,
|
||||
"pandoc" => pandoc,
|
||||
"pandoc2html" => pdoc2html,
|
||||
"md2pdf" => md2pdf,
|
||||
"md2pdf" => md2tex,
|
||||
"github" => github,
|
||||
"multimarkdown" => multimarkdown,
|
||||
"rst" => rst,
|
||||
|
|
|
@ -83,3 +83,18 @@ function pandoc2pdf(formatted::AbstractString, doc::WeaveDoc, outname::AbstractS
|
|||
throw(e)
|
||||
end
|
||||
end
|
||||
|
||||
function xelatex(doc::WeaveDoc, outname)
|
||||
old_wd = pwd()
|
||||
cd(doc.cwd)
|
||||
xname = basename(outname)
|
||||
info("Weaved code to $outname. Running xelatex")
|
||||
try
|
||||
out = readstring(`xelatex $xname`)
|
||||
cd(old_wd)
|
||||
catch e
|
||||
cd(old_wd)
|
||||
warn("Error converting document to pdf")
|
||||
throw(e)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue