| OLD | NEW |
| (Empty) |
| 1 """ | |
| 2 Sane List Extension for Python-Markdown | |
| 3 ======================================= | |
| 4 | |
| 5 Modify the behavior of Lists in Python-Markdown to act in a sane manor. | |
| 6 | |
| 7 See <https://pythonhosted.org/Markdown/extensions/sane_lists.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 ..blockprocessors import OListProcessor, UListProcessor | |
| 22 import re | |
| 23 | |
| 24 | |
| 25 class SaneOListProcessor(OListProcessor): | |
| 26 | |
| 27 CHILD_RE = re.compile(r'^[ ]{0,3}((\d+\.))[ ]+(.*)') | |
| 28 SIBLING_TAGS = ['ol'] | |
| 29 | |
| 30 | |
| 31 class SaneUListProcessor(UListProcessor): | |
| 32 | |
| 33 CHILD_RE = re.compile(r'^[ ]{0,3}(([*+-]))[ ]+(.*)') | |
| 34 SIBLING_TAGS = ['ul'] | |
| 35 | |
| 36 | |
| 37 class SaneListExtension(Extension): | |
| 38 """ Add sane lists to Markdown. """ | |
| 39 | |
| 40 def extendMarkdown(self, md, md_globals): | |
| 41 """ Override existing Processors. """ | |
| 42 md.parser.blockprocessors['olist'] = SaneOListProcessor(md.parser) | |
| 43 md.parser.blockprocessors['ulist'] = SaneUListProcessor(md.parser) | |
| 44 | |
| 45 | |
| 46 def makeExtension(*args, **kwargs): | |
| 47 return SaneListExtension(*args, **kwargs) | |
| OLD | NEW |