@@ -38,7 +38,7 @@ def build_block_parser(md_instance, **kwargs):
38
38
return parser
39
39
40
40
41
- class BlockProcessor :
41
+ class BlockProcessor ( object ) :
42
42
""" Base class for block processors.
43
43
44
44
Each subclass will provide the methods below to work with the source and
@@ -141,7 +141,7 @@ class ListIndentProcessor(BlockProcessor):
141
141
LIST_TYPES = ['ul' , 'ol' ]
142
142
143
143
def __init__ (self , * args ):
144
- BlockProcessor . __init__ ( self , * args )
144
+ super ( ListIndentProcessor , self ). __init__ ( * args )
145
145
self .INDENT_RE = re .compile (r'^(([ ]{%s})+)' % self .tab_length )
146
146
147
147
def test (self , parent , block ):
@@ -300,12 +300,6 @@ class OListProcessor(BlockProcessor):
300
300
""" Process ordered list blocks. """
301
301
302
302
TAG = 'ol'
303
- # Detect an item (``1. item``). ``group(1)`` contains contents of item.
304
- RE = re .compile (r'^[ ]{0,3}\d+\.[ ]+(.*)' )
305
- # Detect items on secondary lines. they can be of either list type.
306
- CHILD_RE = re .compile (r'^[ ]{0,3}((\d+\.)|[*+-])[ ]+(.*)' )
307
- # Detect indented (nested) items of either type
308
- INDENT_RE = re .compile (r'^[ ]{4,7}((\d+\.)|[*+-])[ ]+.*' )
309
303
# The integer (python string) with which the lists starts (default=1)
310
304
# Eg: If list is intialized as)
311
305
# 3. Item
@@ -314,6 +308,17 @@ class OListProcessor(BlockProcessor):
314
308
# List of allowed sibling tags.
315
309
SIBLING_TAGS = ['ol' , 'ul' ]
316
310
311
+ def __init__ (self , parser ):
312
+ super (OListProcessor , self ).__init__ (parser )
313
+ # Detect an item (``1. item``). ``group(1)`` contains contents of item.
314
+ self .RE = re .compile (r'^[ ]{0,%d}\d+\.[ ]+(.*)' % (self .tab_length - 1 ))
315
+ # Detect items on secondary lines. they can be of either list type.
316
+ self .CHILD_RE = re .compile (r'^[ ]{0,%d}((\d+\.)|[*+-])[ ]+(.*)' %
317
+ (self .tab_length - 1 ))
318
+ # Detect indented (nested) items of either type
319
+ self .INDENT_RE = re .compile (r'^[ ]{%d,%d}((\d+\.)|[*+-])[ ]+.*' %
320
+ (self .tab_length , self .tab_length * 2 - 1 ))
321
+
317
322
def test (self , parent , block ):
318
323
return bool (self .RE .match (block ))
319
324
@@ -407,7 +412,11 @@ class UListProcessor(OListProcessor):
407
412
""" Process unordered list blocks. """
408
413
409
414
TAG = 'ul'
410
- RE = re .compile (r'^[ ]{0,3}[*+-][ ]+(.*)' )
415
+
416
+ def __init__ (self , parser ):
417
+ super (UListProcessor , self ).__init__ (parser )
418
+ # Detect an item (``1. item``). ``group(1)`` contains contents of item.
419
+ self .RE = re .compile (r'^[ ]{0,%d}[*+-][ ]+(.*)' % (self .tab_length - 1 ))
411
420
412
421
413
422
class HashHeaderProcessor (BlockProcessor ):
0 commit comments