aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/core.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2018-07-27 10:23:55 -0400
committerGitHub <noreply@github.com>2018-07-27 10:23:55 -0400
commit6ee07d2735d86d7a3d0b31c3409d42d31997a96c (patch)
tree3e7827f8ef4581c321a4a53ccc05d46e9975823f /markdown/core.py
parent5d2cde235c9ad17cdc3678ed51e1d693967b5a5a (diff)
downloadmarkdown-6ee07d2735d86d7a3d0b31c3409d42d31997a96c.tar.gz
markdown-6ee07d2735d86d7a3d0b31c3409d42d31997a96c.tar.bz2
markdown-6ee07d2735d86d7a3d0b31c3409d42d31997a96c.zip
Replace homegrown OrderedDict with purpose-built Registry. (#688)
All processors and patterns now get "registered" to a Registry. Each item is given a name (string) and a priority. The name is for later reference and the priority can be either an integer or float and is used to sort. Priority is sorted from highest to lowest. A Registry instance is a list-like iterable with the items auto-sorted by priority. If two items have the same priority, then they are listed in the order there were "registered". Registering a new item with the same name as an already registered item replaces the old item with the new item (however, the new item is sorted by its newly assigned priority). To remove an item, "deregister" it by name or index. A backwards compatible shim is included so that existing simple extensions should continue to work. DeprecationWarnings will be raised for any code which calls the old API. Fixes #418.
Diffstat (limited to 'markdown/core.py')
-rw-r--r--markdown/core.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/markdown/core.py b/markdown/core.py
index 4b8d1a6..06bf262 100644
--- a/markdown/core.py
+++ b/markdown/core.py
@@ -230,14 +230,14 @@ class Markdown(object):
# Split into lines and run the line preprocessors.
self.lines = source.split("\n")
- for prep in self.preprocessors.values():
+ for prep in self.preprocessors:
self.lines = prep.run(self.lines)
# Parse the high-level elements.
root = self.parser.parseDocument(self.lines).getroot()
# Run the tree-processors
- for treeprocessor in self.treeprocessors.values():
+ for treeprocessor in self.treeprocessors:
newRoot = treeprocessor.run(root)
if newRoot is not None:
root = newRoot
@@ -260,7 +260,7 @@ class Markdown(object):
'tags. Document=%r' % output.strip())
# Run the text post-processors
- for pp in self.postprocessors.values():
+ for pp in self.postprocessors:
output = pp.run(output)
return output.strip()