From 17f19aacc03ba02e3d603bb20595058231bee2a5 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 17 Apr 2018 12:14:07 +0200 Subject: [PATCH] rstrip the line in the parser --- src/Examples.jl | 1 + test/runtests.jl | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Examples.jl b/src/Examples.jl index 55887da..2cc7fbe 100644 --- a/src/Examples.jl +++ b/src/Examples.jl @@ -40,6 +40,7 @@ function parse(content) push!(chunks, startswith(lines[1], "#'") ? MDChunk() : CodeChunk()) for line in lines + line = rstrip(line) if startswith(line, "#-") # new chunk # assume same as last chunk, will be cleaned up otherwise push!(chunks, typeof(chunks[end])()) diff --git a/test/runtests.jl b/test/runtests.jl index 944af2e..dc49459 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -22,7 +22,7 @@ function compare_chunks(chunks1, chunks2) end end -@testset "parser" begin +@testset "Examples.parse" begin content = """ #' Line 1 Line 2 @@ -121,10 +121,10 @@ end for c in expected_chunks if isa(c, CodeChunk) foreach(x-> println(io, x), c.lines) - foreach(x-> println(iows, x), c.lines) + foreach(x-> println(iows, x, " "), c.lines) else foreach(x -> println(io, "#' ", x), c.lines) - foreach(x -> println(iows, "#' ", x), c.lines) + foreach(x -> println(iows, "#' ", x, " "), c.lines) end println(io, "#-") println(iows, "#-") @@ -144,7 +144,7 @@ content = """ #nb Line 6 #jl #' Line 7 #jl Line 8 - #' Line 9 #jl + #' Line 9 #jl Line 10 #jl # #' Line 11 # Line 12