Skip to content

Commit f18725f

Browse files
Merge pull request #667 from Crozzers/fix-unbound-local-in-gfm-em
Fix unbound local error in GFM emphasis processing (#666)
2 parents c87a78c + de9e432 commit f18725f

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [pull #640] Fix code friendly extra stopping other syntax being processed (#638)
77
- [pull #644] Fix a number of em/strong issues (#641, #642, #643)
88
- [pull #659] Fix a number of safemode issues (#647)
9+
- [pull #665] Rewrite emphasis and strong processing to be more GFM compliant
910

1011

1112
## python-markdown2 2.5.4

lib/markdown2.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,17 +2786,19 @@ def has_middle(
27862786
if len(open_syntax) < len(syntax) and opens:
27872787
# expand the em span to the left, meaning we're covering additional chars.
27882788
# check we don't cross an existing span border
2789-
if not self.body_crosses_span_borders(opens[-1], open):
2790-
middle = open
2789+
if self.body_crosses_span_borders(opens[-1], open):
2790+
return False
27912791

2792-
open = opens.pop(-1)
2793-
open_offset = unused_opens.pop(open, 0)
2794-
open_syntax = open.group(1)[open_offset:]
2792+
middle = open
27952793

2796-
if len(open_syntax) == len(syntax):
2797-
# if it turns out the previous open is a perfect match then ignore the middle part
2798-
# eg: **foo*bar**
2799-
middle = None
2794+
open = opens.pop(-1)
2795+
open_offset = unused_opens.pop(open, 0)
2796+
open_syntax = open.group(1)[open_offset:]
2797+
2798+
if len(open_syntax) == len(syntax):
2799+
# if it turns out the previous open is a perfect match then ignore the middle part
2800+
# eg: **foo*bar**
2801+
middle = None
28002802
elif len(open_syntax) > len(syntax) and unused_closes:
28012803
# check if there is a previous closing delim run in the current body
28022804
# since this is already within the body we don't need to do a cross-span border check
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>*<a href="https://example.com/"><em>test</em>*</a></p>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*[*test**](https://example.com/)

0 commit comments

Comments
 (0)