aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/extensions/meta.py5
-rw-r--r--tests/test_extensions.py14
2 files changed, 19 insertions, 0 deletions
diff --git a/markdown/extensions/meta.py b/markdown/extensions/meta.py
index cafad4a..2c2c8e3 100644
--- a/markdown/extensions/meta.py
+++ b/markdown/extensions/meta.py
@@ -36,10 +36,15 @@ class MetaExtension (Extension):
def extendMarkdown(self, md, md_globals):
""" Add MetaPreprocessor to Markdown instance. """
+ md.registerExtension(self)
+ self.md = md
md.preprocessors.add("meta",
MetaPreprocessor(md),
">normalize_whitespace")
+ def reset(self):
+ self.md.Meta = {}
+
class MetaPreprocessor(Preprocessor):
""" Get Meta-Data. """
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index aee9bac..35eaf1d 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -454,6 +454,20 @@ The body. This is paragraph one.'''
self.assertEqual(self.md.convert(text), '')
self.assertEqual(self.md.Meta, {'title': ['No newline']})
+ def testMetaDataReset(self):
+ """ Test that reset call remove Meta entirely """
+
+ text = '''Title: A Test Doc.
+Author: Waylan Limberg
+ John Doe
+Blank_Data:
+
+The body. This is paragraph one.'''
+ self.md.convert(text)
+
+ self.md.reset()
+ self.assertEqual(self.md.Meta, {})
+
class TestWikiLinks(unittest.TestCase):
""" Test Wikilinks Extension. """