bugdown: Disable + as a bullet character for an unordered list

Fixes #272.

(imported from commit 8afaf14965ed1f6a4bb3ccfc9d4c2d807148666d)
This commit is contained in:
Keegan McAllister 2012-11-02 13:25:37 -04:00
parent 7a6fe207c5
commit b87a35c1ff
1 changed files with 12 additions and 1 deletions

View File

@ -22,14 +22,25 @@ class AutoLink(markdown.inlinepatterns.Pattern):
a.text = url
return a
class UListProcessor(markdown.blockprocessors.OListProcessor):
""" Process unordered list blocks.
Based on markdown.blockprocessors.UListProcessor, but does not accept
'+' as a bullet character."""
TAG = 'ul'
RE = re.compile(r'^[ ]{0,3}[*-][ ]+(.*)')
class Bugdown(markdown.Extension):
def extendMarkdown(self, md, md_globals):
for k in ('image_link', 'image_reference', 'automail', 'autolink'):
del md.inlinePatterns[k]
for k in ('hashheader', 'setextheader', 'olist'):
for k in ('hashheader', 'setextheader', 'olist', 'ulist'):
del md.parser.blockprocessors[k]
md.parser.blockprocessors.add('ulist', UListProcessor(md.parser), '>hr')
md.inlinePatterns.add('gravatar', Gravatar(r'!gravatar\((?P<email>[^)]*)\)'), '_begin')
# A link starts after whitespace and continues to the next whitespace.