Skip to content

Commit

Permalink
Merge branch 'jn/Statefulempty' [#21]
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed Oct 28, 2023
2 parents 41c8218 + 508ab57 commit 9b35f08
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/stylemacro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ macro styled_str(raw_content::String)

# Instead we'll just use a `NamedTuple`
state = let content = unescape_string(raw_content, ('{', '}', ':', '$', '\n', '\r'))
(; content, bytes = Vector{UInt8}(content),
s = Iterators.Stateful(zip(eachindex(content), content)),
(; content, bytes = Vector{UInt8}(content),
s = Iterators.Stateful(pairs(content)),
parts = Any[],
active_styles = Vector{Tuple{Int, Int, Union{Symbol, Expr, Pair{Symbol, Any}}}}[],
pending_styles = Tuple{UnitRange{Int}, Union{Symbol, Expr, Pair{Symbol, Any}}}[],
Expand Down Expand Up @@ -246,7 +246,8 @@ macro styled_str(raw_content::String)
end
expr, nextpos = Meta.parseatom(state.content, pos)
nchars = length(state.content[pos:prevind(state.content, nextpos)])
for _ in 1:min(length(state.s), nchars)
for _ in 1:nchars
isempty(state.s) && break
popfirst!(state.s)
end
expr, nextpos
Expand Down

0 comments on commit 9b35f08

Please sign in to comment.