JunoLab / Weave.jl

Scientific reports/literate programming for Julia
http://weavejl.mpastell.com
MIT License
823 stars 94 forks source link

[BUG] Semicolon in `juliaconsole` environment no longer suppresses output #386

Closed mossr closed 3 years ago

mossr commented 4 years ago

When using the juliaconsole environment from pythontex, semicolons no longer suppress outputs in Weave versions 0.10+ (v0.9.4 is the last working version).

Any pointers to help track this down, I'd be happy to help get this fixed.

mykelk commented 4 years ago

I'm able to reproduce this issue and can confirm that v0.9.4 works.

torfjelde commented 3 years ago

Seems like this line (which was introduced after v0.10) is the issue: https://github.com/JunoLab/Weave.jl/blob/174585e5044814a5c1752d9b0184111f38521fd4/src/run.jl#L227

include_string doesn't respect ;, e.g.

julia> include_string(Main, "1 + 2;")
3
aviatesk commented 3 years ago

@torfjelde thanks for tracking the problem. I introduced include_string in this commit just because it's easier way to respect filename and line numbers than to use Core.eval solution (, which needs bit of expression manipulation).

I feel a special casing that adds ; nothing when the input line ends with semicolon would be enough for handling this bug.

torfjelde commented 3 years ago

How about https://github.com/JunoLab/Weave.jl/blob/174585e5044814a5c1752d9b0184111f38521fd4/src/run.jl#L227-L228 becomes

obj = include_string(mod, code, path) # TODO: fix line number
!isnothing(obj) && !REPL.ends_with_semicolon(code) && display(obj)

?

aviatesk commented 3 years ago

ah sounds nice. wanna open a PR ?

torfjelde commented 3 years ago

Sure thing :+1:

aviatesk commented 3 years ago

will be fixed in v0.10.4