forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IPython.jl
35 lines (28 loc) · 900 Bytes
/
IPython.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This file is a part of Julia. License is MIT: https://julialang.org/license
mutable struct LaTeX
formula::String
end
@trigger '$' ->
function tex(stream::IO, md::MD)
result = parse_inline_wrapper(stream, "\$", rep = true)
return result === nothing ? nothing : LaTeX(result)
end
function blocktex(stream::IO, md::MD)
withstream(stream) do
ex = tex(stream, md)
if ex ≡ nothing
return false
else
push!(md, ex)
return true
end
end
end
show(io::IO, tex::LaTeX) =
print(io, '$', tex.formula, '$')
latex(io::IO, tex::LaTeX) =
println(io, "\$\$", tex.formula, "\$\$")
latexinline(io::IO, tex::LaTeX) =
print(io, '$', tex.formula, '$')
term(io::IO, tex::LaTeX, cols) = printstyled(io, tex.formula, '\n', color=:magenta)
terminline(io::IO, tex::LaTeX) = printstyled(io, tex.formula, color=:magenta)