Skip to content

Commit

Permalink
closes #121
Browse files Browse the repository at this point in the history
  • Loading branch information
tlienart committed Jun 13, 2023
1 parent 9348ed7 commit 4490a3a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Xranklin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Xranklin
import Dates
import Dates: Date
import Base.(/)
import REPL: softscope
import REPL: softscope, ends_with_semicolon
import Pkg
import Serialization: serialize, deserialize
import Logging
Expand Down
2 changes: 1 addition & 1 deletion src/context/code/notebook_code.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function _eval_code_cell(

# if the end of the cell is a ';' or a `@show` then
# suppress the result
if endswith(code, HIDE_FINAL_OUTPUT_PAT)
if ends_with_semicolon(code)
result = nothing
else
# Check if the last expression is a show and if so set the returned
Expand Down
4 changes: 0 additions & 4 deletions src/convert/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ const CODE_INFO_PAT = r"^\`+([^\n]+)?"
"Language getter (allow space after language for highlighting in VSCode)"
const CODE_LANG_PAT = r"([^\!\:\s]+)?\s*([\!\:]{1,2})?(\S+)?"

"Check end of code block to see if should be hidden or not.
This is fragile if people do something silly like `x = 5 # foo ; # bar`"
const HIDE_FINAL_OUTPUT_PAT = r";\s*(:?#.*)?\n?"

"Trim the non-relevant part of a stacktrace when evaluating code."
const STACKTRACE_TRIM_PAT = r"\[\d+\]\stop-level\sscope"

Expand Down
11 changes: 11 additions & 0 deletions test/bugs/code.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include(joinpath(@__DIR__, "..", "utils.jl"))

@testset "i121" begin
s = """
```!
x = 5 # with a ;
```
""" |> html
@test contains(s, "code-result")
@test contains(s, ">5</code>")
end

0 comments on commit 4490a3a

Please sign in to comment.