Skip to content

Commit

Permalink
Fix tail out of order issue
Browse files Browse the repository at this point in the history
This issue was discovered when dealing with nested inlines.  In
treeprocessors.py it was incorrectly handling tails.  In short, tail
elements were being inserted earlier than they were supposed to be.

In order to fix this, the insertion index should be incremented by 1 so
that when the tails are inserted into the parent, they will be just
after the child they came from.

Also added a test in nested-patterns to catch this issue.
  • Loading branch information
facelessuser committed Oct 18, 2014
1 parent 57633f1 commit 72c819a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion markdown/treeprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __processElementText(self, node, subnode, isText=True):
childResult = self.__processPlaceholders(text, subnode, isText)

if not isText and node is not subnode:
pos = list(node).index(subnode)
pos = list(node).index(subnode) + 1
else:
pos = 0

Expand Down
3 changes: 2 additions & 1 deletion tests/misc/nested-patterns.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<strong><a href="http://example.com"><em>link</em></a></strong>
<strong><a href="http://example.com"><em>link</em></a></strong>
<strong><a href="http://example.com"><em>link</em></a></strong>
<a href="http://example.com"><strong><em>link</em></strong></a></p>
<a href="http://example.com"><strong><em>link</em></strong></a></p>
<p><strong><em>I am <strong><em>italic</em> and</strong> bold</em> I am <code>just</code> bold</strong></p>
2 changes: 2 additions & 0 deletions tests/misc/nested-patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ __[_link_](http://example.com)__
__[*link*](http://example.com)__
**[_link_](http://example.com)**
[***link***](http://example.com)

***I am ___italic_ and__ bold* I am `just` bold**

0 comments on commit 72c819a

Please sign in to comment.