Skip to content

Commit

Permalink
Add a special jldoctest language tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Sep 9, 2015
1 parent 7cd05db commit 265e0fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion base/markdown/render/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ end

function html(io::IO, code::Code)
withtag(io, :pre) do
maybe_lang = code.language != "" ? Any[:class=>"language-$(code.language)"] : []
maybe_lang = code.language != "" ? Any[:class=>"language-$(code.language == "jldoctest" ? "jl" : code.language)"] : []
withtag(io, :code, maybe_lang...) do
htmlesc(io, code.code)
# TODO should print newline if this is longer than one line ?
Expand Down
2 changes: 1 addition & 1 deletion base/markdown/render/plain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function plain{l}(io::IO, header::Header{l})
end

function plain(io::IO, code::Code)
println(io, "```", code.language)
println(io, "```", code.language == "jldoctest" ? "jl" : code.language)
println(io, code.code)
println(io, "```")
end
Expand Down
6 changes: 5 additions & 1 deletion base/markdown/render/rst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ function rst{l}(io::IO, header::Header{l})
end

function rst(io::IO, code::Code)
code.language == "rst" || println(io, ".. code-block:: julia\n")
if code.language == "jldoctest"
println(io, ".. doctest::\n")
elseif code.language != "rst"
println(io, ".. code-block:: julia\n")
end
for l in lines(code.code)
println(io, " ", l)
end
Expand Down

0 comments on commit 265e0fa

Please sign in to comment.