From 58f4cfb6d6268d3631ad6b7c16e68fd8a44e08b0 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sun, 20 May 2018 02:13:45 +0200 Subject: [PATCH] add back filtering of empty MDChunks, accidentally removed in #6, fix #11 (#12) --- src/Literate.jl | 6 +++--- test/runtests.jl | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Literate.jl b/src/Literate.jl index fe586a8..d8d425d 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -70,13 +70,13 @@ function parse(content; allow_continued = true) # clean up the chunks ## remove empty chunks filter!(x -> !isempty(x.lines), chunks) - filter!(x -> !all(y -> isempty(y), x.lines), chunks) + filter!(x -> !all(y -> isempty(y) || isempty(last(y)), x.lines), chunks) ## remove leading/trailing empty lines for chunk in chunks - while chunk.lines[1] == "" || chunk.lines[1] == ("" => "") + while isempty(chunk.lines[1]) || isempty(last(chunk.lines[1])) popfirst!(chunk.lines) end - while chunk.lines[end] == "" || chunk.lines[end] == ("" => "") + while isempty(chunk.lines[end]) || isempty(last(chunk.lines[end])) pop!(chunk.lines) end end diff --git a/test/runtests.jl b/test/runtests.jl index 0d12300..8ddc648 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -95,6 +95,10 @@ end ## Line 65 Line 66 Line 67 + #- + # + #- + # """ expected_chunks = Chunk[ MDChunk(["" => "Line 1"]),