aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan.limberg@icloud.com>2015-03-14 19:41:15 -0400
committerWaylan Limberg <waylan.limberg@icloud.com>2018-01-11 19:04:49 -0500
commitfd628f3e540425b883f36a9c0d288ef1aafdb19e (patch)
treeae9e7479f87736201c3fe0efc4c96049ba0d42d3
parent997063da6ae18692eab45e8d695e9dbc5aea3efe (diff)
downloadmarkdown-fd628f3e540425b883f36a9c0d288ef1aafdb19e.tar.gz
markdown-fd628f3e540425b883f36a9c0d288ef1aafdb19e.tar.bz2
markdown-fd628f3e540425b883f36a9c0d288ef1aafdb19e.zip
Removed deprecated support for positional args.
-rw-r--r--markdown/core.py36
-rw-r--r--tests/test_extensions.py10
2 files changed, 9 insertions, 37 deletions
diff --git a/markdown/core.py b/markdown/core.py
index 17218a2..a10f41a 100644
--- a/markdown/core.py
+++ b/markdown/core.py
@@ -42,7 +42,7 @@ class Markdown(object):
'xhtml5': to_xhtml_string,
}
- def __init__(self, *args, **kwargs):
+ def __init__(self, **kwargs):
"""
Creates a new Markdown instance.
@@ -76,19 +76,6 @@ class Markdown(object):
"""
- # For backward compatibility, loop through old positional args
- pos = ['extensions', 'extension_configs', 'safe_mode', 'output_format']
- for c, arg in enumerate(args):
- if pos[c] not in kwargs:
- kwargs[pos[c]] = arg
- if c+1 == len(pos): # pragma: no cover
- # ignore any additional args
- break
- if len(args):
- warnings.warn('Positional arguments are deprecated in Markdown. '
- 'Use keyword arguments only.',
- DeprecationWarning)
-
# Loop through kwargs and assign defaults
for option, default in self.option_defaults.items():
setattr(self, option, kwargs.get(option, default))
@@ -442,7 +429,7 @@ markdownFromFile().
"""
-def markdown(text, *args, **kwargs):
+def markdown(text, **kwargs):
"""Convert a markdown string to HTML and return HTML as a unicode string.
This is a shortcut function for `Markdown` class to cover the most
@@ -457,11 +444,11 @@ def markdown(text, *args, **kwargs):
Returns: An HTML document as a string.
"""
- md = Markdown(*args, **kwargs)
+ md = Markdown(**kwargs)
return md.convert(text)
-def markdownFromFile(*args, **kwargs):
+def markdownFromFile(**kwargs):
"""Read markdown code from a file and write it to a file or a stream.
This is a shortcut function which initializes an instance of Markdown,
@@ -475,21 +462,6 @@ def markdownFromFile(*args, **kwargs):
* Any arguments accepted by the Markdown class.
"""
- # For backward compatibility loop through positional args
- pos = ['input', 'output', 'extensions', 'encoding']
- c = 0
- for arg in args:
- if pos[c] not in kwargs:
- kwargs[pos[c]] = arg
- c += 1
- if c == len(pos):
- break
- if len(args):
- warnings.warn('Positional arguments are depreacted in '
- 'Markdown and will raise an error in version 2.7. '
- 'Use keyword arguments only.',
- DeprecationWarning)
-
md = Markdown(**kwargs)
md.convertFile(kwargs.get('input', None),
kwargs.get('output', None),
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index 490d55b..37b6fd6 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -408,7 +408,7 @@ class TestHeaderId(unittest.TestCase):
text = '# Some Header\n# Another Header'
self.assertEqual(
- markdown.markdown(text, [markdown.extensions.headerid.HeaderIdExtension(forceid=False)]),
+ markdown.markdown(text, extensions=[markdown.extensions.headerid.HeaderIdExtension(forceid=False)]),
'<h1>Some Header</h1>\n'
'<h1>Another Header</h1>'
)
@@ -421,7 +421,7 @@ header_forceid: Off
# A Header'''
self.assertEqual(
- markdown.markdown(text, ['markdown.extensions.headerid', 'markdown.extensions.meta']),
+ markdown.markdown(text, extensions=['markdown.extensions.headerid', 'markdown.extensions.meta']),
'<h2>A Header</h2>'
)
@@ -430,13 +430,13 @@ header_forceid: Off
text = '# Header1 {: #foo }\n# Header2 {: .bar }'
self.assertEqual(
- markdown.markdown(text, ['markdown.extensions.headerid', 'markdown.extensions.attr_list']),
+ markdown.markdown(text, extensions=['markdown.extensions.headerid', 'markdown.extensions.attr_list']),
'<h1 id="foo">Header1</h1>\n'
'<h1 class="bar" id="header2">Header2</h1>'
)
# Switch order extensions are loaded - should be no change in behavior.
self.assertEqual(
- markdown.markdown(text, ['markdown.extensions.attr_list', 'markdown.extensions.headerid']),
+ markdown.markdown(text, extensions=['markdown.extensions.attr_list', 'markdown.extensions.headerid']),
'<h1 id="foo">Header1</h1>\n'
'<h1 class="bar" id="header2">Header2</h1>'
)
@@ -540,7 +540,7 @@ class TestWikiLinks(unittest.TestCase):
""" Test Simple Settings. """
self.assertEqual(markdown.markdown(
- self.text, [
+ self.text, extensions=[
markdown.extensions.wikilinks.WikiLinkExtension(
base_url='/wiki/',
end_url='.html',