From 848d373177c4f2ce5f07f8631ff73358d8840afc Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sun, 14 Jun 2020 20:48:34 +0900 Subject: [PATCH] use pandoc_jll --- Project.toml | 1 + src/writer/pandoc.jl | 53 +++++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Project.toml b/Project.toml index 46a710bb..8156a4e3 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/writer/pandoc.jl b/src/writer/pandoc.jl index b0f1456f..184dbba0 100644 --- a/src/writer/pandoc.jl +++ b/src/writer/pandoc.jl @@ -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() @@ -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 @@ -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