Add: julia-0.6.2
Former-commit-id: ccc667cf67d569f3fb3df39aa57c2134755a7551
This commit is contained in:
15
julia-0.6.2/share/julia/base/markdown/Julia/Julia.jl
Normal file
15
julia-0.6.2/share/julia/base/markdown/Julia/Julia.jl
Normal file
@@ -0,0 +1,15 @@
|
||||
# This file is a part of Julia. License is MIT: https://julialang.org/license
|
||||
|
||||
# This file contains markdown extensions designed to make documenting
|
||||
# Julia easy peasy.
|
||||
#
|
||||
# We start by borrowing GitHub's `fencedcode` extension – more to follow.
|
||||
|
||||
include("interp.jl")
|
||||
|
||||
@flavor julia [blocktex, blockinterp, hashheader, list, indentcode, fencedcode,
|
||||
blockquote, admonition, footnote, github_table, horizontalrule, setextheader, paragraph,
|
||||
|
||||
linebreak, escapes, tex, interp, en_dash, inline_code,
|
||||
asterisk_bold, asterisk_italic, image, footnote_link, link, autolink]
|
||||
|
||||
48
julia-0.6.2/share/julia/base/markdown/Julia/interp.jl
Normal file
48
julia-0.6.2/share/julia/base/markdown/Julia/interp.jl
Normal file
@@ -0,0 +1,48 @@
|
||||
# This file is a part of Julia. License is MIT: https://julialang.org/license
|
||||
|
||||
function Base.parse(stream::IO; greedy::Bool = true, raise::Bool = true)
|
||||
pos = position(stream)
|
||||
ex, Δ = Base.parse(readstring(stream), 1, greedy = greedy, raise = raise)
|
||||
seek(stream, pos + Δ - 1)
|
||||
return ex
|
||||
end
|
||||
|
||||
function interpinner(stream::IO, greedy = false)
|
||||
startswith(stream, '$') || return
|
||||
(eof(stream) || Char(peek(stream)) in whitespace) && return
|
||||
try
|
||||
return Base.parse(stream::IOBuffer, greedy = greedy)
|
||||
catch e
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@trigger '$' ->
|
||||
function interp(stream::IO, md::MD)
|
||||
withstream(stream) do
|
||||
ex = interpinner(stream)
|
||||
return ex
|
||||
end
|
||||
end
|
||||
|
||||
function blockinterp(stream::IO, md::MD)
|
||||
withstream(stream) do
|
||||
ex = interpinner(stream)
|
||||
if ex ≡ nothing
|
||||
return false
|
||||
else
|
||||
push!(md, ex)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
toexpr(x) = x
|
||||
|
||||
toexpr(xs::Vector{Any}) = Expr(:call, GlobalRef(Base,:vector_any), map(toexpr, xs)...)
|
||||
|
||||
for T in Any[MD, Paragraph, Header, Link, Bold, Italic]
|
||||
@eval function toexpr(md::$T)
|
||||
Expr(:call, typeof(md), $(map(x->:(toexpr(md.$x)), fieldnames(Base.unwrap_unionall(T)))...))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user