Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: tools/md_browser/gitiles_autolink.py

Issue 2743553002: support gitiles auto-linking (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/md_browser/md_browser.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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)
OLDNEW
« no previous file with comments | « no previous file | tools/md_browser/md_browser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698