Skip to content

Commit

Permalink
markdown: ensure line-break after displayed math
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Jan 21, 2016
1 parent 876240c commit 56594ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion base/markdown/IPython/IPython.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ writemime(io::IO, ::MIME"text/plain", tex::LaTeX) =
print(io, '$', tex.formula, '$')

latex(io::IO, tex::LaTeX) =
print(io, "\$\$", tex.formula, "\$\$")
println(io, "\$\$", tex.formula, "\$\$")

latexinline(io::IO, tex::LaTeX) =
print(io, '$', tex.formula, '$')
Expand Down
5 changes: 4 additions & 1 deletion base/markdown/render/plain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ function plain(io::IO, md::HorizontalRule)
println(io, "-" ^ 3)
end

plain(io::IO, md) = writemime(io, "text/plain", md)
function plain(io::IO, md)
writemime(io, MIME"text/plain"(), md)
println(io)
end

# Inline elements

Expand Down
11 changes: 7 additions & 4 deletions test/markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,15 @@ t = """a | b
latex_doc = md"""
We have $x^2 < x$ whenever:
$|x| < 1$"""
$|x| < 1$
etc."""

@test latex_doc == MD(Any[Paragraph(Any["We have ",
LaTeX("x^2 < x"),
" whenever:"]),
LaTeX("|x| < 1")])

LaTeX("|x| < 1"),
Paragraph(Any["etc."])])

@test latex(latex_doc) == "We have \$x^2 < x\$ whenever:\n\$\$|x| < 1\$\$"
@test plain(latex_doc) == "We have \$x^2 < x\$ whenever:\n\n\$|x| < 1\$\n\netc.\n"
@test latex(latex_doc) == "We have \$x^2 < x\$ whenever:\n\$\$|x| < 1\$\$\netc.\n"

0 comments on commit 56594ed

Please sign in to comment.