Skip to content

Commit

Permalink
Fix rendering bug of Markdown Code.
Browse files Browse the repository at this point in the history
When a code block included a ```, it would not be rendered correctly.
  • Loading branch information
hayd committed Jan 11, 2016
1 parent b9dc4c9 commit 60eda14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions base/markdown/render/plain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ function plain{l}(io::IO, header::Header{l})
end

function plain(io::IO, code::Code)
println(io, "```", code.language)
# If the code includes a fenced block this will break parsing,
# so it must be enclosed by a longer ````-sequence.
n = mapreduce(length, max, 2, matchall(r"^`+"m, code.code)) + 1
println(io, "`" ^ n, code.language)
println(io, code.code)
println(io, "```")
println(io, "`" ^ n)
end

function plain(io::IO, p::Paragraph)
Expand Down
8 changes: 8 additions & 0 deletions test/markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ foo
```
""" == MD(LaTeX("..."))

code_in_code = md"""
````
```
````
"""
@test code_in_code == MD(Code("```"))
@test plain(code_in_code) == "````\n```\n````\n"

@test md"A footnote [^foo]." == MD(Paragraph(["A footnote ", Footnote("foo", nothing), "."]))

@test md"[^foo]: footnote" == MD(Paragraph([Footnote("foo", Any[" footnote"])]))
Expand Down

0 comments on commit 60eda14

Please sign in to comment.