diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2014-11-30 22:15:37 -0500 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2014-11-30 22:15:37 -0500 |
commit | 4cac4ff6095c7b7c0b319f16afb7df349ea93ac8 (patch) | |
tree | 5a3582cb9b348be9b5842779df44b98b1006a6f7 /tests | |
parent | 47329268beb7b86f659753785a1f9f3ed644eefb (diff) | |
parent | ef6eb032b2e08f866b900cbc4d130b18200f712e (diff) | |
download | markdown-4cac4ff6095c7b7c0b319f16afb7df349ea93ac8.tar.gz markdown-4cac4ff6095c7b7c0b319f16afb7df349ea93ac8.tar.bz2 markdown-4cac4ff6095c7b7c0b319f16afb7df349ea93ac8.zip |
Merge branch 'kernc-meta_yaml'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_extensions.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_extensions.py b/tests/test_extensions.py index a037915..e24118f 100644 --- a/tests/test_extensions.py +++ b/tests/test_extensions.py @@ -8,6 +8,7 @@ continue to work as advertised. This used to be accomplished by doctests. """ from __future__ import unicode_literals +import datetime import unittest import markdown @@ -513,6 +514,28 @@ The body. This is paragraph one.''' } ) + def testYamlMetaData(self): + """ Test metadata specified as simple YAML. """ + + text = '''--- +Title: A Test Doc. +Author: [Waylan Limberg, John Doe] +Blank_Data: +--- + +The body. This is paragraph one.''' + self.assertEqual( + self.md.convert(text), + '<p>The body. This is paragraph one.</p>' + ) + self.assertEqual( + self.md.Meta, { + 'author': ['[Waylan Limberg, John Doe]'], + 'blank_data': [''], + 'title': ['A Test Doc.'] + } + ) + def testMissingMetaData(self): """ Test document without Meta Data. """ @@ -530,6 +553,25 @@ The body. This is paragraph one.''' self.assertEqual(self.md.convert(text), '') self.assertEqual(self.md.Meta, {'title': ['No newline']}) + def testYamlObjectMetaData(self): + """ Test metadata specified as a complex YAML object. """ + md = markdown.Markdown(extensions=[markdown.extensions.meta.MetaExtension(yaml=True)]) + text = '''--- +Author: John Doe +Date: 2014-11-29 14:15:16 +Integer: 0x16 +--- + +Some content.''' + self.assertEqual(md.convert(text), '<p>Some content.</p>') + self.assertEqual( + md.Meta, { + 'Author': 'John Doe', + 'Date': datetime.datetime(2014, 11, 29, 14, 15, 16), + 'Integer': 22 + } + ) + class TestWikiLinks(unittest.TestCase): """ Test Wikilinks Extension. """ |