diff options
author | Glandos <bugs-github@antipoul.fr> | 2018-06-20 02:14:29 +0200 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2018-06-19 20:14:29 -0400 |
commit | 2d2183d1beaf0fb2a86461bceb6599f1bcb02605 (patch) | |
tree | d4b2951e09599b69509f645f8a0e6a84e3ddb1a3 | |
parent | d321e798228f6db61d0d477b756a34a8f1d5b8d0 (diff) | |
download | markdown-2d2183d1beaf0fb2a86461bceb6599f1bcb02605.tar.gz markdown-2d2183d1beaf0fb2a86461bceb6599f1bcb02605.tar.bz2 markdown-2d2183d1beaf0fb2a86461bceb6599f1bcb02605.zip |
Implement reset() for Meta extension (#672)
Fixes #671
-rw-r--r-- | markdown/extensions/meta.py | 5 | ||||
-rw-r--r-- | tests/test_extensions.py | 14 |
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. """ |