From f5874c27af1b664f5d4d684d8d79f2504e9e477c Mon Sep 17 00:00:00 2001 From: Andy Hayden Date: Fri, 20 Mar 2015 18:51:47 -0700 Subject: [PATCH] fix fenced code blocks have to have the same level --- base/markdown/GitHub/GitHub.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/base/markdown/GitHub/GitHub.jl b/base/markdown/GitHub/GitHub.jl index d28fb997c842b..6f2c7b89e3550 100644 --- a/base/markdown/GitHub/GitHub.jl +++ b/base/markdown/GitHub/GitHub.jl @@ -12,18 +12,23 @@ function fencedcode(stream::IO, block::MD, config::Config) # inline code block if contains(flavor, string(ch) ^ n) + #TODO edge case where this is a string(ch) ^ (n + 1) seek(stream, start) return false end buffer = IOBuffer() while !eof(stream) + line_start = position(stream) if startswith(stream, string(ch) ^ n) - push!(block, Code(flavor, takebuf_string(buffer) |> chomp)) - return true - else - write(buffer, readline(stream)) + if !startswith(stream, string(ch)) + push!(block, Code(flavor, takebuf_string(buffer) |> chomp)) + return true + else + seek(stream, line_start) + end end + write(buffer, readline(stream)) end seek(stream, start) return false