From 329a44af808bc628f28f9085bcbc89df41202dac Mon Sep 17 00:00:00 2001 From: Christian Schilling Date: Sun, 27 Aug 2023 10:24:43 +0200 Subject: [PATCH] Literate.script: do not end with double newline (#221) --- src/Literate.jl | 5 +++-- test/runtests.jl | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Literate.jl b/src/Literate.jl index d650bc3..c7fe917 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 c31c32b..5970b06 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