OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Implements Gitiles' simpler auto linking. |
| 6 |
| 7 This extention auto links basic URLs that aren't bracketed by <...>. |
| 8 |
| 9 https://gerrit.googlesource.com/gitiles/+/master/gitiles-servlet/src/main/java/c
om/google/gitiles/Linkifier.java |
| 10 """ |
| 11 |
| 12 from markdown.inlinepatterns import (AutolinkPattern, Pattern) |
| 13 from markdown.extensions import Extension |
| 14 |
| 15 |
| 16 AUTOLINK_RE = r'([Hh][Tt][Tt][Pp][Ss]?://[^>]*)' |
| 17 |
| 18 |
| 19 class _GitilesSmartQuotesExtension(Extension): |
| 20 """Add Gitiles' simpler linkifier to Markdown.""" |
| 21 def extendMarkdown(self, md, md_globals): |
| 22 md.inlinePatterns.add('gitilesautolink', |
| 23 AutolinkPattern(AUTOLINK_RE, md), |
| 24 '<autolink') |
| 25 |
| 26 |
| 27 def makeExtension(*args, **kwargs): |
| 28 return _GitilesSmartQuotesExtension(*args, **kwargs) |
OLD | NEW |