mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Update MD013/line-length with new code_block_line_length parameter (fixes #184).
This commit is contained in:
parent
1d8b9e7e62
commit
64351f73be
6 changed files with 59 additions and 4 deletions
11
lib/md013.js
11
lib/md013.js
|
|
@ -27,10 +27,13 @@ module.exports = {
|
|||
"function": function MD013(params, onError) {
|
||||
const lineLength = params.config.line_length || 80;
|
||||
const headingLineLength = params.config.heading_line_length || lineLength;
|
||||
const codeLineLength = params.config.code_block_line_length || lineLength;
|
||||
const longLineRe =
|
||||
new RegExp(longLineRePrefix + lineLength + longLineRePostfix);
|
||||
const longHeadingLineRe =
|
||||
new RegExp(longLineRePrefix + headingLineLength + longLineRePostfix);
|
||||
const longCodeLineRe =
|
||||
new RegExp(longLineRePrefix + codeLineLength + longLineRePostfix);
|
||||
const codeBlocks = params.config.code_blocks;
|
||||
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
const tables = params.config.tables;
|
||||
|
|
@ -59,8 +62,12 @@ module.exports = {
|
|||
forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence, inTable) => {
|
||||
const lineNumber = lineIndex + 1;
|
||||
const isHeading = includesSorted(headingLineNumbers, lineNumber);
|
||||
const length = isHeading ? headingLineLength : lineLength;
|
||||
const lengthRe = isHeading ? longHeadingLineRe : longLineRe;
|
||||
const length = inCode ?
|
||||
codeLineLength :
|
||||
(isHeading ? headingLineLength : lineLength);
|
||||
const lengthRe = inCode ?
|
||||
longCodeLineRe :
|
||||
(isHeading ? longHeadingLineRe : longLineRe);
|
||||
if ((includeCodeBlocks || !inCode) &&
|
||||
(includeTables || !inTable) &&
|
||||
(includeHeadings || !isHeading) &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue