Browse Source

add back filtering of empty MDChunks, accidentally removed in #6, fix #11

pull/12/head
Fredrik Ekre 8 years ago
parent
commit
eb3bf0a19a
  1. 6
      src/Literate.jl
  2. 4
      test/runtests.jl

6
src/Literate.jl

@ -70,13 +70,13 @@ function parse(content; allow_continued = true) @@ -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

4
test/runtests.jl

@ -95,6 +95,10 @@ end @@ -95,6 +95,10 @@ end
## Line 65
Line 66
Line 67
#-
#
#-
#
"""
expected_chunks = Chunk[
MDChunk(["" => "Line 1"]),

Loading…
Cancel
Save