diff options
author | Waylan Limberg <waylan@gmail.com> | 2014-07-31 22:40:33 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2014-07-31 22:40:33 -0400 |
commit | 47372051cf9724f1355b1c07c63c4beff9a5f626 (patch) | |
tree | 82130393bfa7118cab45a80579fbed2eeed05261 /markdown/extensions/codehilite.py | |
parent | aae373860b5c5cbb40f126bf5acb9693dc577c4a (diff) | |
download | markdown-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/codehilite.py')
-rw-r--r-- | markdown/extensions/codehilite.py | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py index f379da7..e3c5b3d 100644 --- a/markdown/extensions/codehilite.py +++ b/markdown/extensions/codehilite.py @@ -225,7 +225,7 @@ class HiliteTreeprocessor(Treeprocessor): class CodeHiliteExtension(Extension): """ Add source code hilighting to markdown codeblocks. """ - def __init__(self, configs): + def __init__(self, *args, **kwargs): # define default configs self.config = { 'linenums': [None, "Use lines numbers. True=yes, False=no, None=auto"], @@ -237,22 +237,7 @@ class CodeHiliteExtension(Extension): 'noclasses': [False, 'Use inline styles instead of CSS classes - Default false'] } - # Override defaults with user settings - for key, value in configs: - # convert strings to booleans - if value == 'True': value = True - if value == 'False': value = False - if value == 'None': value = None - - if key == 'force_linenos': #pragma: no cover - warnings.warn('The "force_linenos" config setting' - ' to the CodeHilite extension is deprecrecated.' - ' Use "linenums" instead.', DeprecationWarning) - if value: - # Carry 'force_linenos' over to new 'linenos'. - self.setConfig('linenums', True) - - self.setConfig(key, value) + super(CodeHiliteExtension, self).__init__(*args, **kwargs) def extendMarkdown(self, md, md_globals): """ Add HilitePostprocessor to Markdown instance. """ @@ -263,6 +248,6 @@ class CodeHiliteExtension(Extension): md.registerExtension(self) -def makeExtension(configs={}): - return CodeHiliteExtension(configs=configs) +def makeExtension(*args, **kwargs): + return CodeHiliteExtension(*args, **kwargs) |