mirror of https://github.com/mpastell/Weave.jl
more generic name
parent
db5308b286
commit
29546b7716
|
@ -194,7 +194,7 @@ function weave(
|
|||
keep_unicode = get(weave_options, "keep_unicode", keep_unicode)
|
||||
end
|
||||
|
||||
set_rendering_options!(doc; template = template, highlight_theme = highlight_theme, css = css, keep_unicode = keep_unicode)
|
||||
set_format_options!(doc; template = template, highlight_theme = highlight_theme, css = css, keep_unicode = keep_unicode)
|
||||
rendered = render_doc(doc)
|
||||
|
||||
out_path = get_out_path(doc, out_path)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# fallback methods
|
||||
# ----------------
|
||||
|
||||
set_rendering_options!(docformat::WeaveFormat; kwargs...) = return
|
||||
set_format_options!(docformat::WeaveFormat; _kwargs...) = return
|
||||
|
||||
function restore_header!(doc)
|
||||
(hasproperty(doc.format, :preserve_header) && doc.format.preserve_header) || return
|
||||
|
@ -149,8 +149,8 @@ end
|
|||
|
||||
addlines(op, inline) = inline.ctype === :line ? string('\n', op, '\n') : op
|
||||
|
||||
get_template(path::AbstractString) = Mustache.template_from_file(path)
|
||||
get_template(tpl::Mustache.MustacheTokens) = tpl
|
||||
get_mustache_template(path::AbstractString) = Mustache.template_from_file(path)
|
||||
get_mustache_template(tpl::Mustache.MustacheTokens) = tpl
|
||||
|
||||
get_highlight_stylesheet(mime, highlight_theme) =
|
||||
get_highlight_stylesheet(mime, get_highlight_theme(highlight_theme))
|
||||
|
|
|
@ -35,14 +35,14 @@ Base.@kwdef mutable struct JMarkdown2HTML <: HTMLFormat
|
|||
end
|
||||
register_format!("md2html", JMarkdown2HTML())
|
||||
|
||||
function set_rendering_options!(docformat::JMarkdown2HTML; template = nothing, css = nothing, highlight_theme = nothing, kwargs...)
|
||||
function set_format_options!(docformat::JMarkdown2HTML; template = nothing, css = nothing, highlight_theme = nothing, _kwargs...)
|
||||
docformat.template = get_html_template(template)
|
||||
docformat.stylesheet = get_stylesheet(css)
|
||||
docformat.highlight_theme = get_highlight_theme(highlight_theme)
|
||||
end
|
||||
|
||||
get_html_template(::Nothing) = get_template(normpath(TEMPLATE_DIR, "md2html.tpl"))
|
||||
get_html_template(x) = get_template(x)
|
||||
get_html_template(::Nothing) = get_mustache_template(normpath(TEMPLATE_DIR, "md2html.tpl"))
|
||||
get_html_template(x) = get_mustache_template(x)
|
||||
|
||||
get_stylesheet(::Nothing) = get_stylesheet(normpath(STYLESHEET_DIR, "skeleton.css"))
|
||||
get_stylesheet(path::AbstractString) = read(path, String)
|
||||
|
|
|
@ -13,7 +13,7 @@ const FORMATS = Dict{String,WeaveFormat}()
|
|||
register_format!(format_name::AbstractString, format::WeaveFormat) = push!(FORMATS, format_name => format)
|
||||
register_format!(_, format) = error("Format needs to be a subtype of WeaveFormat.")
|
||||
|
||||
set_rendering_options!(doc; kwargs...) = set_rendering_options!(doc.format; kwargs...)
|
||||
set_format_options!(doc; kwargs...) = set_format_options!(doc.format; kwargs...)
|
||||
|
||||
function render_doc(doc::WeaveDoc)
|
||||
restore_header!(doc)
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
abstract type TexFormat <: WeaveFormat end
|
||||
|
||||
function set_rendering_options!(docformat::TexFormat; keep_unicode = false, template=nothing, kwargs...)
|
||||
function set_format_options!(docformat::TexFormat; keep_unicode = false, template=nothing, _kwargs...)
|
||||
docformat.keep_unicode |= keep_unicode
|
||||
docformat.template = get_tex_template(template)
|
||||
end
|
||||
|
||||
get_tex_template(::Nothing) = get_template(normpath(TEMPLATE_DIR, "md2pdf.tpl"))
|
||||
get_tex_template(x) = get_template(x)
|
||||
get_tex_template(::Nothing) = get_mustache_template(normpath(TEMPLATE_DIR, "md2pdf.tpl"))
|
||||
get_tex_template(x) = get_mustache_template(x)
|
||||
|
||||
# very similar to export to html
|
||||
function format_chunk(chunk::DocChunk, docformat::TexFormat)
|
||||
|
@ -203,7 +203,7 @@ end
|
|||
register_format!("md2tex", JMarkdown2PDF())
|
||||
register_format!("md2pdf", JMarkdown2PDF())
|
||||
|
||||
function set_rendering_options!(docformat::JMarkdown2PDF; template = nothing, highlight_theme = nothing, keep_unicode = false, kwargs...)
|
||||
function set_format_options!(docformat::JMarkdown2PDF; template = nothing, highlight_theme = nothing, keep_unicode = false, _kwargs...)
|
||||
docformat.template = get_tex_template(template)
|
||||
docformat.highlight_theme = get_highlight_theme(highlight_theme)
|
||||
docformat.keep_unicode |= keep_unicode
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
```
|
||||
"""
|
||||
doc = mock_run(str; doctype = "md2tex")
|
||||
Weave.set_rendering_options!(doc.format)
|
||||
Weave.set_format_options!(doc.format)
|
||||
rendered = Weave.render_doc(doc)
|
||||
@test occursin("alpha", rendered)
|
||||
@test !occursin("α", rendered)
|
||||
|
||||
doc = mock_run(str; doctype = "md2tex")
|
||||
Weave.set_rendering_options!(doc.format; keep_unicode = true)
|
||||
Weave.set_format_options!(doc.format; keep_unicode = true)
|
||||
rendered = Weave.render_doc(doc)
|
||||
@test !occursin("alpha", rendered)
|
||||
@test occursin("α", rendered)
|
||||
|
|
Loading…
Reference in New Issue