mirror of https://github.com/mpastell/Weave.jl
Changing chunk representation to own type instead of just Dicts. Reader works, everyting else is broken
parent
fc8f5814f1
commit
42108cb69d
|
@ -339,7 +339,7 @@ function get_figname(report::Report, chunk; fignum = nothing)
|
||||||
end
|
end
|
||||||
|
|
||||||
export weave, list_out_formats, tangle
|
export weave, list_out_formats, tangle
|
||||||
|
include("chunks.jl")
|
||||||
include("config.jl")
|
include("config.jl")
|
||||||
include("readers.jl")
|
include("readers.jl")
|
||||||
include("formatters.jl")
|
include("formatters.jl")
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
type CodeChunk
|
||||||
|
content::String
|
||||||
|
number::Int
|
||||||
|
start_line::Int
|
||||||
|
option_string::String
|
||||||
|
options::Dict{Symbol, Any}
|
||||||
|
output::String
|
||||||
|
figures::Array
|
||||||
|
function CodeChunk(content, number, start_line, option_string, options)
|
||||||
|
new(content, number, start_line, option_string, options, "", String[])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
type DocChunk
|
||||||
|
content::String
|
||||||
|
number::Int
|
||||||
|
start_line::Int
|
||||||
|
end
|
|
@ -12,8 +12,8 @@ const input_formats = @compat Dict{String, Any}(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@doc "Read input document" ->
|
||||||
function read_document(document, format)
|
function read_document(document, format="noweb")
|
||||||
#doctext = readall(open(document))
|
#doctext = readall(open(document))
|
||||||
lines = split(bytestring(open(document) do io
|
lines = split(bytestring(open(document) do io
|
||||||
mmap_array(Uint8,(filesize(document),),io)
|
mmap_array(Uint8,(filesize(document),),io)
|
||||||
|
@ -30,7 +30,7 @@ function read_document(document, format)
|
||||||
|
|
||||||
options = Dict()
|
options = Dict()
|
||||||
optionstring = ""
|
optionstring = ""
|
||||||
parsed = Dict[]
|
parsed = Any[]
|
||||||
for lineno in 1:length(lines)
|
for lineno in 1:length(lines)
|
||||||
line = lines[lineno]
|
line = lines[lineno]
|
||||||
if (m = match(codestart, line)) != nothing && state=="doc"
|
if (m = match(codestart, line)) != nothing && state=="doc"
|
||||||
|
@ -50,8 +50,9 @@ function read_document(document, format)
|
||||||
haskey(options, :label) && (options[:name] = options[:label])
|
haskey(options, :label) && (options[:name] = options[:label])
|
||||||
haskey(options, :name) || (options[:name] = nothing)
|
haskey(options, :name) || (options[:name] = nothing)
|
||||||
#@show options
|
#@show options
|
||||||
chunk = @compat Dict{Symbol,Any}(:type => "doc", :content => content,
|
chunk = DocChunk(content, docno, start_line)
|
||||||
:number => docno,:start_line => start_line)
|
#chunk = @compat Dict{Symbol,Any}(:type => "doc", :content => content,
|
||||||
|
# :number => docno,:start_line => start_line)
|
||||||
docno += 1
|
docno += 1
|
||||||
start_line = lineno
|
start_line = lineno
|
||||||
push!(parsed, chunk)
|
push!(parsed, chunk)
|
||||||
|
@ -59,10 +60,13 @@ function read_document(document, format)
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
if ismatch(codeend, line) && state=="code"
|
if ismatch(codeend, line) && state=="code"
|
||||||
chunk = @compat Dict{Symbol,Any}(:type => "code", :content => content,
|
|
||||||
:number => codeno, :options => options,
|
chunk = CodeChunk(content, codeno, start_line, optionstring, options)
|
||||||
:optionstring => optionstring,
|
#chunk = @compat Dict{Symbol,Any}(:type => "code", :content => content,
|
||||||
:start_line => start_line)
|
# :number => codeno, :options => options,
|
||||||
|
# :optionstring => optionstring,
|
||||||
|
# :start_line => start_line)
|
||||||
|
|
||||||
codeno+=1
|
codeno+=1
|
||||||
start_line = lineno
|
start_line = lineno
|
||||||
content = ""
|
content = ""
|
||||||
|
@ -75,9 +79,10 @@ function read_document(document, format)
|
||||||
end
|
end
|
||||||
|
|
||||||
#Remember the last chunk
|
#Remember the last chunk
|
||||||
if content != ""
|
if strip(content) != ""
|
||||||
chunk = @compat Dict{Symbol,Any}(:type => "doc", :content => content,
|
chunk = DocChunk(content, docno, start_line)
|
||||||
:number => docno, :start_line => start_line)
|
#chunk = @compat Dict{Symbol,Any}(:type => "doc", :content => content,
|
||||||
|
# :number => docno, :start_line => start_line)
|
||||||
push!(parsed, chunk)
|
push!(parsed, chunk)
|
||||||
end
|
end
|
||||||
return parsed
|
return parsed
|
||||||
|
|
Loading…
Reference in New Issue