mirror of https://github.com/mpastell/Weave.jl
`WEAVE_OPTION_NAME`
parent
36bdd4f82b
commit
4dae2a0816
|
@ -4,7 +4,7 @@ using Mustache
|
|||
using Requires
|
||||
|
||||
|
||||
const WEAVE_OPTION = "options" # TODO: rename to "weave_options"
|
||||
const WEAVE_OPTION_NAME = "options" # TODO: rename to "weave_options"
|
||||
|
||||
function __init__()
|
||||
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Base.include(
|
||||
|
@ -126,7 +126,7 @@ function weave(
|
|||
doc.doctype = doctype
|
||||
|
||||
# Read args from document header, overrides command line args
|
||||
if haskey(doc.header, "options")
|
||||
if haskey(doc.header, WEAVE_OPTION_NAME)
|
||||
(
|
||||
doctype,
|
||||
informat,
|
||||
|
|
|
@ -107,7 +107,7 @@ function header_args(
|
|||
pandoc_options,
|
||||
latex_cmd,
|
||||
)
|
||||
args = get(doc.header, "options", Dict())
|
||||
args = get(doc.header, WEAVE_OPTION_NAME, Dict())
|
||||
doctype = get(args, "doctype", doc.doctype)
|
||||
args = combine_args(args, doctype)
|
||||
informat = get(args, "informat", :auto)
|
||||
|
|
|
@ -131,7 +131,7 @@ function strip_header!(docchunk::DocChunk, doctype)
|
|||
else
|
||||
# only strips Weave headers
|
||||
header = YAML.load(m[:header])
|
||||
delete!(header, "options")
|
||||
delete!(header, WEAVE_OPTION_NAME)
|
||||
if isempty(header)
|
||||
lstrip(replace(content, HEADER_REGEX => ""))
|
||||
else
|
||||
|
|
|
@ -20,9 +20,9 @@ function WeaveDoc(source, chunks)
|
|||
header = parse_header(first(chunks))
|
||||
# get chunk defaults from header and update
|
||||
chunk_defaults = deepcopy(rcParams[:chunk_defaults])
|
||||
if haskey(header, WEAVE_OPTION)
|
||||
if haskey(header, WEAVE_OPTION_NAME)
|
||||
for key in keys(chunk_defaults)
|
||||
if (val = get(header[WEAVE_OPTION], string(key), nothing)) !== nothing
|
||||
if (val = get(header[WEAVE_OPTION_NAME], string(key), nothing)) !== nothing
|
||||
chunk_defaults[key] = val
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using YAML
|
||||
using Weave.YAML
|
||||
|
||||
# TODO:
|
||||
# - header stripping
|
||||
|
@ -19,7 +19,7 @@ options:
|
|||
---
|
||||
""")
|
||||
|
||||
let args = header["options"]
|
||||
let args = header[Weave.WEAVE_OPTION_NAME]
|
||||
@test Weave.combine_args(args, "md2html") == Dict("fig_ext" => ".png", "out_path" => "html/")
|
||||
@test Weave.combine_args(args, "github") == Dict("fig_ext" => ".png", "out_path" => "md/")
|
||||
@test Weave.combine_args(args, "pandoc") == Dict("fig_ext" => ".png", "out_path" => "reports")
|
||||
|
|
Loading…
Reference in New Issue