mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD037/no-space-in-emphasis to handle multiple embedded underscores separated by a single character (fixes #804).
This commit is contained in:
parent
dc4acff067
commit
8471914a1d
5 changed files with 17 additions and 4 deletions
|
|
@ -7,11 +7,12 @@ const { addErrorContext, emphasisMarkersInContent, forEachLine, isBlankLine,
|
|||
const { htmlElementRanges, lineMetadata } = require("./cache");
|
||||
|
||||
const emphasisRe = /(^|[^\\]|\\\\)(?:(\*{1,3})|(_{1,3}))/g;
|
||||
const embeddedUnderscoreRe = /([A-Za-z\d])_([A-Za-z\d])/g;
|
||||
const embeddedUnderscoreRe = /([A-Za-z\d])(_([A-Za-z\d]))+/g;
|
||||
const asteriskListItemMarkerRe = /^([\s>]*)\*(\s+)/;
|
||||
const leftSpaceRe = /^\s+/;
|
||||
const rightSpaceRe = /\s+$/;
|
||||
const tablePipeRe = /\|/;
|
||||
const allUnderscoresRe = /_/g;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD037", "no-space-in-emphasis" ],
|
||||
|
|
@ -102,7 +103,10 @@ module.exports = {
|
|||
// Emphasis has no meaning here
|
||||
return;
|
||||
}
|
||||
let patchedLine = line.replace(embeddedUnderscoreRe, "$1 $2");
|
||||
let patchedLine = line.replace(
|
||||
embeddedUnderscoreRe,
|
||||
(match) => match.replace(allUnderscoresRe, " ")
|
||||
);
|
||||
if (onItemStart) {
|
||||
// Trim overlapping '*' list item marker
|
||||
patchedLine = patchedLine.replace(asteriskListItemMarkerRe, "$1 $2");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue