diff --git a/examples/gadfly_md_sample.jmd b/examples/gadfly_md_sample.jmd index 15398be..f701215 100644 --- a/examples/gadfly_md_sample.jmd +++ b/examples/gadfly_md_sample.jmd @@ -4,6 +4,8 @@ author : Matti Pastell date : 13th December 2016 --- +# Intro + This a sample [Julia](http://julialang.org/) markdown document that can be executed using [Weave.jl](https://github.com/mpastell/Weave.jl). @@ -35,7 +37,7 @@ weave(Pkg.dir("Weave","examples","gadfly_md_sample.jmd"), informat="markdown", The documents will be written to the Julia working directory when you use the `out_path = :pwd`. -## Capturing code +# Capturing code The basic code chunk will be run with default options and the code and output will be captured. @@ -64,7 +66,7 @@ syntax from the source document): plot(y = cumsum(randn(1000, 1)), Geom.line) ``` -## Whats next +# Whats next Read the documentation: diff --git a/src/format.jl b/src/format.jl index df0a2d4..b25f6d8 100644 --- a/src/format.jl +++ b/src/format.jl @@ -132,8 +132,8 @@ function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2HTML) return string(Documenter.Writers.HTMLWriter.mdconvert(m)) end -if VERSION < v"v0.6.0-362b271" -#Fixes to Base latex writer +if VERSION < v"v0.6-alpha" +#Fixes to Base latex writer, included in JuliaLang/julia#19842 and JuliaLang/julia#19832. function Base.Markdown.latex(io::IO, md::Base.Markdown.Paragraph) println(io) for md in md.content diff --git a/test/documents/multimedia/rich_output.md.ref b/test/documents/multimedia/0.5/rich_output.md.ref similarity index 100% rename from test/documents/multimedia/rich_output.md.ref rename to test/documents/multimedia/0.5/rich_output.md.ref diff --git a/test/documents/multimedia/rich_output.tex.ref b/test/documents/multimedia/0.5/rich_output.tex.ref similarity index 100% rename from test/documents/multimedia/rich_output.tex.ref rename to test/documents/multimedia/0.5/rich_output.tex.ref diff --git a/test/documents/multimedia/0.6/rich_output.md.ref b/test/documents/multimedia/0.6/rich_output.md.ref new file mode 100644 index 0000000..39c58e5 --- /dev/null +++ b/test/documents/multimedia/0.6/rich_output.md.ref @@ -0,0 +1,122 @@ +~~~~{.julia} +using DataFrames +df = DataFrame(letters = 'a':'z', numbers = 1:26) + +df +~~~~~~~~~~~~~ + + +~~~~ +26×2 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) +~~~~~~~~~~~~~ + + +~~~~ +26×2 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) +~~~~~~~~~~~~~ + + +~~~~ +6×2 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 +26×2 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** + diff --git a/test/documents/multimedia/0.6/rich_output.tex.ref b/test/documents/multimedia/0.6/rich_output.tex.ref new file mode 100644 index 0000000..a4d9993 --- /dev/null +++ b/test/documents/multimedia/0.6/rich_output.tex.ref @@ -0,0 +1,107 @@ +\begin{juliacode} +using DataFrames +df = DataFrame(letters = 'a':'z', numbers = 1:26) + +df +\end{juliacode} +\begin{juliaout} +26×2 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} +26×2 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} +6×2 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 +26×2 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} + + diff --git a/test/rich_output.jl b/test/rich_output.jl index 197ea26..51fc708 100644 --- a/test/rich_output.jl +++ b/test/rich_output.jl @@ -2,10 +2,12 @@ using Weave using Base.Test function mmtest(source, resfile, doctype) + VER = "$(VERSION.major).$(VERSION.minor)" weave("documents/$source", out_path = "documents/multimedia/$resfile", doctype=doctype, plotlib=nothing) result = readstring(open("documents/multimedia/$resfile")) - ref = readstring(open("documents/multimedia/$resfile.ref")) + ref = readstring(open("documents/multimedia/$VER/$resfile.ref")) @test result == ref + rm("documents/multimedia/$resfile") end mmtest("rich_output.jmd", "rich_output.md", "pandoc") diff --git a/test/runtests.jl b/test/runtests.jl index 8da8ae2..aeb02dd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -11,10 +11,11 @@ include("convert_test.jl") info("Testing formatters") include("formatter_test.jl") -if VERSION < v"0.6-" - info("Testing rich output") - include("rich_output.jl") +info("Testing rich output") +include("rich_output.jl") + +if VERSION < v"0.6-" info("Test: Caching") include("cache_test.jl")