Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pandoc_jll #375

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
pandoc_jll = "c5432543-76ad-5c9d-82bf-db097047a5e2"

[compat]
Highlights = "0.3.1, 0.4"
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/htmlformats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ end
# ------

Base.@kwdef mutable struct Pandoc2HTML <: HTMLFormat
description = "HTML via intermediate Pandoc Markdown (requires Pandoc 2)"
description = "HTML via intermediate Pandoc Markdown"
extension = "md"
codestart = "\n"
codeend = "\n"
Expand Down
53 changes: 30 additions & 23 deletions src/writer/pandoc.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using pandoc_jll


function write_doc(docformat::Pandoc2HTML, doc, rendered, out_path)
_, weave_source = splitdir(abspath(doc.source))
weave_version, weave_date = weave_info()
Expand All @@ -20,21 +23,23 @@ function write_doc(docformat::Pandoc2HTML, doc, rendered, out_path)
try
out = basename(out_path)
highlight_stylesheet = get_highlight_stylesheet(MIME("text/html"), docformat.highlight_theme)
cmd = `pandoc -f markdown+raw_html -s --mathjax=""
$filt $citeproc $(docformat.pandoc_options)
--template $(docformat.template_path)
-H $(docformat.stylesheet_path)
$(self_contained)
-V highlight_stylesheet=$(highlight_stylesheet)
-V weave_version=$(weave_version)
-V weave_date=$(weave_date)
-V weave_source=$(weave_source)
-V headerscript=$(header_script)
-o $(out)`
proc = open(cmd, "r+")
println(proc.in, rendered)
close(proc.in)
proc_output = read(proc.out, String)
pandoc() do pandoc_exe
cmd = `$(pandoc_exe) -f markdown+raw_html -s --mathjax=""
$filt $citeproc $(docformat.pandoc_options)
--template $(docformat.template_path)
-H $(docformat.stylesheet_path)
$(self_contained)
-V highlight_stylesheet=$(highlight_stylesheet)
-V weave_version=$(weave_version)
-V weave_date=$(weave_date)
-V weave_source=$(weave_source)
-V headerscript=$(header_script)
-o $(out)`
proc = open(cmd, "r+")
println(proc.in, rendered)
close(proc.in)
read(proc.out, String)
end
catch
rethrow() # TODO: just show error content instead of rethrow the err
finally
Expand All @@ -58,14 +63,16 @@ function write_doc(docformat::Pandoc2PDF, doc, rendered, out_path)
cd(dirname(out_path))
try
out = basename(out_path)
cmd = `pandoc -f markdown+raw_tex -s --pdf-engine=xelatex --highlight-style=tango
$filt $citeproc $(docformat.pandoc_options)
--include-in-header=$(docformat.header_template)
-V fontsize=12pt -o $(out)`
proc = open(cmd, "r+")
println(proc.in, rendered)
close(proc.in)
proc_output = read(proc.out, String)
pandoc() do pandoc_exe
cmd = `$(pandoc_exe) -f markdown+raw_tex -s --pdf-engine=xelatex --highlight-style=tango
$filt $citeproc $(docformat.pandoc_options)
--include-in-header=$(docformat.header_template)
-V fontsize=12pt -o $(out)`
proc = open(cmd, "r+")
println(proc.in, rendered)
close(proc.in)
read(proc.out, String)
end
catch
rethrow()
finally
Expand Down
4 changes: 2 additions & 2 deletions test/end2end/test_simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ using Weave.Dates


test_doctypes = filter(first.(Weave.list_out_formats())) do doctype
# don't test doctypes which need external programs
doctype ∉ ("pandoc2html", "pandoc2pdf", "md2pdf")
# don't test doctypes which need LaTeX to be installed
doctype ∉ ("pandoc2pdf", "md2pdf")
end

function test_func(body)
Expand Down