mirror of https://github.com/mpastell/Weave.jl
Dispatch on when
parent
eecef35305
commit
1834b93cb3
32
src/run.jl
32
src/run.jl
|
@ -209,8 +209,6 @@ function eval_chunk(chunk::CodeChunk, report::Report, SandBox::Module)
|
|||
chunk.result = run_code(chunk, report, SandBox)
|
||||
if chunk.options[:term]
|
||||
chunks = collect_results(chunk, TermResult())
|
||||
elseif chunk.options[:display]
|
||||
chunks = collect_results(chunk, DispResult())
|
||||
elseif chunk.options[:hold]
|
||||
chunks = collect_results(chunk, CollectResult())
|
||||
else
|
||||
|
@ -355,36 +353,6 @@ function collect_results(chunk::CodeChunk, fmt::ScriptResult)
|
|||
return result_chunks
|
||||
end
|
||||
|
||||
|
||||
function collect_results(chunk::CodeChunk, fmt::DispResult)
|
||||
content = ""
|
||||
result_no = 1
|
||||
result_chunks = CodeChunk[ ]
|
||||
for r = chunk.result
|
||||
#Check if there is any output from chunk
|
||||
if strip(r.stdout) == "" && isempty(r.figures) && strip(r.rich_output) == ""
|
||||
content *= r.code
|
||||
else
|
||||
content = "\n" * content * r.code
|
||||
rchunk = CodeChunk(content, chunk.number, chunk.start_line, chunk.optionstring, copy(chunk.options))
|
||||
content = ""
|
||||
rchunk.result_no = result_no
|
||||
result_no *=1
|
||||
rchunk.figures = r.figures
|
||||
rchunk.output = r.stdout * r.displayed
|
||||
rchunk.rich_output = r.rich_output
|
||||
push!(result_chunks, rchunk)
|
||||
end
|
||||
end
|
||||
if content != ""
|
||||
startswith(content, "\n") || (content = "\n" * content)
|
||||
rchunk = CodeChunk(content, chunk.number, chunk.start_line, chunk.optionstring, copy(chunk.options))
|
||||
push!(result_chunks, rchunk)
|
||||
end
|
||||
|
||||
return result_chunks
|
||||
end
|
||||
|
||||
function collect_results(chunk::CodeChunk, fmt::TermResult)
|
||||
output = ""
|
||||
prompt = chunk.options[:prompt]
|
||||
|
|
Loading…
Reference in New Issue