mirror of https://github.com/mpastell/Weave.jl
Fix output for `term=true`. Closes #82.
parent
b0d2ccdba2
commit
888b732f86
|
@ -45,7 +45,7 @@ type CodeChunk <: WeaveChunk
|
||||||
figures::Array{AbstractString}
|
figures::Array{AbstractString}
|
||||||
result::Array{ChunkOutput}
|
result::Array{ChunkOutput}
|
||||||
function CodeChunk(content, number, start_line, optionstring, options)
|
function CodeChunk(content, number, start_line, optionstring, options)
|
||||||
new(rstrip(content), number, 0, start_line, optionstring, options, "","", AbstractString[], ChunkOutput[])
|
new(rstrip(content) * "\n", number, 0, start_line, optionstring, options, "","", AbstractString[], ChunkOutput[])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ end
|
||||||
#Text is written to stdout, called from "term" mode chunks
|
#Text is written to stdout, called from "term" mode chunks
|
||||||
function Base.display(report::Report, m::MIME"text/plain", data)
|
function Base.display(report::Report, m::MIME"text/plain", data)
|
||||||
s = reprmime(m, data)
|
s = reprmime(m, data)
|
||||||
print("\n" * s)
|
println(s)
|
||||||
end
|
end
|
||||||
|
|
||||||
#Catch "rich_output"
|
#Catch "rich_output"
|
||||||
|
|
|
@ -182,7 +182,7 @@ function format_chunk(chunk::CodeChunk, formatdict, docformat)
|
||||||
|
|
||||||
if !chunk.options[:eval]
|
if !chunk.options[:eval]
|
||||||
if chunk.options[:echo]
|
if chunk.options[:echo]
|
||||||
result = "$(formatdict[:codestart])$(chunk.content)\n$(formatdict[:codeend])"
|
result = "$(formatdict[:codestart])\n$(chunk.content)$(formatdict[:codeend])"
|
||||||
return result
|
return result
|
||||||
else
|
else
|
||||||
r = ""
|
r = ""
|
||||||
|
@ -196,7 +196,7 @@ function format_chunk(chunk::CodeChunk, formatdict, docformat)
|
||||||
|
|
||||||
if chunk.options[:echo]
|
if chunk.options[:echo]
|
||||||
#Convert to output format and highlight (html, tex...) if needed
|
#Convert to output format and highlight (html, tex...) if needed
|
||||||
result = "$(formatdict[:codestart])$(chunk.content)\n$(formatdict[:codeend])\n"
|
result = "$(formatdict[:codestart])$(chunk.content)$(formatdict[:codeend])\n"
|
||||||
else
|
else
|
||||||
result = ""
|
result = ""
|
||||||
end
|
end
|
||||||
|
|
|
@ -129,8 +129,6 @@ function parse_doc(document::AbstractString, format::MarkupInput)
|
||||||
end
|
end
|
||||||
if ismatch(codeend, line) && state=="code"
|
if ismatch(codeend, line) && state=="code"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
chunk = CodeChunk(content, codeno, start_line, optionString, options)
|
chunk = CodeChunk(content, codeno, start_line, optionString, options)
|
||||||
|
|
||||||
codeno+=1
|
codeno+=1
|
||||||
|
@ -142,7 +140,7 @@ function parse_doc(document::AbstractString, format::MarkupInput)
|
||||||
end
|
end
|
||||||
|
|
||||||
if lineno == 1
|
if lineno == 1
|
||||||
content *= line
|
content *= line
|
||||||
else
|
else
|
||||||
content *= "\n" * line
|
content *= "\n" * line
|
||||||
end
|
end
|
||||||
|
@ -310,6 +308,6 @@ function parse_inline(text::AbstractString, inline_ex::Regex)
|
||||||
codeno += 1
|
codeno += 1
|
||||||
end
|
end
|
||||||
push!(res, InlineText(text[e:end], e, length(text), textno))
|
push!(res, InlineText(text[e:end], e, length(text), textno))
|
||||||
|
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
y= [2, 5, 12]
|
y= [2, 5, 12]
|
||||||
@
|
@
|
||||||
|
|
||||||
|
<<term=true>>=
|
||||||
|
x = 1:10
|
||||||
|
d = Dict("Weave" => "testing")
|
||||||
|
y = [2, 4 ,8]
|
||||||
|
@
|
||||||
|
|
||||||
<<>>=
|
<<>>=
|
||||||
x = [12, 10]
|
x = [12, 10]
|
||||||
println(y)
|
println(y)
|
||||||
|
|
|
@ -4,6 +4,25 @@ julia> y= [2, 5, 12]
|
||||||
2
|
2
|
||||||
5
|
5
|
||||||
12
|
12
|
||||||
|
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
~~~~{.julia}
|
||||||
|
julia> x = 1:10
|
||||||
|
1:10
|
||||||
|
|
||||||
|
julia> d = Dict("Weave" => "testing")
|
||||||
|
Dict{String,String} with 1 entry:
|
||||||
|
"Weave" => "testing"
|
||||||
|
|
||||||
|
julia> y = [2, 4 ,8]
|
||||||
|
3-element Array{Int64,1}:
|
||||||
|
2
|
||||||
|
4
|
||||||
|
8
|
||||||
|
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +34,7 @@ println(y)
|
||||||
|
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
[2,5,12]
|
[2,4,8]
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +63,7 @@ Results without code
|
||||||
|
|
||||||
|
|
||||||
~~~~{.julia}
|
~~~~{.julia}
|
||||||
|
|
||||||
y = randn(5)
|
y = randn(5)
|
||||||
println("Don't eval, but show code")
|
println("Don't eval, but show code")
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
|
@ -1,23 +1,37 @@
|
||||||
|
|
||||||
y= [2, 5, 12]
|
y= [2, 5, 12]
|
||||||
|
|
||||||
|
|
||||||
|
x = 1:10
|
||||||
|
d = Dict("Weave" => "testing")
|
||||||
|
y = [2, 4 ,8]
|
||||||
|
|
||||||
|
|
||||||
x = [12, 10]
|
x = [12, 10]
|
||||||
println(y)
|
println(y)
|
||||||
println(x)
|
println(x)
|
||||||
|
|
||||||
|
|
||||||
println("Results without code")
|
println("Results without code")
|
||||||
println(x)
|
println(x)
|
||||||
|
|
||||||
|
|
||||||
y = 1:5
|
y = 1:5
|
||||||
println(y)
|
println(y)
|
||||||
|
|
||||||
|
|
||||||
a = "Don't print me"
|
a = "Don't print me"
|
||||||
println(a)
|
println(a)
|
||||||
|
|
||||||
|
|
||||||
println("No markup for results.")
|
println("No markup for results.")
|
||||||
|
|
||||||
println(collect(0:10:1000))
|
|
||||||
|
|
||||||
println(collect(0:10:1000))
|
println(collect(0:10:1000))
|
||||||
|
|
||||||
|
|
||||||
println(collect(0:10:1000))
|
println(collect(0:10:1000))
|
||||||
|
|
||||||
|
|
||||||
|
println(collect(0:10:1000))
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ display(x)
|
||||||
julia> using Gadfly
|
julia> using Gadfly
|
||||||
|
|
||||||
julia> x = 1:10
|
julia> x = 1:10
|
||||||
|
|
||||||
1:10
|
1:10
|
||||||
|
|
||||||
julia> plot(x = x, y = x)
|
julia> plot(x = x, y = x)
|
||||||
|
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
@ -73,6 +73,7 @@ julia> plot(x = x, y = x)
|
||||||
~~~~{.julia}
|
~~~~{.julia}
|
||||||
julia> display(x)
|
julia> display(x)
|
||||||
1:10
|
1:10
|
||||||
|
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,8 +86,8 @@ julia> display(x)
|
||||||
julietta> using Gadfly
|
julietta> using Gadfly
|
||||||
|
|
||||||
julietta> x = 1:10
|
julietta> x = 1:10
|
||||||
|
|
||||||
1:10
|
1:10
|
||||||
|
|
||||||
julietta> plot(x = x, y = x)
|
julietta> plot(x = x, y = x)
|
||||||
|
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
@ -109,6 +110,7 @@ julietta> plot(x = x, y = x)
|
||||||
~~~~{.julia}
|
~~~~{.julia}
|
||||||
julietta> display(x)
|
julietta> display(x)
|
||||||
1:10
|
1:10
|
||||||
|
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,8 +177,8 @@ display(x)
|
||||||
julia> using Gadfly
|
julia> using Gadfly
|
||||||
|
|
||||||
julia> x = 1:10
|
julia> x = 1:10
|
||||||
|
|
||||||
1:10
|
1:10
|
||||||
|
|
||||||
julia> plot(x = x, y = x)
|
julia> plot(x = x, y = x)
|
||||||
|
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
@ -199,6 +201,7 @@ julia> plot(x = x, y = x)
|
||||||
~~~~{.julia}
|
~~~~{.julia}
|
||||||
julia> display(x)
|
julia> display(x)
|
||||||
1:10
|
1:10
|
||||||
|
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,8 +222,7 @@ display(x)
|
||||||
|
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
1:10
|
1:101:10
|
||||||
1:10
|
|
||||||
~~~~
|
~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue