mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD037/no-space-in-emphasis to avoid pairing different kinds of emphasis marker.
This commit is contained in:
parent
f5a71521d4
commit
70dc8fb6d3
2 changed files with 26 additions and 2 deletions
11
lib/md037.js
11
lib/md037.js
|
@ -17,11 +17,13 @@ module.exports = {
|
|||
"tags": [ "whitespace", "emphasis" ],
|
||||
"function": function MD037(params, onError) {
|
||||
// eslint-disable-next-line init-declarations
|
||||
let effectiveEmphasisLength, emphasisIndex, emphasisLength, pendingError;
|
||||
let effectiveEmphasisLength, emphasisIndex, emphasisKind, emphasisLength,
|
||||
pendingError = null;
|
||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||
function resetRunTracking() {
|
||||
emphasisIndex = -1;
|
||||
emphasisLength = 0;
|
||||
emphasisKind = "";
|
||||
effectiveEmphasisLength = 0;
|
||||
pendingError = null;
|
||||
}
|
||||
|
@ -92,12 +94,17 @@ module.exports = {
|
|||
continue;
|
||||
}
|
||||
const matchLength = match[0].length - match[1].length;
|
||||
const matchKind = (match[2] || match[3])[0];
|
||||
if (emphasisIndex === -1) {
|
||||
// New run
|
||||
emphasisIndex = matchIndex + matchLength;
|
||||
emphasisLength = matchLength;
|
||||
emphasisKind = matchKind;
|
||||
effectiveEmphasisLength = matchLength;
|
||||
} else if (matchLength === effectiveEmphasisLength) {
|
||||
} else if (
|
||||
(matchLength === effectiveEmphasisLength) &&
|
||||
(matchKind === emphasisKind)
|
||||
) {
|
||||
// Ending an existing run, report any pending error
|
||||
if (pendingError) {
|
||||
addErrorContext(...pendingError);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue