diff --git a/.gitignore b/.gitignore index 9dd5f62..37eb0ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ examples/figures/ examples/*.md examples/*.pdf examples/*.html +examples/*.rst +examples/*.tex + tmp/ .idea *.*~ diff --git a/README.md b/README.md index dd01f61..e56eb32 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,8 @@ weave(Pkg.dir("JuliaReport","examples","gadfly_sample.mdw"), plotlib="Gadfly") The signature of weave functions is: ````julia -function weave(source ; doctype = "pandoc", plotlib="PyPlot", informat="noweb", fig_path = "figures", fig_ext = nothing) +function weave(source ; doctype = "pandoc", + plotlib="PyPlot", informat="noweb", fig_path = "figures", fig_ext = nothing) ```` **Note:** Run JuliaReport from terminal and not using IJulia, Juno or ESS, they tend to mess with capturing output. diff --git a/examples/gadfly_sample.jmd b/examples/gadfly_sample.jmd index 64a394d..8c2ba0d 100644 --- a/examples/gadfly_sample.jmd +++ b/examples/gadfly_sample.jmd @@ -1,7 +1,7 @@ # Gadfly -```{julia term=true; fig_width=5} +```{julia;term=true;fig_width=5} using Gadfly x = linspace(0, 2π, 200) plot(x=x, y = sin(x), Geom.line) @@ -10,7 +10,21 @@ plot(x=x, y = cos(x), Geom.line) ``` -```{julia} +```julia x = linspace(0, 200) println(x) ``` + + +~~~{julia;term=true;fig_width=5} +using Gadfly +x = linspace(0, 2π, 200) +plot(x=x, y = sin(x), Geom.line) +y = 20 +plot(x=x, y = cos(x), Geom.line) +~~~ + +~~~julia +x = linspace(0, 200) +println(x) +~~~ diff --git a/src/readers.jl b/src/readers.jl index 43e0ffa..24cf334 100644 --- a/src/readers.jl +++ b/src/readers.jl @@ -4,11 +4,11 @@ pushopt(options::Dict,expr::Expr) = Base.Meta.isexpr(expr,:(=)) && (options[expr const input_formats = @compat Dict{String, Any}( "noweb" => Dict{Symbol, Any}( :codestart => r"^<<(.*?)>>=\s*$", - :codeend => r"^@(\s*)$" + :codeend => r"^@\s*$" ), "markdown" => Dict{Symbol, Any}( - :codestart => r"^```{julia(.*)}", - :codeend => r"^```+\s*$" + :codestart => r"(?:^`|~{3,}\s*(?:\{|\{\.|)julia(?:;|\s)(.*)\}\s*$)|(?:^`|~{3,}\s*julia\s*$)", + :codeend => r"^`|~{3,}\s*$" ) ) @@ -35,7 +35,11 @@ function read_document(document, format) line = lines[lineno] if (m = match(codestart, line)) != nothing && state=="doc" state = "code" - optionstring=strip(m.captures[1]) + if m.captures[1] == nothing + optionstring = "" + else + optionstring=strip(m.captures[1]) + end @show optionstring options = Dict{Symbol,Any}() if length(optionstring) > 0