mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
MD037 should try to ignore escaped emphasis markers (fixes #168).
This commit is contained in:
parent
dd3bd3d7ee
commit
2ccacf03f5
2 changed files with 39 additions and 7 deletions
|
|
@ -11,19 +11,22 @@ module.exports = {
|
|||
"function": function MD037(params, onError) {
|
||||
shared.forEachInlineChild(params, "text", function forToken(token) {
|
||||
let left = true;
|
||||
let match = /(?:^|\s)(\*\*?|__?)\s.+\1/.exec(token.content);
|
||||
let match = /(?:^|\s)(\*\*?|__?)\s.*[^\\]\1/.exec(token.content);
|
||||
if (!match) {
|
||||
left = false;
|
||||
match = /(\*\*?|__?).+\s\1(?:\s|$)/.exec(token.content);
|
||||
match = /(?:^|[^\\])(\*\*?|__?).+\s\1(?:\s|$)/.exec(token.content);
|
||||
}
|
||||
if (match) {
|
||||
const text = match[0].trim();
|
||||
const fullText = match[0];
|
||||
const line = params.lines[token.lineNumber - 1];
|
||||
if (line.indexOf(fullText) !== -1) {
|
||||
const text = fullText.trim();
|
||||
const column = line.indexOf(text) + 1;
|
||||
const length = text.length;
|
||||
shared.addErrorContext(onError, token.lineNumber,
|
||||
text, left, !left, [ column, length ]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
29
test/escaped-emphasis-markers.md
Normal file
29
test/escaped-emphasis-markers.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Heading
|
||||
|
||||
Escaped asterisks \* should \* be ignored by MD037.
|
||||
|
||||
Escaped asterisks \* should * be ignored by MD037.
|
||||
|
||||
Escaped asterisks * should \* be ignored by MD037.
|
||||
|
||||
Escaped asterisks \** should ** be ignored by MD037.
|
||||
|
||||
Escaped asterisks *\* should ** be ignored by MD037.
|
||||
|
||||
Escaped asterisks ** should \** be ignored by MD037.
|
||||
|
||||
Escaped asterisks ** should *\* be ignored by MD037.
|
||||
|
||||
Escaped underscores \_ should \_ be ignored by MD037.
|
||||
|
||||
Escaped underscores \_ should _ be ignored by MD037.
|
||||
|
||||
Escaped underscores _ should \_ be ignored by MD037.
|
||||
|
||||
Escaped underscores \__ should __ be ignored by MD037.
|
||||
|
||||
Escaped underscores _\_ should __ be ignored by MD037.
|
||||
|
||||
Escaped underscores __ should \__ be ignored by MD037.
|
||||
|
||||
Escaped underscores __ should _\_ be ignored by MD037.
|
||||
Loading…
Add table
Add a link
Reference in a new issue