mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Fix broken MD020/MD021/MD038 scenarios.
This commit is contained in:
parent
677255a484
commit
33e3797084
5 changed files with 32 additions and 28 deletions
12
lib/md020.js
12
lib/md020.js
|
|
@ -12,7 +12,8 @@ module.exports = {
|
|||
"function": function MD020(params, onError) {
|
||||
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
||||
if (!inCode) {
|
||||
const match = /^(#+)(\s*)([^#]+?)(\s*)(\\?)(#+)(\s*)$/.exec(line);
|
||||
const match =
|
||||
/^(#+)(\s*)([^#]+?[^#\\])(\s*)((?:\\#)?)(#+)(\s*)$/.exec(line);
|
||||
if (match) {
|
||||
const [
|
||||
,
|
||||
|
|
@ -27,9 +28,8 @@ module.exports = {
|
|||
const leftHashLength = leftHash.length;
|
||||
const rightHashLength = rightHash.length;
|
||||
const left = !leftSpaceLength;
|
||||
const right =
|
||||
(!rightSpaceLength && (!rightEscape || (rightHashLength > 1))) ||
|
||||
(rightEscape && (rightHashLength > 1));
|
||||
const right = !rightSpaceLength || rightEscape;
|
||||
const rightEscapeReplacement = rightEscape ? `${rightEscape} ` : "";
|
||||
if (left || right) {
|
||||
const range = left ?
|
||||
[
|
||||
|
|
@ -49,9 +49,9 @@ module.exports = {
|
|||
range,
|
||||
{
|
||||
"editColumn": 1,
|
||||
"deleteLength": line.length,
|
||||
"deleteCount": line.length,
|
||||
"insertText":
|
||||
`${leftHash} ${content} ${rightEscape}${rightHash}`
|
||||
`${leftHash} ${content} ${rightEscapeReplacement}${rightHash}`
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue