@@ -463,10 +463,10 @@ var text_effect_color := Color('#898276')
463463func _get_syntax_highlighting (Highlighter :SyntaxHighlighter , dict :Dictionary , line :String ) -> Dictionary :
464464 load_text_effects ()
465465 if text_random_word_regex .get_pattern ().is_empty ():
466- text_random_word_regex .compile ("(?<!\\\\ ) \\ <[^\\ [ \\ >]+(\\ /[^\\ >]*)\ \ >" )
466+ text_random_word_regex .compile (r "(?<!\\ ) \ < [^\> ]+(\/ [^\> ]*)\> " )
467467
468468 var result := regex .search (line )
469- if ! result :
469+ if not result :
470470 return dict
471471 if Highlighter .mode == Highlighter .Modes .FULL_HIGHLIGHTING :
472472 if result .get_string ('name' ):
@@ -476,24 +476,29 @@ func _get_syntax_highlighting(Highlighter:SyntaxHighlighter, dict:Dictionary, li
476476 dict [result .get_start ('portrait' )] = {"color" :Highlighter .character_portrait_color }
477477 dict [result .get_end ('portrait' )] = {"color" :Highlighter .normal_color }
478478 if result .get_string ('text' ):
479- var effects_result := text_effects_regex .search_all (line )
480- for eff in effects_result :
481- dict [eff .get_start ()] = {"color" :text_effect_color }
482- dict [eff .get_end ()] = {"color" :Highlighter .normal_color }
483- dict = Highlighter .color_region (dict , Highlighter .variable_color , line , '{' , '}' , result .get_start ('text' ))
484479
480+ ## Color the random selection modifier
485481 for replace_mod_match in text_random_word_regex .search_all (result .get_string ('text' )):
486482 var color : Color = Highlighter .string_color
487483 color = color .lerp (Highlighter .normal_color , 0.4 )
488484 dict [replace_mod_match .get_start ()+ result .get_start ('text' )] = {'color' :Highlighter .string_color }
489485 var offset := 1
490- for b in replace_mod_match . get_string (). trim_suffix ( '>' ).trim_prefix ('<' ). split ( '/' ):
486+ for b : RegExMatch in RegEx . create_from_string ( r "( \[ [^ \] ]* \] |[^ \/ ]| \/\/ )+" ). search_all ( replace_mod_match . get_string ( ).trim_prefix ("<" ). trim_suffix ( ">" ) ):
491487 color .h = wrap (color .h + 0.2 , 0 , 1 )
492488 dict [replace_mod_match .get_start ()+ result .get_start ('text' )+ offset ] = {'color' :color }
493- offset += len (b )
489+ offset += len (b . get_string () )
494490 dict [replace_mod_match .get_start ()+ result .get_start ('text' )+ offset ] = {'color' :Highlighter .string_color }
495491 offset += 1
496492 dict [replace_mod_match .get_end ()+ result .get_start ('text' )] = {'color' :Highlighter .normal_color }
493+
494+ ## Color bbcode and text effects
495+ var effects_result := text_effects_regex .search_all (line )
496+ for eff in effects_result :
497+ var prev_color : Color = Highlighter .dict_get_color_at_column (dict , eff .get_start ())
498+ dict [eff .get_start ()] = {"color" :text_effect_color .lerp (prev_color , 0.4 )}
499+ dict [eff .get_end ()] = {"color" :prev_color }
500+ dict = Highlighter .color_region (dict , Highlighter .variable_color , line , '{' , '}' , result .get_start ('text' ))
501+
497502 return dict
498503
499504#endregion
0 commit comments