From 26b5d2f54fd02e38e142ebc5d3bc381b9082901b Mon Sep 17 00:00:00 2001 From: TEC Date: Sun, 11 Feb 2024 00:00:50 +0800 Subject: [PATCH] Fix invalid non-empty state assumptions in macro In the expansion, it's assumed that there is at least one charater after an escaped character, but this is not always the case. --- src/stylemacro.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stylemacro.jl b/src/stylemacro.jl index f6b551fa..dbd1c7c0 100644 --- a/src/stylemacro.jl +++ b/src/stylemacro.jl @@ -215,13 +215,13 @@ macro styled_str(raw_content::String) if char in ('{', '}', '$', '\\') deleteat!(state.bytes, i + state.offset[] - 1) state.offset[] -= ncodeunits('\\') - elseif char ∈ ('\n', '\r') + elseif char ∈ ('\n', '\r') && !isempty(state.s) skipped = 0 if char == '\r' && last(peek(state.s)) == '\n' popfirst!(state.s) skipped += 1 end - while last(peek(state.s)) ∈ (' ', '\t') + while !isempty(state.s) && last(peek(state.s)) ∈ (' ', '\t') popfirst!(state.s) skipped += 1 end