diff options
Diffstat (limited to 'markdown/extensions/headerid.py')
-rw-r--r-- | markdown/extensions/headerid.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py index 0476f9e..8221fe1 100644 --- a/markdown/extensions/headerid.py +++ b/markdown/extensions/headerid.py @@ -78,7 +78,7 @@ from __future__ import absolute_import from __future__ import unicode_literals from . import Extension from ..treeprocessors import Treeprocessor -from ..util import HTML_PLACEHOLDER_RE +from ..util import HTML_PLACEHOLDER_RE, parseBoolValue import re import logging import unicodedata @@ -166,23 +166,14 @@ class HeaderIdTreeprocessor(Treeprocessor): def _get_meta(self): """ Return meta data suported by this ext as a tuple """ level = int(self.config['level']) - 1 - force = self._str2bool(self.config['forceid']) + force = parseBoolValue(self.config['forceid']) if hasattr(self.md, 'Meta'): if 'header_level' in self.md.Meta: level = int(self.md.Meta['header_level'][0]) - 1 if 'header_forceid' in self.md.Meta: - force = self._str2bool(self.md.Meta['header_forceid'][0]) + force = parseBoolValue(self.md.Meta['header_forceid'][0]) return level, force - def _str2bool(self, s, default=False): - """ Convert a string to a booleen value. """ - s = str(s) - if s.lower() in ['0', 'f', 'false', 'off', 'no', 'n']: - return False - elif s.lower() in ['1', 't', 'true', 'on', 'yes', 'y']: - return True - return default - class HeaderIdExtension(Extension): def __init__(self, configs): |