Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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