From 39c8c1c64fe04bbde625b314386cb109b11527da Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Thu, 25 Sep 2014 21:17:57 -0400 Subject: Fixed TOC Option parsing. The new option parser assumes bool values if the default is bool or None. As the "title" option is not a bool value, it should default to an empty string rather than None. Fixes #347. --- markdown/extensions/toc.py | 4 ++-- tests/test_apis.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index 22cf063..d21ea96 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -216,9 +216,9 @@ class TocExtension(Extension): "slugify" : [slugify, "Function to generate anchors based on header text - " "Defaults to the headerid ext's slugify function."], - "title" : [None, + "title" : ["", "Title to insert into TOC
- " - "Defaults to None"], + "Defaults to an empty string"], "anchorlink" : [0, "1 if header should be a self link - " "Defaults to 0"], diff --git a/tests/test_apis.py b/tests/test_apis.py index b19db62..34cd6f0 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -590,7 +590,7 @@ class TestCliOptionParsing(unittest.TestCase): with os.fdopen(fd, 'w') as fp: fp.write(config) - def testExtensonConfigOption(self): + def testExtensionConfigOption(self): config = { 'markdown.extensions.wikilinks': { 'base_url': 'http://example.com/', @@ -606,6 +606,19 @@ class TestCliOptionParsing(unittest.TestCase): self.default_options['extension_configs'] = config self.assertEqual(options, self.default_options) + def textBoolExtensionConfigOption(self): + config = { + 'markdown.extensions.toc': { + 'title': 'Some Title', + 'anchorlink': True, + 'permalink': True + } + } + self.create_config_file(config) + options, logging_level = parse_options(['-c', self.tempfile]) + self.default_options['extension_configs'] = config + self.assertEqual(options, self.default_options) + def testExtensonConfigOptionAsJSON(self): config = { 'markdown.extensions.wikilinks': { -- cgit v1.2.3