diff --git a/src/Literate.jl b/src/Literate.jl index d650bc33..c7fe9179 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index c31c32bc..5970b060 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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