@@ -2,7 +2,7 @@ module JuliaSyntaxHighlighting
22
33import Base: JuliaSyntax, AnnotatedString, annotate!
44import Base. JuliaSyntax: @K_str , Kind, GreenNode, parseall, kind, flags
5- using StyledStrings: Face, addface!
5+ using StyledStrings: Face, addface!, getface
66
77public highlight, highlight!
88
@@ -238,7 +238,7 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
238238 elseif nkind == K " `" || nkind == K " ```" ; :julia_cmdstring
239239 elseif nkind == K " Char"
240240 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 ) ))
242242 :julia_char
243243 elseif nkind == K " '" && kind (lnode) == K " Char" ; :julia_char_delim
244244 elseif nkind == K " true" || nkind == K " false" ; :julia_bool
@@ -247,8 +247,8 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
247247 if nkind == K " ="
248248 ifelse (ppkind == K " for" , :julia_keyword , :julia_assignment )
249249 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 ) ))
252252 nothing
253253 end
254254 elseif nkind == K " ;" && pkind == K " parameters" && pnode == lnode
@@ -321,19 +321,19 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
321321 end
322322 end
323323 ! isnothing (face) &&
324- push! (highlights, (region, :face , face))
324+ push! (highlights, (region, :face , getface ( face) ))
325325 if nkind == K " Comment"
326326 for match in eachmatch (
327327 r" (?:^|[(\[ {[:space:]-])`([^[:space:]](?:.*?[^[:space:]])?)`(?:$|[!,\- .:;?\[\] [:space:]])" ,
328328 regionstr)
329329 code = first (match. captures)
330330 push! (highlights, (firstindex (content)+ offset+ code. offset: firstindex (content)+ offset+ code. offset+ code. ncodeunits- 1 ,
331- :face , :code ))
331+ :face , getface ( :code ) ))
332332 end
333333 elseif nkind == K " String"
334334 for match in eachmatch (r" \\ ." , regionstr)
335335 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 ) ))
337337 end
338338 end
339339 isempty (node. args) && return
0 commit comments