diff --git a/rich/highlighter.py b/rich/highlighter.py index 32bf79e0..57600e48 100644 --- a/rich/highlighter.py +++ b/rich/highlighter.py @@ -85,8 +85,8 @@ class ReprHighlighter(RegexHighlighter): _combine_regex( r"(?P[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", r"(?P([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})", - r"(?P([0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})", - r"(?P([0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|([0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})", + r"(?P(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})", + r"(?P(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})", r"(?P[\{\[\(\)\]\}])", r"(?P\w+?)=(?P\"?[\w_]+\"?)?", r"(?PTrue)|(?PFalse)|(?PNone)", diff --git a/rich/rule.py b/rich/rule.py index 2844ec17..ad393d20 100644 --- a/rich/rule.py +++ b/rich/rule.py @@ -42,9 +42,13 @@ class Rule(JupyterMixin): ) -> RenderResult: width = options.max_width + # Python3.6 doesn't have an isascii method on str + isascii = getattr(str, "isascii", None) or ( + lambda s: all(ord(c) < 128 for c in s) + ) characters = ( "-" - if (options.ascii_only and not self.characters.isascii()) + if (options.ascii_only and not isascii(self.characters)) else self.characters )