|
1 | 1 | function Base.parse(stream::IOBuffer; greedy::Bool = true, raise::Bool = true)
|
2 |
| - pos = position(stream) |
3 |
| - ex, Δ = Base.parse(readall(stream), 1, greedy = greedy, raise = raise) |
4 |
| - seek(stream, pos + Δ - 1) |
5 |
| - return ex |
| 2 | + pos = position(stream) |
| 3 | + ex, Δ = Base.parse(readall(stream), 1, greedy = greedy, raise = raise) |
| 4 | + seek(stream, pos + Δ - 1) |
| 5 | + return ex |
6 | 6 | end
|
7 | 7 |
|
8 | 8 | function interpinner(stream::IO, greedy = false)
|
9 |
| - startswith(stream, '$') || return |
10 |
| - (eof(stream) || peek(stream) in whitespace) && return |
11 |
| - try |
12 |
| - return Base.parse(stream::IOBuffer, greedy = greedy) |
13 |
| - catch e |
14 |
| - return |
15 |
| - end |
| 9 | + startswith(stream, '$') || return |
| 10 | + (eof(stream) || peek(stream) in whitespace) && return |
| 11 | + try |
| 12 | + return Base.parse(stream::IOBuffer, greedy = greedy) |
| 13 | + catch e |
| 14 | + return |
| 15 | + end |
16 | 16 | end
|
17 | 17 |
|
18 | 18 | @trigger '$' ->
|
19 | 19 | function interp(stream::IO)
|
20 |
| - withstream(stream) do |
21 |
| - ex = interpinner(stream) |
22 |
| - return ex |
23 |
| - end |
| 20 | + withstream(stream) do |
| 21 | + ex = interpinner(stream) |
| 22 | + return ex |
| 23 | + end |
24 | 24 | end
|
25 | 25 |
|
26 | 26 | function blockinterp(stream::IO, md::MD, config::Config)
|
27 |
| - withstream(stream) do |
28 |
| - ex = interpinner(stream) |
29 |
| - if ex ≡ nothing |
30 |
| - return false |
31 |
| - else |
32 |
| - push!(md, ex) |
33 |
| - return true |
| 27 | + withstream(stream) do |
| 28 | + ex = interpinner(stream) |
| 29 | + if ex ≡ nothing |
| 30 | + return false |
| 31 | + else |
| 32 | + push!(md, ex) |
| 33 | + return true |
| 34 | + end |
34 | 35 | end
|
35 |
| - end |
36 | 36 | end
|
37 | 37 |
|
38 | 38 | toexpr(x) = x
|
39 | 39 |
|
40 | 40 | toexpr(xs::Vector{Any}) = Expr(:cell1d, map(toexpr, xs)...)
|
41 | 41 |
|
42 | 42 | function deftoexpr(T)
|
43 |
| - @eval function toexpr(md::$T) |
44 |
| - Expr(:call, $T, $(map(x->:(toexpr(md.$x)), names(T))...)) |
45 |
| - end |
| 43 | + @eval function toexpr(md::$T) |
| 44 | + Expr(:call, typeof(md), $(map(x->:(toexpr(md.$x)), names(T))...)) |
| 45 | + end |
46 | 46 | end
|
47 | 47 |
|
48 | 48 | map(deftoexpr, [MD, Paragraph, Header,
|
|
0 commit comments