Upgrade markdown to 2.4.1

This commit is contained in:
Matthew Jones
2014-08-06 15:33:24 -04:00
parent 07b538e5c5
commit 7cb892a869
31 changed files with 5682 additions and 5688 deletions

View File

@@ -32,7 +32,7 @@ importlib==1.0.3 (importlib/*, needed for Python 2.6 support)
iso8601==0.1.10 (iso8601/*) iso8601==0.1.10 (iso8601/*)
keyring==4.0 (keyring/*, excluded bin/keyring) keyring==4.0 (keyring/*, excluded bin/keyring)
kombu==3.0.21 (kombu/*) kombu==3.0.21 (kombu/*)
Markdown==2.4 (markdown/*, excluded bin/markdown_py) Markdown==2.4.1 (markdown/*, excluded bin/markdown_py)
mock==1.0.1 (mock.py) mock==1.0.1 (mock.py)
ordereddict==1.1 (ordereddict.py, needed for Python 2.6 support) ordereddict==1.1 (ordereddict.py, needed for Python 2.6 support)
os-diskconfig-python-novaclient-ext==0.1.2 (os_diskconfig_python_novaclient_ext/*) os-diskconfig-python-novaclient-ext==0.1.2 (os_diskconfig_python_novaclient_ext/*)

View File

@@ -5,7 +5,7 @@
# (major, minor, micro, alpha/beta/rc/final, #) # (major, minor, micro, alpha/beta/rc/final, #)
# (1, 1, 2, 'alpha', 0) => "1.1.2.dev" # (1, 1, 2, 'alpha', 0) => "1.1.2.dev"
# (1, 2, 0, 'beta', 2) => "1.2b2" # (1, 2, 0, 'beta', 2) => "1.2b2"
version_info = (2, 4, 0, 'final', 0) version_info = (2, 4, 1, 'final', 0)
def _get_version(): def _get_version():
" Returns a PEP 386-compliant version number from version_info. " " Returns a PEP 386-compliant version number from version_info. "

View File

@@ -75,12 +75,9 @@ class MarkdownInHtmlProcessor(BlockProcessor):
# Build list of indexes of each nest within the parent element. # Build list of indexes of each nest within the parent element.
nest_index = [] # a list of tuples: (left index, right index) nest_index = [] # a list of tuples: (left index, right index)
i = self.parser.blockprocessors.tag_counter + 1 i = self.parser.blockprocessors.tag_counter + 1
is_nest = self.parser.markdown.htmlStash.tag_data[i]['left_index'] while len(self._tag_data) > i and self._tag_data[i]['left_index']:
while len(self.parser.markdown.htmlStash.tag_data) > i and is_nest: left_child_index = self._tag_data[i]['left_index']
left_child_index = \ right_child_index = self._tag_data[i]['right_index']
self.parser.markdown.htmlStash.tag_data[i]['left_index']
right_child_index = \
self.parser.markdown.htmlStash.tag_data[i]['right_index']
nest_index.append((left_child_index - 1, right_child_index)) nest_index.append((left_child_index - 1, right_child_index))
i += 1 i += 1
@@ -92,35 +89,32 @@ class MarkdownInHtmlProcessor(BlockProcessor):
block[nest_index[-1][1]:], True) # nest block[nest_index[-1][1]:], True) # nest
def run(self, parent, blocks, tail=None, nest=False): def run(self, parent, blocks, tail=None, nest=False):
self._tag_data = self.parser.markdown.htmlStash.tag_data
self.parser.blockprocessors.tag_counter += 1 self.parser.blockprocessors.tag_counter += 1
tag_data = self.parser.markdown.htmlStash.tag_data[ tag = self._tag_data[self.parser.blockprocessors.tag_counter]
self.parser.blockprocessors.tag_counter]
# Create Element # Create Element
markdown_value = tag_data['attrs'].pop('markdown') markdown_value = tag['attrs'].pop('markdown')
element = util.etree.SubElement(parent, tag_data['tag'], element = util.etree.SubElement(parent, tag['tag'], tag['attrs'])
tag_data['attrs'])
# Slice Off Block # Slice Off Block
if nest: if nest:
self.parser.parseBlocks(parent, tail) # Process Tail self.parser.parseBlocks(parent, tail) # Process Tail
block = blocks[1:] block = blocks[1:]
else: # includes nests since a third level of nesting isn't supported else: # includes nests since a third level of nesting isn't supported
block = blocks[tag_data['left_index'] + 1: block = blocks[tag['left_index'] + 1: tag['right_index']]
tag_data['right_index']] del blocks[:tag['right_index']]
del blocks[:tag_data['right_index']]
# Process Text # Process Text
if (self.parser.blockprocessors.contain_span_tags.match( # Span Mode if (self.parser.blockprocessors.contain_span_tags.match( # Span Mode
tag_data['tag']) and markdown_value != 'block') or \ tag['tag']) and markdown_value != 'block') or \
markdown_value == 'span': markdown_value == 'span':
element.text = '\n'.join(block) element.text = '\n'.join(block)
else: # Block Mode else: # Block Mode
i = self.parser.blockprocessors.tag_counter + 1 i = self.parser.blockprocessors.tag_counter + 1
if len(self.parser.markdown.htmlStash.tag_data) > i and self.\ if len(self._tag_data) > i and self._tag_data[i]['left_index']:
parser.markdown.htmlStash.tag_data[i]['left_index']: first_subelement_index = self._tag_data[i]['left_index'] - 1
first_subelement_index = self.parser.markdown.htmlStash.\
tag_data[i]['left_index'] - 1
self.parser.parseBlocks( self.parser.parseBlocks(
element, block[:first_subelement_index]) element, block[:first_subelement_index])
if not nest: if not nest:

View File

@@ -73,7 +73,7 @@ from ..util import parseBoolValue
# Constants for quote education. # Constants for quote education.
punctClass = r"""[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]""" punctClass = r"""[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]"""
endOfWordClass = r"[\s.,;:!?)]" endOfWordClass = r"[\s.,;:!?)]"
closeClass = r"[^\ \t\r\n\[\{\(\-\u0002\u0003]" closeClass = "[^\ \t\r\n\[\{\(\-\u0002\u0003]"
openingQuotesBase = ( openingQuotesBase = (
'(\s' # a whitespace char '(\s' # a whitespace char
@@ -150,14 +150,14 @@ class SmartyExtension(Extension):
md.inlinePatterns.add(name, pattern, after) md.inlinePatterns.add(name, pattern, after)
def educateDashes(self, md): def educateDashes(self, md):
emDashesPattern = SubstituteTextPattern(r'(?<!-)---(?!-)', '&mdash;', md) emDashesPattern = SubstituteTextPattern(r'(?<!-)---(?!-)', ('&mdash;',), md)
enDashesPattern = SubstituteTextPattern(r'(?<!-)--(?!-)', '&ndash;', md) enDashesPattern = SubstituteTextPattern(r'(?<!-)--(?!-)', ('&ndash;',), md)
md.inlinePatterns.add('smarty-em-dashes', emDashesPattern, '>entity') md.inlinePatterns.add('smarty-em-dashes', emDashesPattern, '>entity')
md.inlinePatterns.add('smarty-en-dashes', enDashesPattern, md.inlinePatterns.add('smarty-en-dashes', enDashesPattern,
'>smarty-em-dashes') '>smarty-em-dashes')
def educateEllipses(self, md): def educateEllipses(self, md):
ellipsesPattern = SubstituteTextPattern(r'(?<!\.)\.{3}(?!\.)', '&hellip;', md) ellipsesPattern = SubstituteTextPattern(r'(?<!\.)\.{3}(?!\.)', ('&hellip;',), md)
md.inlinePatterns.add('smarty-ellipses', ellipsesPattern, '>entity') md.inlinePatterns.add('smarty-ellipses', ellipsesPattern, '>entity')
def educateQuotes(self, md): def educateQuotes(self, md):

View File

@@ -143,7 +143,7 @@ class HtmlBlockPreprocessor(Preprocessor):
""" """
Same effect as concatenating the strings in items, Same effect as concatenating the strings in items,
finding the character to which stringindex refers in that string, finding the character to which stringindex refers in that string,
and returning the item in which that character resides. and returning the index of the item in which that character resides.
""" """
items.append('dummy') items.append('dummy')
i, count = 0, 0 i, count = 0, 0
@@ -175,8 +175,8 @@ class HtmlBlockPreprocessor(Preprocessor):
if len(items) - right_listindex <= 1: # last element if len(items) - right_listindex <= 1: # last element
right_listindex -= 1 right_listindex -= 1
placeholder = self.markdown.htmlStash.store('\n\n'.join( placeholder = self.markdown.htmlStash.store('\n\n'.join(
items[i:right_listindex])) items[i:right_listindex + 1]))
del items[i:right_listindex] del items[i:right_listindex + 1]
items.insert(i, placeholder) items.insert(i, placeholder)
return items return items

View File

@@ -30,7 +30,7 @@ BLOCK_LEVEL_ELEMENTS = re.compile("^(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul"
"|hr|hr/|style|li|dt|dd|thead|tbody" "|hr|hr/|style|li|dt|dd|thead|tbody"
"|tr|th|td|section|footer|header|group|figure" "|tr|th|td|section|footer|header|group|figure"
"|figcaption|aside|article|canvas|output" "|figcaption|aside|article|canvas|output"
"|progress|video)$", re.IGNORECASE) "|progress|video|nav)$", re.IGNORECASE)
# Placeholders # Placeholders
STX = '\u0002' # Use STX ("Start of text") for start-of-placeholder STX = '\u0002' # Use STX ("Start of text") for start-of-placeholder
ETX = '\u0003' # Use ETX ("End of text") for end-of-placeholder ETX = '\u0003' # Use ETX ("End of text") for end-of-placeholder