Update MD037/no-space-in-emphasis to avoid hang when backtracking for embedded emphasis on first character of line.

This commit is contained in:
David Anson 2020-06-15 19:42:46 -07:00
parent 8c79b48855
commit 26e70a2c6d
2 changed files with 19 additions and 1 deletions

View file

@ -128,7 +128,9 @@ module.exports = {
}
// Back up one character so RegExp has a chance to match the
// next marker (ex: "**star**_underscore_")
emphasisRe.lastIndex--;
if (emphasisRe.lastIndex > 1) {
emphasisRe.lastIndex--;
}
} else if (emphasisRe.lastIndex > 1) {
// Back up one character so RegExp has a chance to match the
// mis-matched marker (ex: "*text_*")

View file

@ -297,3 +297,19 @@ text [reference*link] star * star text
[reference_link]: https://example.com
[reference*link]: https://example.com
***text
*text*
***
*** text
*text*
***
*** text
\*text\*
***
*** text
**text**
***