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}
|
||||
result::Array{ChunkOutput}
|
||||
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
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ end
|
|||
#Text is written to stdout, called from "term" mode chunks
|
||||
function Base.display(report::Report, m::MIME"text/plain", data)
|
||||
s = reprmime(m, data)
|
||||
print("\n" * s)
|
||||
println(s)
|
||||
end
|
||||
|
||||
#Catch "rich_output"
|
||||
|
|
|
@ -182,7 +182,7 @@ function format_chunk(chunk::CodeChunk, formatdict, docformat)
|
|||
|
||||
if !chunk.options[:eval]
|
||||
if chunk.options[:echo]
|
||||
result = "$(formatdict[:codestart])$(chunk.content)\n$(formatdict[:codeend])"
|
||||
result = "$(formatdict[:codestart])\n$(chunk.content)$(formatdict[:codeend])"
|
||||
return result
|
||||
else
|
||||
r = ""
|
||||
|
@ -196,7 +196,7 @@ function format_chunk(chunk::CodeChunk, formatdict, docformat)
|
|||
|
||||
if chunk.options[:echo]
|
||||
#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
|
||||
result = ""
|
||||
end
|
||||
|
|
|
@ -129,8 +129,6 @@ function parse_doc(document::AbstractString, format::MarkupInput)
|
|||
end
|
||||
if ismatch(codeend, line) && state=="code"
|
||||
|
||||
|
||||
|
||||
chunk = CodeChunk(content, codeno, start_line, optionString, options)
|
||||
|
||||
codeno+=1
|
||||
|
@ -142,7 +140,7 @@ function parse_doc(document::AbstractString, format::MarkupInput)
|
|||
end
|
||||
|
||||
if lineno == 1
|
||||
content *= line
|
||||
content *= line
|
||||
else
|
||||
content *= "\n" * line
|
||||
end
|
||||
|
@ -310,6 +308,6 @@ function parse_inline(text::AbstractString, inline_ex::Regex)
|
|||
codeno += 1
|
||||
end
|
||||
push!(res, InlineText(text[e:end], e, length(text), textno))
|
||||
|
||||
|
||||
return res
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
y= [2, 5, 12]
|
||||
@
|
||||
|
||||
<<term=true>>=
|
||||
x = 1:10
|
||||
d = Dict("Weave" => "testing")
|
||||
y = [2, 4 ,8]
|
||||
@
|
||||
|
||||
<<>>=
|
||||
x = [12, 10]
|
||||
println(y)
|
||||
|
|
|
@ -4,6 +4,25 @@ julia> y= [2, 5, 12]
|
|||
2
|
||||
5
|
||||
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}
|
||||
|
||||
y = randn(5)
|
||||
println("Don't eval, but show code")
|
||||
~~~~~~~~~~~~~
|
||||
|
|
|
@ -1,23 +1,37 @@
|
|||
|
||||
y= [2, 5, 12]
|
||||
|
||||
|
||||
x = 1:10
|
||||
d = Dict("Weave" => "testing")
|
||||
y = [2, 4 ,8]
|
||||
|
||||
|
||||
x = [12, 10]
|
||||
println(y)
|
||||
println(x)
|
||||
|
||||
|
||||
println("Results without code")
|
||||
println(x)
|
||||
|
||||
|
||||
y = 1:5
|
||||
println(y)
|
||||
|
||||
|
||||
a = "Don't print me"
|
||||
println(a)
|
||||
|
||||
|
||||
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))
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ display(x)
|
|||
julia> using Gadfly
|
||||
|
||||
julia> x = 1:10
|
||||
|
||||
1:10
|
||||
|
||||
julia> plot(x = x, y = x)
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
|
@ -73,6 +73,7 @@ julia> plot(x = x, y = x)
|
|||
~~~~{.julia}
|
||||
julia> display(x)
|
||||
1:10
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
@ -85,8 +86,8 @@ julia> display(x)
|
|||
julietta> using Gadfly
|
||||
|
||||
julietta> x = 1:10
|
||||
|
||||
1:10
|
||||
|
||||
julietta> plot(x = x, y = x)
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
|
@ -109,6 +110,7 @@ julietta> plot(x = x, y = x)
|
|||
~~~~{.julia}
|
||||
julietta> display(x)
|
||||
1:10
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
@ -175,8 +177,8 @@ display(x)
|
|||
julia> using Gadfly
|
||||
|
||||
julia> x = 1:10
|
||||
|
||||
1:10
|
||||
|
||||
julia> plot(x = x, y = x)
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
|
@ -199,6 +201,7 @@ julia> plot(x = x, y = x)
|
|||
~~~~{.julia}
|
||||
julia> display(x)
|
||||
1:10
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
@ -219,8 +222,7 @@ display(x)
|
|||
|
||||
|
||||
~~~~
|
||||
1:10
|
||||
1:10
|
||||
1:101:10
|
||||
~~~~
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue