Browse Source

Literate.script: do not end with double newline (#221)

pull/223/head
Christian Schilling 2 years ago committed by GitHub
parent
commit
329a44af80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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.
# create the script file # create the script file
ioscript = IOBuffer() ioscript = IOBuffer()
isfirst = true
for chunk in chunks for chunk in chunks
if isa(chunk, CodeChunk) if isa(chunk, CodeChunk)
isfirst ? (isfirst = false) : write(ioscript, '\n') # add a newline between each chunk
for line in chunk.lines for line in chunk.lines
write(ioscript, line, '\n') write(ioscript, line, '\n')
end end
write(ioscript, '\n') # add a newline between each chunk
elseif isa(chunk, MDChunk) && config["keep_comments"]::Bool 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 for line in chunk.lines
write(ioscript, rstrip(line.first * "# " * line.second) * '\n') write(ioscript, rstrip(line.first * "# " * line.second) * '\n')
end end
write(ioscript, '\n') # add a newline between each chunk
end end
end end

1
test/runtests.jl

@ -345,7 +345,6 @@ const GITLAB_ENV = Dict(
hidden2 * hidden2 hidden2 * hidden2
# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl # This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl
""" """
script = read(joinpath(outdir, "inputfile.jl"), String) script = read(joinpath(outdir, "inputfile.jl"), String)
@test script == expected_script @test script == expected_script

Loading…
Cancel
Save