diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2014-11-20 16:07:03 -0500 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2014-11-20 16:07:03 -0500 |
commit | 8f66a94eab1389d97041944ed24afd2bf7c4389c (patch) | |
tree | 10b53664076650be951468cbbb163f3d637e5891 /markdown/extensions/meta.py | |
parent | 0c2143819ef7de53be52f7a4d47e027ff194a9b4 (diff) | |
download | markdown-8f66a94eab1389d97041944ed24afd2bf7c4389c.tar.gz markdown-8f66a94eab1389d97041944ed24afd2bf7c4389c.tar.bz2 markdown-8f66a94eab1389d97041944ed24afd2bf7c4389c.zip |
Flake8 cleanup (mostly whitespace).
Got all but a couple files in the tests (ran out of time today).
Apparently I have been using some bad form for years (although a few
things seemed to look better before the update). Anyway, conformant now.
Diffstat (limited to 'markdown/extensions/meta.py')
-rw-r--r-- | markdown/extensions/meta.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/markdown/extensions/meta.py b/markdown/extensions/meta.py index bcc25a0..a733a8a 100644 --- a/markdown/extensions/meta.py +++ b/markdown/extensions/meta.py @@ -4,14 +4,14 @@ Meta Data Extension for Python-Markdown This extension adds Meta Data handling to markdown. -See <https://pythonhosted.org/Markdown/extensions/meta_data.html> +See <https://pythonhosted.org/Markdown/extensions/meta_data.html> for documentation. Original code Copyright 2007-2008 [Waylan Limberg](http://achinghead.com). All changes Copyright 2008-2014 The Python Markdown Project -License: [BSD](http://www.opensource.org/licenses/bsd-license.php) +License: [BSD](http://www.opensource.org/licenses/bsd-license.php) """ @@ -25,13 +25,16 @@ import re META_RE = re.compile(r'^[ ]{0,3}(?P<key>[A-Za-z0-9_-]+):\s*(?P<value>.*)') META_MORE_RE = re.compile(r'^[ ]{4,}(?P<value>.*)') + class MetaExtension (Extension): """ Meta-Data extension for Python-Markdown. """ def extendMarkdown(self, md, md_globals): """ Add MetaPreprocessor to Markdown instance. """ - md.preprocessors.add("meta", MetaPreprocessor(md), ">normalize_whitespace") + md.preprocessors.add( + "meta", MetaPreprocessor(md), ">normalize_whitespace" + ) class MetaPreprocessor(Preprocessor): @@ -44,7 +47,7 @@ class MetaPreprocessor(Preprocessor): while lines: line = lines.pop(0) if line.strip() == '': - break # blank line - done + break # blank line - done m1 = META_RE.match(line) if m1: key = m1.group('key').lower().strip() @@ -60,11 +63,10 @@ class MetaPreprocessor(Preprocessor): meta[key].append(m2.group('value').strip()) else: lines.insert(0, line) - break # no meta data - done + break # no meta data - done self.markdown.Meta = meta return lines - + def makeExtension(*args, **kwargs): return MetaExtension(*args, **kwargs) - |