| Index: third_party/Python-Markdown/markdown/blockparser.py
|
| diff --git a/third_party/markdown/blockparser.py b/third_party/Python-Markdown/markdown/blockparser.py
|
| similarity index 55%
|
| copy from third_party/markdown/blockparser.py
|
| copy to third_party/Python-Markdown/markdown/blockparser.py
|
| index 3402394ea8e0edc90ea7f11c7fd61aecd5bc3091..32d3254cdf832b869a83c0fd1cb6a0607090511e 100644
|
| --- a/third_party/markdown/blockparser.py
|
| +++ b/third_party/Python-Markdown/markdown/blockparser.py
|
| @@ -1,50 +1,19 @@
|
| -# markdown is released under the BSD license
|
| -# Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)
|
| -# Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
|
| -# Copyright 2004 Manfred Stienstra (the original version)
|
| -#
|
| -# All rights reserved.
|
| -#
|
| -# Redistribution and use in source and binary forms, with or without
|
| -# modification, are permitted provided that the following conditions are met:
|
| -#
|
| -# * Redistributions of source code must retain the above copyright
|
| -# notice, this list of conditions and the following disclaimer.
|
| -# * Redistributions in binary form must reproduce the above copyright
|
| -# notice, this list of conditions and the following disclaimer in the
|
| -# documentation and/or other materials provided with the distribution.
|
| -# * Neither the name of the <organization> nor the
|
| -# names of its contributors may be used to endorse or promote products
|
| -# derived from this software without specific prior written permission.
|
| -#
|
| -# THIS SOFTWARE IS PROVIDED BY THE PYTHON MARKDOWN PROJECT ''AS IS'' AND ANY
|
| -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| -# DISCLAIMED. IN NO EVENT SHALL ANY CONTRIBUTORS TO THE PYTHON MARKDOWN PROJECT
|
| -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
| -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
| -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
| -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
| -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
| -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
| -# POSSIBILITY OF SUCH DAMAGE.
|
| -
|
| -
|
| from __future__ import unicode_literals
|
| from __future__ import absolute_import
|
| from . import util
|
| from . import odict
|
|
|
| +
|
| class State(list):
|
| - """ Track the current and nested state of the parser.
|
| -
|
| - This utility class is used to track the state of the BlockParser and
|
| + """ Track the current and nested state of the parser.
|
| +
|
| + This utility class is used to track the state of the BlockParser and
|
| support multiple levels if nesting. It's just a simple API wrapped around
|
| a list. Each time a state is set, that state is appended to the end of the
|
| list. Each time a state is reset, that state is removed from the end of
|
| the list.
|
|
|
| - Therefore, each time a state is set for a nested block, that state must be
|
| + Therefore, each time a state is set for a nested block, that state must be
|
| reset when we back out of that level of nesting or the state could be
|
| corrupted.
|
|
|
| @@ -68,9 +37,10 @@ class State(list):
|
| else:
|
| return False
|
|
|
| +
|
| class BlockParser:
|
| - """ Parse Markdown blocks into an ElementTree object.
|
| -
|
| + """ Parse Markdown blocks into an ElementTree object.
|
| +
|
| A wrapper class that stitches the various BlockProcessors together,
|
| looping through them and creating an ElementTree object.
|
| """
|
| @@ -81,12 +51,12 @@ class BlockParser:
|
| self.markdown = markdown
|
|
|
| def parseDocument(self, lines):
|
| - """ Parse a markdown document into an ElementTree.
|
| -
|
| - Given a list of lines, an ElementTree object (not just a parent Element)
|
| - is created and the root element is passed to the parser as the parent.
|
| - The ElementTree object is returned.
|
| -
|
| + """ Parse a markdown document into an ElementTree.
|
| +
|
| + Given a list of lines, an ElementTree object (not just a parent
|
| + Element) is created and the root element is passed to the parser
|
| + as the parent. The ElementTree object is returned.
|
| +
|
| This should only be called on an entire document, not pieces.
|
|
|
| """
|
| @@ -96,29 +66,30 @@ class BlockParser:
|
| return util.etree.ElementTree(self.root)
|
|
|
| def parseChunk(self, parent, text):
|
| - """ Parse a chunk of markdown text and attach to given etree node.
|
| -
|
| + """ Parse a chunk of markdown text and attach to given etree node.
|
| +
|
| While the ``text`` argument is generally assumed to contain multiple
|
| blocks which will be split on blank lines, it could contain only one
|
| block. Generally, this method would be called by extensions when
|
| - block parsing is required.
|
| -
|
| - The ``parent`` etree Element passed in is altered in place.
|
| + block parsing is required.
|
| +
|
| + The ``parent`` etree Element passed in is altered in place.
|
| Nothing is returned.
|
|
|
| """
|
| self.parseBlocks(parent, text.split('\n\n'))
|
|
|
| def parseBlocks(self, parent, blocks):
|
| - """ Process blocks of markdown text and attach to given etree node.
|
| -
|
| + """ Process blocks of markdown text and attach to given etree node.
|
| +
|
| Given a list of ``blocks``, each blockprocessor is stepped through
|
| until there are no blocks left. While an extension could potentially
|
| - call this method directly, it's generally expected to be used internally.
|
| + call this method directly, it's generally expected to be used
|
| + internally.
|
|
|
| - This is a public method as an extension may need to add/alter additional
|
| - BlockProcessors which call this method to recursively parse a nested
|
| - block.
|
| + This is a public method as an extension may need to add/alter
|
| + additional BlockProcessors which call this method to recursively
|
| + parse a nested block.
|
|
|
| """
|
| while blocks:
|
| @@ -127,5 +98,3 @@ class BlockParser:
|
| if processor.run(parent, blocks) is not False:
|
| # run returns True or None
|
| break
|
| -
|
| -
|
|
|