mirror of https://github.com/mpastell/Weave.jl
Sepated reading and parsing to different methods
parent
3407564589
commit
3c4cc04e14
|
@ -78,7 +78,7 @@ function tangle(source ; out_path=:doc, informat="noweb")
|
||||||
|
|
||||||
outname = "$(cwd)/$(basename).jl"
|
outname = "$(cwd)/$(basename).jl"
|
||||||
open(outname, "w") do io
|
open(outname, "w") do io
|
||||||
for chunk in read_document(source, informat)
|
for chunk in read(source, informat)
|
||||||
if typeof(chunk) == CodeChunk
|
if typeof(chunk) == CodeChunk
|
||||||
write(io, chunk.content*"\n")
|
write(io, chunk.content*"\n")
|
||||||
end
|
end
|
||||||
|
@ -153,7 +153,7 @@ function weave(source ; doctype = "pandoc", plotlib="Gadfly", informat="noweb",
|
||||||
end
|
end
|
||||||
|
|
||||||
pushdisplay(report)
|
pushdisplay(report)
|
||||||
parsed = read_document(source, informat)
|
parsed = read(source, informat)
|
||||||
executed = run(parsed)
|
executed = run(parsed)
|
||||||
popdisplay(report)
|
popdisplay(report)
|
||||||
formatted = format(executed, doctype)
|
formatted = format(executed, doctype)
|
||||||
|
|
|
@ -12,12 +12,19 @@ const input_formats = @compat Dict{String, Any}(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@doc "Read input document" ->
|
|
||||||
function read_document(document, format="noweb")
|
@doc "Read and parse input document" ->
|
||||||
|
function Base.read(document, format="noweb")
|
||||||
|
document = bytestring(open(document) do io
|
||||||
|
mmap_array(Uint8,(filesize(document),),io)
|
||||||
|
end)
|
||||||
|
return parse(document, format)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc "Parse document from string" ->
|
||||||
|
function Base.parse(document, format="noweb")
|
||||||
#doctext = readall(open(document))
|
#doctext = readall(open(document))
|
||||||
lines = split(bytestring(open(document) do io
|
lines = split(document, "\n")
|
||||||
mmap_array(Uint8,(filesize(document),),io)
|
|
||||||
end), "\n")
|
|
||||||
|
|
||||||
codestart = input_formats[format][:codestart]
|
codestart = input_formats[format][:codestart]
|
||||||
codeend = input_formats[format][:codeend]
|
codeend = input_formats[format][:codeend]
|
||||||
|
|
Loading…
Reference in New Issue