Improved markdown reader

pull/17/head
Matti Pastell 2014-12-06 16:40:50 +02:00
parent 29d15b00b7
commit 85bfafb760
4 changed files with 29 additions and 7 deletions

3
.gitignore vendored
View File

@ -4,6 +4,9 @@ examples/figures/
examples/*.md examples/*.md
examples/*.pdf examples/*.pdf
examples/*.html examples/*.html
examples/*.rst
examples/*.tex
tmp/ tmp/
.idea .idea
*.*~ *.*~

View File

@ -68,7 +68,8 @@ weave(Pkg.dir("JuliaReport","examples","gadfly_sample.mdw"), plotlib="Gadfly")
The signature of weave functions is: The signature of weave functions is:
````julia ````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. **Note:** Run JuliaReport from terminal and not using IJulia, Juno or ESS, they tend to mess with capturing output.

View File

@ -1,7 +1,7 @@
# Gadfly # Gadfly
```{julia term=true; fig_width=5} ```{julia;term=true;fig_width=5}
using Gadfly using Gadfly
x = linspace(0, 2π, 200) x = linspace(0, 2π, 200)
plot(x=x, y = sin(x), Geom.line) 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) x = linspace(0, 200)
println(x) 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)
~~~

View File

@ -4,11 +4,11 @@ pushopt(options::Dict,expr::Expr) = Base.Meta.isexpr(expr,:(=)) && (options[expr
const input_formats = @compat Dict{String, Any}( const input_formats = @compat Dict{String, Any}(
"noweb" => Dict{Symbol, Any}( "noweb" => Dict{Symbol, Any}(
:codestart => r"^<<(.*?)>>=\s*$", :codestart => r"^<<(.*?)>>=\s*$",
:codeend => r"^@(\s*)$" :codeend => r"^@\s*$"
), ),
"markdown" => Dict{Symbol, Any}( "markdown" => Dict{Symbol, Any}(
:codestart => r"^```{julia(.*)}", :codestart => r"(?:^`|~{3,}\s*(?:\{|\{\.|)julia(?:;|\s)(.*)\}\s*$)|(?:^`|~{3,}\s*julia\s*$)",
:codeend => r"^```+\s*$" :codeend => r"^`|~{3,}\s*$"
) )
) )
@ -35,7 +35,11 @@ function read_document(document, format)
line = lines[lineno] line = lines[lineno]
if (m = match(codestart, line)) != nothing && state=="doc" if (m = match(codestart, line)) != nothing && state=="doc"
state = "code" state = "code"
optionstring=strip(m.captures[1]) if m.captures[1] == nothing
optionstring = ""
else
optionstring=strip(m.captures[1])
end
@show optionstring @show optionstring
options = Dict{Symbol,Any}() options = Dict{Symbol,Any}()
if length(optionstring) > 0 if length(optionstring) > 0