aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/extensions/__init__.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2014-07-31 22:40:33 -0400
committerWaylan Limberg <waylan@gmail.com>2014-07-31 22:40:33 -0400
commit47372051cf9724f1355b1c07c63c4beff9a5f626 (patch)
tree82130393bfa7118cab45a80579fbed2eeed05261 /markdown/extensions/__init__.py
parentaae373860b5c5cbb40f126bf5acb9693dc577c4a (diff)
downloadmarkdown-47372051cf9724f1355b1c07c63c4beff9a5f626.tar.gz
markdown-47372051cf9724f1355b1c07c63c4beff9a5f626.tar.bz2
markdown-47372051cf9724f1355b1c07c63c4beff9a5f626.zip
Update extensions for Extension.__init__ refactor
Fixes #325. All extensions can now accept a dict of configs or **kwargs, not just a list of tuples. Third party extensions may want to follow suite. Extensions may only accept keyword arguments in the future. These changes still need to be documented. A couple things of note: The CodeHilite extension previously issued a DeprecationWarning if the old config key `force_linenos` was used. With thins change, a KeyError will now be raised. The `markdown.util.parseBoolValue` function gained a new argument: `preserve_none` (defaults to False), which when set to True, will pass None through unaltered (will not convert it to False).
Diffstat (limited to 'markdown/extensions/__init__.py')
-rw-r--r--markdown/extensions/__init__.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/markdown/extensions/__init__.py b/markdown/extensions/__init__.py
index 296ce0c..2751eef 100644
--- a/markdown/extensions/__init__.py
+++ b/markdown/extensions/__init__.py
@@ -4,6 +4,7 @@ Extensions
"""
from __future__ import unicode_literals
+from ..util import parseBoolValue
class Extension(object):
""" Base class for extensions to subclass. """
@@ -47,6 +48,10 @@ class Extension(object):
def setConfig(self, key, value):
""" Set a config setting for `key` with the given `value`. """
+ if isinstance(self.config[key][0], bool):
+ value = parseBoolValue(value)
+ if self.config[key][0] is None:
+ value = parseBoolValue(value, preserve_none=True)
self.config[key][0] = value
def setConfigs(self, items):