Skip to content

Commit

Permalink
Merge pull request #398 from d0ugal/meta_fix
Browse files Browse the repository at this point in the history
Meta fix
  • Loading branch information
d0ugal committed Apr 2, 2015
2 parents c39d758 + 9c1f038 commit 9999c25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mkdocs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ def convert_markdown(markdown_source, site_navigation=None, extensions=(), stric
extensions=extensions
)
html_content = md.convert(markdown_source)
meta = md.Meta
toc_html = md.toc

# On completely blank markdown files, no Meta or tox properties are added
# to the generated document.
meta = getattr(md, 'Meta', {})
toc_html = getattr(md, 'toc', '')

# Post process the generated table of contents into a data structure
table_of_contents = toc.TableOfContents(toc_html)
Expand Down
8 changes: 8 additions & 0 deletions mkdocs/tests/build_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@


class BuildTests(unittest.TestCase):

def test_empty_document(self):
html, toc, meta = build.convert_markdown("")

self.assertEqual(html, '')
self.assertEqual(len(list(toc)), 0)
self.assertEqual(meta, {})

def test_convert_markdown(self):
"""
Ensure that basic Markdown -> HTML and TOC works.
Expand Down

0 comments on commit 9999c25

Please sign in to comment.