Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not end script files with double empty lines #221

Merged
merged 2 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
fredrikekre marked this conversation as resolved.
Show resolved Hide resolved
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
fredrikekre marked this conversation as resolved.
Show resolved Hide resolved
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
Loading