aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2012-03-21 10:13:05 -0400
committerWaylan Limberg <waylan@gmail.com>2012-03-21 10:13:05 -0400
commitb3e0359421ee0a649975ca29635ac8c0d7cf7641 (patch)
treec69522a2ec75e7a8a515c4d698613185bc2560c1
parent4dd11abae221fdd76d863487fac16ee45b05c96b (diff)
downloadmarkdown-b3e0359421ee0a649975ca29635ac8c0d7cf7641.tar.gz
markdown-b3e0359421ee0a649975ca29635ac8c0d7cf7641.tar.bz2
markdown-b3e0359421ee0a649975ca29635ac8c0d7cf7641.zip
Allow blockprocessor.run to return True or False.
This allows the run method to determine if a block is or is not a match in the midst of parsing outside of the test method. The goal is to eliminate the often redundant test method in the future. In the interim, it remains and if the run method returns None, the existing behavior is maintained. Returning None may generate a DepreciationWarning later. Note that test must still return True to even get to the run method.
-rw-r--r--markdown/blockparser.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/markdown/blockparser.py b/markdown/blockparser.py
index fae136c..9b59a97 100644
--- a/markdown/blockparser.py
+++ b/markdown/blockparser.py
@@ -89,9 +89,10 @@ class BlockParser:
"""
while blocks:
- for processor in self.blockprocessors.values():
- if processor.test(parent, blocks[0]):
- processor.run(parent, blocks)
- break
+ for processor in self.blockprocessors.values():
+ if processor.test(parent, blocks[0]):
+ if processor.run(parent, blocks) is not False:
+ # run returns True or None
+ break