Skip to content

Instantly share code, notes, and snippets.

@mortenpi
Last active May 19, 2017 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mortenpi/4c4b50362bf22561524d884f5d9e5289 to your computer and use it in GitHub Desktop.
Save mortenpi/4c4b50362bf22561524d884f5d9e5289 to your computer and use it in GitHub Desktop.
Work around the world counter issue in Documenter
diff --git a/src/Expanders.jl b/src/Expanders.jl
index 484622f..f7025f4 100644
--- a/src/Expanders.jl
+++ b/src/Expanders.jl
@@ -471,11 +471,7 @@ function Selectors.runner(::Type{ExampleBlocks}, x, page, doc)
# Splice the input and output into the document.
content = []
input = droplines(x.code)
-
- # Special-case support for displaying SVG graphics. TODO: make this more general.
- output = mimewritable(MIME"image/svg+xml"(), result) ?
- Documents.RawHTML(stringmime(MIME"image/svg+xml"(), result)) :
- Markdown.Code(Documenter.DocChecks.result_to_string(buffer, result))
+ output = Base.invokelatest(get_output, result, buffer)
# Only add content when there's actually something to add.
isempty(input) || push!(content, Markdown.Code("julia", input))
@@ -484,6 +480,15 @@ function Selectors.runner(::Type{ExampleBlocks}, x, page, doc)
page.mapping[x] = Markdown.MD(content)
end
+function get_output(result, buffer)
+ # Special-case support for displaying SVG graphics. TODO: make this more general.
+ if mimewritable(MIME"image/svg+xml"(), result)
+ Documents.RawHTML(stringmime(MIME"image/svg+xml"(), result))
+ else
+ Markdown.Code(Documenter.DocChecks.result_to_string(buffer, result))
+ end
+end
+
# @repl
# -----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment