-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle bold/strong nested inside italics/em #307
Changes from all commits
a9ad544
e161098
9e52993
46938c9
eda51b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1185,23 +1185,20 @@ func helperFindEmphChar(data []byte, c byte) int { | |
func helperEmphasis(p *Parser, data []byte, c byte) (int, ast.Node) { | ||
i := 0 | ||
|
||
// skip one symbol if coming from emph3 | ||
// skip two symbols if coming from emph3, as it detected a double emphasis case | ||
if len(data) > 1 && data[0] == c && data[1] == c { | ||
i = 1 | ||
i += 2 | ||
} | ||
|
||
for i < len(data) { | ||
length := helperFindEmphChar(data[i:], c) | ||
if length == 0 { | ||
return 0, nil | ||
} | ||
i += length | ||
if i >= len(data) { | ||
return 0, nil | ||
} | ||
|
||
if i+1 < len(data) && data[i+1] == c { | ||
i++ | ||
i += 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
continue | ||
} | ||
|
||
|
@@ -1218,6 +1215,11 @@ func helperEmphasis(p *Parser, data []byte, c byte) (int, ast.Node) { | |
p.Inline(emph, data[:i]) | ||
return i + 1, emph | ||
} | ||
|
||
// We have to check this at the end, otherwise the scenario where we find repeated c's will get skipped | ||
if length == 0 { | ||
return 0, nil | ||
} | ||
} | ||
|
||
return 0, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building on last commit, in the triple
c
case, we'd still have short-circuited here - but we actually want to claim thisc
as our own. So we do the rest of the validity checks first, and then do this check at the end to exit the loop