diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2015-03-28 14:51:45 -0400 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2015-04-22 19:53:48 -0400 |
commit | 17b16a2e63b98185fd3b15114204d04132c1d9aa (patch) | |
tree | dcbc3834a31df6ee73f74faf3a6f768996299c1f | |
parent | e34d0121fd3c4f29035c6e944e3ee042828728c1 (diff) | |
download | python-markdown-17b16a2e63b98185fd3b15114204d04132c1d9aa.tar.gz |
Removed md_globals from extension API.
There is no need for this anymore. In the past, most config was using
globals. Today all config is held on the class instance.
-rw-r--r-- | markdown/core.py | 2 | ||||
-rw-r--r-- | markdown/extensions/__init__.py | 4 | ||||
-rw-r--r-- | markdown/extensions/abbr.py | 2 | ||||
-rw-r--r-- | markdown/extensions/admonition.py | 2 | ||||
-rw-r--r-- | markdown/extensions/attr_list.py | 2 | ||||
-rw-r--r-- | markdown/extensions/codehilite.py | 2 | ||||
-rw-r--r-- | markdown/extensions/def_list.py | 2 | ||||
-rw-r--r-- | markdown/extensions/extra.py | 2 | ||||
-rw-r--r-- | markdown/extensions/fenced_code.py | 2 | ||||
-rw-r--r-- | markdown/extensions/footnotes.py | 2 | ||||
-rw-r--r-- | markdown/extensions/headerid.py | 2 | ||||
-rw-r--r-- | markdown/extensions/meta.py | 2 | ||||
-rw-r--r-- | markdown/extensions/nl2br.py | 2 | ||||
-rw-r--r-- | markdown/extensions/sane_lists.py | 2 | ||||
-rw-r--r-- | markdown/extensions/smart_strong.py | 2 | ||||
-rw-r--r-- | markdown/extensions/smarty.py | 2 | ||||
-rw-r--r-- | markdown/extensions/tables.py | 2 | ||||
-rw-r--r-- | markdown/extensions/toc.py | 2 | ||||
-rw-r--r-- | markdown/extensions/wikilinks.py | 2 | ||||
-rw-r--r-- | tests/test_apis.py | 2 |
20 files changed, 20 insertions, 22 deletions
diff --git a/markdown/core.py b/markdown/core.py index 442b183..773e984 100644 --- a/markdown/core.py +++ b/markdown/core.py @@ -115,7 +115,7 @@ class Markdown(object): if isinstance(ext, util.string_type): ext = self.build_extension(ext, configs.get(ext, {})) if isinstance(ext, Extension): - ext.extendMarkdown(self, globals()) + ext.extendMarkdown(self) logger.debug( 'Successfully loaded extension "%s.%s".' % (ext.__class__.__module__, ext.__class__.__name__) diff --git a/markdown/extensions/__init__.py b/markdown/extensions/__init__.py index 1e33a14..342a014 100644 --- a/markdown/extensions/__init__.py +++ b/markdown/extensions/__init__.py @@ -54,7 +54,7 @@ class Extension(object): for key, value in items: self.setConfig(key, value) - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add the various proccesors and patterns to the Markdown Instance. @@ -64,8 +64,6 @@ class Extension(object): * md: The Markdown instance. - * md_globals: Global variables in the markdown module namespace. - """ raise NotImplementedError( 'Extension "%s.%s" must define an "extendMarkdown"' diff --git a/markdown/extensions/abbr.py b/markdown/extensions/abbr.py index c3941a5..a78c9a3 100644 --- a/markdown/extensions/abbr.py +++ b/markdown/extensions/abbr.py @@ -31,7 +31,7 @@ ABBR_REF_RE = re.compile(r'[*]\[(?P<abbr>[^\]]*)\][ ]?:\s*(?P<title>.*)') class AbbrExtension(Extension): """ Abbreviation Extension for Python-Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Insert AbbrPreprocessor before ReferencePreprocessor. """ md.preprocessors.add('abbr', AbbrPreprocessor(md), '<reference') diff --git a/markdown/extensions/admonition.py b/markdown/extensions/admonition.py index ad3c59d..72f1e5f 100644 --- a/markdown/extensions/admonition.py +++ b/markdown/extensions/admonition.py @@ -28,7 +28,7 @@ import re class AdmonitionExtension(Extension): """ Admonition extension for Python-Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add Admonition to Markdown instance. """ md.registerExtension(self) diff --git a/markdown/extensions/attr_list.py b/markdown/extensions/attr_list.py index 84e9da1..f5c307f 100644 --- a/markdown/extensions/attr_list.py +++ b/markdown/extensions/attr_list.py @@ -167,7 +167,7 @@ class AttrListTreeprocessor(Treeprocessor): class AttrListExtension(Extension): - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): md.treeprocessors.add( 'attr_list', AttrListTreeprocessor(md), '>prettify' ) diff --git a/markdown/extensions/codehilite.py b/markdown/extensions/codehilite.py index 857601f..ed6da7b 100644 --- a/markdown/extensions/codehilite.py +++ b/markdown/extensions/codehilite.py @@ -251,7 +251,7 @@ class CodeHiliteExtension(Extension): super(CodeHiliteExtension, self).__init__(**kwargs) - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add HilitePostprocessor to Markdown instance. """ hiliter = HiliteTreeprocessor(md) hiliter.config = self.getConfigs() diff --git a/markdown/extensions/def_list.py b/markdown/extensions/def_list.py index f5224c2..be674f8 100644 --- a/markdown/extensions/def_list.py +++ b/markdown/extensions/def_list.py @@ -101,7 +101,7 @@ class DefListIndentProcessor(ListIndentProcessor): class DefListExtension(Extension): """ Add definition lists to Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add an instance of DefListProcessor to BlockParser. """ md.parser.blockprocessors.add('defindent', DefListIndentProcessor(md.parser), diff --git a/markdown/extensions/extra.py b/markdown/extensions/extra.py index 9a9d717..e3ead8a 100644 --- a/markdown/extensions/extra.py +++ b/markdown/extensions/extra.py @@ -53,7 +53,7 @@ class ExtraExtension(Extension): def __init__(self, **kwargs): self.config = kwargs - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Register extension instances. """ md.registerExtensions(extensions, self.config) # Turn on processing of markdown text within raw html diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py index af278b5..41d14fd 100644 --- a/markdown/extensions/fenced_code.py +++ b/markdown/extensions/fenced_code.py @@ -25,7 +25,7 @@ import re class FencedCodeExtension(Extension): - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add FencedBlockPreprocessor to the Markdown instance. """ md.registerExtension(self) diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index 24ef4c4..c04ad68 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -56,7 +56,7 @@ class FootnoteExtension(Extension): self.reset() - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add pieces to Markdown. """ md.registerExtension(self) self.parser = md.parser diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py index 5466544..7c6bbeb 100644 --- a/markdown/extensions/headerid.py +++ b/markdown/extensions/headerid.py @@ -77,7 +77,7 @@ class HeaderIdExtension(Extension): PendingDeprecationWarning ) - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): md.registerExtension(self) self.processor = HeaderIdTreeprocessor() self.processor.md = md diff --git a/markdown/extensions/meta.py b/markdown/extensions/meta.py index f64babc..bea50e2 100644 --- a/markdown/extensions/meta.py +++ b/markdown/extensions/meta.py @@ -34,7 +34,7 @@ END_RE = re.compile(r'^(-{3}|\.{3})(\s.*)?') class MetaExtension (Extension): """ Meta-Data extension for Python-Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add MetaPreprocessor to Markdown instance. """ md.preprocessors.add("meta", MetaPreprocessor(md), diff --git a/markdown/extensions/nl2br.py b/markdown/extensions/nl2br.py index 946ad90..e70b876 100644 --- a/markdown/extensions/nl2br.py +++ b/markdown/extensions/nl2br.py @@ -26,6 +26,6 @@ BR_RE = r'\n' class Nl2BrExtension(Extension): - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): br_tag = SubstituteTagPattern(BR_RE, 'br') md.inlinePatterns.add('nl', br_tag, '_end') diff --git a/markdown/extensions/sane_lists.py b/markdown/extensions/sane_lists.py index 81cf8ad..838340b 100644 --- a/markdown/extensions/sane_lists.py +++ b/markdown/extensions/sane_lists.py @@ -37,7 +37,7 @@ class SaneUListProcessor(UListProcessor): class SaneListExtension(Extension): """ Add sane lists to Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Override existing Processors. """ md.parser.blockprocessors['olist'] = SaneOListProcessor(md.parser) md.parser.blockprocessors['ulist'] = SaneUListProcessor(md.parser) diff --git a/markdown/extensions/smart_strong.py b/markdown/extensions/smart_strong.py index bb387ce..4137b17 100644 --- a/markdown/extensions/smart_strong.py +++ b/markdown/extensions/smart_strong.py @@ -27,7 +27,7 @@ STRONG_RE = r'(\*{2})(.+?)\2' class SmartEmphasisExtension(Extension): """ Add smart_emphasis extension to Markdown class.""" - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Modify inline patterns. """ md.inlinePatterns['strong'] = SimpleTagPattern(STRONG_RE, 'strong') md.inlinePatterns.add( diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py index 7e4634f..85a2611 100644 --- a/markdown/extensions/smarty.py +++ b/markdown/extensions/smarty.py @@ -242,7 +242,7 @@ class SmartyExtension(Extension): ) self._addPatterns(md, patterns, 'quotes') - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): configs = self.getConfigs() self.inlinePatterns = OrderedDict() if configs['smart_ellipses']: diff --git a/markdown/extensions/tables.py b/markdown/extensions/tables.py index 15840b0..294d5c9 100644 --- a/markdown/extensions/tables.py +++ b/markdown/extensions/tables.py @@ -91,7 +91,7 @@ class TableProcessor(BlockProcessor): class TableExtension(Extension): """ Add tables to Markdown. """ - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): """ Add an instance of TableProcessor to BlockParser. """ md.parser.blockprocessors.add('table', TableProcessor(md.parser), diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py index f1cfa17..74cd5f4 100644 --- a/markdown/extensions/toc.py +++ b/markdown/extensions/toc.py @@ -287,7 +287,7 @@ class TocExtension(Extension): super(TocExtension, self).__init__(**kwargs) - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): md.registerExtension(self) self.md = md self.reset() diff --git a/markdown/extensions/wikilinks.py b/markdown/extensions/wikilinks.py index 284dbb7..14f47a1 100644 --- a/markdown/extensions/wikilinks.py +++ b/markdown/extensions/wikilinks.py @@ -41,7 +41,7 @@ class WikiLinkExtension(Extension): super(WikiLinkExtension, self).__init__(**kwargs) - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): self.md = md # append to end of inline patterns diff --git a/tests/test_apis.py b/tests/test_apis.py index bc8a337..dec913d 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -483,7 +483,7 @@ class testSerializers(unittest.TestCase): return '<div><p>foo</p></div>' class registerFakeSerializer(markdown.extensions.Extension): - def extendMarkdown(self, md, md_globals): + def extendMarkdown(self, md): md.output_formats['fake'] = fakeSerializer return registerFakeSerializer() |