Metadata-Version: 2.1
Name: Markdown
-Version: 3.2
+Version: 3.2.1
Summary: Python implementation of Markdown.
Home-page: https://Python-Markdown.github.io/
Author: Manfred Stienstra, Yuri takhteyev and Waylan limberg
Maintainer: Waylan Limberg
Maintainer-email: waylan.limberg@icloud.com
License: BSD License
-Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2-py2.py3-none-any.whl
+Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2.1-py2.py3-none-any.whl
Description:
This is a Python implementation of John Gruber's Markdown_.
It is almost completely compliant with the reference implementation,
Metadata-Version: 2.1
Name: Markdown
-Version: 3.2
+Version: 3.2.1
Summary: Python implementation of Markdown.
Home-page: https://Python-Markdown.github.io/
Author: Manfred Stienstra, Yuri takhteyev and Waylan limberg
Maintainer: Waylan Limberg
Maintainer-email: waylan.limberg@icloud.com
License: BSD License
-Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2-py2.py3-none-any.whl
+Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-3.2.1-py2.py3-none-any.whl
Description:
This is a Python implementation of John Gruber's Markdown_.
It is almost completely compliant with the reference implementation,
Python-Markdown Change Log
=========================
+Feb 12, 2020: Released version 3.2.1 (a bug-fix release).
+
+* The `name` property in `toc_tokens` from the TOC extension now
+ escapes HTML special characters (`<`, `>`, and `&`).
+
Feb 7, 2020: Released version 3.2 ([Notes](release-3.2.md)).
May 20, 2019: Released version 3.1.1 (a bug-fix release).
# (1, 2, 0, 'beta', 2) => "1.2b2"
# (1, 2, 0, 'rc', 4) => "1.2rc4"
# (1, 2, 0, 'final', 0) => "1.2"
-__version_info__ = (3, 2, 0, 'final', 0)
+__version_info__ = (3, 2, 1, 'final', 0)
def _get_version(): # pragma: no cover
from . import Extension
from ..treeprocessors import Treeprocessor
-from ..util import parseBoolValue, AMP_SUBSTITUTE, HTML_PLACEHOLDER_RE
+from ..util import code_escape, parseBoolValue, AMP_SUBSTITUTE, HTML_PLACEHOLDER_RE
from ..postprocessors import UnescapePostprocessor
import re
import unicodedata
'level': int(el.tag[-1]),
'id': el.attrib["id"],
'name': unescape(stashedHTML2text(
- el.attrib.get('data-toc-label', text), self.md, strip_entities=False
+ code_escape(el.attrib.get('data-toc-label', text)),
+ self.md, strip_entities=False
))
})
{'level': 1, 'id': 'foo-bar', 'name': 'Foo & bar', 'children': []},
])
+ def testHtmlSpecialChars(self):
+ """ Test Headers with HTML special characters. """
+ text = '# Foo > & bar'
+ self.assertEqual(
+ self.md.convert(text),
+ '<h1 id="foo-bar">Foo > & bar</h1>'
+ )
+ self.assertEqual(
+ self.md.toc,
+ '<div class="toc">\n'
+ '<ul>\n' # noqa
+ '<li><a href="#foo-bar">Foo > & bar</a></li>\n' # noqa
+ '</ul>\n' # noqa
+ '</div>\n'
+ )
+ self.assertEqual(self.md.toc_tokens, [
+ {'level': 1, 'id': 'foo-bar', 'name': 'Foo > & bar', 'children': []},
+ ])
+
def testRawHtml(self):
""" Test Headers with raw HTML. """
text = '# Foo <b>Bar</b> Baz.'
md = markdown.Markdown(extensions=['toc', 'attr_list'])
text = ('# Header 1\n\n'
'## Header 2 { #foo }\n\n'
- '## Header 3 { data-toc-label="Foo Bar"}\n\n'
- '# Header 4 { data-toc-label="Foo <b>Baz</b>" }')
+ '## Header 3 { data-toc-label="Foo Bar" }\n\n'
+ '# Header 4 { data-toc-label="Foo > Baz" }\n\n'
+ '# Header 5 { data-toc-label="Foo <b>Quux</b>" }')
+
self.assertEqual(
md.convert(text),
'<h1 id="header-1">Header 1</h1>\n'
'<h2 id="foo">Header 2</h2>\n'
'<h2 id="header-3">Header 3</h2>\n'
- '<h1 id="header-4">Header 4</h1>'
+ '<h1 id="header-4">Header 4</h1>\n'
+ '<h1 id="header-5">Header 5</h1>'
)
self.assertEqual(
md.toc,
'<div class="toc">\n'
- '<ul>\n' # noqa
- '<li><a href="#header-1">Header 1</a>' # noqa
- '<ul>\n' # noqa
- '<li><a href="#foo">Header 2</a></li>\n' # noqa
- '<li><a href="#header-3">Foo Bar</a></li>\n' # noqa
- '</ul>\n' # noqa
- '</li>\n' # noqa
- '<li><a href="#header-4">Foo Baz</a></li>\n' # noqa
- '</ul>\n' # noqa
+ '<ul>\n' # noqa
+ '<li><a href="#header-1">Header 1</a>' # noqa
+ '<ul>\n' # noqa
+ '<li><a href="#foo">Header 2</a></li>\n' # noqa
+ '<li><a href="#header-3">Foo Bar</a></li>\n' # noqa
+ '</ul>\n' # noqa
+ '</li>\n' # noqa
+ '<li><a href="#header-4">Foo > Baz</a></li>\n' # noqa
+ '<li><a href="#header-5">Foo Quux</a></li>\n' # noqa
+ '</ul>\n' # noqa
'</div>\n'
)
self.assertEqual(md.toc_tokens, [
{'level': 2, 'id': 'foo', 'name': 'Header 2', 'children': []},
{'level': 2, 'id': 'header-3', 'name': 'Foo Bar', 'children': []}
]},
- {'level': 1, 'id': 'header-4', 'name': 'Foo Baz', 'children': []},
+ {'level': 1, 'id': 'header-4', 'name': 'Foo > Baz', 'children': []},
+ {'level': 1, 'id': 'header-5', 'name': 'Foo Quux', 'children': []},
])
def testUniqueFunc(self):