Skip to content

Commit

Permalink
Literate.script: do not end with double newline (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Aug 27, 2023
1 parent d59c8c1 commit 329a44a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -501,17 +501,18 @@ function script(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs.

# create the script file
ioscript = IOBuffer()
isfirst = true
for chunk in chunks
if isa(chunk, CodeChunk)
isfirst ? (isfirst = false) : write(ioscript, '\n') # add a newline between each chunk
for line in chunk.lines
write(ioscript, line, '\n')
end
write(ioscript, '\n') # add a newline between each chunk
elseif isa(chunk, MDChunk) && config["keep_comments"]::Bool
isfirst ? (isfirst = false) : write(ioscript, '\n') # add a newline between each chunk
for line in chunk.lines
write(ioscript, rstrip(line.first * "# " * line.second) * '\n')
end
write(ioscript, '\n') # add a newline between each chunk
end
end

Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ const GITLAB_ENV = Dict(
hidden2 * hidden2
# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl
"""
script = read(joinpath(outdir, "inputfile.jl"), String)
@test script == expected_script
Expand Down

0 comments on commit 329a44a

Please sign in to comment.