Skip to content

Commit

Permalink
bugdown: refactor AutoLink to use VerbosePattern.
Browse files Browse the repository at this point in the history
This makes it possible to reuse the verbose pattern logic for other
regexs as well.
  • Loading branch information
paxapy authored and timabbott committed Nov 2, 2016
1 parent a0dadfd commit d965ff1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zerver/lib/bugdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def url_to_a(url, text = None):
fixup_link(a, 'mailto:' not in href[:7])
return a

class AutoLink(markdown.inlinepatterns.Pattern):
class VerbosePattern(markdown.inlinepatterns.Pattern):
def __init__(self, pattern):
# type: (text_type) -> None
markdown.inlinepatterns.Pattern.__init__(self, ' ')
Expand All @@ -773,6 +773,7 @@ def __init__(self, pattern):
self.compiled_re = re.compile(u"^(.*?)%s(.*?)$" % pattern,
re.DOTALL | re.UNICODE | re.VERBOSE)

class AutoLink(VerbosePattern):
def handleMatch(self, match):
# type: (Match[text_type]) -> ElementStringNone
url = match.group('url')
Expand Down

0 comments on commit d965ff1

Please sign in to comment.