fix header handling in noweb doc

pull/331/head
Shuhei Kadowaki 2020-05-16 20:33:48 +09:00
parent 6121d21bfb
commit ba8e9f4724
4 changed files with 15 additions and 15 deletions

View File

@ -5,7 +5,7 @@ A YAML header should be in the beginning of the input document delimited with `-
!!! warning
YAML header configuration is only supported when `weave`ing [Julia markdown documents](@ref document-syntax).
YAML header configuration is only supported when `weave`ing [markdown or Noweb syntax documents](@ref document-syntax).
## Document Metadata
@ -31,7 +31,7 @@ date: 16th May 2020
### Dynamic Metadata
The metadata can be "dynamic"; if you have [inline code](@ref) within YAML header, they will be evaluated _after_ evaluating all the chunks and replaced with the results.
The metadata can be given "dynamically"; if you have [inline code](@ref) within YAML header, they will be evaluated _after_ evaluating all the chunks and replaced with the results.
The example document below will set `date` metadata dynamically.
Note that `Date` is available since the chunk is evaluated first.

View File

@ -75,7 +75,7 @@ return "noweb"
## Documentation Chunks
In Markdown and Noweb input formats documentation chunks are the parts that aren't inside code delimiters. Documentation chunks can be written with several different markup languages.
In markdown and Noweb input formats documentation chunks are the parts that aren't inside code delimiters. Documentation chunks can be written with several different markup languages.
## Code Chunks

View File

@ -1,14 +1,12 @@
function parse_markdown(document_body; is_pandoc = false)
if is_pandoc
header = Dict()
offset = 0
code_start = r"^<<(?<options>.*?)>>=\s*$"
code_end = r"^@\s*$"
header_text, document_body, offset = separate_header_text(document_body)
header = parse_header(header_text)
code_start, code_end = if is_pandoc
r"^<<(?<options>.*?)>>=\s*$",
r"^@\s*$"
else
header_text, document_body, offset = separate_header_text(document_body)
header = parse_header(header_text)
code_start = r"^[`~]{3}(?:\{?)julia(?:;?)\s*(?<options>.*?)(\}|\s*)$"
code_end = r"^[`~]{3}\s*$"
r"^[`~]{3}(?:\{?)julia(?:;?)\s*(?<options>.*?)(\}|\s*)$",
r"^[`~]{3}\s*$"
end
return header, parse_markdown_body(document_body, code_start, code_end, offset)
end

View File

@ -4,9 +4,11 @@ using Gadfly, Cairo
function test_gadfly(doctype, fig_ext)
out = weave(joinpath(@__DIR__ , "documents/gadfly_formats_test.jnw"),
out_path = joinpath(@__DIR__ , "documents/gadfly/"),
doctype = doctype, fig_ext = fig_ext)
out = weave(
joinpath(@__DIR__ , "documents/gadfly_formats_test.jnw"),
doctype = doctype,
fig_ext = fig_ext
)
result = read(out, String)
# cp(out, out*fig_ext*"."*doctype, force=true) # Used when adding new tests
ref = read(out*fig_ext*"."*doctype, String)