mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD037/no-space-in-emphasis to ignore emphasis markers in link text (fixes #280).
This commit is contained in:
parent
f607a49a5b
commit
ac5d52a3e3
3 changed files with 46 additions and 3 deletions
|
@ -28,8 +28,8 @@ module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
|
||||||
// Regular expression for all instances of emphasis markers
|
// Regular expression for all instances of emphasis markers
|
||||||
const emphasisMarkersRe = /[_*]/g;
|
const emphasisMarkersRe = /[_*]/g;
|
||||||
|
|
||||||
// Regular expression for links
|
// Regular expression for inline links and shortcut reference links
|
||||||
const linkRe = /\[(?:[^\]]|\[[^\]]*\])*\]\(\S*\)/g;
|
const linkRe = /\[(?:[^[\]]|\[[^\]]*\])*\](?:\(\S*\))?/g;
|
||||||
|
|
||||||
// readFile options for reading with the UTF-8 encoding
|
// readFile options for reading with the UTF-8 encoding
|
||||||
module.exports.utf8Encoding = { "encoding": "utf8" };
|
module.exports.utf8Encoding = { "encoding": "utf8" };
|
||||||
|
|
|
@ -129,7 +129,7 @@ module.exports = {
|
||||||
// Back up one character so RegExp has a chance to match the
|
// Back up one character so RegExp has a chance to match the
|
||||||
// next marker (ex: "**star**_underscore_")
|
// next marker (ex: "**star**_underscore_")
|
||||||
emphasisRe.lastIndex--;
|
emphasisRe.lastIndex--;
|
||||||
} else {
|
} else if (emphasisRe.lastIndex > 1) {
|
||||||
// Back up one character so RegExp has a chance to match the
|
// Back up one character so RegExp has a chance to match the
|
||||||
// mis-matched marker (ex: "*text_*")
|
// mis-matched marker (ex: "*text_*")
|
||||||
emphasisRe.lastIndex--;
|
emphasisRe.lastIndex--;
|
||||||
|
|
|
@ -254,3 +254,46 @@ text _underscore_**star** text _underscore_**star** text
|
||||||
`****** text ******`
|
`****** text ******`
|
||||||
|
|
||||||
`******* text *******`
|
`******* text *******`
|
||||||
|
|
||||||
|
under_score
|
||||||
|
_underscore_
|
||||||
|
|
||||||
|
st*ar
|
||||||
|
*star*
|
||||||
|
|
||||||
|
under_score
|
||||||
|
*star*
|
||||||
|
|
||||||
|
st*ar
|
||||||
|
_underscore_
|
||||||
|
|
||||||
|
*star*
|
||||||
|
_underscore_
|
||||||
|
|
||||||
|
_underscore_
|
||||||
|
*star*
|
||||||
|
|
||||||
|
_underscore
|
||||||
|
_*star*
|
||||||
|
|
||||||
|
*star
|
||||||
|
*_underscore_
|
||||||
|
|
||||||
|
[reference_link]
|
||||||
|
_first_ and _second_
|
||||||
|
|
||||||
|
[reference_link]
|
||||||
|
*first* and *second*
|
||||||
|
|
||||||
|
[reference*link]
|
||||||
|
_first_ and _second_
|
||||||
|
|
||||||
|
[reference*link]
|
||||||
|
*first* and *second*
|
||||||
|
|
||||||
|
text [reference_link] under _ score text
|
||||||
|
|
||||||
|
text [reference*link] star * star text
|
||||||
|
|
||||||
|
[reference_link]: https://example.com
|
||||||
|
[reference*link]: https://example.com
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue