Literate.jl
Literate.jl copied to clipboard
Add stderr to cell output
If a cell causes a warning, I would like to have that included in a rendered Markdown document. How would I achieve this?
function maywarn()
@warn "whoopsie"
42
end
maywarn()
Which renders as:
````
42
````
Expected result:
````
┌ Warning: whoopsie
└ @ Main anonymized_path.jl:2
````
````
42
````
Would you be interested in a PR that adds a configuration switch to enable this?
Having had a look at the code,
https://github.com/fredrikekre/Literate.jl/blob/0d308e4185c322092f0593765ae17acc7c8897a0/src/Literate.jl#L719-L722
I can come close to my desired solution by separating the logging part from the displaying part:
function maywarn()
@warn "method did not converge"
42
end
res = maywarn();
#-
res #hide
Which renders as follows. The only downsides are the empty line in the first output fence (see #270) and the two consecutive empty line in between the output fences (should only be one):
````
┌ Warning: method did not converge
└ @ Main.var"##225" ~/tmp/julia-literate-print/warn2.md:2
````
````
42
````