Skip to content

Commit

Permalink
hard line breaks
Browse files Browse the repository at this point in the history
closes #9410
  • Loading branch information
MikeInnes committed Jan 25, 2015
1 parent d1d0210 commit 1eca232
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion base/markdown/Common/Common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ include("block.jl")
include("inline.jl")

@flavor common [list, indentcode, blockquote, hashheader, paragraph,
escapes, en_dash, inline_code, asterisk_bold, asterisk_italic, image, link]

linebreak, escapes, en_dash, inline_code, asterisk_bold,
asterisk_italic, image, link]
10 changes: 9 additions & 1 deletion base/markdown/Common/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,22 @@ end
# Punctuation
# –––––––––––

type LineBreak end

@trigger "\\\n" ->
function linebreak(stream::IO)
skip(stream, 2)
return LineBreak()
end

@trigger '-' ->
function en_dash(stream::IO)
if startswith(stream, "--")
return ""
end
end

const escape_chars = "\\`*_#+-.!{[("
const escape_chars = "\\`*_#+-.!{[(\$"

@trigger '\\' ->
function escapes(stream::IO)
Expand Down
4 changes: 3 additions & 1 deletion base/markdown/GitHub/GitHub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ end
# TODO: tables

@flavor github [list, indentcode, blockquote, fencedcode, hashheader, github_paragraph,
en_dash, inline_code, asterisk_bold, asterisk_italic, image, link]

linebreak, escapes, en_dash, inline_code, asterisk_bold, asterisk_italic,
image, link]
2 changes: 1 addition & 1 deletion base/markdown/Julia/Julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ include("interp.jl")
@flavor julia [blocktex, blockinterp, hashheader, list, indentcode, fencedcode,
blockquote, paragraph,

escapes, latex, interp, en_dash, inline_code, asterisk_bold,
linebreak, escapes, latex, interp, en_dash, inline_code, asterisk_bold,
asterisk_italic, image, link]
4 changes: 4 additions & 0 deletions base/markdown/render/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function htmlinline(io::IO, link::Link)
print(io,"""</a>""")
end

function htmlinline(io::IO, br::LineBreak)
print(io, "<br />")
end

htmlinline(io::IO, x) = tohtml(io, x)

# API
Expand Down
4 changes: 4 additions & 0 deletions base/markdown/render/plain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function plain(io::IO, list::List)
end
end

function plaininline(io::IO, br::LineBreak)
println(io)
end

plain(io::IO, x) = tohtml(io, x)

# Inline elements
Expand Down
4 changes: 4 additions & 0 deletions base/markdown/render/terminal/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ function term(io::IO, md::Code, columns)
end
end

function term(io::IO, br::LineBreak, columns)
println(io)
end

term(io::IO, x, _) = writemime(io, MIME"text/plain"(), x)

# Inline Content
Expand Down

0 comments on commit 1eca232

Please sign in to comment.