diff --git a/src/chunks.jl b/src/chunks.jl index c7ef082..1a5aced 100644 --- a/src/chunks.jl +++ b/src/chunks.jl @@ -7,10 +7,11 @@ type WeaveDoc cwd::AbstractString format doctype::AbstractString + header_script::String function WeaveDoc(source, chunks) path, fname = splitdir(abspath(source)) basename = splitext(fname)[1] - new(source, basename, path, chunks, "", nothing, "") + new(source, basename, path, chunks, "", nothing, "", "") end end diff --git a/src/display_methods.jl b/src/display_methods.jl index a0d9fa5..b8e7116 100644 --- a/src/display_methods.jl +++ b/src/display_methods.jl @@ -12,10 +12,11 @@ type Report <: Display cur_chunk mimetypes::Array{AbstractString} first_plot::Bool + header_script::String end function Report(cwd, basename, formatdict, mimetypes) - Report(cwd, basename, formatdict, "", "", "", 1, AbstractString[], :text, nothing, mimetypes, true) + Report(cwd, basename, formatdict, "", "", "", 1, AbstractString[], :text, nothing, mimetypes, true, "") end diff --git a/src/pandoc.jl b/src/pandoc.jl index e7d6946..9109453 100644 --- a/src/pandoc.jl +++ b/src/pandoc.jl @@ -13,6 +13,16 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc, outname::Abstract wversion = string(Pkg.installed("Weave")) wtime = string(Date(now())) + #Header is inserted from displayed plots + header_script = doc.header_script + #info(doc.header_script) + + if header_script ≠ "" + self_contained = [] + else + self_contained = "--self-contained" + end + #Change path for pandoc old_wd = pwd() cd(doc.cwd) @@ -20,9 +30,10 @@ function pandoc2html(formatted::AbstractString, doc::WeaveDoc, outname::Abstract outname = basename(outname) try - pandoc_out, pandoc_in, proc = readandwrite(`pandoc -R -s --mathjax --highlight-style=tango - --template $html_template -c $css_template + pandoc_out, pandoc_in, proc = readandwrite(`pandoc -R -s --mathjax="" --highlight-style=tango + --template $html_template -H $css_template $self_contained -V wversion=$wversion -V wtime=$wtime -V wsource=$wsource + -V headerscript=$header_script -o $outname`) println(pandoc_in, formatted) diff --git a/src/plots.jl b/src/plots.jl index 6bf0215..43d16f3 100644 --- a/src/plots.jl +++ b/src/plots.jl @@ -18,14 +18,11 @@ function Base.display(report::Report, m::MIME"image/svg+xml", data::Plots.Plot{P start = split(splitted[1], r"(?=