Literate.jl
Literate.jl copied to clipboard
Inconsistent Documenter rendering between code execution in Literate.jl and Documenter.jl
I'm not sure if this is issue on side of Literate, or Documenter, or both and fix needs to be applied to both of them.
When I generate markdown, execute it, and generate html site, the output is colored differently than when @example is executed using Documenter.
Here is a MWE:
using Pkg
cd(@__DIR__)
pkg"activate ."
using Literate, Documenter
open("script.jl", "w+") do io
write(io, """
a = 2 + 2
""")
end
Literate.markdown("script.jl", "src", execute=true, credit=false)
open("src/index.md", "w+") do io
write(io, """
```@example
a = 2 + 2
```
""")
end
makedocs(
sitename = "Test",
pages = [
"Home" => "index.md",
"Script from Literate" => "script.md",
],
)
The Home looks like this:
and Script from Literate like this:

specifically, when executed by documenter, generated code is
<article class="content" id="documenter-page">
<pre><code class="language-julia hljs">a = 2 + 2</code></pre>
<pre class="documenter-example-output"><code class="nohighlight hljs ansi">4</code></pre>
</article>
and when by literate, generated code is
<article class="content" id="documenter-page">
<pre><code class="language-julia hljs">a = 2 + 2</code></pre>
<pre><code class="nohighlight hljs">4</code></pre>
</article>
It is not really a bug/issue with either Literate or Documenter, it is just how things work. Documenter knows what it generates and insert those classes, but when you execute with Literate the result will look like regular code blocks (```-blocks with no language) from Documenters perspective.
I know.
Would it make sense to add some ```` block, e.g. julia-output and then add feature to Documenter so it would properly color them?