From c87782f451e82ca6c6289770ccddc525f911c46c Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Wed, 27 May 2020 13:04:51 +0200 Subject: [PATCH 01/13] [RFC] Do not define Markdown.latex using eval This PR solves #356 at the expense of a warning: ``` WARNING: Method definition latex(IO, Markdown.LaTeX) in module Markdown at /home/fredrikb/julia/usr/share/julia/stdlib/v1.5/Markdown/src/IPython/IPython.jl:28 overwritten in module WeaveMarkdown at /home/fredrikb/.julia/dev/Weave/src/WeaveMarkdown/markdown.jl:10. ** incremental compilation may be fatally broken for this module ** ``` --- src/WeaveMarkdown/markdown.jl | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/WeaveMarkdown/markdown.jl b/src/WeaveMarkdown/markdown.jl index d1c4c66..a0b70cc 100644 --- a/src/WeaveMarkdown/markdown.jl +++ b/src/WeaveMarkdown/markdown.jl @@ -5,23 +5,15 @@ using ..Weave: isnothing, take2string! using Markdown import Markdown: @trigger, @breaking, Code, MD, withstream, startswith, LaTeX - -function __init__() - # NOTE: - # overwriting `Markdown.latex` function should be done here in order to allow - # incremental precompilations - Markdown.eval( - quote - function latex(io::IO, tex::Markdown.LaTeX) - math_envs = ["align", "equation", "eqnarray"] - use_dollars = - !any([occursin("\\begin{$me", tex.formula) for me in math_envs]) - use_dollars && write(io, "\\[") - write(io, string("\n", tex.formula, "\n")) - use_dollars && write(io, "\\]\n") - end - end, - ) +# Note that this definition causes a "Method overwritten" warning, +# but defining this function in __init__() is not legal in julia v1.5 +function Markdown.latex(io::IO, tex::Markdown.LaTeX) + math_envs = ["align", "equation", "eqnarray"] + use_dollars = + !any([occursin("\\begin{$me", tex.formula) for me in math_envs]) + use_dollars && write(io, "\\[") + write(io, string("\n", tex.formula, "\n")) + use_dollars && write(io, "\\]\n") end mutable struct Comment From b5ba227e757520f389a6d6e0f2cacb731eab8b12 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Mon, 17 Aug 2020 10:13:39 +0200 Subject: [PATCH 02/13] 0.10.3 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 46a710b..2267695 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Weave" uuid = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9" -version = "0.10.2" +version = "0.10.3" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 51f905ca834e56e689f15d471f6f8e8ce730108d Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Fri, 4 Sep 2020 16:03:58 +1200 Subject: [PATCH 03/13] Fix typo in header.md --- doc/src/header.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/header.md b/doc/src/header.md index cc86789..848c304 100644 --- a/doc/src/header.md +++ b/doc/src/header.md @@ -43,7 +43,7 @@ Note that `Date` is available since the chunk is evaluated first. --- ```julia; echo = false - using Datas + using Dates ``` ``` From 766847ec65d159e5add64eea7352e7ca594ba220 Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Thu, 24 Sep 2020 16:09:33 +0100 Subject: [PATCH 04/13] fix for #386 --- src/run.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run.jl b/src/run.jl index 71442ed..903f83c 100644 --- a/src/run.jl +++ b/src/run.jl @@ -225,7 +225,7 @@ function capture_output(code, mod, path, error, report) task_local_storage(:SOURCE_PATH, path) do try obj = include_string(mod, code, path) # TODO: fix line number - !isnothing(obj) && display(obj) + !isnothing(obj) && !REPL.ends_with_semicolon(code) && display(obj) catch _err err = unwrap_load_err(_err) error || throw(err) From 21d7fbdbeab008eeb7db2904c8a2a95ce5f452fc Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Fri, 25 Sep 2020 00:41:30 +0900 Subject: [PATCH 05/13] version 0.10.4 --- Project.toml | 2 +- src/plots.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 2267695..4446a67 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Weave" uuid = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9" -version = "0.10.3" +version = "0.10.4" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/plots.jl b/src/plots.jl index 9211c35..6746cb0 100644 --- a/src/plots.jl +++ b/src/plots.jl @@ -17,7 +17,7 @@ function Base.display( report::Weave.Report, m::MIME"image/svg+xml", data::Plots.Plot{Plots.PlotlyBackend}, -)# +) # Remove extra spaces from start of line for pandoc s = repr(MIME("text/html"), data) splitted = split(s, "\n") @@ -39,7 +39,7 @@ function Base.display( report::Weave.Report, m::MIME"image/png", data::Plots.Plot{Plots.PlotlyBackend}, -)# +) display(report, MIME("image/svg+xml"), data) end From fa718304795177564affd6ca478dff5e75a6d4e0 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Sat, 26 Sep 2020 08:41:42 +0200 Subject: [PATCH 06/13] Import Dates One must now `import Dates` for `now, Date` to be defined. --- doc/src/header.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/header.md b/doc/src/header.md index 848c304..de1eb68 100644 --- a/doc/src/header.md +++ b/doc/src/header.md @@ -39,7 +39,7 @@ Note that `Date` is available since the chunk is evaluated first. --- title : Header Example author : Shuhei Kadowaki - date: `j Date(now())` + date: `j import Dates; Dates.Date(Dates.now())` --- ```julia; echo = false From a1830e05029f33195627ec5dedbacb30af23947e Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Mon, 28 Sep 2020 01:10:21 +0900 Subject: [PATCH 07/13] triple quote for markdown output --- src/rendering/miscformats.jl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rendering/miscformats.jl b/src/rendering/miscformats.jl index 09ca0b4..ecc7e7b 100644 --- a/src/rendering/miscformats.jl +++ b/src/rendering/miscformats.jl @@ -4,12 +4,12 @@ Base.@kwdef mutable struct GitHubMarkdown <: WeaveFormat description = "GitHub Markdown" extension = "md" - codestart = "````julia" - codeend = "````\n\n" + codestart = "```julia" + codeend = "```\n\n" termstart = codestart termend = codeend - outputstart = "````" - outputend = "````\n\n" + outputstart = "```" + outputend = "```\n\n" fig_ext = ".png" mimetypes = ["image/png", "image/svg+xml", "image/jpg", "text/markdown", "text/plain"] @@ -50,12 +50,12 @@ end Base.@kwdef mutable struct Hugo <: WeaveFormat description = "Hugo Markdown (using shortcodes)" extension = "md" - codestart = "````julia" - codeend = "````\n\n" + codestart = "```julia" + codeend = "```\n\n" termstart = codestart termend = codeend - outputstart = "````" - outputend = "````\n\n" + outputstart = "```" + outputend = "```\n\n" mimetypes = default_mime_types fig_ext = ".png" out_width = nothing @@ -88,12 +88,12 @@ end Base.@kwdef mutable struct MultiMarkdown <: WeaveFormat description = "MultiMarkdown" extension = "md" - codestart = "````julia" - codeend = "````\n\n" + codestart = "```julia" + codeend = "```\n\n" termstart = codestart termend = codeend - outputstart = "````" - outputend = "````\n\n" + outputstart = "```" + outputend = "```\n\n" mimetypes = default_mime_types fig_ext = ".png" out_width = nothing From 8f23084471ab04a46561ccc5d7040692cecabe8e Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 30 Sep 2020 18:26:49 +0900 Subject: [PATCH 08/13] fixes #398 --- src/run.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/run.jl b/src/run.jl index 903f83c..6e76e26 100644 --- a/src/run.jl +++ b/src/run.jl @@ -20,8 +20,9 @@ function run_doc( doc.format = deepcopy(get_format(doctype)) cwd = doc.cwd = get_cwd(doc, out_path) - isdir(cwd) || mkdir(cwd) + mkpath(cwd) + # TODO: provide a way not to create `fig_path` ? if isnothing(fig_path) fig_path = if (endswith(doctype, "2pdf") && cache === :off) || endswith(doctype, "2html") basename(mktempdir(abspath(cwd))) @@ -29,7 +30,7 @@ function run_doc( DEFAULT_FIG_PATH end end - let d = normpath(cwd, fig_path); isdir(d) || mkdir(d); end + mkpath(normpath(cwd, fig_path)) # This is needed for latex and should work on all output formats @static Sys.iswindows() && (fig_path = replace(fig_path, "\\" => "/")) set_rc_params(doc, fig_path, fig_ext) From c24a2621359b5d0af1bb6825f488e58cc11b8a9e Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 30 Sep 2020 18:43:15 +0900 Subject: [PATCH 09/13] allow arbitrary runtime argument --- doc/src/usage.md | 25 ++++--------------------- src/Weave.jl | 4 ++-- src/run.jl | 4 ++-- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/doc/src/usage.md b/doc/src/usage.md index a6cb589..a838417 100644 --- a/doc/src/usage.md +++ b/doc/src/usage.md @@ -165,29 +165,12 @@ See [Header Configuration](@ref) section for more details. ## Passing Runtime Arguments to Documents -You can pass arguments as `Dict` to the weaved document using the `args` argument -to `weave`. The arguments will be available as `WEAVE_ARGS` variable in the document. +You can pass arbitrary object to the weaved document using [`weave`](@ref)'s optional argument `args`. +It will be available as `WEAVE_ARGS` variable in the `weave`d document. -This makes it possible to create the same report easily for e.g. different -date ranges of input data from a database or from files with similar format giving the -filename as input. +This makes it possible to create the same report easily for e.g. different date ranges of input data from a database or from files with similar format giving the filename as input. -In order to pass a filename to a document you need call `weave` using: - -```julia -weave("mydoc.jmd", args = Dict("filename" => "somedata.h5")) -``` - -and you can access the filename from document as follows: - -``` - ```julia - print(WEAVE_ARGS["filename"]) - ``` -``` - -You can use the `out_path` argument to control the name of the -output document. +E.g. if you call `weave("weavefile.jmd", args = (datalocation = "somedata.h5",))`, and then you can retrieve `datalocation` in `weavefile.jmd` as follows: `WEAVE_ARGS.datalocation` ## `include_weave` diff --git a/src/Weave.jl b/src/Weave.jl index 898dabd..f740b4f 100644 --- a/src/Weave.jl +++ b/src/Weave.jl @@ -102,7 +102,7 @@ Weave an input document to output file. * `:doc`: Path of the source document (default) * `:pwd`: Julia working directory * `"somepath"`: `String` of output directory e.g. `"~/outdir"`, or of filename e.g. `"~/outdir/outfile.tex"` -- `args::Dict = Dict()`: Arguments to be passed to the weaved document; will be available as `WEAVE_ARGS` in the document +- `args::Any = Dict()`: A runtime object that is available as `WEAVE_ARGS` while `weave`ing - `mod::Union{Module,Nothing} = nothing`: Module where Weave `eval`s code. You can pass a `Module` object, otherwise create an new sandbox module. - `fig_path::Union{Nothing,AbstractString} = nothing`: Where figures will be generated, relative to `out_path`. By default (i.e. given `nothing`), Weave will automatically create `$(DEFAULT_FIG_PATH)` directory. - `fig_ext::Union{Nothing,AbstractString} = nothing`: Extension for saved figures e.g. `".pdf"`, `".png"`. Default setting depends on `doctype` @@ -127,7 +127,7 @@ function weave( doctype::Union{Nothing,AbstractString} = nothing, informat::Union{Nothing,AbstractString} = nothing, out_path::Union{Symbol,AbstractString} = :doc, - args::Dict = Dict(), + args::Any = Dict(), mod::Union{Module,Nothing} = nothing, fig_path::Union{Nothing,AbstractString} = nothing, fig_ext::Union{Nothing,AbstractString} = nothing, diff --git a/src/run.jl b/src/run.jl index 6e76e26..279e279 100644 --- a/src/run.jl +++ b/src/run.jl @@ -7,7 +7,7 @@ function run_doc( doc::WeaveDoc; doctype::Union{Nothing,AbstractString} = nothing, out_path::Union{Symbol,AbstractString} = :doc, - args::Dict = Dict(), + args::Any = Dict(), mod::Union{Module,Nothing} = nothing, fig_path::Union{Nothing,AbstractString} = nothing, fig_ext::Union{Nothing,AbstractString} = nothing, @@ -39,7 +39,7 @@ function run_doc( # New sandbox for each document with args exposed isnothing(mod) && (mod = sandbox = Core.eval(Main, :(module $(gensym(:WeaveSandBox)) end))::Module) - @eval mod WEAVE_ARGS = $args + Core.eval(mod, :(const WEAVE_ARGS = $(args))) mimetypes = doc.format.mimetypes From 78befc61b5664cee718c43c88db33a47b27435ce Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 30 Sep 2020 19:07:26 +0900 Subject: [PATCH 10/13] version 0.10.5 --- .travis.yml | 2 +- Project.toml | 2 +- doc/src/usage.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2baf28a..cb33b33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: julia jobs: include: - stage: "Documentation" - julia: 1 + julia: 1.5 os: linux script: - julia --project=doc/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' diff --git a/Project.toml b/Project.toml index 4446a67..bc4fe11 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Weave" uuid = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9" -version = "0.10.4" +version = "0.10.5" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/doc/src/usage.md b/doc/src/usage.md index a838417..36574cf 100644 --- a/doc/src/usage.md +++ b/doc/src/usage.md @@ -170,7 +170,7 @@ It will be available as `WEAVE_ARGS` variable in the `weave`d document. This makes it possible to create the same report easily for e.g. different date ranges of input data from a database or from files with similar format giving the filename as input. -E.g. if you call `weave("weavefile.jmd", args = (datalocation = "somedata.h5",))`, and then you can retrieve `datalocation` in `weavefile.jmd` as follows: `WEAVE_ARGS.datalocation` +E.g. if you call `weave("weavefile.jmd", args = (datalocation = "somedata.h5",))`, and then you can retrieve the `datalocation` in `weavefile.jmd` as follows: `WEAVE_ARGS.datalocation` ## `include_weave` From e927495a62f2ff9be2571ebbd9645f19c15f8d6d Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sat, 3 Oct 2020 04:21:19 +0900 Subject: [PATCH 11/13] fixes #400 --- .github/workflows/ci.yml | 2 +- src/rendering/common.jl | 14 +++++--------- src/rendering/htmlformats.jl | 12 ++++++------ src/rendering/miscformats.jl | 10 +++++----- src/rendering/pandocformats.jl | 4 ++-- src/run.jl | 9 +++------ 6 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 941d115..0a6d998 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false # don't stop CI even when one of them fails matrix: version: - - '1.4' + - '1.5' os: - ubuntu-latest - macOS-latest diff --git a/src/rendering/common.jl b/src/rendering/common.jl index 8f39b03..b877809 100644 --- a/src/rendering/common.jl +++ b/src/rendering/common.jl @@ -44,18 +44,14 @@ function render_chunk(docformat::WeaveFormat, chunk::CodeChunk) chunk.content = render_code(docformat, chunk.content) - if !chunk.options[:eval] - return if chunk.options[:echo] - string(docformat.codestart, '\n', chunk.content, docformat.codeend) - else - "" - end - end + echo = chunk.options[:echo] + + chunk.options[:eval] || return echo ? string(docformat.codestart, chunk.content, docformat.codeend) : "" if chunk.options[:term] result = render_termchunk(docformat, chunk) else - result = if chunk.options[:echo] + result = if echo # Convert to output format and highlight (html, tex...) if needed string(docformat.codestart, chunk.content, docformat.codeend, '\n') else @@ -126,7 +122,7 @@ render_output(docformat::WeaveFormat, output) = output function render_termchunk(docformat::WeaveFormat, chunk) return if should_render(chunk) - string(docformat.termstart, chunk.output, '\n', docformat.termend, '\n') + string(docformat.termstart, chunk.output, docformat.termend) else "" end diff --git a/src/rendering/htmlformats.jl b/src/rendering/htmlformats.jl index 949e94a..d7684f0 100644 --- a/src/rendering/htmlformats.jl +++ b/src/rendering/htmlformats.jl @@ -15,8 +15,8 @@ render_termchunk(docformat::HTMLFormat, chunk) = Base.@kwdef mutable struct WeaveHTML <: HTMLFormat description = "Weave-style HTML" extension = "html" - codestart = "\n" - codeend = "\n" + codestart = '\n' + codeend = '\n' termstart = codestart termend = codeend outputstart = "
"
@@ -127,12 +127,12 @@ end
 Base.@kwdef mutable struct Pandoc2HTML <: HTMLFormat
     description = "HTML via intermediate Pandoc Markdown (requires Pandoc 2)"
     extension = "md"
-    codestart = "\n"
-    codeend = "\n"
+    codestart = '\n'
+    codeend = '\n'
     termstart = codestart
     termend = codeend
-    outputstart = "\n"
-    outputend = "\n"
+    outputstart = '\n'
+    outputend = '\n'
     mimetypes = ["image/png", "image/svg+xml", "image/jpg", "text/html", "text/markdown", "text/plain"]
     fig_ext = ".png"
     out_width = nothing
diff --git a/src/rendering/miscformats.jl b/src/rendering/miscformats.jl
index ecc7e7b..6a19365 100644
--- a/src/rendering/miscformats.jl
+++ b/src/rendering/miscformats.jl
@@ -5,7 +5,7 @@ Base.@kwdef mutable struct GitHubMarkdown <: WeaveFormat
     description = "GitHub Markdown"
     extension = "md"
     codestart = "```julia"
-    codeend = "```\n\n"
+    codeend = "```\n"
     termstart = codestart
     termend = codeend
     outputstart = "```"
@@ -51,7 +51,7 @@ Base.@kwdef mutable struct Hugo <: WeaveFormat
     description = "Hugo Markdown (using shortcodes)"
     extension = "md"
     codestart = "```julia"
-    codeend = "```\n\n"
+    codeend = "```\n"
     termstart = codestart
     termend = codeend
     outputstart = "```"
@@ -89,7 +89,7 @@ Base.@kwdef mutable struct MultiMarkdown <: WeaveFormat
     description = "MultiMarkdown"
     extension = "md"
     codestart = "```julia"
-    codeend = "```\n\n"
+    codeend = "```\n"
     termstart = codestart
     termend = codeend
     outputstart = "```"
@@ -143,7 +143,7 @@ Base.@kwdef mutable struct Rest <: WeaveFormat
     description = "reStructuredText and Sphinx"
     extension = "rst"
     codestart = ".. code-block:: julia\n"
-    codeend = "\n\n"
+    codeend = "\n"
     termstart = codestart
     termend = codeend
     outputstart = "::\n"
@@ -190,7 +190,7 @@ Base.@kwdef mutable struct AsciiDoc <: WeaveFormat
     description = "AsciiDoc"
     extension = "txt"
     codestart = "[source,julia]\n--------------------------------------"
-    codeend = "--------------------------------------\n\n"
+    codeend = "--------------------------------------\n"
     termstart = codestart
     termend = codeend
     outputstart = "--------------------------------------"
diff --git a/src/rendering/pandocformats.jl b/src/rendering/pandocformats.jl
index 0c18401..30364fe 100644
--- a/src/rendering/pandocformats.jl
+++ b/src/rendering/pandocformats.jl
@@ -37,7 +37,7 @@ Base.@kwdef mutable struct Pandoc <: PandocFormat
     description = "Pandoc Markdown"
     extension = "md"
     codestart = "~~~~{.julia}"
-    codeend = "~~~~~~~~~~~~~\n\n"
+    codeend = "~~~~~~~~~~~~~\n"
     termstart = codestart
     termend = codeend
     outputstart = "~~~~"
@@ -60,7 +60,7 @@ Base.@kwdef mutable struct Pandoc2PDF <: PandocFormat
     description = "PDF via intermediate Pandoc Markdown"
     extension = "md"
     codestart = "~~~~{.julia}"
-    codeend = "~~~~~~~~~~~~~\n\n"
+    codeend = "~~~~~~~~~~~~~\n"
     termstart = codestart
     termend = codeend
     outputstart = "~~~~"
diff --git a/src/run.jl b/src/run.jl
index 279e279..6dcc044 100644
--- a/src/run.jl
+++ b/src/run.jl
@@ -353,11 +353,9 @@ function collect_results(chunk::CodeChunk)
     content = ""
     result_chunks = CodeChunk[]
     for r in chunk.result
+        content *= r.code
         # Check if there is any output from chunk
-        if strip(r.stdout) == "" && isempty(r.figures) && strip(r.rich_output) == ""
-            content *= r.code
-        else
-            content = "\n" * content * r.code
+        if any(!isempty ∘ strip, (r.stdout, r.rich_output)) || !isempty(r.figures)
             rchunk = CodeChunk(
                 content,
                 chunk.number,
@@ -365,15 +363,14 @@ function collect_results(chunk::CodeChunk)
                 chunk.optionstring,
                 copy(chunk.options),
             )
-            content = ""
             rchunk.figures = r.figures
             rchunk.output = r.stdout
             rchunk.rich_output = r.rich_output
             push!(result_chunks, rchunk)
+            content = ""
         end
     end
     if !isempty(content)
-        startswith(content, "\n") || (content = "\n" * content)
         rchunk = CodeChunk(
             content,
             chunk.number,

From d3a7f2aea778627a055fe532253668eb401d387b Mon Sep 17 00:00:00 2001
From: Shuhei Kadowaki 
Date: Sat, 3 Oct 2020 04:50:49 +0900
Subject: [PATCH 12/13] version 0.10.6

---
 NEWS.md      | 15 ++++++++++++++-
 Project.toml |  2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 4742d7d..622559d 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,19 @@
 ## Release notes for Weave.jl
 
-### v0.10 - 2020/05/18
+### v0.10.6 – 2020/10/03
+
+improvements:
+- cleaned up chunk rendering (removed unnecessary extra newlines): #401
+- `WEAVE_ARGS` now can take arbitrary objects: https://github.com/JunoLab/Weave.jl/commit/c24a2621359b5d0af1bb6825f488e58cc11b8a9e
+- improved docs: #397 by @baggepinnen
+
+bug fixes
+- fixed #398: #399
+- removed unnecessary quote for markdown output: https://github.com/JunoLab/Weave.jl/commit/a1830e05029f33195627ec5dedbacb30af23947e
+- fixed #386: #396 by @torfjelde
+
+
+### v0.10 – 2020/05/18
 
 improvements:
 - `weave` is now integrated with Juno's progress bar; just call `weave` function inside Juno or use `julia-client: weave-to-html(pdf)` command (#331)
diff --git a/Project.toml b/Project.toml
index bc4fe11..62ede36 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,6 +1,6 @@
 name = "Weave"
 uuid = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9"
-version = "0.10.5"
+version = "0.10.6"
 
 [deps]
 Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

From 196d4ca7ce80e65f7365642218c43a8c94d5f286 Mon Sep 17 00:00:00 2001
From: Shuhei Kadowaki 
Date: Sat, 3 Oct 2020 13:17:39 +0900
Subject: [PATCH 13/13] don't decl const for `WEAVE_ARGS`

---
 src/run.jl | 54 +++++++++++++++++++++---------------------------------
 1 file changed, 21 insertions(+), 33 deletions(-)

diff --git a/src/run.jl b/src/run.jl
index 6dcc044..b47aa97 100644
--- a/src/run.jl
+++ b/src/run.jl
@@ -39,7 +39,7 @@ function run_doc(
 
     # New sandbox for each document with args exposed
     isnothing(mod) && (mod = sandbox = Core.eval(Main, :(module $(gensym(:WeaveSandBox)) end))::Module)
-    Core.eval(mod, :(const WEAVE_ARGS = $(args)))
+    Core.eval(mod, :(WEAVE_ARGS = $(args)))
 
     mimetypes = doc.format.mimetypes
 
@@ -140,27 +140,17 @@ function embed_figures!(chunk::CodeChunk, cwd)
         chunk.figures[i] = img2base64(fig, cwd)
     end
 end
-
-function embed_figures!(chunks::Vector{CodeChunk}, cwd)
-    for chunk in chunks
-        embed_figures!(chunk, cwd)
-    end
-end
+embed_figures!(chunks, cwd) = embed_figures!.(chunks, Ref(cwd))
 
 function img2base64(fig, cwd)
     ext = splitext(fig)[2]
     f = open(joinpath(cwd, fig), "r")
     raw = read(f)
     close(f)
-    if ext == ".png"
-        return "data:image/png;base64," * stringmime(MIME("image/png"), raw)
-    elseif ext == ".svg"
-        return "data:image/svg+xml;base64," * stringmime(MIME("image/svg"), raw)
-    elseif ext == ".gif"
-        return "data:image/gif;base64," * stringmime(MIME("image/gif"), raw)
-    else
-        return (fig)
-    end
+    return ext == ".png" ? "data:image/png;base64," * stringmime(MIME("image/png"), raw) :
+           ext == ".svg" ? "data:image/svg+xml;base64," * stringmime(MIME("image/svg"), raw) :
+           ext == ".gif" ? "data:image/gif;base64," * stringmime(MIME("image/gif"), raw) :
+           fig
 end
 
 function run_chunk(chunk::DocChunk, doc, report, mod)
@@ -274,15 +264,9 @@ function eval_chunk(doc::WeaveDoc, chunk::CodeChunk, report::Report, mod::Module
 
     execute_posthooks!(chunk)
 
-    chunks = if chunk.options[:term]
-        collect_term_results(chunk)
-    elseif chunk.options[:hold]
-        collect_hold_results(chunk)
-    else
-        collect_results(chunk)
-    end
-
-    return chunks
+    return chunk.options[:term] ? collect_term_results(chunk) :
+           chunk.options[:hold] ? collect_hold_results(chunk) :
+           collect_results(chunk)
 end
 
 # Hooks to run before and after chunks, this is form IJulia,
@@ -293,7 +277,11 @@ function pop_preexecution_hook!(f::Function)
     isnothing(i) && error("this function has not been registered in the pre-execution hook yet")
     return splice!(preexecution_hooks, i)
 end
-execute_prehooks!(chunk::CodeChunk) = for prehook in preexecution_hooks; Base.invokelatest(prehook, chunk); end
+function execute_prehooks!(chunk::CodeChunk)
+    for prehook in preexecution_hooks
+        Base.invokelatest(prehook, chunk)
+    end
+end
 
 const postexecution_hooks = Function[]
 push_postexecution_hook!(f::Function) = push!(postexecution_hooks, f)
@@ -302,7 +290,11 @@ function pop_postexecution_hook!(f::Function)
     isnothing(i) && error("this function has not been registered in the post-execution hook yet")
     return splice!(postexecution_hooks, i)
 end
-execute_posthooks!(chunk::CodeChunk) = for posthook in postexecution_hooks; Base.invokelatest(posthook, chunk); end
+function execute_posthooks!(chunk::CodeChunk)
+    for posthook in postexecution_hooks
+        Base.invokelatest(posthook, chunk)
+    end
+end
 
 """
     clear_module!(mod::Module)
@@ -341,11 +333,7 @@ function get_figname(report::Report, chunk; fignum = nothing, ext = nothing)
 end
 
 function set_rc_params(doc::WeaveDoc, fig_path, fig_ext)
-    if isnothing(fig_ext)
-        doc.chunk_defaults[:fig_ext] = doc.format.fig_ext
-    else
-        doc.chunk_defaults[:fig_ext] = fig_ext
-    end
+    doc.chunk_defaults[:fig_ext] = isnothing(fig_ext) ? doc.format.fig_ext : fig_ext
     doc.chunk_defaults[:fig_path] = fig_path
 end
 
@@ -363,9 +351,9 @@ function collect_results(chunk::CodeChunk)
                 chunk.optionstring,
                 copy(chunk.options),
             )
-            rchunk.figures = r.figures
             rchunk.output = r.stdout
             rchunk.rich_output = r.rich_output
+            rchunk.figures = r.figures
             push!(result_chunks, rchunk)
             content = ""
         end