OLD | NEW |
(Empty) | |
| 1 ''' |
| 2 Smart_Strong Extension for Python-Markdown |
| 3 ========================================== |
| 4 |
| 5 This extention adds smarter handling of double underscores within words. |
| 6 |
| 7 See <https://pythonhosted.org/Markdown/extensions/smart_strong.html> |
| 8 for documentation. |
| 9 |
| 10 Original code Copyright 2011 [Waylan Limberg](http://achinghead.com) |
| 11 |
| 12 All changes Copyright 2011-2014 The Python Markdown Project |
| 13 |
| 14 License: [BSD](http://www.opensource.org/licenses/bsd-license.php) |
| 15 |
| 16 ''' |
| 17 |
| 18 from __future__ import absolute_import |
| 19 from __future__ import unicode_literals |
| 20 from . import Extension |
| 21 from ..inlinepatterns import SimpleTagPattern |
| 22 |
| 23 SMART_STRONG_RE = r'(?<!\w)(_{2})(?!_)(.+?)(?<!_)\2(?!\w)' |
| 24 STRONG_RE = r'(\*{2})(.+?)\2' |
| 25 |
| 26 |
| 27 class SmartEmphasisExtension(Extension): |
| 28 """ Add smart_emphasis extension to Markdown class.""" |
| 29 |
| 30 def extendMarkdown(self, md, md_globals): |
| 31 """ Modify inline patterns. """ |
| 32 md.inlinePatterns['strong'] = SimpleTagPattern(STRONG_RE, 'strong') |
| 33 md.inlinePatterns.add( |
| 34 'strong2', |
| 35 SimpleTagPattern(SMART_STRONG_RE, 'strong'), |
| 36 '>emphasis2' |
| 37 ) |
| 38 |
| 39 |
| 40 def makeExtension(*args, **kwargs): |
| 41 return SmartEmphasisExtension(*args, **kwargs) |
OLD | NEW |