mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Refactor to remove helpers addErrorContextForLine and blockquotePrefixRe, add micromark helper getBlockQuotePrefixText.
This commit is contained in:
parent
29ebb28f10
commit
5182911acc
6 changed files with 170 additions and 152 deletions
|
@ -18,10 +18,6 @@ const inlineCommentStartRe =
|
|||
/(<!--\s*markdownlint-(disable|enable|capture|restore|disable-file|enable-file|disable-line|disable-next-line|configure-file))(?:\s|-->)/gi;
|
||||
module.exports.inlineCommentStartRe = inlineCommentStartRe;
|
||||
|
||||
// Regular expression for blockquote prefixes
|
||||
const blockquotePrefixRe = /^[>\s]*/;
|
||||
module.exports.blockquotePrefixRe = blockquotePrefixRe;
|
||||
|
||||
// Regular expression for link reference definitions
|
||||
const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])\]:/;
|
||||
module.exports.linkReferenceDefinitionRe = linkReferenceDefinitionRe;
|
||||
|
@ -346,34 +342,6 @@ function addErrorContext(
|
|||
}
|
||||
module.exports.addErrorContext = addErrorContext;
|
||||
|
||||
/**
|
||||
* Adds an error object with context for a construct missing a blank line.
|
||||
*
|
||||
* @param {Object} onError RuleOnError instance.
|
||||
* @param {string[]} lines Lines of Markdown content.
|
||||
* @param {number} lineIndex Line index of line.
|
||||
* @param {number} [lineNumber] Line number for override.
|
||||
* @returns {void}
|
||||
*/
|
||||
function addErrorContextForLine(onError, lines, lineIndex, lineNumber) {
|
||||
const line = lines[lineIndex];
|
||||
// @ts-ignore
|
||||
const quotePrefix = line.match(blockquotePrefixRe)[0].trimEnd();
|
||||
addErrorContext(
|
||||
onError,
|
||||
lineIndex + 1,
|
||||
line.trim(),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
lineNumber,
|
||||
"insertText": `${quotePrefix}\n`
|
||||
}
|
||||
);
|
||||
}
|
||||
module.exports.addErrorContextForLine = addErrorContextForLine;
|
||||
|
||||
/**
|
||||
* Defines a range within a file (start line/column to end line/column, subset of MicromarkToken).
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue