From eb3bf0a19a3b11bab41875cb336d997380db2622 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sun, 20 May 2018 01:59:12 +0200 Subject: [PATCH] add back filtering of empty MDChunks, accidentally removed in #6, fix #11 --- 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"]),