mirror of https://github.com/mpastell/Weave.jl
Added tests for rich text, added display methods for markdown and latex
parent
2681f19c19
commit
daa645ac58
|
@ -11,13 +11,13 @@ test/documents/figures
|
|||
test/documents/cache
|
||||
test/documents/output/figures
|
||||
test/documents/output/gadfly_formats_test.txt
|
||||
test/documents/*.tex
|
||||
test/documents/*.md
|
||||
test/documents/*.rst
|
||||
test/documents/*.html
|
||||
test/documents/*.pdf
|
||||
test/documents/chunk_options.jl
|
||||
!test/documents/*ref.*
|
||||
test/**/*.tex
|
||||
test/**/*.md
|
||||
test/**/*.rst
|
||||
test/**/*.html
|
||||
test/**/*.pdf
|
||||
test/**/chunk_options.jl
|
||||
!test/**/*ref.*
|
||||
|
||||
doc/build
|
||||
doc/site
|
||||
|
|
|
@ -70,6 +70,18 @@ function Base.display(report::Report, m::MIME"text/html", data)
|
|||
report.rich_output *= "\n" * s
|
||||
end
|
||||
|
||||
#Catch "rich_output"
|
||||
function Base.display(report::Report, m::MIME"text/markdown", data)
|
||||
s = reprmime(m, data)
|
||||
report.rich_output *= "\n" * s
|
||||
end
|
||||
|
||||
function Base.display(report::Report, m::MIME"text/latex", data)
|
||||
s = reprmime(m, data)
|
||||
report.rich_output *= "\n" * s
|
||||
end
|
||||
|
||||
|
||||
"""Add saved figure name to results and return the name"""
|
||||
function add_figure(report::Report, ext)
|
||||
chunk = report.cur_chunk
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
|
||||
|
||||
~~~~{.julia}
|
||||
using DataFrames
|
||||
df = DataFrame(letters = 'a':'z', numbers = 1:26)
|
||||
|
||||
df
|
||||
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
~~~~
|
||||
26x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
│ 7 │ 'g' │ 7 │
|
||||
│ 8 │ 'h' │ 8 │
|
||||
⋮
|
||||
│ 18 │ 'r' │ 18 │
|
||||
│ 19 │ 's' │ 19 │
|
||||
│ 20 │ 't' │ 20 │
|
||||
│ 21 │ 'u' │ 21 │
|
||||
│ 22 │ 'v' │ 22 │
|
||||
│ 23 │ 'w' │ 23 │
|
||||
│ 24 │ 'x' │ 24 │
|
||||
│ 25 │ 'y' │ 25 │
|
||||
│ 26 │ 'z' │ 26 │
|
||||
~~~~
|
||||
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
z = 51
|
||||
display(df)
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
~~~~
|
||||
26x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
│ 7 │ 'g' │ 7 │
|
||||
│ 8 │ 'h' │ 8 │
|
||||
⋮
|
||||
│ 18 │ 'r' │ 18 │
|
||||
│ 19 │ 's' │ 19 │
|
||||
│ 20 │ 't' │ 20 │
|
||||
│ 21 │ 'u' │ 21 │
|
||||
│ 22 │ 'v' │ 22 │
|
||||
│ 23 │ 'w' │ 23 │
|
||||
│ 24 │ 'x' │ 24 │
|
||||
│ 25 │ 'y' │ 25 │
|
||||
│ 26 │ 'z' │ 26 │
|
||||
~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
head(df)
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
~~~~
|
||||
6x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
julia> df
|
||||
26x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
│ 7 │ 'g' │ 7 │
|
||||
│ 8 │ 'h' │ 8 │
|
||||
⋮
|
||||
│ 18 │ 'r' │ 18 │
|
||||
│ 19 │ 's' │ 19 │
|
||||
│ 20 │ 't' │ 20 │
|
||||
│ 21 │ 'u' │ 21 │
|
||||
│ 22 │ 'v' │ 22 │
|
||||
│ 23 │ 'w' │ 23 │
|
||||
│ 24 │ 'x' │ 24 │
|
||||
│ 25 │ 'y' │ 25 │
|
||||
│ 26 │ 'z' │ 26 │
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
~~~~{.julia}
|
||||
m = Base.Markdown.parse("**Some Markdown**")
|
||||
m
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
|
||||
**Some Markdown**
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
|
||||
|
||||
\begin{juliacode}
|
||||
using DataFrames
|
||||
df = DataFrame(letters = 'a':'z', numbers = 1:26)
|
||||
|
||||
df
|
||||
|
||||
\end{juliacode}
|
||||
\begin{juliaout}
|
||||
26x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
│ 7 │ 'g' │ 7 │
|
||||
│ 8 │ 'h' │ 8 │
|
||||
⋮
|
||||
│ 18 │ 'r' │ 18 │
|
||||
│ 19 │ 's' │ 19 │
|
||||
│ 20 │ 't' │ 20 │
|
||||
│ 21 │ 'u' │ 21 │
|
||||
│ 22 │ 'v' │ 22 │
|
||||
│ 23 │ 'w' │ 23 │
|
||||
│ 24 │ 'x' │ 24 │
|
||||
│ 25 │ 'y' │ 25 │
|
||||
│ 26 │ 'z' │ 26 │
|
||||
\end{juliaout}
|
||||
|
||||
\begin{juliacode}
|
||||
z = 51
|
||||
display(df)
|
||||
\end{juliacode}
|
||||
\begin{juliaout}
|
||||
26x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
│ 7 │ 'g' │ 7 │
|
||||
│ 8 │ 'h' │ 8 │
|
||||
⋮
|
||||
│ 18 │ 'r' │ 18 │
|
||||
│ 19 │ 's' │ 19 │
|
||||
│ 20 │ 't' │ 20 │
|
||||
│ 21 │ 'u' │ 21 │
|
||||
│ 22 │ 'v' │ 22 │
|
||||
│ 23 │ 'w' │ 23 │
|
||||
│ 24 │ 'x' │ 24 │
|
||||
│ 25 │ 'y' │ 25 │
|
||||
│ 26 │ 'z' │ 26 │
|
||||
\end{juliaout}
|
||||
|
||||
|
||||
|
||||
\begin{juliacode}
|
||||
head(df)
|
||||
\end{juliacode}
|
||||
\begin{juliaout}
|
||||
6x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
\end{juliaout}
|
||||
|
||||
|
||||
|
||||
\begin{juliaterm}
|
||||
julia> df
|
||||
26x2 DataFrames.DataFrame
|
||||
│ Row │ letters │ numbers │
|
||||
┝━━━━━┿━━━━━━━━━┿━━━━━━━━━┥
|
||||
│ 1 │ 'a' │ 1 │
|
||||
│ 2 │ 'b' │ 2 │
|
||||
│ 3 │ 'c' │ 3 │
|
||||
│ 4 │ 'd' │ 4 │
|
||||
│ 5 │ 'e' │ 5 │
|
||||
│ 6 │ 'f' │ 6 │
|
||||
│ 7 │ 'g' │ 7 │
|
||||
│ 8 │ 'h' │ 8 │
|
||||
⋮
|
||||
│ 18 │ 'r' │ 18 │
|
||||
│ 19 │ 's' │ 19 │
|
||||
│ 20 │ 't' │ 20 │
|
||||
│ 21 │ 'u' │ 21 │
|
||||
│ 22 │ 'v' │ 22 │
|
||||
│ 23 │ 'w' │ 23 │
|
||||
│ 24 │ 'x' │ 24 │
|
||||
│ 25 │ 'y' │ 25 │
|
||||
│ 26 │ 'z' │ 26 │
|
||||
\end{juliaterm}
|
||||
|
||||
|
||||
|
||||
|
||||
\begin{juliacode}
|
||||
m = Base.Markdown.parse("**Some Markdown**")
|
||||
m
|
||||
\end{juliacode}
|
||||
|
||||
\textbf{Some Markdown}
|
||||
|
|
@ -16,3 +16,9 @@ head(df)
|
|||
```julia; term=true
|
||||
df
|
||||
```
|
||||
|
||||
|
||||
```julia
|
||||
m = Base.Markdown.parse("**Some Markdown**")
|
||||
m
|
||||
```
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using Weave, Compat
|
||||
using Base.Test
|
||||
|
||||
function mmtest(source, resfile, doctype)
|
||||
weave("documents/$source", out_path = "documents/multimedia/$resfile", doctype=doctype, plotlib=nothing)
|
||||
result = @compat readstring(open("documents/multimedia/$resfile"))
|
||||
ref = @compat readstring(open("documents/multimedia/$resfile.ref"))
|
||||
@test result == ref
|
||||
end
|
||||
|
||||
mmtest("rich_output.jmd", "rich_output.md", "pandoc")
|
||||
mmtest("rich_output.jmd", "rich_output.tex", "tex")
|
|
@ -12,6 +12,9 @@ include("chunk_options.jl")
|
|||
info("Test: Caching")
|
||||
include("cache_test.jl")
|
||||
|
||||
info("Testing rich output")
|
||||
include("rich_output.jl")
|
||||
|
||||
if VERSION < v"0.5-dev"
|
||||
info("Test: Chunk options with Gadfly")
|
||||
include("chunk_opts_gadfly.jl")
|
||||
|
|
Loading…
Reference in New Issue