OLD | NEW |
(Empty) | |
| 1 """ |
| 2 NL2BR Extension |
| 3 =============== |
| 4 |
| 5 A Python-Markdown extension to treat newlines as hard breaks; like |
| 6 GitHub-flavored Markdown does. |
| 7 |
| 8 See <https://pythonhosted.org/Markdown/extensions/nl2br.html> |
| 9 for documentation. |
| 10 |
| 11 Oringinal code Copyright 2011 [Brian Neal](http://deathofagremmie.com/) |
| 12 |
| 13 All changes Copyright 2011-2014 The Python Markdown Project |
| 14 |
| 15 License: [BSD](http://www.opensource.org/licenses/bsd-license.php) |
| 16 |
| 17 """ |
| 18 |
| 19 from __future__ import absolute_import |
| 20 from __future__ import unicode_literals |
| 21 from . import Extension |
| 22 from ..inlinepatterns import SubstituteTagPattern |
| 23 |
| 24 BR_RE = r'\n' |
| 25 |
| 26 |
| 27 class Nl2BrExtension(Extension): |
| 28 |
| 29 def extendMarkdown(self, md, md_globals): |
| 30 br_tag = SubstituteTagPattern(BR_RE, 'br') |
| 31 md.inlinePatterns.add('nl', br_tag, '_end') |
| 32 |
| 33 |
| 34 def makeExtension(*args, **kwargs): |
| 35 return Nl2BrExtension(*args, **kwargs) |
OLD | NEW |