mirror of https://github.com/mpastell/Weave.jl
Catching of rich output implemented, initial tests with DataFrames and HTML
parent
64fd4daa1d
commit
dca852ed89
6
NEWS.md
6
NEWS.md
|
@ -1,6 +1,12 @@
|
|||
|
||||
# Release notes for Weave.jl
|
||||
|
||||
### Git
|
||||
|
||||
* Fix parsing of lone variables from chunks
|
||||
* Support for displaying general multimedia objects e.g. Plots.jl and Images.jl
|
||||
now work with weave
|
||||
|
||||
### v0.1.2
|
||||
|
||||
27th April 2016
|
||||
|
|
|
@ -58,27 +58,30 @@ function format_chunk(chunk::CodeChunk, formatdict, docformat)
|
|||
result = format_termchunk(chunk, formatdict)
|
||||
else
|
||||
|
||||
if chunk.options[:echo]
|
||||
result = "$(formatdict[:codestart])$(chunk.content)\n$(formatdict[:codeend])\n"
|
||||
if chunk.options[:echo]
|
||||
result = "$(formatdict[:codestart])$(chunk.content)\n$(formatdict[:codeend])\n"
|
||||
else
|
||||
result = ""
|
||||
end
|
||||
|
||||
if (strip(chunk.output)!= "" || strip(chunk.rich_output) != "") && (chunk.options[:results] != "hidden")
|
||||
if chunk.options[:results] != "markup" && chunk.options[:results] != "hold"
|
||||
strip(chunk.output) ≠ "" && (result *= "$(chunk.output)\n")
|
||||
strip(chunk.rich_output) ≠ "" && (result *= "$(chunk.rich_output)\n")
|
||||
else
|
||||
result = ""
|
||||
end
|
||||
|
||||
if (strip(chunk.output)!= "") && (chunk.options[:results] != "hidden")
|
||||
if chunk.options[:results] != "markup" && chunk.options[:results] != "hold"
|
||||
result *= "$(chunk.output)\n"
|
||||
else
|
||||
if chunk.options[:wrap]
|
||||
chunk.output = "\n" * wraplines(chunk.output,
|
||||
chunk.options[:line_width])
|
||||
end
|
||||
|
||||
if haskey(formatdict, :indent)
|
||||
chunk.output = indent(chunk.output, formatdict[:indent])
|
||||
end
|
||||
result *= "$(formatdict[:outputstart])$(chunk.output)\n$(formatdict[:outputend])\n"
|
||||
if chunk.options[:wrap]
|
||||
chunk.output = "\n" * wraplines(chunk.output,
|
||||
chunk.options[:line_width])
|
||||
end
|
||||
|
||||
if haskey(formatdict, :indent)
|
||||
chunk.output = indent(chunk.output, formatdict[:indent])
|
||||
end
|
||||
strip(chunk.output) ≠ "" &&
|
||||
(result *= "$(formatdict[:outputstart])$(chunk.output)\n$(formatdict[:outputend])\n")
|
||||
strip(chunk.rich_output) ≠ "" && (result *= chunk.rich_output * "\n")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -151,7 +154,7 @@ const tex = Tex("Latex with custom code environments",
|
|||
:fig_env=> "figure",
|
||||
:fig_pos => "htpb",
|
||||
:doctype => "tex",
|
||||
:mimetypes => ["application/pdf", "image/png", "text/plain"]
|
||||
:mimetypes => ["application/pdf", "image/png", "text/latex", "text/plain"]
|
||||
))
|
||||
|
||||
const texminted = Tex("Latex using minted for highlighting",
|
||||
|
@ -168,7 +171,7 @@ const texminted = Tex("Latex using minted for highlighting",
|
|||
:fig_env=> "figure",
|
||||
:fig_pos => "htpb",
|
||||
:doctype => "texminted",
|
||||
:mimetypes => ["application/pdf", "image/png", "text/plain"]
|
||||
:mimetypes => ["application/pdf", "image/png", "text/latex", "text/plain"]
|
||||
))
|
||||
|
||||
type Pandoc
|
||||
|
|
10
src/run.jl
10
src/run.jl
|
@ -153,15 +153,15 @@ function capture_output(expr, SandBox::Module, term, plotlib, lastline)
|
|||
obj = eval(SandBox, expr)
|
||||
if term
|
||||
obj != nothing && display(obj)
|
||||
elseif typeof(expr) == Symbol
|
||||
display(obj)
|
||||
elseif plotlib == "Gadfly" && typeof(obj) == Gadfly.Plot
|
||||
obj != nothing && display(obj)
|
||||
#This shows images and lone variables, result can
|
||||
#still be e.g. SVG depending on the avaible methods
|
||||
#for the type
|
||||
#Handle last line sepately
|
||||
elseif lastline && obj != nothing
|
||||
if typeof(expr) == Symbol
|
||||
display(obj)
|
||||
elseif mimewritable("image/png", obj) && expr.head == :call
|
||||
#elseif mimewritable("image/png", obj) && expr.head == :call
|
||||
if expr.head == :call
|
||||
display(obj)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Winston
|
||||
|
||||
function Base.display(report::Report, m::MIME"image/svg+xml", Winston.FramedPlot)
|
||||
function Base.display(report::Report, m::MIME"image/svg+xml", data::Winston.FramedPlot)
|
||||
|
||||
chunk = report.cur_chunk
|
||||
full_name, rel_name = get_figname(report, chunk)
|
||||
|
|
|
@ -5,7 +5,7 @@ using Plots
|
|||
pyplot()
|
||||
x = linspace(0, 2*pi)
|
||||
println(x)
|
||||
plot(x = x, y = sin(x), size =(900,300))
|
||||
p = plot(x = x, y = sin(x), size =(900,300))
|
||||
```
|
||||
|
||||
|
||||
|
@ -28,13 +28,13 @@ scatter!(rand(100),markersize=6,c=:orange)
|
|||
plot(y = cumsum(randn(1000, 1)))
|
||||
```
|
||||
|
||||
```julia
|
||||
```
|
||||
using TestImages
|
||||
testimage("mandrill")
|
||||
```
|
||||
|
||||
|
||||
```julia
|
||||
```
|
||||
using RDatasets
|
||||
iris = dataset("datasets", "iris")
|
||||
head(iris)
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
|
||||
|
||||
```julia
|
||||
using RDatasets
|
||||
iris = dataset("datasets", "iris")
|
||||
display(iris)
|
||||
using DataFrames
|
||||
df = DataFrame(letters = 'a':'z', numbers = 1:26)
|
||||
|
||||
df
|
||||
z = 51
|
||||
display(df)
|
||||
```
|
||||
|
||||
```julia; hold=true
|
||||
display(head(iris))
|
||||
head(df)
|
||||
```
|
||||
|
||||
```julia; term=true
|
||||
iris
|
||||
df
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue