aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/blockprocessors.py
diff options
context:
space:
mode:
authorKar Epker <karepker+services@gmail.com>2015-06-01 01:03:51 -0400
committerKar Epker <karepker+services@gmail.com>2015-06-01 01:03:51 -0400
commit6cbc66b4e63de0ddba7413b653591274fc6587cf (patch)
tree2340c8226ce8c9eefd2cf301cab271928d94b811 /markdown/blockprocessors.py
parente594213ab689847ee7d9654817b8fa80fafb0fb7 (diff)
downloadmarkdown-6cbc66b4e63de0ddba7413b653591274fc6587cf.tar.gz
markdown-6cbc66b4e63de0ddba7413b653591274fc6587cf.tar.bz2
markdown-6cbc66b4e63de0ddba7413b653591274fc6587cf.zip
Fixed parser ignoring value of tab_length.
Diffstat (limited to 'markdown/blockprocessors.py')
-rw-r--r--markdown/blockprocessors.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py
index 29db022..4b296d5 100644
--- a/markdown/blockprocessors.py
+++ b/markdown/blockprocessors.py
@@ -300,12 +300,6 @@ class OListProcessor(BlockProcessor):
""" Process ordered list blocks. """
TAG = 'ol'
- # Detect an item (``1. item``). ``group(1)`` contains contents of item.
- RE = re.compile(r'^[ ]{0,3}\d+\.[ ]+(.*)')
- # Detect items on secondary lines. they can be of either list type.
- CHILD_RE = re.compile(r'^[ ]{0,3}((\d+\.)|[*+-])[ ]+(.*)')
- # Detect indented (nested) items of either type
- INDENT_RE = re.compile(r'^[ ]{4,7}((\d+\.)|[*+-])[ ]+.*')
# The integer (python string) with which the lists starts (default=1)
# Eg: If list is intialized as)
# 3. Item
@@ -314,6 +308,20 @@ class OListProcessor(BlockProcessor):
# List of allowed sibling tags.
SIBLING_TAGS = ['ol', 'ul']
+ def __init__(self, parser):
+ BlockProcessor.__init__(self, parser)
+ # Detect an item (``1. item``). ``group(1)`` contains contents of item.
+ self.RE = re.compile(''.join([
+ r'^[ ]{0,', str(self.tab_length - 1), r'}\d+\.[ ]+(.*)']))
+ # Detect items on secondary lines. they can be of either list type.
+ self.CHILD_RE = re.compile(''.join([
+ r'^[ ]{0,', str(self.tab_length - 1), '}((\d+\.)|[*+-])[ ]+(.*)']))
+ # Detect indented (nested) items of either type
+ self.INDENT_RE = re.compile(''.join([
+ r'^[ ]{', str(self.tab_length), ',', str(self.tab_length * 2 - 1),
+ r'}((\d+\.)|[*+-])[ ]+.*']))
+
+
def test(self, parent, block):
return bool(self.RE.match(block))
@@ -407,7 +415,12 @@ class UListProcessor(OListProcessor):
""" Process unordered list blocks. """
TAG = 'ul'
- RE = re.compile(r'^[ ]{0,3}[*+-][ ]+(.*)')
+
+ def __init__(self, parser):
+ OListProcessor.__init__(self, parser)
+ # Detect an item (``1. item``). ``group(1)`` contains contents of item.
+ self.RE = re.compile(''.join([
+ r'^[ ]{0,', str(self.tab_length - 1), r'}[*+-][ ]+(.*)']))
class HashHeaderProcessor(BlockProcessor):