@@ -2,7 +2,7 @@ module JuliaSyntaxHighlighting
2
2
3
3
import Base: JuliaSyntax, AnnotatedString, annotate!
4
4
import Base. JuliaSyntax: @K_str , Kind, GreenNode, parseall, kind, flags
5
- using StyledStrings: Face, addface!
5
+ using StyledStrings: Face, addface!, getface
6
6
7
7
public highlight, highlight!
8
8
@@ -238,7 +238,7 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
238
238
elseif nkind == K " `" || nkind == K " ```" ; :julia_cmdstring
239
239
elseif nkind == K " Char"
240
240
kind (lnode) == K " '" && ! isempty (highlights) &&
241
- (highlights[end ] = (highlights[end ][1 ], :face , :julia_char_delim ))
241
+ (highlights[end ] = (highlights[end ][1 ], :face , getface ( :julia_char_delim ) ))
242
242
:julia_char
243
243
elseif nkind == K " '" && kind (lnode) == K " Char" ; :julia_char_delim
244
244
elseif nkind == K " true" || nkind == K " false" ; :julia_bool
@@ -247,8 +247,8 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
247
247
if nkind == K " ="
248
248
ifelse (ppkind == K " for" , :julia_keyword , :julia_assignment )
249
249
else # updating for <op>=
250
- push! (highlights, (firstindex (content)+ offset: node. span+ offset- 1 , :face , :julia_operator ))
251
- push! (highlights, (node. span+ offset: node. span+ offset, :face , :julia_assignment ))
250
+ push! (highlights, (firstindex (content)+ offset: node. span+ offset- 1 , :face , getface ( :julia_operator ) ))
251
+ push! (highlights, (node. span+ offset: node. span+ offset, :face , getface ( :julia_assignment ) ))
252
252
nothing
253
253
end
254
254
elseif nkind == K " ;" && pkind == K " parameters" && pnode == lnode
@@ -321,19 +321,19 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
321
321
end
322
322
end
323
323
! isnothing (face) &&
324
- push! (highlights, (region, :face , face))
324
+ push! (highlights, (region, :face , getface ( face) ))
325
325
if nkind == K " Comment"
326
326
for match in eachmatch (
327
327
r" (?:^|[(\[ {[:space:]-])`([^[:space:]](?:.*?[^[:space:]])?)`(?:$|[!,\- .:;?\[\] [:space:]])" ,
328
328
regionstr)
329
329
code = first (match. captures)
330
330
push! (highlights, (firstindex (content)+ offset+ code. offset: firstindex (content)+ offset+ code. offset+ code. ncodeunits- 1 ,
331
- :face , :code ))
331
+ :face , getface ( :code ) ))
332
332
end
333
333
elseif nkind == K " String"
334
334
for match in eachmatch (r" \\ ." , regionstr)
335
335
push! (highlights, (firstindex (content)+ offset+ match. offset- 1 : firstindex (content)+ offset+ match. offset+ ncodeunits (match. match)- 2 ,
336
- :face , :julia_backslash_literal ))
336
+ :face , getface ( :julia_backslash_literal ) ))
337
337
end
338
338
end
339
339
isempty (node. args) && return
0 commit comments