diff --git a/lib/markdown2.py b/lib/markdown2.py index 8b99ec3d..3f7e4b87 100755 --- a/lib/markdown2.py +++ b/lib/markdown2.py @@ -3003,7 +3003,8 @@ def __init__(self, md, options): def sub(self, match: re.Match) -> str: syntax = match.group(1) - text: str = match.string[match.start(): match.end()] + # use match.regs because strong/em regex may include preceding text in the match as well + text: str = match.string[match.regs[1][0]: match.end()] if '_' in syntax: # if using _this_ syntax, hash it to avoid processing, but don't hash the contents incase of nested syntax text = text.replace(syntax, _hash_text(self.name + syntax)) diff --git a/test/tm-cases/code_friendly_issue646.html b/test/tm-cases/code_friendly_issue646.html new file mode 100644 index 00000000..5c8e0779 --- /dev/null +++ b/test/tm-cases/code_friendly_issue646.html @@ -0,0 +1 @@ +
A_B
diff --git a/test/tm-cases/code_friendly_issue646.opts b/test/tm-cases/code_friendly_issue646.opts new file mode 100644 index 00000000..245e9828 --- /dev/null +++ b/test/tm-cases/code_friendly_issue646.opts @@ -0,0 +1 @@ +{"extras":["code-friendly"]} \ No newline at end of file diff --git a/test/tm-cases/code_friendly_issue646.text b/test/tm-cases/code_friendly_issue646.text new file mode 100644 index 00000000..8f94c786 --- /dev/null +++ b/test/tm-cases/code_friendly_issue646.text @@ -0,0 +1 @@ +A_**B** \ No newline at end of file