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

Add pandoc-crossref filter support #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
33 changes: 27 additions & 6 deletions src/pandoc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc, outname::Abstract
header_script = doc.header_script
self_contained = (header_script ≠ "") ? [] : "--self-contained"

#Filters setup
filter_flag="--filter"
if haskey(doc.header, "crossref")
filt_cr = filter_flag
crossref = "pandoc-crossref"
else
filt_cr = []
crossref = []
end

if haskey(doc.header, "bibliography")
filt = "--filter"
filt_cite = filter_flag
citeproc = "pandoc-citeproc"
else
filt = []
filt_cite = []
citeproc = []
end

Expand All @@ -40,7 +50,7 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc, outname::Abstract

try
cmd = `pandoc -f markdown+raw_html -s --mathjax=""
$filt $citeproc $pandoc_options
$filt_cr $crossref $filt_cite $citeproc $pandoc_options
--template $html_template -H $css_template $self_contained
-V wversion=$wversion -V wtime=$wtime -V wsource=$wsource
-V highlightcss=$css
Expand Down Expand Up @@ -78,18 +88,29 @@ function pandoc2pdf(formatted::AbstractString, doc::WeaveDoc, outname::AbstractS
cd(doc.cwd)
html =""

#Filters setup
filter_flag="--filter"
if haskey(doc.header, "crossref")
filt_cr = filter_flag
crossref = "pandoc-crossref"
else
filt_cr = []
crossref = []
end

if haskey(doc.header, "bibliography")
filt = "--filter"
filt_cite = filter_flag
citeproc = "pandoc-citeproc"
else
filt = []
filt_cite = []
citeproc = []
end


@info("Done executing code. Running xelatex")
try
cmd = `pandoc -f markdown+raw_tex -s --pdf-engine=xelatex --highlight-style=tango
$filt $citeproc $pandoc_options
$filt_cr $crossref $filt_cite $citeproc $pandoc_options
--include-in-header=$header_template
-V fontsize=12pt -o $outname`
proc = open(cmd, "r+")
Expand Down