mirror of https://github.com/mpastell/Weave.jl
consistent and clearer terminology:
- formatted -> body/rendered - wdate -> weave_date - wsource (or source) -> weave_source - wdate -> weave_datepull/341/head
parent
3c76b804dc
commit
29ff436a00
|
@ -192,23 +192,23 @@ function weave(
|
||||||
end
|
end
|
||||||
|
|
||||||
get!(doc.format.formatdict, :keep_unicode, keep_unicode)
|
get!(doc.format.formatdict, :keep_unicode, keep_unicode)
|
||||||
formatted = format(doc, template, highlight_theme; css = css)
|
rendered = format(doc, template, highlight_theme; css = css)
|
||||||
|
|
||||||
outname = get_outname(out_path, doc)
|
outname = get_outname(out_path, doc)
|
||||||
|
|
||||||
open(io->write(io,formatted), outname, "w")
|
open(io->write(io,rendered), outname, "w")
|
||||||
|
|
||||||
# document generation via external programs
|
# document generation via external programs
|
||||||
doctype = doc.doctype
|
doctype = doc.doctype
|
||||||
if doctype == "pandoc2html"
|
if doctype == "pandoc2html"
|
||||||
mdname = outname
|
mdname = outname
|
||||||
outname = get_outname(out_path, doc, ext = "html")
|
outname = get_outname(out_path, doc, ext = "html")
|
||||||
pandoc2html(formatted, doc, highlight_theme, outname, pandoc_options)
|
pandoc2html(rendered, doc, highlight_theme, outname, pandoc_options)
|
||||||
rm(mdname)
|
rm(mdname)
|
||||||
elseif doctype == "pandoc2pdf"
|
elseif doctype == "pandoc2pdf"
|
||||||
mdname = outname
|
mdname = outname
|
||||||
outname = get_outname(out_path, doc, ext = "pdf")
|
outname = get_outname(out_path, doc, ext = "pdf")
|
||||||
pandoc2pdf(formatted, doc, outname, pandoc_options)
|
pandoc2pdf(rendered, doc, outname, pandoc_options)
|
||||||
rm(mdname)
|
rm(mdname)
|
||||||
elseif doctype == "md2pdf"
|
elseif doctype == "md2pdf"
|
||||||
run_latex(doc, outname, latex_cmd)
|
run_latex(doc, outname, latex_cmd)
|
||||||
|
|
|
@ -17,37 +17,37 @@ function format(doc, template = nothing, highlight_theme = nothing; css = nothin
|
||||||
|
|
||||||
restore_header!(doc)
|
restore_header!(doc)
|
||||||
|
|
||||||
formatted_lines = map(copy(doc.chunks)) do chunk
|
lines = map(copy(doc.chunks)) do chunk
|
||||||
format_chunk(chunk, formatdict, format)
|
format_chunk(chunk, formatdict, format)
|
||||||
end
|
end
|
||||||
formatted = join(formatted_lines, '\n')
|
body = join(lines, '\n')
|
||||||
|
|
||||||
return format isa JMarkdown2HTML ? render2html(formatted, doc, template, css, highlight_theme) :
|
return format isa JMarkdown2HTML ? render2html(body, doc, template, css, highlight_theme) :
|
||||||
format isa JMarkdown2tex ? render2tex(formatted, doc, template, highlight_theme) :
|
format isa JMarkdown2tex ? render2tex(body, doc, template, highlight_theme) :
|
||||||
formatted
|
body
|
||||||
end
|
end
|
||||||
|
|
||||||
function render2html(formatted, doc, template, css, highlight_theme)
|
function render2html(body, doc, template, css, highlight_theme)
|
||||||
_, source = splitdir(abspath(doc.source))
|
_, weave_source = splitdir(abspath(doc.source))
|
||||||
wversion, wdate = weave_info()
|
weave_version, weave_date = weave_info()
|
||||||
|
|
||||||
return Mustache.render(
|
return Mustache.render(
|
||||||
get_template(template, false);
|
get_template(template, false);
|
||||||
body = formatted,
|
body = body,
|
||||||
themecss = get_stylesheet(css),
|
stylesheet = get_stylesheet(css),
|
||||||
highlightcss = get_highlight_stylesheet(MIME("text/html"), highlight_theme),
|
highlight_stylesheet = get_highlight_stylesheet(MIME("text/html"), highlight_theme),
|
||||||
header_script = doc.header_script,
|
header_script = doc.header_script,
|
||||||
source = source,
|
weave_source = weave_source,
|
||||||
wversion = wversion,
|
weave_version = weave_version,
|
||||||
wdate = wdate,
|
weave_date = weave_date,
|
||||||
[Pair(Symbol(k), v) for (k, v) in doc.header]...,
|
[Pair(Symbol(k), v) for (k, v) in doc.header]...,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function render2tex(formatted, doc, template, highlight_theme)
|
function render2tex(body, doc, template, highlight_theme)
|
||||||
return Mustache.render(
|
return Mustache.render(
|
||||||
get_template(template, true);
|
get_template(template, true);
|
||||||
body = formatted,
|
body = body,
|
||||||
highlight = get_highlight_stylesheet(MIME("text/latex"), highlight_theme),
|
highlight = get_highlight_stylesheet(MIME("text/latex"), highlight_theme),
|
||||||
[Pair(Symbol(k), v) for (k, v) in doc.header]...,
|
[Pair(Symbol(k), v) for (k, v) in doc.header]...,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
function pandoc2html(formatted, doc, highlight_theme, outname, pandoc_options)
|
function pandoc2html(rendered, doc, highlight_theme, outname, pandoc_options)
|
||||||
template_path = normpath(PKG_DIR, "templates/pandoc_skeleton.html")
|
template_path = normpath(PKG_DIR, "templates/pandoc_skeleton.html")
|
||||||
themecss_path = normpath(PKG_DIR, "templates/pandoc_skeleton.css")
|
stylesheet_path = normpath(PKG_DIR, "templates/pandoc_skeleton.css")
|
||||||
highlightcss = get_highlight_stylesheet(MIME("text/html"), highlight_theme)
|
highlight_stylesheet = get_highlight_stylesheet(MIME("text/html"), highlight_theme)
|
||||||
|
|
||||||
path, wsource = splitdir(abspath(doc.source))
|
_, weave_source = splitdir(abspath(doc.source))
|
||||||
wversion, wdate = weave_info()
|
weave_version, weave_date = weave_info()
|
||||||
|
|
||||||
# Header is inserted from displayed plots
|
# Header is inserted from displayed plots
|
||||||
header_script = doc.header_script
|
header_script = doc.header_script
|
||||||
|
@ -27,16 +27,16 @@ function pandoc2html(formatted, doc, highlight_theme, outname, pandoc_options)
|
||||||
cmd = `pandoc -f markdown+raw_html -s --mathjax=""
|
cmd = `pandoc -f markdown+raw_html -s --mathjax=""
|
||||||
$filt $citeproc $pandoc_options
|
$filt $citeproc $pandoc_options
|
||||||
--template $template_path
|
--template $template_path
|
||||||
-H $themecss_path
|
-H $stylesheet_path
|
||||||
$self_contained
|
$self_contained
|
||||||
-V wversion=$wversion
|
-V highlight_stylesheet=$highlight_stylesheet
|
||||||
-V wdate=$wdate
|
-V weave_version=$weave_version
|
||||||
-V wsource=$wsource
|
-V weave_date=$weave_date
|
||||||
-V highlightcss=$highlightcss
|
-V weave_source=$weave_source
|
||||||
-V headerscript=$header_script
|
-V headerscript=$header_script
|
||||||
-o $outname`
|
-o $outname`
|
||||||
proc = open(cmd, "r+")
|
proc = open(cmd, "r+")
|
||||||
println(proc.in, formatted)
|
println(proc.in, rendered)
|
||||||
close(proc.in)
|
close(proc.in)
|
||||||
proc_output = read(proc.out, String)
|
proc_output = read(proc.out, String)
|
||||||
catch
|
catch
|
||||||
|
@ -47,11 +47,10 @@ function pandoc2html(formatted, doc, highlight_theme, outname, pandoc_options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function pandoc2pdf(formatted, doc, outname, pandoc_options)
|
function pandoc2pdf(rendered, doc, outname, pandoc_options)
|
||||||
weavedir = dirname(@__FILE__)
|
weavedir = dirname(@__FILE__)
|
||||||
header_template = joinpath(weavedir, "../templates/pandoc_header.txt")
|
header_template = joinpath(weavedir, "../templates/pandoc_header.txt")
|
||||||
|
|
||||||
path, wsource = splitdir(abspath(doc.source))
|
|
||||||
outname = basename(outname)
|
outname = basename(outname)
|
||||||
|
|
||||||
# Change path for pandoc
|
# Change path for pandoc
|
||||||
|
@ -73,7 +72,7 @@ function pandoc2pdf(formatted, doc, outname, pandoc_options)
|
||||||
--include-in-header=$header_template
|
--include-in-header=$header_template
|
||||||
-V fontsize=12pt -o $outname`
|
-V fontsize=12pt -o $outname`
|
||||||
proc = open(cmd, "r+")
|
proc = open(cmd, "r+")
|
||||||
println(proc.in, formatted)
|
println(proc.in, rendered)
|
||||||
close(proc.in)
|
close(proc.in)
|
||||||
proc_output = read(proc.out, String)
|
proc_output = read(proc.out, String)
|
||||||
catch
|
catch
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{{ :highlightcss }}}
|
{{{ :highlight_stylesheet }}}
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
{{{ :themecss }}}
|
{{{ :stylesheet }}}
|
||||||
</style>
|
</style>
|
||||||
</HEAD>
|
</HEAD>
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@
|
||||||
<HR/>
|
<HR/>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p>
|
<p>
|
||||||
Published from <a href="{{{:source}}}">{{{:source}}}</a>
|
Published from <a href="{{{:weave_source}}}">{{{:weave_source}}}</a>
|
||||||
using <a href="http://github.com/JunoLab/Weave.jl">Weave.jl</a> {{:wversion}} on {{:wdate}}.
|
using <a href="http://github.com/JunoLab/Weave.jl">Weave.jl</a> {{:weave_version}} on {{:weave_date}}.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -32,7 +32,7 @@ $for(header-includes)$
|
||||||
$header-includes$
|
$header-includes$
|
||||||
$endfor$
|
$endfor$
|
||||||
|
|
||||||
$highlightcss$
|
$highlight_stylesheet$
|
||||||
|
|
||||||
$if(highlighting-css)$
|
$if(highlighting-css)$
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
@ -85,8 +85,8 @@ $endfor$
|
||||||
|
|
||||||
<HR/>
|
<HR/>
|
||||||
<div class="footer"><p>
|
<div class="footer"><p>
|
||||||
Published from <a href="$wsource$">$wsource$</a> using
|
Published from <a href="$source$">$source$</a> using
|
||||||
<a href="http://github.com/mpastell/Weave.jl">Weave.jl</a> $wversion$ on $wdate$.
|
<a href="http://github.com/mpastell/Weave.jl">Weave.jl</a> $weave_version$ on $weave_date$.
|
||||||
<p></div>
|
<p></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue