mirror of https://github.com/mpastell/Weave.jl
add Weave version
parent
0831144393
commit
cec388e94f
|
@ -9,6 +9,7 @@ Highlights = "eafb193a-b7ab-5a9e-9068-77385905fa72"
|
|||
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
|
||||
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
|
||||
Mustache = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70"
|
||||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
|
||||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
||||
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
|
||||
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Mustache, Highlights, .WeaveMarkdown, Markdown, Dates
|
||||
using Mustache, Highlights, .WeaveMarkdown, Markdown, Dates, Pkg
|
||||
using REPL.REPLCompletions: latex_symbols
|
||||
|
||||
function format(doc::WeaveDoc)
|
||||
|
@ -49,9 +49,7 @@ end
|
|||
function render_doc(formatted, doc, format::JMarkdown2HTML)
|
||||
css = stylesheet(MIME("text/html"), doc.highlight_theme)
|
||||
path, wsource = splitdir(abspath(doc.source))
|
||||
# wversion = string(Pkg.installed("Weave"))
|
||||
wversion = ""
|
||||
wtime = string(Date(now()))
|
||||
wversion, wdate = weave_info()
|
||||
|
||||
theme_path = isempty(doc.css) ? normpath(TEMPLATE_DIR, "skeleton_css.css") : doc.css
|
||||
theme_css = read(theme_path, String)
|
||||
|
@ -70,8 +68,8 @@ function render_doc(formatted, doc, format::JMarkdown2HTML)
|
|||
body = formatted,
|
||||
header_script = doc.header_script,
|
||||
source = wsource,
|
||||
wtime = wtime,
|
||||
wversion = wversion,
|
||||
wdate = wdate,
|
||||
[Pair(Symbol(k), v) for (k, v) in doc.header]...,
|
||||
)
|
||||
end
|
||||
|
@ -79,9 +77,6 @@ end
|
|||
function render_doc(formatted, doc, format::JMarkdown2tex)
|
||||
highlight = stylesheet(MIME("text/latex"), doc.highlight_theme)
|
||||
path, wsource = splitdir(abspath(doc.source))
|
||||
# wversion = string(Pkg.installed("Weave"))
|
||||
wversion = ""
|
||||
wtime = string(Date(now()))
|
||||
|
||||
template = if isa(doc.template, Mustache.MustacheTokens)
|
||||
doc.template
|
||||
|
@ -98,6 +93,14 @@ function render_doc(formatted, doc, format::JMarkdown2tex)
|
|||
)
|
||||
end
|
||||
|
||||
const WEAVE_VERSION = try
|
||||
'v' * Pkg.TOML.parsefile(normpath(PKG_DIR, "Project.toml"))["version"]
|
||||
catch
|
||||
""
|
||||
end
|
||||
|
||||
weave_info() = WEAVE_VERSION, string(Date(now()))
|
||||
|
||||
# TODO: is there any other format where we want to restore headers ?
|
||||
const HEADER_PRESERVE_DOCTYPES = ("github", "hugo")
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@ function pandoc2html(
|
|||
css = stylesheet(MIME("text/html"), doc.highlight_theme)
|
||||
|
||||
path, wsource = splitdir(abspath(doc.source))
|
||||
# wversion = string(Pkg.installed("Weave"))
|
||||
wversion = ""
|
||||
wtime = string(Date(now()))
|
||||
wversion, wdate = weave_info()
|
||||
|
||||
# Header is inserted from displayed plots
|
||||
header_script = doc.header_script
|
||||
|
@ -41,7 +39,7 @@ function pandoc2html(
|
|||
cmd = `pandoc -f markdown+raw_html -s --mathjax=""
|
||||
$filt $citeproc $pandoc_options
|
||||
--template $html_template -H $css_template $self_contained
|
||||
-V wversion=$wversion -V wtime=$wtime -V wsource=$wsource
|
||||
-V wversion=$wversion -V wdate=$wdate -V wsource=$wsource
|
||||
-V highlightcss=$css
|
||||
-V headerscript=$header_script
|
||||
-o $outname`
|
||||
|
@ -72,9 +70,6 @@ function pandoc2pdf(
|
|||
header_template = joinpath(weavedir, "../templates/pandoc_header.txt")
|
||||
|
||||
path, wsource = splitdir(abspath(doc.source))
|
||||
# wversion = string(Pkg.installed("Weave"))
|
||||
wversion = ""
|
||||
wtime = Date(now())
|
||||
outname = basename(outname)
|
||||
|
||||
# Change path for pandoc
|
||||
|
|
|
@ -21,34 +21,30 @@
|
|||
<style type="text/css">
|
||||
{{{ :themecss }}}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<div class ="container">
|
||||
<div class = "row">
|
||||
<div class = "col-md-12 twelve columns">
|
||||
|
||||
<div class="title">
|
||||
{{#:title}}<h1 class="title">{{:title}}</h1>{{/:title}}
|
||||
{{#:author}}<h5>{{{:author}}}</h5>{{/:author}}
|
||||
{{#:date}}<h5>{{{:date}}}</h5>{{/:date}}
|
||||
</div>
|
||||
|
||||
{{{ :body }}}
|
||||
|
||||
|
||||
<HR/>
|
||||
<div class="footer"><p>
|
||||
Published from <a href="{{{:source}}}">{{{:source}}}</a> using
|
||||
<a href="http://github.com/mpastell/Weave.jl">Weave.jl</a>
|
||||
{{:wversion}} on {{:wtime}}.
|
||||
<p></div>
|
||||
<BODY>
|
||||
<div class ="container">
|
||||
<div class = "row">
|
||||
<div class = "col-md-12 twelve columns">
|
||||
<div class="title">
|
||||
{{#:title}}<h1 class="title">{{:title}}</h1>{{/:title}}
|
||||
{{#:author}}<h5>{{{:author}}}</h5>{{/:author}}
|
||||
{{#:date}}<h5>{{{:date}}}</h5>{{/:date}}
|
||||
</div>
|
||||
|
||||
{{{ :body }}}
|
||||
|
||||
<HR/>
|
||||
<div class="footer">
|
||||
<p>
|
||||
Published from <a href="{{{:source}}}">{{{:source}}}</a>
|
||||
using <a href="http://github.com/JunoLab/Weave.jl">Weave.jl</a> {{:wversion}} on {{:wdate}}.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BODY>
|
||||
</div>
|
||||
</BODY>
|
||||
|
||||
</HTML>
|
||||
|
|
|
@ -86,7 +86,7 @@ $endfor$
|
|||
<HR/>
|
||||
<div class="footer"><p>
|
||||
Published from <a href="$wsource$">$wsource$</a> using
|
||||
<a href="http://github.com/mpastell/Weave.jl">Weave.jl</a> $wversion$ on $wtime$.
|
||||
<a href="http://github.com/mpastell/Weave.jl">Weave.jl</a> $wversion$ on $wdate$.
|
||||
<p></div>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue