Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering bug of Markdown Code. #14638

Merged
merged 1 commit into from
Jan 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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