Skip to content

Commit

Permalink
Make repr tag highlighting greedy
Browse files Browse the repository at this point in the history
Addressing Textualize#2468; before this change the tag-matching code was non-greedy,
resulting in an unbalanced match if there were tags within tags. This
change makes this greedy to ensure that there's a better chance of the match
being balanced.
  • Loading branch information
davep committed Oct 10, 2022
1 parent 84e6286 commit ce55112
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rich/highlighter.py
Expand Up @@ -82,7 +82,7 @@ class ReprHighlighter(RegexHighlighter):

base_style = "repr."
highlights = [
r"(?P<tag_start><)(?P<tag_name>[-\w.:|]*)(?P<tag_contents>[\w\W]*?)(?P<tag_end>>)",
r"(?P<tag_start><)(?P<tag_name>[-\w.:|]*)(?P<tag_contents>[\w\W]*)(?P<tag_end>>)",
r'(?P<attrib_name>[\w_]{1,50})=(?P<attrib_value>"?[\w_]+"?)?',
r"(?P<brace>[][{}()])",
_combine_regex(
Expand Down

0 comments on commit ce55112

Please sign in to comment.