Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [pull #640] Fix code friendly extra stopping other syntax being processed (#638)
- [pull #644] Fix a number of em/strong issues (#641, #642, #643)
- [pull #659] Fix a number of safemode issues (#647)
- [pull #665] Rewrite emphasis and strong processing to be more GFM compliant


## python-markdown2 2.5.4
Expand Down
20 changes: 11 additions & 9 deletions lib/markdown2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2786,17 +2786,19 @@ def has_middle(
if len(open_syntax) < len(syntax) and opens:
# expand the em span to the left, meaning we're covering additional chars.
# check we don't cross an existing span border
if not self.body_crosses_span_borders(opens[-1], open):
middle = open
if self.body_crosses_span_borders(opens[-1], open):
return False

open = opens.pop(-1)
open_offset = unused_opens.pop(open, 0)
open_syntax = open.group(1)[open_offset:]
middle = open

if len(open_syntax) == len(syntax):
# if it turns out the previous open is a perfect match then ignore the middle part
# eg: **foo*bar**
middle = None
open = opens.pop(-1)
open_offset = unused_opens.pop(open, 0)
open_syntax = open.group(1)[open_offset:]

if len(open_syntax) == len(syntax):
# if it turns out the previous open is a perfect match then ignore the middle part
# eg: **foo*bar**
middle = None
elif len(open_syntax) > len(syntax) and unused_closes:
# check if there is a previous closing delim run in the current body
# since this is already within the body we don't need to do a cross-span border check
Expand Down
1 change: 1 addition & 0 deletions test/tm-cases/gfm_emphasis_issue666.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>*<a href="https://example.com/"><em>test</em>*</a></p>
1 change: 1 addition & 0 deletions test/tm-cases/gfm_emphasis_issue666.text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*[*test**](https://example.com/)