-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move markdown types into their own file.
- Loading branch information
Showing
25 changed files
with
698 additions
and
730 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
# This file is a part of Julia. License is MIT: http://julialang.org/license | ||
|
||
include("block.jl") | ||
include("inline.jl") | ||
include("blockquote.jl") | ||
include("bold.jl") | ||
include("code.jl") | ||
include("escapes.jl") | ||
include("header.jl") | ||
include("horizontalrule.jl") | ||
include("image.jl") | ||
include("italic.jl") | ||
include("linebreak.jl") | ||
include("link.jl") | ||
include("list.jl") | ||
include("paragraph.jl") | ||
include("vector.jl") | ||
|
||
@flavor common [list, indentcode, blockquote, hashheader, horizontalrule, | ||
paragraph, | ||
fencedcode, paragraph, | ||
|
||
linebreak, escapes, inline_code, | ||
asterisk_bold, asterisk_italic, image, link] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
type BlockQuote | ||
content | ||
end | ||
|
||
BlockQuote() = BlockQuote([]) | ||
|
||
# TODO: Laziness | ||
@breaking true -> | ||
function blockquote(stream::IO, block::MD) | ||
withstream(stream) do | ||
buffer = IOBuffer() | ||
empty = true | ||
while eatindent(stream) && startswith(stream, '>') | ||
startswith(stream, " ") | ||
write(buffer, readline(stream)) | ||
empty = false | ||
end | ||
empty && return false | ||
|
||
md = takebuf_string(buffer) | ||
push!(block, BlockQuote(parse(md, flavor = config(block)).content)) | ||
return true | ||
end | ||
end | ||
|
||
function html(io::IO, md::BlockQuote) | ||
withtag(io, :blockquote) do | ||
println(io) | ||
html(io, md.content) | ||
end | ||
end | ||
|
||
function latex(io::IO, md::BlockQuote) | ||
wrapblock(io, "quote") do | ||
latex(io, md.content) | ||
end | ||
end | ||
|
||
function term(io::IO, md::BlockQuote, columns) | ||
s = sprint(io->term(io, md.content, columns - 10)) | ||
for line in split(rstrip(s), "\n") | ||
println(io, " "^margin, "|", line) | ||
end | ||
println(io) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
type Bold | ||
text | ||
end | ||
|
||
@trigger '*' -> | ||
function asterisk_bold(stream::IO, md::MD) | ||
result = parse_inline_wrapper(stream, "**") | ||
return result == nothing ? nothing : Bold(parseinline(result, md)) | ||
end | ||
|
||
function htmlinline(io::IO, md::Bold) | ||
withtag(io, :strong) do | ||
htmlinline(io, md.text) | ||
end | ||
end | ||
|
||
function latexinline(io::IO, md::Bold) | ||
wrapinline(io, "textbf") do | ||
latexinline(io, md.text) | ||
end | ||
end | ||
|
||
plaininline(io::IO, md::Bold) = plaininline(io, "**", md.text, "**") | ||
|
||
function terminline(io::IO, md::Bold) | ||
with_output_format(:bold, terminline, io, md.text) | ||
end |
Oops, something went wrong.