Skip to content

Commit

Permalink
add back filtering of empty MDChunks, accidentally removed in #6, fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored May 20, 2018
1 parent a34a1b1 commit 58f4cfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Literate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ end
## Line 65
Line 66
Line 67
#-
#
#-
#
"""
expected_chunks = Chunk[
MDChunk(["" => "Line 1"]),
Expand Down

0 comments on commit 58f4cfb

Please sign in to comment.