mirror of https://github.com/mpastell/Weave.jl
more consistent templates names, move stylesheets into ./stylesheets
parent
b8b9b095b7
commit
0bc0d3b510
|
@ -41,8 +41,8 @@ e.g.: `weave("FIR_design_plots.jl", template = "custom.tpl"`.
|
|||
|
||||
As starting point, you can use the existing templates:
|
||||
|
||||
- HTML (`md2html`): [julia_html.tpl](https://github.com/mpastell/Weave.jl/blob/master/templates/julia_html.tpl)
|
||||
- LaTex (`md2pdf`): [julia_tex.tpl](https://github.com/mpastell/Weave.jl/blob/master/templates/julia_tex.tpl)
|
||||
- HTML (`md2html`): [`md2html.tpl`](https://github.com/mpastell/Weave.jl/blob/master/templates/md2html.tpl)
|
||||
- LaTex (`md2pdf`): [`md2pdf.tpl`](https://github.com/mpastell/Weave.jl/blob/master/templates/md2pdf.tpl)
|
||||
|
||||
Templates are rendered using [Mustache.jl](https://github.com/jverzani/Mustache.jl).
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using Highlights, Mustache, Requires
|
|||
|
||||
const PKG_DIR = normpath(@__DIR__, "..")
|
||||
const TEMPLATE_DIR = normpath(PKG_DIR, "templates")
|
||||
const STYLESHEET_DIR = normpath(PKG_DIR, "stylesheets")
|
||||
const WEAVE_OPTION_NAME = "weave_options"
|
||||
const WEAVE_OPTION_NAME_DEPRECATED = "options" # remove this when tagging v0.11
|
||||
const WEAVE_OPTION_DEPRECATE_ID = "weave_option_duplicate_id"
|
||||
|
|
|
@ -57,11 +57,11 @@ get_highlight_theme(::Nothing) = Highlights.Themes.DefaultTheme
|
|||
get_highlight_theme(highlight_theme::Type{<:Highlights.AbstractTheme}) = highlight_theme
|
||||
|
||||
get_template(::Nothing, tex::Bool = false) =
|
||||
Mustache.template_from_file(normpath(TEMPLATE_DIR, tex ? "julia_tex.tpl" : "julia_html.tpl"))
|
||||
Mustache.template_from_file(normpath(TEMPLATE_DIR, tex ? "md2pdf.tpl" : "md2html.tpl"))
|
||||
get_template(path::AbstractString, tex) = Mustache.template_from_file(path)
|
||||
get_template(tpl::Mustache.MustacheTokens, tex) = tpl
|
||||
|
||||
get_stylesheet(::Nothing) = get_stylesheet(normpath(TEMPLATE_DIR, "skeleton_css.css"))
|
||||
get_stylesheet(::Nothing) = get_stylesheet(normpath(STYLESHEET_DIR, "skeleton.css"))
|
||||
get_stylesheet(path::AbstractString) = read(path, String)
|
||||
|
||||
get_highlight_stylesheet(mime, highlight_theme) =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
function pandoc2html(rendered, doc, highlight_theme, outname, pandoc_options)
|
||||
template_path = normpath(PKG_DIR, "templates/pandoc_skeleton.html")
|
||||
stylesheet_path = normpath(PKG_DIR, "templates/pandoc_skeleton.css")
|
||||
template_path = normpath(TEMPLATE_DIR, "pandoc2html.html")
|
||||
stylesheet_path = normpath(STYLESHEET_DIR, "pandoc2html_skeleton.css")
|
||||
highlight_stylesheet = get_highlight_stylesheet(MIME("text/html"), highlight_theme)
|
||||
|
||||
_, weave_source = splitdir(abspath(doc.source))
|
||||
|
@ -48,8 +48,7 @@ function pandoc2html(rendered, doc, highlight_theme, outname, pandoc_options)
|
|||
end
|
||||
|
||||
function pandoc2pdf(rendered, doc, outname, pandoc_options)
|
||||
weavedir = dirname(@__FILE__)
|
||||
header_template = joinpath(weavedir, "../templates/pandoc_header.txt")
|
||||
header_template = normpath(TEMPLATE_DIR, "pandoc2pdf_header.txt")
|
||||
|
||||
outname = basename(outname)
|
||||
|
||||
|
|
Loading…
Reference in New Issue