[Python-modules-commits] [python-markdown] 01/03: Import python-markdown_2.6.3.orig.tar.gz
Dmitry Shachnev
mitya57 at moszumanska.debian.org
Tue Oct 27 12:27:14 UTC 2015
This is an automated email from the git hooks/post-receive script.
mitya57 pushed a commit to branch master
in repository python-markdown.
commit c2a5dde1f1345cb89667fa244bc81793054c36f5
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date: Tue Oct 27 15:12:23 2015 +0300
Import python-markdown_2.6.3.orig.tar.gz
---
MANIFEST | 2 +
PKG-INFO | 4 +-
docs/change_log.txt | 4 ++
markdown/__version__.py | 2 +-
markdown/blockprocessors.py | 27 ++++++---
markdown/extensions/footnotes.py | 4 +-
markdown/extensions/sane_lists.py | 12 +++-
markdown/extensions/smarty.py | 7 ++-
markdown/extensions/tables.py | 51 +++++++++++++++-
markdown/preprocessors.py | 7 ++-
tests/basic/inline-html-simple.html | 3 +-
tests/basic/inline-html-simple.txt | 2 +
.../extra/footnote_placeholder_depth.html | 13 +++++
.../extra/footnote_placeholder_depth.txt | 5 ++
tests/extensions/extra/raw-html.html | 7 ++-
tests/extensions/extra/raw-html.txt | 6 ++
tests/extensions/extra/tables.html | 67 ++++++++++++++++++++++
tests/extensions/extra/tables.txt | 18 +++++-
tests/extensions/smarty.html | 3 +-
tests/extensions/smarty.txt | 3 +-
tests/extensions/test.cfg | 2 +-
21 files changed, 222 insertions(+), 27 deletions(-)
diff --git a/MANIFEST b/MANIFEST
index 3be3df0..2a08331 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -170,6 +170,8 @@ tests/extensions/extra/footnote_many_footnotes.html
tests/extensions/extra/footnote_many_footnotes.txt
tests/extensions/extra/footnote_placeholder.html
tests/extensions/extra/footnote_placeholder.txt
+tests/extensions/extra/footnote_placeholder_depth.html
+tests/extensions/extra/footnote_placeholder_depth.txt
tests/extensions/extra/loose_def_list.html
tests/extensions/extra/loose_def_list.txt
tests/extensions/extra/markdown-syntax.html
diff --git a/PKG-INFO b/PKG-INFO
index 293533a..509ccee 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: Markdown
-Version: 2.6.2
+Version: 2.6.3
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.2.tar.gz
+Download-URL: http://pypi.python.org/packages/source/M/Markdown/Markdown-2.6.3.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/docs/change_log.txt b/docs/change_log.txt
index ad149ea..676d56d 100644
--- a/docs/change_log.txt
+++ b/docs/change_log.txt
@@ -7,6 +7,10 @@ next_url: release-2.6.html
Python-Markdown Change Log
=========================
+Oct 26, 2015: Released version 2.6.3 (a bug-fix release).
+
+Apr 20, 2015: Released version 2.6.2 (a bug-fix release).
+
Mar 8, 2015: Released version 2.6.1 (a bug-fix release). The (new)
`yaml` option has been removed from the Meta-Data Extension as it was buggy
(see [#390](https://github.com/waylan/Python-Markdown/issues/390)).
diff --git a/markdown/__version__.py b/markdown/__version__.py
index 3442504..f7c1099 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, 2, 'final', 0)
+version_info = (2, 6, 3, 'final', 0)
def _get_version():
diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py
index 29db022..870151b 100644
--- a/markdown/blockprocessors.py
+++ b/markdown/blockprocessors.py
@@ -38,7 +38,7 @@ def build_block_parser(md_instance, **kwargs):
return parser
-class BlockProcessor:
+class BlockProcessor(object):
""" Base class for block processors.
Each subclass will provide the methods below to work with the source and
@@ -141,7 +141,7 @@ class ListIndentProcessor(BlockProcessor):
LIST_TYPES = ['ul', 'ol']
def __init__(self, *args):
- BlockProcessor.__init__(self, *args)
+ super(ListIndentProcessor, self).__init__(*args)
self.INDENT_RE = re.compile(r'^(([ ]{%s})+)' % self.tab_length)
def test(self, parent, block):
@@ -300,12 +300,6 @@ class OListProcessor(BlockProcessor):
""" Process ordered list blocks. """
TAG = 'ol'
- # Detect an item (``1. item``). ``group(1)`` contains contents of item.
- RE = re.compile(r'^[ ]{0,3}\d+\.[ ]+(.*)')
- # Detect items on secondary lines. they can be of either list type.
- CHILD_RE = re.compile(r'^[ ]{0,3}((\d+\.)|[*+-])[ ]+(.*)')
- # Detect indented (nested) items of either type
- INDENT_RE = re.compile(r'^[ ]{4,7}((\d+\.)|[*+-])[ ]+.*')
# The integer (python string) with which the lists starts (default=1)
# Eg: If list is intialized as)
# 3. Item
@@ -314,6 +308,17 @@ class OListProcessor(BlockProcessor):
# List of allowed sibling tags.
SIBLING_TAGS = ['ol', 'ul']
+ def __init__(self, parser):
+ super(OListProcessor, self).__init__(parser)
+ # Detect an item (``1. item``). ``group(1)`` contains contents of item.
+ self.RE = re.compile(r'^[ ]{0,%d}\d+\.[ ]+(.*)' % (self.tab_length - 1))
+ # Detect items on secondary lines. they can be of either list type.
+ self.CHILD_RE = re.compile(r'^[ ]{0,%d}((\d+\.)|[*+-])[ ]+(.*)' %
+ (self.tab_length - 1))
+ # Detect indented (nested) items of either type
+ self.INDENT_RE = re.compile(r'^[ ]{%d,%d}((\d+\.)|[*+-])[ ]+.*' %
+ (self.tab_length, self.tab_length * 2 - 1))
+
def test(self, parent, block):
return bool(self.RE.match(block))
@@ -407,7 +412,11 @@ class UListProcessor(OListProcessor):
""" Process unordered list blocks. """
TAG = 'ul'
- RE = re.compile(r'^[ ]{0,3}[*+-][ ]+(.*)')
+
+ def __init__(self, parser):
+ super(UListProcessor, self).__init__(parser)
+ # Detect an item (``1. item``). ``group(1)`` contains contents of item.
+ self.RE = re.compile(r'^[ ]{0,%d}[*+-][ ]+(.*)' % (self.tab_length - 1))
class HashHeaderProcessor(BlockProcessor):
diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py
index d8caae2..b52815f 100644
--- a/markdown/extensions/footnotes.py
+++ b/markdown/extensions/footnotes.py
@@ -96,7 +96,9 @@ class FootnoteExtension(Extension):
if child.tail:
if child.tail.find(self.getConfig("PLACE_MARKER")) > -1:
return child, element, False
- finder(child)
+ child_res = finder(child)
+ if child_res is not None:
+ return child_res
return None
res = finder(root)
diff --git a/markdown/extensions/sane_lists.py b/markdown/extensions/sane_lists.py
index 213c8a6..828ae7a 100644
--- a/markdown/extensions/sane_lists.py
+++ b/markdown/extensions/sane_lists.py
@@ -24,15 +24,23 @@ import re
class SaneOListProcessor(OListProcessor):
- CHILD_RE = re.compile(r'^[ ]{0,3}((\d+\.))[ ]+(.*)')
SIBLING_TAGS = ['ol']
+ def __init__(self, parser):
+ super(SaneOListProcessor, self).__init__(parser)
+ self.CHILD_RE = re.compile(r'^[ ]{0,%d}((\d+\.))[ ]+(.*)' %
+ (self.tab_length - 1))
+
class SaneUListProcessor(UListProcessor):
- CHILD_RE = re.compile(r'^[ ]{0,3}(([*+-]))[ ]+(.*)')
SIBLING_TAGS = ['ul']
+ def __init__(self, parser):
+ super(SaneUListProcessor, self).__init__(parser)
+ self.CHILD_RE = re.compile(r'^[ ]{0,%d}(([*+-]))[ ]+(.*)' %
+ (self.tab_length - 1))
+
class SaneListExtension(Extension):
""" Add sane lists to Markdown. """
diff --git a/markdown/extensions/smarty.py b/markdown/extensions/smarty.py
index 46e54c1..600d74c 100644
--- a/markdown/extensions/smarty.py
+++ b/markdown/extensions/smarty.py
@@ -83,7 +83,7 @@ smartypants.py license:
from __future__ import unicode_literals
from . import Extension
-from ..inlinepatterns import HtmlPattern
+from ..inlinepatterns import HtmlPattern, HTML_RE
from ..odict import OrderedDict
from ..treeprocessors import InlineProcessor
@@ -147,6 +147,8 @@ closingSingleQuotesRegex2 = r"(?<=%s)'(\s|s\b)" % closeClass
remainingSingleQuotesRegex = "'"
remainingDoubleQuotesRegex = '"'
+HTML_STRICT_RE = HTML_RE + r'(?!\>)'
+
class SubstituteTextPattern(HtmlPattern):
def __init__(self, pattern, replace, markdown_instance):
@@ -251,6 +253,9 @@ class SmartyExtension(Extension):
self.educateQuotes(md)
if configs['smart_angled_quotes']:
self.educateAngledQuotes(md)
+ # Override HTML_RE from inlinepatterns.py so that it does not
+ # process tags with duplicate closing quotes.
+ md.inlinePatterns["html"] = HtmlPattern(HTML_STRICT_RE, md)
if configs['smart_dashes']:
self.educateDashes(md)
inlineProcessor = InlineProcessor(md)
diff --git a/markdown/extensions/tables.py b/markdown/extensions/tables.py
index 368321d..494aaeb 100644
--- a/markdown/extensions/tables.py
+++ b/markdown/extensions/tables.py
@@ -19,6 +19,7 @@ from __future__ import absolute_import
from __future__ import unicode_literals
from . import Extension
from ..blockprocessors import BlockProcessor
+from ..inlinepatterns import BacktickPattern, BACKTICK_RE
from ..util import etree
@@ -72,7 +73,11 @@ class TableProcessor(BlockProcessor):
for i, a in enumerate(align):
c = etree.SubElement(tr, tag)
try:
- c.text = cells[i].strip()
+ if isinstance(cells[i], str) or isinstance(cells[i], unicode):
+ c.text = cells[i].strip()
+ else:
+ # we've already inserted a code element
+ c.append(cells[i])
except IndexError: # pragma: no cover
c.text = ""
if a:
@@ -85,7 +90,49 @@ class TableProcessor(BlockProcessor):
row = row[1:]
if row.endswith('|'):
row = row[:-1]
- return row.split('|')
+ return self._split(row, '|')
+
+ def _split(self, row, marker):
+ """ split a row of text with some code into a list of cells. """
+ if self._row_has_unpaired_backticks(row):
+ # fallback on old behaviour
+ return row.split(marker)
+ # modify the backtick pattern to only match at the beginning of the search string
+ backtick_pattern = BacktickPattern('^' + BACKTICK_RE)
+ elements = []
+ current = ''
+ i = 0
+ while i < len(row):
+ letter = row[i]
+ if letter == marker:
+ if current != '' or len(elements) == 0:
+ # Don't append empty string unless it is the first element
+ # The border is already removed when we get the row, then the line is strip()'d
+ # If the first element is a marker, then we have an empty first cell
+ elements.append(current)
+ current = ''
+ else:
+ match = backtick_pattern.getCompiledRegExp().match(row[i:])
+ if not match:
+ current += letter
+ else:
+ groups = match.groups()
+ delim = groups[1] # the code block delimeter (ie 1 or more backticks)
+ row_contents = groups[2] # the text contained inside the code block
+ i += match.start(4) # jump pointer to the beginning of the rest of the text (group #4)
+ element = delim + row_contents + delim # reinstert backticks
+ current += element
+ i += 1
+ elements.append(current)
+ return elements
+
+ def _row_has_unpaired_backticks(self, row):
+ count_total_backtick = row.count('`')
+ count_escaped_backtick = row.count('\`')
+ count_backtick = count_total_backtick - count_escaped_backtick
+ # odd number of backticks,
+ # we won't be able to build correct code blocks
+ return count_backtick & 1
class TableExtension(Extension):
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py
index 7fd38d3..7ea4fcf 100644
--- a/markdown/preprocessors.py
+++ b/markdown/preprocessors.py
@@ -178,10 +178,11 @@ class HtmlBlockPreprocessor(Preprocessor):
else: # raw html
if len(items) - right_listindex <= 1: # last element
right_listindex -= 1
- offset = 1 if i == right_listindex else 0
+ if right_listindex <= i:
+ right_listindex = i + 1
placeholder = self.markdown.htmlStash.store('\n\n'.join(
- items[i:right_listindex + offset]))
- del items[i:right_listindex + offset]
+ items[i:right_listindex]))
+ del items[i:right_listindex]
items.insert(i, placeholder)
return items
diff --git a/tests/basic/inline-html-simple.html b/tests/basic/inline-html-simple.html
index 2159e1d..0f2633c 100644
--- a/tests/basic/inline-html-simple.html
+++ b/tests/basic/inline-html-simple.html
@@ -57,4 +57,5 @@ Blah
<hr class="foo" id="bar" >
-<p><some <a href="http://example.com">weird</a> stuff></p>
\ No newline at end of file
+<p><some <a href="http://example.com">weird</a> stuff></p>
+<p><some>> <<unbalanced>> <<brackets></p>
\ No newline at end of file
diff --git a/tests/basic/inline-html-simple.txt b/tests/basic/inline-html-simple.txt
index 7210750..359aca4 100644
--- a/tests/basic/inline-html-simple.txt
+++ b/tests/basic/inline-html-simple.txt
@@ -68,3 +68,5 @@ Hr's:
<hr class="foo" id="bar" >
<some [weird](http://example.com) stuff>
+
+<some>> <<unbalanced>> <<brackets>
\ No newline at end of file
diff --git a/tests/extensions/extra/footnote_placeholder_depth.html b/tests/extensions/extra/footnote_placeholder_depth.html
new file mode 100644
index 0000000..9793a49
--- /dev/null
+++ b/tests/extensions/extra/footnote_placeholder_depth.html
@@ -0,0 +1,13 @@
+<blockquote>
+<blockquote>
+<div class="footnote">
+<hr />
+<ol>
+<li id="fn:1">
+<p>A Footnote. <a class="footnote-backref" href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text">↩</a></p>
+</li>
+</ol>
+</div>
+<p>Some text with a footnote<sup id="fnref:1"><a class="footnote-ref" href="#fn:1" rel="footnote">1</a></sup>.</p>
+</blockquote>
+</blockquote>
\ No newline at end of file
diff --git a/tests/extensions/extra/footnote_placeholder_depth.txt b/tests/extensions/extra/footnote_placeholder_depth.txt
new file mode 100644
index 0000000..cfe87c0
--- /dev/null
+++ b/tests/extensions/extra/footnote_placeholder_depth.txt
@@ -0,0 +1,5 @@
+>> ///Footnotes Go Here///
+>>
+>> Some text with a footnote[^1].
+
+[^1]: A Footnote.
diff --git a/tests/extensions/extra/raw-html.html b/tests/extensions/extra/raw-html.html
index 7acb2ee..9c0222f 100644
--- a/tests/extensions/extra/raw-html.html
+++ b/tests/extensions/extra/raw-html.html
@@ -41,4 +41,9 @@ Raw html blocks may also be nested.
<p>Markdown is <em>still</em> active here.</p>
</div>
-<p>Markdown is <em>active again</em> here.</p>
\ No newline at end of file
+<p>Markdown is <em>active again</em> here.</p>
+<div>
+<p>foo bar</p>
+<p><em>bar</em>
+</p>
+</div>
\ No newline at end of file
diff --git a/tests/extensions/extra/raw-html.txt b/tests/extensions/extra/raw-html.txt
index 72f530b..da24af0 100644
--- a/tests/extensions/extra/raw-html.txt
+++ b/tests/extensions/extra/raw-html.txt
@@ -65,3 +65,9 @@ Markdown is *still* active here.
</div>
Markdown is *active again* here.
+
+<div markdown=1>
+foo bar
+
+<em>bar</em>
+</div>
diff --git a/tests/extensions/extra/tables.html b/tests/extensions/extra/tables.html
index 85a998d..91337e5 100644
--- a/tests/extensions/extra/tables.html
+++ b/tests/extensions/extra/tables.html
@@ -168,4 +168,71 @@ Content Cell | Content Cell
</tr>
</thead>
<tbody></tbody>
+</table>
+<p>More inline code block tests</p>
+<table>
+<thead>
+<tr>
+<th>Column 1</th>
+<th>Column 2</th>
+<th>Column 3</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>word 1</td>
+<td>word 2</td>
+<td>word 3</td>
+</tr>
+<tr>
+<td>word 1</td>
+<td><code>word 2</code></td>
+<td>word 3</td>
+</tr>
+<tr>
+<td>word 1</td>
+<td>`word 2</td>
+<td>word 3</td>
+</tr>
+<tr>
+<td>word 1</td>
+<td>`word 2</td>
+<td>word 3</td>
+</tr>
+<tr>
+<td>word 1</td>
+<td><code>word |2</code></td>
+<td>word 3</td>
+</tr>
+<tr>
+<td>words</td>
+<td><code>some | code</code></td>
+<td>more words</td>
+</tr>
+<tr>
+<td>words</td>
+<td><code>some | code</code></td>
+<td>more words</td>
+</tr>
+<tr>
+<td>words</td>
+<td><code>some | code</code></td>
+<td>more words</td>
+</tr>
+<tr>
+<td>words</td>
+<td><code>some ` | ` code</code></td>
+<td>more words</td>
+</tr>
+<tr>
+<td>words</td>
+<td><code>some ` | ` code</code></td>
+<td>more words</td>
+</tr>
+<tr>
+<td>words</td>
+<td><code>some ` | ` code</code></td>
+<td>more words</td>
+</tr>
+</tbody>
</table>
\ No newline at end of file
diff --git a/tests/extensions/extra/tables.txt b/tests/extensions/extra/tables.txt
index 8acc3c6..1602d1f 100644
--- a/tests/extensions/extra/tables.txt
+++ b/tests/extensions/extra/tables.txt
@@ -52,4 +52,20 @@ Four spaces is a code block:
Content Cell | Content Cell
| First Header | Second Header |
-| ------------ | ------------- |
\ No newline at end of file
+| ------------ | ------------- |
+
+More inline code block tests
+
+Column 1 | Column 2 | Column 3
+---------|----------|---------
+word 1 | word 2 | word 3
+word 1 | `word 2` | word 3
+word 1 | \`word 2 | word 3
+word 1 | `word 2 | word 3
+word 1 | `word |2` | word 3
+words |`` some | code `` | more words
+words |``` some | code ``` | more words
+words |```` some | code ```` | more words
+words |`` some ` | ` code `` | more words
+words |``` some ` | ` code ``` | more words
+words |```` some ` | ` code ```` | more words
\ No newline at end of file
diff --git a/tests/extensions/smarty.html b/tests/extensions/smarty.html
index d41e467..50cf774 100644
--- a/tests/extensions/smarty.html
+++ b/tests/extensions/smarty.html
@@ -16,6 +16,7 @@ em-dashes (—) and ellipes (…)<br />
“<a href="http://example.com">Link</a>” — she said.</p>
<p>“Ellipsis within quotes…”</p>
<p>Кавычки-«ёлочки»<br />
+«hello»<br />
Anführungszeichen-»Chevrons«</p>
<hr />
<p>Escaped -- ndash<br />
@@ -23,7 +24,7 @@ Anführungszeichen-»Chevrons«</p>
Escaped ellipsis...</p>
<p>‘Escaped "quotes" in real ones’<br />
'“Real” quotes in escaped ones'</p>
-<p>Skip <code>"code" -- --- 'spans' ...</code>.</p>
+<p>Skip <code><<all>> "code" -- --- 'spans' ...</code>.</p>
<pre><code>Also skip "code" 'blocks'
foo -- bar --- baz ...
</code></pre>
\ No newline at end of file
diff --git a/tests/extensions/smarty.txt b/tests/extensions/smarty.txt
index 48430bb..f2f4041 100644
--- a/tests/extensions/smarty.txt
+++ b/tests/extensions/smarty.txt
@@ -19,6 +19,7 @@ em-dashes (---) and ellipes (...)
"Ellipsis within quotes..."
Кавычки-<<ёлочки>>
+<<hello>>
Anführungszeichen->>Chevrons<<
--- -- ---
@@ -30,7 +31,7 @@ Escaped ellipsis\...
'Escaped \"quotes\" in real ones'
\'"Real" quotes in escaped ones\'
-Skip `"code" -- --- 'spans' ...`.
+Skip `<<all>> "code" -- --- 'spans' ...`.
Also skip "code" 'blocks'
foo -- bar --- baz ...
diff --git a/tests/extensions/test.cfg b/tests/extensions/test.cfg
index 7e27b29..ce66cfc 100644
--- a/tests/extensions/test.cfg
+++ b/tests/extensions/test.cfg
@@ -70,4 +70,4 @@ smarty:
- markdown.extensions.smarty
extension_configs:
markdown.extensions.smarty:
- smart_angled_quotes: True
+ smart_angled_quotes: True
\ No newline at end of file
--
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