[Python-modules-commits] [python-markdown] 01/05: Import python-markdown_2.6.6.orig.tar.gz
Dmitry Shachnev
mitya57 at moszumanska.debian.org
Mon Mar 21 06:53:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
mitya57 pushed a commit to branch master
in repository python-markdown.
commit 1c86452221e4c9d492cd3e47f134f68c1bccd2e9
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date: Mon Mar 21 07:46:01 2016 +0100
Import python-markdown_2.6.6.orig.tar.gz
---
PKG-INFO | 4 +-
README.md | 1 +
docs/change_log.txt | 2 +
markdown/__version__.py | 2 +-
markdown/extensions/toc.py | 3 +-
markdown/postprocessors.py | 17 +++--
tests/plugins.py | 2 +
tests/test_extensions.py | 164 +++++++++++++++++++++++++++++++--------------
tox.ini | 3 +-
9 files changed, 134 insertions(+), 64 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 29d7794..f2e829a 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: Markdown
-Version: 2.6.5
+Version: 2.6.6
Summary: Python implementation of Markdown.
Home-page: https://pythonhosted.org/Markdown/
Author: Waylan Limberg
Author-email: waylan.limberg [at] icloud.com
License: BSD License
-Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-2.6.5.tar.gz
+Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-2.6.6.tar.gz
Description:
This is a Python implementation of John Gruber's Markdown_.
It is almost completely compliant with the reference implementation,
diff --git a/README.md b/README.md
index a7f8550..51c5a14 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,7 @@
[![Downloads](http://img.shields.io/pypi/dm/Markdown.svg)](https://pypi.python.org/pypi/Markdown#downloads)
[![Latest Version](http://img.shields.io/pypi/v/Markdown.svg)](http://pypi.python.org/pypi/Markdown)
[![BSD License](http://img.shields.io/badge/license-BSD-yellow.svg)](http://opensource.org/licenses/BSD-3-Clause)
+[![Issue Stats](http://issuestats.com/github/waylan/Python-Markdown/badge/issue?style=flat)](http://issuestats.com/github/waylan/Python-Markdown)
This is a Python implementation of John Gruber's [Markdown][].
It is almost completely compliant with the reference implementation,
diff --git a/docs/change_log.txt b/docs/change_log.txt
index ee33e6c..e4a991b 100644
--- a/docs/change_log.txt
+++ b/docs/change_log.txt
@@ -7,6 +7,8 @@ next_url: release-2.6.html
Python-Markdown Change Log
=========================
+Nov 24, 2015: Released version 2.6.5 (a bug-fix release).
+
Nov 6, 2015: Released version 2.6.4 (a bug-fix release).
Oct 26, 2015: Released version 2.6.3 (a bug-fix release).
diff --git a/markdown/__version__.py b/markdown/__version__.py
index bc2f07c..d5bbed4 100644
--- a/markdown/__version__.py
+++ b/markdown/__version__.py
@@ -5,7 +5,7 @@
# (major, minor, micro, alpha/beta/rc/final, #)
# (1, 1, 2, 'alpha', 0) => "1.1.2.dev"
# (1, 2, 0, 'beta', 2) => "1.2b2"
-version_info = (2, 6, 5, 'final', 0)
+version_info = (2, 6, 6, 'final', 0)
def _get_version():
diff --git a/markdown/extensions/toc.py b/markdown/extensions/toc.py
index b3cf898..56db33c 100644
--- a/markdown/extensions/toc.py
+++ b/markdown/extensions/toc.py
@@ -180,7 +180,8 @@ class TocTreeprocessor(Treeprocessor):
c.text = ""
for elem in c:
anchor.append(elem)
- c.remove(elem)
+ while c:
+ c.remove(c[0])
c.append(anchor)
def add_permalink(self, c, elem_id):
diff --git a/markdown/postprocessors.py b/markdown/postprocessors.py
index 2d4dcb5..8b311b2 100644
--- a/markdown/postprocessors.py
+++ b/markdown/postprocessors.py
@@ -10,6 +10,7 @@ processing.
from __future__ import absolute_import
from __future__ import unicode_literals
+from collections import OrderedDict
from . import util
from . import odict
import re
@@ -50,6 +51,7 @@ class RawHtmlPostprocessor(Postprocessor):
def run(self, text):
""" Iterate over html stash and restore "safe" html. """
+ replacements = OrderedDict()
for i in range(self.markdown.htmlStash.html_counter):
html, safe = self.markdown.htmlStash.rawHtmlBlocks[i]
if self.markdown.safeMode and not safe:
@@ -61,14 +63,15 @@ class RawHtmlPostprocessor(Postprocessor):
html = self.markdown.html_replacement_text
if (self.isblocklevel(html) and
(safe or not self.markdown.safeMode)):
- text = text.replace(
- "<p>%s</p>" %
- (self.markdown.htmlStash.get_placeholder(i)),
+ replacements["<p>%s</p>" %
+ (self.markdown.htmlStash.get_placeholder(i))] = \
html + "\n"
- )
- text = text.replace(
- self.markdown.htmlStash.get_placeholder(i), html
- )
+ replacements[self.markdown.htmlStash.get_placeholder(i)] = html
+
+ if replacements:
+ pattern = re.compile("|".join(re.escape(k) for k in replacements))
+ text = pattern.sub(lambda m: replacements[m.group(0)], text)
+
return text
def escape(self, html):
diff --git a/tests/plugins.py b/tests/plugins.py
index 90c5c0d..4e7af97 100644
--- a/tests/plugins.py
+++ b/tests/plugins.py
@@ -97,6 +97,8 @@ class HtmlOutput(Plugin):
def formatErr(self, err):
exctype, value, tb = err
+ if not isinstance(value, exctype):
+ value = exctype(value)
return ''.join(traceback.format_exception(exctype, value, tb))
def startContext(self, ctx):
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index 38f0be3..19a1389 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -12,6 +12,17 @@ import unittest
import markdown
+class TestCaseWithAssertStartsWith(unittest.TestCase):
+
+ def assertStartsWith(self, expectedPrefix, text, msg=None):
+ if not text.startswith(expectedPrefix):
+ if len(expectedPrefix) + 5 < len(text):
+ text = text[:len(expectedPrefix) + 5] + '...'
+ standardMsg = '%s not found at the start of %s' % (repr(expectedPrefix),
+ repr(text))
+ self.fail(self._formatMessage(msg, standardMsg))
+
+
class TestExtensionClass(unittest.TestCase):
""" Test markdown.extensions.Extension. """
@@ -86,7 +97,7 @@ class TestAbbr(unittest.TestCase):
)
-class TestCodeHilite(unittest.TestCase):
+class TestCodeHilite(TestCaseWithAssertStartsWith):
""" Test codehilite extension. """
def setUp(self):
@@ -101,7 +112,7 @@ class TestCodeHilite(unittest.TestCase):
md = markdown.Markdown(extensions=['markdown.extensions.codehilite'])
if self.has_pygments:
# Pygments can use random lexer here as we did not specify the language
- self.assertTrue(md.convert(text).startswith('<div class="codehilite"><pre>'))
+ self.assertStartsWith('<div class="codehilite"><pre>', md.convert(text))
else:
self.assertEqual(
md.convert(text),
@@ -117,10 +128,9 @@ class TestCodeHilite(unittest.TestCase):
# Different versions of pygments output slightly different markup.
# So we use 'startwith' and test just enough to confirm that
# pygments received and processed linenums.
- self.assertTrue(
- md.convert(text).startswith(
- '<table class="codehilitetable"><tr><td class="linenos">'
- )
+ self.assertStartsWith(
+ '<table class="codehilitetable"><tr><td class="linenos">',
+ md.convert(text)
)
else:
self.assertEqual(
@@ -134,12 +144,7 @@ class TestCodeHilite(unittest.TestCase):
md = markdown.Markdown(
extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=False)])
if self.has_pygments:
- self.assertEqual(
- md.convert(text),
- '<div class="codehilite">'
- '<pre><span class="c"># A Code Comment</span>\n'
- '</pre></div>'
- )
+ self.assertStartsWith('<div class="codehilite"><pre><span', md.convert(text))
else:
self.assertEqual(
md.convert(text),
@@ -153,7 +158,7 @@ class TestCodeHilite(unittest.TestCase):
extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=None)])
if self.has_pygments:
# Pygments can use random lexer here as we did not specify the language
- self.assertTrue(md.convert(text).startswith('<div class="codehilite"><pre>'))
+ self.assertStartsWith('<div class="codehilite"><pre>', md.convert(text))
else:
self.assertEqual(
md.convert(text),
@@ -169,10 +174,9 @@ class TestCodeHilite(unittest.TestCase):
# Differant versions of pygments output slightly different markup.
# So we use 'startwith' and test just enough to confirm that
# pygments received and processed linenums.
- self.assertTrue(
- md.convert(text).startswith(
- '<table class="codehilitetable"><tr><td class="linenos">'
- )
+ self.assertStartsWith(
+ '<table class="codehilitetable"><tr><td class="linenos">',
+ md.convert(text)
)
else:
self.assertEqual(
@@ -187,12 +191,7 @@ class TestCodeHilite(unittest.TestCase):
extensions=[markdown.extensions.codehilite.CodeHiliteExtension(linenums=None)]
)
if self.has_pygments:
- self.assertEqual(
- md.convert(text),
- '<div class="codehilite">'
- '<pre><span class="c"># A Code Comment</span>\n'
- '</pre></div>'
- )
+ self.assertStartsWith('<div class="codehilite"><pre><span', md.convert(text))
else:
self.assertEqual(
md.convert(text),
@@ -202,19 +201,15 @@ class TestCodeHilite(unittest.TestCase):
def testHighlightLinesWithColon(self):
# Test with hl_lines delimited by single or double quotes.
- text0 = '\t:::Python hl_lines="2"\n\t#line 1\n\t#line 2\n\t#line 3'
- text1 = "\t:::Python hl_lines='2'\n\t#line 1\n\t#line 2\n\t#line 3"
+ text0 = '\t:::Python hl_lines="1"\n\t#line 1\n\t#line 2\n\t#line 3'
+ text1 = "\t:::Python hl_lines='1'\n\t#line 1\n\t#line 2\n\t#line 3"
for text in (text0, text1):
md = markdown.Markdown(extensions=['markdown.extensions.codehilite'])
if self.has_pygments:
- self.assertEqual(
- md.convert(text),
- '<div class="codehilite"><pre>'
- '<span class="c">#line 1</span>\n'
- '<span class="hll"><span class="c">#line 2</span>\n</span>'
- '<span class="c">#line 3</span>\n'
- '</pre></div>'
+ self.assertStartsWith(
+ '<div class="codehilite"><pre><span class="hll"',
+ md.convert(text).replace('<span></span>', '')
)
else:
self.assertEqual(
@@ -237,7 +232,7 @@ class TestCodeHilite(unittest.TestCase):
)
-class TestFencedCode(unittest.TestCase):
+class TestFencedCode(TestCaseWithAssertStartsWith):
""" Test fenced_code extension. """
def setUp(self):
@@ -333,13 +328,9 @@ line 3
)
if self.has_pygments:
- self.assertEqual(
- md.convert(text),
- '<div class="codehilite"><pre>'
- '<span class="hll">line 1\n</span>'
- 'line 2\n'
- '<span class="hll">line 3\n</span>'
- '</pre></div>'
+ self.assertStartsWith(
+ '<div class="codehilite"><pre><span class="hll"',
+ md.convert(text).replace('<span></span>', '')
)
else:
self.assertEqual(
@@ -372,13 +363,9 @@ line 3
]
)
if self.has_pygments:
- self.assertEqual(
- md.convert(text),
- '<div class="codehilite"><pre>'
- '<span class="hll"><span class="c">#line 1</span>\n</span>'
- '<span class="c">#line 2</span>\n'
- '<span class="hll"><span class="c">#line 3</span>\n</span>'
- '</pre></div>'
+ self.assertStartsWith(
+ '<div class="codehilite"><pre><span class="hll"',
+ md.convert(text).replace('<span></span>', '')
)
else:
self.assertEqual(
@@ -625,7 +612,7 @@ class TestAdmonition(unittest.TestCase):
self.assertEqual(RE.match(test).groups(), expected)
-class TestTOC(unittest.TestCase):
+class TestTOC(TestCaseWithAssertStartsWith):
""" Test TOC Extension. """
def setUp(self):
@@ -703,13 +690,13 @@ class TestTOC(unittest.TestCase):
'<h1 id="header-1">Header 1</h1>\n'
'<h2 id="header-2">Header 2</h2>'
)
- self.assertTrue(md.toc.startswith('<div class="toc">'))
+ self.assertStartsWith('<div class="toc">', md.toc)
def testReset(self):
""" Test TOC Reset. """
self.assertEqual(self.md.toc, '')
self.md.convert('# Header 1\n\n## Header 2')
- self.assertTrue(self.md.toc.startswith('<div class="toc">'))
+ self.assertStartsWith('<div class="toc">', self.md.toc)
self.md.reset()
self.assertEqual(self.md.toc, '')
@@ -788,13 +775,88 @@ class TestTOC(unittest.TestCase):
'<h2 id="header-2"><a class="toclink" href="#header-2">Header <em>2</em></a></h2>'
)
+ def testAnchorLinkWithSingleInlineCode(self):
+ """ Test TOC Anchorlink with single inline code. """
+ md = markdown.Markdown(
+ extensions=[markdown.extensions.toc.TocExtension(anchorlink=True)]
+ )
+ text = '# This is `code`.'
+ self.assertEqual(
+ md.convert(text),
+ '<h1 id="this-is-code">' # noqa
+ '<a class="toclink" href="#this-is-code">' # noqa
+ 'This is <code>code</code>.' # noqa
+ '</a>' # noqa
+ '</h1>' # noqa
+ )
+
+ def testAnchorLinkWithDoubleInlineCode(self):
+ """ Test TOC Anchorlink with double inline code. """
+ md = markdown.Markdown(
+ extensions=[markdown.extensions.toc.TocExtension(anchorlink=True)]
+ )
+ text = '# This is `code` and `this` too.'
+ self.assertEqual(
+ md.convert(text),
+ '<h1 id="this-is-code-and-this-too">' # noqa
+ '<a class="toclink" href="#this-is-code-and-this-too">' # noqa
+ 'This is <code>code</code> and <code>this</code> too.' # noqa
+ '</a>' # noqa
+ '</h1>' # noqa
+ )
+
+ def testPermalink(self):
+ """ Test TOC Permalink. """
+ md = markdown.Markdown(
+ extensions=[markdown.extensions.toc.TocExtension(permalink=True)]
+ )
+ text = '# Header'
+ self.assertEqual(
+ md.convert(text),
+ '<h1 id="header">' # noqa
+ 'Header' # noqa
+ '<a class="headerlink" href="#header" title="Permanent link">¶</a>' # noqa
+ '</h1>' # noqa
+ )
+
+ def testPermalinkWithSingleInlineCode(self):
+ """ Test TOC Permalink with single inline code. """
+ md = markdown.Markdown(
+ extensions=[markdown.extensions.toc.TocExtension(permalink=True)]
+ )
+ text = '# This is `code`.'
+ self.assertEqual(
+ md.convert(text),
+ '<h1 id="this-is-code">' # noqa
+ 'This is <code>code</code>.' # noqa
+ '<a class="headerlink" href="#this-is-code" title="Permanent link">¶</a>' # noqa
+ '</h1>' # noqa
+ )
+
+ def testPermalinkWithDoubleInlineCode(self):
+ """ Test TOC Permalink with double inline code. """
+ md = markdown.Markdown(
+ extensions=[markdown.extensions.toc.TocExtension(permalink=True)]
+ )
+ text = '# This is `code` and `this` too.'
+ self.assertEqual(
+ md.convert(text),
+ '<h1 id="this-is-code-and-this-too">' # noqa
+ 'This is <code>code</code> and <code>this</code> too.' # noqa
+ '<a class="headerlink" href="#this-is-code-and-this-too" title="Permanent link">¶</a>' # noqa
+ '</h1>' # noqa
+ )
+
def testTitle(self):
""" Test TOC Title. """
md = markdown.Markdown(
extensions=[markdown.extensions.toc.TocExtension(title='Table of Contents')]
)
md.convert('# Header 1\n\n## Header 2')
- self.assertTrue(md.toc.startswith('<div class="toc"><span class="toctitle">Table of Contents</span><ul>'))
+ self.assertStartsWith(
+ '<div class="toc"><span class="toctitle">Table of Contents</span><ul>',
+ md.toc
+ )
def testWithAttrList(self):
""" Test TOC with attr_list Extension. """
diff --git a/tox.ini b/tox.ini
index c4384a2..3292773 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,7 +2,6 @@
envlist = py27, py32, py33, py34, pypy, flake8, checkspelling
[testenv]
-downloadcache = {toxworkdir}/cache
deps = -rtest-requirements.txt
commands = coverage run --source=markdown {toxinidir}/run-tests.py {posargs}
coverage report --show-missing
@@ -16,4 +15,4 @@ deps =
commands = {toxinidir}/checkspelling.sh
[flake8]
-max-line-length = 119
\ No newline at end of file
+max-line-length = 119
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-markdown.git
More information about the Python-modules-commits
mailing list