Skip to content

Commit fb12f9b

Browse files
committed
Also skip over carriage returns with newlines
As I develop on a LF system, not a CRLF system (Windows), it's easy for me to forget about carriage returns. However, in places where I skip over whitespace including newlines, it seems prudent to treat carriage returns and newlines alike.
1 parent 220d833 commit fb12f9b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/styledmarkup.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ end
201201
readexpr!(state) = readexpr!(state, first(popfirst!(state.s)) + 1)
202202

203203
function skipwhitespace!(state::State)
204-
while isnextchar(state, (' ', '\t', '\n'))
204+
while isnextchar(state, (' ', '\t', '\n', '\r'))
205205
popfirst!(state.s)
206206
end
207207
end
@@ -254,7 +254,7 @@ function read_annotation!(state::State, i::Int, char::Char, newstyles)
254254
true
255255
elseif nextchar == ':'
256256
true
257-
elseif nextchar (' ', '\t', '\n')
257+
elseif nextchar (' ', '\t', '\n', '\r')
258258
skipwhitespace!(state)
259259
true
260260
else
@@ -272,7 +272,7 @@ function read_inlineface!(state::State, i::Int, char::Char, newstyles)
272272
end
273273
function readsymbol!(state, lastchar)
274274
Iterators.takewhile(
275-
c -> (lastchar = last(c)) (' ', '\t', '\n', ',', ')'), state.s) |>
275+
c -> (lastchar = last(c)) (' ', '\t', '\n', '\r', ',', ')'), state.s) |>
276276
collect .|> last |> String, lastchar
277277
end
278278
function parsecolor(color::String)
@@ -286,7 +286,7 @@ function read_inlineface!(state::State, i::Int, char::Char, newstyles)
286286
end
287287
end
288288
function nextnonwhitespace!(state, lastchar)
289-
if lastchar (' ', '\t', '\n')
289+
if lastchar (' ', '\t', '\n', '\r')
290290
skipwhitespace!(state)
291291
_, lastchar = popfirst!(state.s)
292292
end
@@ -571,9 +571,7 @@ function read_face_or_keyval!(state::State, i::Int, char::Char, newstyles)
571571
if isempty(state.s)
572572
elseif last(peek(state.s)) == '='
573573
popfirst!(state.s)
574-
if isnextchar(state, (' ', '\t', '\n'))
575-
skipwhitespace!(state)
576-
end
574+
skipwhitespace!(state)
577575
nextchar = if !isempty(state.s) last(peek(state.s)) else '\0' end
578576
value = if isempty(state.s) ""
579577
elseif nextchar == '{'
@@ -610,7 +608,7 @@ function read_face_or_keyval!(state::State, i::Int, char::Char, newstyles)
610608
Pair{Symbol, Any}(:face, Symbol(key))
611609
end))
612610
end
613-
if isempty(state.s) || last(peek(state.s)) (' ', '\t', '\n', ',', ':')
611+
if isempty(state.s) || last(peek(state.s)) (' ', '\t', '\n', '\r', ',', ':')
614612
styerr!(state, "Incomplete annotation declaration", prevind(state.content, i), "starts here")
615613
end
616614
end

0 commit comments

Comments
 (0)