Browse Source

do not end script files with double empty lines

pull/221/head
schillic 2 years ago
parent
commit
d8b000fb40
  1. 5
      src/Literate.jl
  2. 1
      test/runtests.jl

5
src/Literate.jl

@ -501,17 +501,18 @@ function script(inputfile, outputdir=pwd(); config::AbstractDict=Dict(), kwargs. @@ -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

1
test/runtests.jl

@ -345,7 +345,6 @@ const GITLAB_ENV = Dict( @@ -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

Loading…
Cancel
Save