From 29976d097c3526d57ff311f46917aa30bad48c26 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 31 Aug 2015 14:26:50 +0200 Subject: [PATCH] Add en- and disabling multiple rules in one comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: * Disabling more than one rule currently needs multiple HTML comments. Those are often added, after each other. But markdown needs blank lines between HTML to distinguish it, thus when lint-comments were adjacent without black-lines they were ignored. How: * Space-delimit the ruleId’s in `lint disable` and `lint-enable` comments, and toggle each ruleId. --- lib/index.js | 47 +++++++++++++++------- mdast-lint.js | 47 +++++++++++++++------- mdast-lint.min.js | 2 +- test/fixtures/comments-disable-multiple.md | 13 ++++++ test/index.js | 6 +++ 5 files changed, 84 insertions(+), 31 deletions(-) create mode 100644 test/fixtures/comments-disable-multiple.md diff --git a/lib/index.js b/lib/index.js index b2348fdb..ff43058e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -267,29 +267,19 @@ function lint(mdast, options) { } /** - * Handle a new-found marker. + * Handle a rule. * + * @param {VFile} file - Virtual file. * @param {Object} marker - Marker context. - * @param {Object} parser - Parser instance. + * @param {string} type - Type to toggle to. + * @param {*} ruleId - Rule to toggle. */ - function onparse(marker, parser) { - var file = parser.file; + function toggle(file, marker, type, ruleId) { var scope = file.namespace('mdast-lint'); - var attributes = marker.attributes.split(' '); - var type = attributes[0]; - var ruleId = attributes[1]; var markers; var currentState; var previousState; - store(file); - - if (type !== 'disable' && type !== 'enable') { - file.fail('Unknown lint keyword `' + type + '`: use either `\'enable\'` or `\'disable\'`', marker.node); - - return; - } - if (!(ruleId in rules)) { file.fail('Unknown rule: cannot ' + type + ' `\'' + ruleId + '\'`', marker.node); @@ -309,6 +299,33 @@ function lint(mdast, options) { } } + /** + * Handle a new-found marker. + * + * @param {Object} marker - Marker context. + * @param {Object} parser - Parser instance. + */ + function onparse(marker, parser) { + var file = parser.file; + var attributes = marker.attributes.split(' '); + var type = attributes[0]; + var ids = attributes.slice(1); + var length = ids.length; + var index = -1; + + if (type !== 'disable' && type !== 'enable') { + file.fail('Unknown lint keyword `' + type + '`: use either `\'enable\'` or `\'disable\'`', marker.node); + + return; + } + + store(file); + + while (++index < length) { + toggle(file, marker, type, ids[index]); + } + } + mdast.use(zone({ 'name': 'lint', 'onparse': onparse diff --git a/mdast-lint.js b/mdast-lint.js index 2a7b79fd..d93ad312 100644 --- a/mdast-lint.js +++ b/mdast-lint.js @@ -420,29 +420,19 @@ function lint(mdast, options) { } /** - * Handle a new-found marker. + * Handle a rule. * + * @param {VFile} file - Virtual file. * @param {Object} marker - Marker context. - * @param {Object} parser - Parser instance. + * @param {string} type - Type to toggle to. + * @param {*} ruleId - Rule to toggle. */ - function onparse(marker, parser) { - var file = parser.file; + function toggle(file, marker, type, ruleId) { var scope = file.namespace('mdast-lint'); - var attributes = marker.attributes.split(' '); - var type = attributes[0]; - var ruleId = attributes[1]; var markers; var currentState; var previousState; - store(file); - - if (type !== 'disable' && type !== 'enable') { - file.fail('Unknown lint keyword `' + type + '`: use either `\'enable\'` or `\'disable\'`', marker.node); - - return; - } - if (!(ruleId in rules)) { file.fail('Unknown rule: cannot ' + type + ' `\'' + ruleId + '\'`', marker.node); @@ -462,6 +452,33 @@ function lint(mdast, options) { } } + /** + * Handle a new-found marker. + * + * @param {Object} marker - Marker context. + * @param {Object} parser - Parser instance. + */ + function onparse(marker, parser) { + var file = parser.file; + var attributes = marker.attributes.split(' '); + var type = attributes[0]; + var ids = attributes.slice(1); + var length = ids.length; + var index = -1; + + if (type !== 'disable' && type !== 'enable') { + file.fail('Unknown lint keyword `' + type + '`: use either `\'enable\'` or `\'disable\'`', marker.node); + + return; + } + + store(file); + + while (++index < length) { + toggle(file, marker, type, ids[index]); + } + } + mdast.use(zone({ 'name': 'lint', 'onparse': onparse diff --git a/mdast-lint.min.js b/mdast-lint.min.js index a7db9b3a..d26eaf47 100644 --- a/mdast-lint.min.js +++ b/mdast-lint.min.js @@ -1 +1 @@ -!function(b,a){typeof exports==='object'&&typeof module!=='undefined'?module.exports=b():typeof define==='function'&&define.amd?define([],b):(typeof window!=='undefined'?a=window:typeof global!=='undefined'?a=global:typeof self!=='undefined'?a=self:a=this,a.mdastLint=b())}(function(){return function a(b,c,e){function f(d,k){if(!c[d]){if(!b[d]){var i=typeof require=='function'&&require;if(!k&&i)return i(d,!0);if(g)return g(d,!0);var j=new Error("Cannot find module '"+d+"'");throw j.code='MODULE_NOT_FOUND',j}var h=c[d]={exports:{}};b[d][0].call(h.exports,function(c){var a=b[d][1][c];return f(a?a:c)},h,h.exports,a,b,c,e)}return c[d].exports}var g=typeof require=='function'&&require;for(var d=0;da)return;g&&(d.push({start:e,end:a}),g=!1),e=a}var i=h.children[h.children.length-1],d=[],e=0,g=!1,j=b.namespace('mdast-lint').ranges;if(!(b&&b.messages&&b.messages.length))return;c(h,function(b){var c=a.start(b),d=a.end(b);f(c&&c.offset),b.children||f(d&&d.offset)}),e===a.end(i).offset&&(f(),f(b.toString().length-1)),b.messages=b.messages.filter(function(a){var e=j[a.ruleId],g=e&&e.length,f=d.length,i=-1,h,c;a.line||(a.line=1),a.column||(a.column=1),h=b.positionToOffset(a);while(f--)if(d[f].start<=h&&d[f].end>h)return!1;while(--g>i)if(c=e[g],c.position.line0?'Add':'Remove',d=Math.abs(d),d!==0&&g.warn(i+' '+d+' '+f('space',d)+' between blockquote and content',a.start(e.children[0]))):b=c(e)}),h()}var d=b('unist-util-visit'),e=b('mdast-util-to-string'),f=b('plur'),a=b('mdast-util-position');g.exports=h},{'mdast-util-position':62,'mdast-util-to-string':63,plur:65,'unist-util-visit':66}],5:[function(f,i,j){'use strict';function h(j,h,f,k){var i=h.toString();(f==='consistent'||typeof f!=='object')&&(f={}),f.unchecked||(f.unchecked=null),f.checked||(f.checked=null),f.unchecked!==null&&e[f.unchecked]!==!0&&h.fail('Invalid unchecked checkbox marker `'+f.unchecked+"`: use either `'\\t'`, or `' '`"),f.checked!==null&&g[f.checked]!==!0&&h.fail('Invalid checked checkbox marker `'+f.checked+"`: use either `'x'`, or `'X'`"),c(j,'listItem',function(c){var e,k,n,l,g,j,m;if(c.checked!==Boolean(c.checked)||a.generated(c))return;e=c.checked?'checked':'unchecked',k=b(c).offset,n=(c.children.length?b(c.children[0]):d(c)).offset,g=i.slice(k,n).trimRight().slice(0,-1),m=g.charAt(g.length-1),j=f[e],j===null?f[e]=m:m!==j&&(l=k+g.length,h.warn(e.charAt(0).toUpperCase()+e.slice(1)+' checkboxes should use `'+j+'` as a marker',{start:h.offsetToPosition(l-1),end:h.offsetToPosition(l)}))}),k()}var c=f('unist-util-visit'),a=f('mdast-util-position'),b=a.start,d=a.end,g={x:!0,X:!0},e={' ':!0,' ':!0};i.exports=h},{'mdast-util-position':62,'unist-util-visit':66}],6:[function(c,f,h){'use strict';function g(g,c,i,h){var f=c.toString();d(g,'listItem',function(d){var i,g,h;if(d.checked!==Boolean(d.checked)||a.generated(d))return;i=b(d).offset,g=(d.children.length?b(d.children[0]):e(d)).offset;while(/[^\S\n]/.test(f.charAt(g)))g++;if(h=f.slice(i,g),h=h.slice(h.indexOf(']')+1),h.length===1)return;c.warn('Checkboxes should be followed by a single character',{start:c.offsetToPosition(g-h.length+1),end:c.offsetToPosition(g)})}),h()}var d=c('unist-util-visit'),a=c('mdast-util-position'),b=a.start,e=a.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],7:[function(b,g,i){'use strict';function h(i,g,b,j){function k(b){var c=d(b).offset,f=e(b).offset;return a.generated(b)?null:b.lang||/^\s*([~`])\1{2,}/.test(h.slice(c,f))?'fenced':'indented'}var h=g.toString();if(b=typeof b!=='string'||b==='consistent'?null:b,f[b]!==!0){g.fail('Invalid code block style `'+b+"`: use either `'consistent'`, `'fenced'`, or `'indented'`");return}c(i,'code',function(c){var a=k(c);if(!a)return;b?b!==a&&g.warn('Code blocks should be '+b,c):b=a}),j()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=a.start,e=a.end,f={null:!0,fenced:!0,indented:!0};g.exports=h},{'mdast-util-position':62,'unist-util-visit':66}],8:[function(c,e,g){'use strict';function f(c,e,i,h){function f(b){var f=a.start(b).offset,h=a.end(b).offset,c;if(a.generated(b))return;c=g.slice(f,h).match(d)[1],c!==c.toLowerCase()&&e.warn('Do not use upper-case characters in definition labels',b)}var g=e.toString();b(c,'definition',f),b(c,'footnoteDefinition',f),h()}var b=c('unist-util-visit'),a=c('mdast-util-position'),d=/^\s*\[((?:\\[\s\S]|[^\[\]])+)\]/;e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],9:[function(c,e,g){'use strict';function f(c,e,i,h){function f(b){var c=a.start(b).offset,f=a.end(b).offset,h;if(a.generated(b))return;h=g.slice(c,f).match(d)[1],/[ \t\n]{2,}/.test(h)&&e.warn('Do not use consecutive white-space in definition labels',b)}var g=e.toString();b(c,'definition',f),b(c,'footnoteDefinition',f),h()}var b=c('unist-util-visit'),a=c('mdast-util-position'),d=/^\s*\[((?:\\[\s\S]|[^\[\]])+)\]/;e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],10:[function(b,e,g){'use strict';function f(f,e,b,g){if(b=typeof b!=='string'||b==='consistent'?null:b,d[b]!==!0){e.fail('Invalid emphasis marker `'+b+"`: use either `'consistent'`, `'*'`, or `'_'`");return}c(f,'emphasis',function(c){var d=e.toString().charAt(a.start(c).offset);if(a.generated(c))return;b?d!==b&&e.warn('Emphasis should use `'+b+'` as a marker',c):b=d}),g()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d={'*':!0,_:!0,null:!0};e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],11:[function(b,f,h){'use strict';function g(j,g,b,k){var i=g.toString(),h=!1,f=[];typeof b==='object'&&!('length'in b)&&(h=Boolean(b.allowEmpty),b=b.flags),typeof b==='object'&&'length'in b&&(f=String(b).split(',')),c(j,'code',function(b){var c=i.slice(d(b).offset,e(b).offset);if(a.generated(b))return;b.lang?f.length&&f.indexOf(b.lang)===-1&&g.warn('Invalid code-language flag',b):/^\ {0,3}([~`])\1{2,}/.test(c)&&!h&&g.warn('Missing code-language flag',b)}),k()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=a.start,e=a.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],12:[function(c,e,g){'use strict';function f(g,e,c,h){var f=e.toString();if(c=typeof c!=='string'||c==='consistent'?null:c,b[c]!==!0){e.fail('Invalid fenced code marker `'+c+"`: use either `'consistent'`, `` '`' ``, or `'~'`");return}d(g,'code',function(g){var d=f.substr(a.start(g).offset,4);if(a.generated(g))return;if(d=d.trimLeft().charAt(0),b[d]!==!0)return;c?d!==c&&e.warn('Fenced code should use '+c+' as a marker',g):c=d}),h()}var d=c('unist-util-visit'),a=c('mdast-util-position'),b={'`':!0,'~':!0,null:!0};e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],13:[function(c,a,d){'use strict';function b(e,c,a,d){var b=c.extension;a=typeof a==='string'?a:'md',b!==''&&b!==a&&c.warn('Invalid extension: use `'+a+'`'),d()}a.exports=b},{}],14:[function(b,e,g){'use strict';function f(e,f,h,g){var b=null;c(e,function(c){var e=d(c).line;if(c.type==='root'||a.generated(c))return;c.type==='definition'?b!==null&&b>e&&f.warn('Move definitions to the end of the file (after the node at line `'+b+'`)',c):b===null&&(b=e)},!0),g()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=a.start;e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],15:[function(c,a,d){'use strict';function b(e,c,f,d){var a=c.toString(),b=a.length-1;b>0&&a.charAt(b)!=='\n'&&c.warn('Missing newline character at end of file'),d()}a.exports=b},{}],16:[function(a,d,f){'use strict';function e(a,d,f,e){b(a,'heading',function(a){return c.generated(a)?null:(a.depth!==1&&d.warn('First heading level should be `1`',a),!1)}),e()}var b=a('unist-util-visit'),c=a('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],17:[function(b,d,f){'use strict';function e(e,b,g,f){var d=b.toString();c(e,'break',function(c){var e=a.start(c).offset,f=a.end(c).offset;if(a.generated(c))return;d.slice(e,f).length>3&&b.warn('Use two spaces for hard line breaks',c)}),f()}var c=b('unist-util-visit'),a=b('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],18:[function(a,d,f){'use strict';function e(d,e,g,f){var a=null;b(d,'heading',function(b){var d=b.depth;if(c.generated(b))return;a&&d>a+1&&e.warn('Heading levels should increment by one level at a time',b),a=d}),f()}var b=a('unist-util-visit'),c=a('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],19:[function(a,f,h){'use strict';function g(f,g,a,h){a=e.indexOf(a)===-1?null:a,c(f,'heading',function(c){if(d.generated(c))return;a?b(c,a)!==a&&g.warn('Headings should use '+a,c):a=b(c,a)}),h()}var c=a('unist-util-visit'),b=a('mdast-util-heading-style'),d=a('mdast-util-position'),e=['atx','atx-closed','setext'];f.exports=g},{'mdast-util-heading-style':61,'mdast-util-position':62,'unist-util-visit':66}],20:[function(a,b,c){'use strict';b.exports={'no-auto-link-without-protocol':a('./no-auto-link-without-protocol'),'no-literal-urls':a('./no-literal-urls'),'no-consecutive-blank-lines':a('./no-consecutive-blank-lines'),'no-missing-blank-lines':a('./no-missing-blank-lines'),'blockquote-indentation':a('./blockquote-indentation'),'no-blockquote-without-caret':a('./no-blockquote-without-caret'),'code-block-style':a('./code-block-style'),'checkbox-content-indent':a('./checkbox-content-indent'),'checkbox-character-style':a('./checkbox-character-style'),'definition-case':a('./definition-case'),'definition-spacing':a('./definition-spacing'),'no-emphasis-as-heading':a('./no-emphasis-as-heading'),'emphasis-marker':a('./emphasis-marker'),'fenced-code-flag':a('./fenced-code-flag'),'fenced-code-marker':a('./fenced-code-marker'),'file-extension':a('./file-extension'),'final-newline':a('./final-newline'),'no-file-name-articles':a('./no-file-name-articles'),'no-file-name-consecutive-dashes':a('./no-file-name-consecutive-dashes'),'no-file-name-irregular-characters':a('./no-file-name-irregular-characters'),'no-file-name-mixed-case':a('./no-file-name-mixed-case'),'no-file-name-outer-dashes':a('./no-file-name-outer-dashes'),'final-definition':a('./final-definition'),'hard-break-spaces':a('./hard-break-spaces'),'heading-increment':a('./heading-increment'),'no-heading-content-indent':a('./no-heading-content-indent'),'no-heading-indent':a('./no-heading-indent'),'first-heading-level':a('./first-heading-level'),'maximum-heading-length':a('./maximum-heading-length'),'no-heading-punctuation':a('./no-heading-punctuation'),'heading-style':a('./heading-style'),'no-multiple-toplevel-headings':a('./no-multiple-toplevel-headings'),'no-duplicate-headings':a('./no-duplicate-headings'),'no-duplicate-definitions':a('./no-duplicate-definitions'),'no-html':a('./no-html'),'no-inline-padding':a('./no-inline-padding'),'maximum-line-length':a('./maximum-line-length'),'link-title-style':a('./link-title-style'),'list-item-bullet-indent':a('./list-item-bullet-indent'),'list-item-content-indent':a('./list-item-content-indent'),'list-item-indent':a('./list-item-indent'),'list-item-spacing':a('./list-item-spacing'),'ordered-list-marker-style':a('./ordered-list-marker-style'),'ordered-list-marker-value':a('./ordered-list-marker-value'),'no-shortcut-reference-image':a('./no-shortcut-reference-image'),'no-shortcut-reference-link':a('./no-shortcut-reference-link'),'rule-style':a('./rule-style'),'no-shell-dollars':a('./no-shell-dollars'),'strong-marker':a('./strong-marker'),'no-table-indentation':a('./no-table-indentation'),'table-pipe-alignment':a('./table-pipe-alignment'),'table-cell-padding':a('./table-cell-padding'),'table-pipes':a('./table-pipes'),'no-tabs':a('./no-tabs'),'unordered-list-marker-style':a('./unordered-list-marker-style')}},{'./blockquote-indentation':4,'./checkbox-character-style':5,'./checkbox-content-indent':6,'./code-block-style':7,'./definition-case':8,'./definition-spacing':9,'./emphasis-marker':10,'./fenced-code-flag':11,'./fenced-code-marker':12,'./file-extension':13,'./final-definition':14,'./final-newline':15,'./first-heading-level':16,'./hard-break-spaces':17,'./heading-increment':18,'./heading-style':19,'./link-title-style':21,'./list-item-bullet-indent':22,'./list-item-content-indent':23,'./list-item-indent':24,'./list-item-spacing':25,'./maximum-heading-length':26,'./maximum-line-length':27,'./no-auto-link-without-protocol':28,'./no-blockquote-without-caret':29,'./no-consecutive-blank-lines':30,'./no-duplicate-definitions':31,'./no-duplicate-headings':32,'./no-emphasis-as-heading':33,'./no-file-name-articles':34,'./no-file-name-consecutive-dashes':35,'./no-file-name-irregular-characters':36,'./no-file-name-mixed-case':37,'./no-file-name-outer-dashes':38,'./no-heading-content-indent':39,'./no-heading-indent':40,'./no-heading-punctuation':41,'./no-html':42,'./no-inline-padding':43,'./no-literal-urls':44,'./no-missing-blank-lines':45,'./no-multiple-toplevel-headings':46,'./no-shell-dollars':47,'./no-shortcut-reference-image':48,'./no-shortcut-reference-link':49,'./no-table-indentation':50,'./no-tabs':51,'./ordered-list-marker-style':52,'./ordered-list-marker-value':53,'./rule-style':54,'./strong-marker':55,'./table-cell-padding':56,'./table-pipe-alignment':57,'./table-pipes':58,'./unordered-list-marker-style':59}],21:[function(d,f,h){'use strict';function g(g,f,d,j){function h(h){var a=e(h).offset-1,g,j;if(b.generated(h))return;h.type!=='definition'&&a--;while(a){if(g=i.charAt(a),!/\s/.test(g))break;a--}if(!(g in c))return;d?d!==g&&(j=f.offsetToPosition(a+1),f.warn(d===')'?'Titles should use `()` as a quote':'Titles should use `'+d+'` as a quote',j)):d=g}var i=f.toString();if(d=typeof d!=='string'||d==='consistent'?null:d,(d==='()'||d==='(')&&(d=')'),c[d]!==!0){f.fail('Invalid link title style marker `'+d+"`: use either `'consistent'`, `'\"'`, `'\\''`, or `'()'`");return}a(g,'link',h),a(g,'image',h),a(g,'definition',h),j()}var a=d('unist-util-visit'),b=d('mdast-util-position'),c={'"':!0,"'":!0,')':!0,null:!0},e=b.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],22:[function(b,f,h){'use strict';function g(g,b,i,h){var f=b.toString();d(g,'list',function(d){var g=d.children;g.forEach(function(j){var i=j.children[0],g=a(j).offset,k=a(i).offset,h;if(c.generated(d))return;h=f.slice(g,k).match(/^\s*/)[0].length,h!==0&&(g=a(i),b.warn('Incorrect indentation before bullet: remove '+h+' '+e('space',h),{line:g.line,column:g.column-h}))})}),h()}var d=b('unist-util-visit'),c=b('mdast-util-position'),e=b('plur'),a=c.start;f.exports=g},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],23:[function(a,f,h){'use strict';function g(g,a,i,h){var f=a.toString();d(g,'listItem',function(d){var g;d.children.forEach(function(l,n){var j=c(l),h=j.column,k,i,m;if(b.generated(l))return;if(n===0){if(Boolean(d.checked)===d.checked){k=j.offset;while(f.charAt(k)!=='[')k--;h-=j.offset-k}g=h;return}h!==g&&(i=g-h,m=i>0?'add':'remove',i=Math.abs(i),a.warn('Don’t use mixed indentation for children, '+m+' '+i+' '+e('space',i),{line:c(l).line,column:h}))})}),h()}var d=a('unist-util-visit'),b=a('mdast-util-position'),e=a('plur'),c=b.start;f.exports=g},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],24:[function(b,g,i){'use strict';function h(i,g,b,j){var h=g.toString();if(b=typeof b!=='string'?'tab-size':b,f[b]!==!0){g.fail('Invalid list-item indent style `'+b+"`: use either `'tab-size'`, `'space'`, or `'mixed'`");return}d(i,'list',function(d){var f=d.children,i=d.ordered,j=d.start||1;if(c.generated(d))return;f.forEach(function(r,s){var m=r.children[0],l=i?String(j+s).length+1:1,n=Math.ceil(l/4)*4,o=a(r).offset,p=a(m).offset,f,k,c,q;f=h.slice(o,p),f=f.replace(/\[[x ]?\]\s*$/i,''),b==='tab-size'?k=n:b==='space'?k=l+1:k=d.loose?n:l+1,f.length!==k&&(c=k-f.length,q=c>0?'add':'remove',c=Math.abs(c),g.warn('Incorrect list-item indent: '+q+' '+c+' '+e('space',c),a(m)))})}),j()}var d=b('unist-util-visit'),c=b('mdast-util-position'),e=b('plur'),a=c.start,f={'tab-size':!0,mixed:!0,space:!0};g.exports=h},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],25:[function(d,f,h){'use strict';function g(d,f,h,g){e(d,'list',function(g){var d=g.children,e=!0,h=b(g).column,i;if(a.generated(g))return;d.forEach(function(h){var a=h.children,d=a[0],f=a[a.length-1],g=c(f).line-b(d).line>0;g&&(e=!1)}),i=e?'tight':'loose',d.forEach(function(g,k){var a=d[k+1],j=c(g).column>h;if(!a)return;j!==e&&f.warn('List item should be '+i+', isn’t',{start:c(g),end:b(a)})})}),g()}var e=d('unist-util-visit'),a=d('mdast-util-position'),b=a.start,c=a.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],26:[function(a,e,g){'use strict';function f(e,f,a,g){a=isNaN(a)||typeof a!=='number'?60:a,b(e,'heading',function(b){if(d.generated(b))return;c(b).length>a&&f.warn('Use headings shorter than `'+a+'`',b)}),g()}var b=a('unist-util-visit'),c=a('mdast-util-to-string'),d=a('mdast-util-position');e.exports=f},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],27:[function(e,f,i){'use strict';function g(a){return a.type==='heading'||a.type==='table'||a.type==='code'||a.type==='definition'}function h(k,l,j,q){function p(a,b){a--;while(++ae||h.columne&&l.warn('Line must be at most '+e+' characters',{line:h+1,column:i+1});q()}var b=e('unist-util-visit'),a=e('mdast-util-position'),c=a.start,d=a.end;f.exports=h},{'mdast-util-position':62,'unist-util-visit':66}],28:[function(d,j,k){'use strict';function i(a){return g.test(f(a))}function h(d,f,h,g){e(d,'link',function(d){var e=c(d.children[0]).column,g=b(d.children[d.children.length-1]).column,h=c(d).column,j=b(d).column;if(a.generated(d))return;h===e-1&&j===g+1&&!i(d)&&f.warn('All automatic links must start with a protocol',d)}),g()}var e=d('unist-util-visit'),f=d('mdast-util-to-string'),a=d('mdast-util-position'),c=a.start,b=a.end,g=/^[a-z][a-z+.-]+:\/?/i;j.exports=h},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],29:[function(b,d,f){'use strict';function e(f,b,h,g){var d=b.toString(),e=d.length;c(f,'blockquote',function(c){var g=a.start(c).line,f=c.position&&c.position.indent;if(a.generated(c)||!f||!f.length)return;f.forEach(function(h,i){var a,c=g+i+1,f=b.positionToOffset({line:c,column:h})-1;while(++f')return;if(a!==' '&&a!==' ')break}b.warn('Missing caret in blockquote',{line:c,column:h})})}),g()}var c=b('unist-util-visit'),a=b('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],30:[function(b,f,h){'use strict';function g(f,g,i,h){function b(e,b,f){var a=b.line-e.line,c=a>0?'before':'after';a=Math.abs(a)-f,a>0&&g.warn('Remove '+a+' '+d('line',a)+' '+c+' node',b)}c(f,function(d){var c=d.children;if(a.generated(d))return;c&&c[0]&&(b(a.start(d),a.start(c[0]),0),c.forEach(function(f,h){var d=c[h-1],g=e;if(!d||a.generated(d)||a.generated(f))return;(d.type==='list'&&f.type==='list'||f.type==='code'&&d.type==='list'&&!f.lang)&&g++,b(a.end(d),a.start(f),g)}),b(a.end(d),a.end(c[c.length-1]),1))}),h()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=b('plur'),e=2;f.exports=g},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],31:[function(c,d,f){'use strict';function e(d,f,h,g){function e(b){var d=c[b.identifier],e;if(a.generated(b))return;d&&d.type&&(e=a.start(d),f.warn('Do not use definitions with the same identifier ('+e.line+':'+e.column+')',b)),c[b.identifier]=b}var c={};b(d,'definition',e),b(d,'footnoteDefinition',e),g()}var a=c('mdast-util-position'),b=c('unist-util-visit');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],32:[function(a,e,g){'use strict';function f(e,f,h,g){var a={};c(e,'heading',function(c){var g=d(c).toUpperCase(),e=a[g],h;if(b.generated(c))return;e&&e.type==='heading'&&(h=b.start(e),f.warn('Do not use headings with similar content ('+h.line+':'+h.column+')',c)),a[g]=c}),g()}var b=a('mdast-util-position'),c=a('unist-util-visit'),d=a('mdast-util-to-string');e.exports=f},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],33:[function(a,e,g){'use strict';function f(a,e,g,f){b(a,'paragraph',function(b,j,k){var f=b.children,a=f[0],g=k.children[j-1],h=k.children[j+1],i;if(d.generated(b))return;(!g||g.type!=='heading')&&h&&h.type==='paragraph'&&f.length===1&&(a.type==='emphasis'||a.type==='strong')&&(i=c(a),i.charAt(i.length-1)===':'&&e.warn('Don’t use emphasis to introduce a section, use a heading',b))}),f()}var b=a('unist-util-visit'),c=a('mdast-util-to-string'),d=a('mdast-util-position');e.exports=f},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],34:[function(c,a,d){'use strict';function b(d,a,e,c){var b=a.filename&&a.filename.match(/^(the|an?)\b/i);b&&a.warn('Do not start file names with `'+b[0]+'`'),c()}a.exports=b},{}],35:[function(c,a,d){'use strict';function b(c,a,d,b){a.filename&&/-{2,}/.test(a.filename)&&a.warn('Do not use consecutive dashes in a file name'),b()}a.exports=b},{}],36:[function(c,a,d){'use strict';function b(d,a,e,c){var b=a.filename&&a.filename.match(/[^.a-zA-Z0-9-]/);b&&a.warn('Do not use `'+b[0]+'` in a file name'),c()}a.exports=b},{}],37:[function(c,a,d){'use strict';function b(d,b,e,c){var a=b.filename;a&&!(a===a.toLowerCase()||a===a.toUpperCase())&&b.warn('Do not mix casing in file names'),c()}a.exports=b},{}],38:[function(c,a,d){'use strict';function b(c,a,d,b){a.filename&&/^-|-$/.test(a.filename)&&a.warn('Do not use initial or final dashes in a file name'),b()}a.exports=b},{}],39:[function(c,i,j){'use strict';function h(i,c,k,j){var h=c.toString();f(i,'heading',function(i){var n=i.depth,k=i.children,l=g(i,'atx'),m,o,f,p,j;if(b.generated(i))return;if(l==='atx'||l==='atx-closed'){m=a(i),j=m.offset;while(h.charAt(j)!=='#')j++;j=n+(j-m.offset),f=a(k[0]).column-m.column-1-j,f&&(p=f>0?'Remove':'Add',f=Math.abs(f),c.warn(p+' '+f+' '+e('space',f)+' before this heading’s content',a(k[0])))}l==='atx-closed'&&(o=d(k[k.length-1]),f=d(i).column-o.column-1-n,f&&c.warn('Remove '+f+' '+e('space',f)+' after this heading’s content',o))}),j()}var f=c('unist-util-visit'),g=c('mdast-util-heading-style'),e=c('plur'),b=c('mdast-util-position'),a=b.start,d=b.end;i.exports=h},{'mdast-util-heading-style':61,'mdast-util-position':62,plur:65,'unist-util-visit':66}],40:[function(a,f,h){'use strict';function g(h,f,j,i){var a=f.toString(),g=a.length;c(h,'heading',function(l){var h=e(l),j=h.offset,i=j-1,k,c;if(b.generated(l))return;while(++i1&&b.warn('Do not indent table rows',c)})}),e()}var c=b('unist-util-visit'),a=b('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],51:[function(c,a,d){'use strict';function b(f,b,g,e){var c=b.toString(),a=-1,d=c.length;while(++ac)return{line:b+1,column:c-(a[b-1]||0)+1};return{}}return b}function h(i,c){var e=String(c).split('\n'),h;if(!c||typeof c.contents!=='string')throw new Error('Missing `file` for mdast-range');e=d(e),h=f(e),c.offsetToPosition=g(e),c.positionToOffset=h,b(i,function(c){var b=c.position;b&&b.start&&a(b.start,h),b&&b.end&&a(b.end,h)})}function i(){return h}var b=e('unist-util-visit');c.exports=i},{'unist-util-visit':66}],61:[function(d,b,e){'use strict';function a(b,a){return b<3?'atx':a==='atx'||a==='setext'?a:null}function c(b,g){var c=b.children[b.children.length-1],d=b.depth,e=b&&b.position&&b.position.end,f=c&&c.position&&c.position.end;return e?c?f.line+1===e.line?'setext':f.column+d'+'\\s*'+')')}function f(b){var a={};return b.replace(e,function(g,c,d,e,f){var b=d||e||f||'';return b==='true'||b===''?b=!0:b==='false'?b=!1:isNaN(b)||(b=Number(b)),a[c]=b,''}),a}function a(a,b){function e(e,i){var g=e.value,c,h;return e.type!=='html'?null:(c=g.match(d),!c||c[1].length!==g.length||c[2]!==a.name?null:(h={type:c[3]||'marker',attributes:c[4]||'',parameters:f(c[4]||''),node:e},b&&b(h,i),h))}var c=a.name,d=g(c);return e}function b(e,b){var c=b.onparse,d=a(b,function(a,b){a.type==='marker'&&c(a,b)});return function(){var a=e.apply(this,arguments);return d(a,this),a}}function i(e,b){var c=b.onstringify,d=a(b,function(a,b){a.type==='marker'&&c(a,b)});return function(a){return d(a,this),e.apply(this,arguments)}}function j(i){function l(l,i,m){var a=k(l),d=a&&a.type;e&&m===e&&(d==='start'&&f++,d==='end'&&f--,d==='end'&&f===0?(b=j(g,b,a,{start:i-b.length-1,end:i,parent:e}),b&&c.apply(e.children,[h,i+1].concat(b)),g=null,e=null,h=null,b=[]):b.push(l)),!e&&d==='start'&&(f=1,h=i,g=a,e=m)}var j=i.onrun,k=a(i),b=[],g=null,e=null,f=0,h;return function(a){d(a,l)}}function k(c,a){var d=c.Parser.prototype.blockTokenizers,e=c.Parser.prototype.inlineTokenizers,f=c.Compiler.prototype;return a.onparse&&(d.html=b(d.html,a),e.tag=b(e.tag,a)),a.onstringify&&(f.html=i(f.html,a)),a.onrun?j(a):null}function l(a){if(!(a&&a.name))throw new Error('Missing `name` in `options`');return function(b){return k(b,a)}}var d=h('unist-util-visit'),c=[].splice,e=new RegExp('\\s*([-a-z09_]+)(?:=(?:"((?:\\\\[\\s\\S]|[^"])+)"|\'((?:\\\\[\\s\\S]|[^\'])+)\'|((?:\\\\[\\s\\S]|[^"\'\\s])+)))?\\s*','gi');m.exports=l},{'unist-util-visit':66}],65:[function(b,a,c){'use strict';a.exports=function(a,b,c){return typeof b==='number'&&(c=b,b=(a.replace(/(?:s|x|z|ch|sh)$/i,'$&e').replace(/y$/i,'ie')+'s').replace(/i?e?s$/i,function(b){var c=a.slice(-1)===a.slice(-1).toLowerCase();return c?b.toLowerCase():b.toUpperCase()})),c===1?a:b}},{}],66:[function(e,a,f){'use strict';function b(b,d){var a=-1,c=b.length;while(++ac)if(d(b[a],a)===!1)return!1;return!0}function d(i,a,d,f){var g,e,h;typeof a==='function'&&(f=d,d=a,a=null),g=f?c:b,h=function(a,b){return g(a,function(a,c){return a&&e(a,c,b)})},e=function(b,c,f){var e;return c=c||(f?0:null),(!a||b.type===a)&&(e=d(b,c,f||null)),b.children&&e!==!1?h(b.children,b):e},e(i)}a.exports=d},{}],67:[function(e,b,f){'use strict';function a(b,c,a){return(b[a]||0)-(c[a]||0)}function c(b,c){return a(b,c,'line')||a(b,c,'column')||-1}function d(a){return a.messages.sort(c),a}b.exports=d},{}]},{},[1])(1)}) +!function(b,a){typeof exports==='object'&&typeof module!=='undefined'?module.exports=b():typeof define==='function'&&define.amd?define([],b):(typeof window!=='undefined'?a=window:typeof global!=='undefined'?a=global:typeof self!=='undefined'?a=self:a=this,a.mdastLint=b())}(function(){return function a(b,c,e){function f(d,k){if(!c[d]){if(!b[d]){var i=typeof require=='function'&&require;if(!k&&i)return i(d,!0);if(g)return g(d,!0);var j=new Error("Cannot find module '"+d+"'");throw j.code='MODULE_NOT_FOUND',j}var h=c[d]={exports:{}};b[d][0].call(h.exports,function(c){var a=b[d][1][c];return f(a?a:c)},h,h.exports,a,b,c,e)}return c[d].exports}var g=typeof require=='function'&&require;for(var d=0;da)return;g&&(d.push({start:e,end:a}),g=!1),e=a}var i=h.children[h.children.length-1],d=[],e=0,g=!1,j=b.namespace('mdast-lint').ranges;if(!(b&&b.messages&&b.messages.length))return;c(h,function(b){var c=a.start(b),d=a.end(b);f(c&&c.offset),b.children||f(d&&d.offset)}),e===a.end(i).offset&&(f(),f(b.toString().length-1)),b.messages=b.messages.filter(function(a){var e=j[a.ruleId],g=e&&e.length,f=d.length,i=-1,h,c;a.line||(a.line=1),a.column||(a.column=1),h=b.positionToOffset(a);while(f--)if(d[f].start<=h&&d[f].end>h)return!1;while(--g>i)if(c=e[g],c.position.line0?'Add':'Remove',d=Math.abs(d),d!==0&&g.warn(i+' '+d+' '+f('space',d)+' between blockquote and content',a.start(e.children[0]))):b=c(e)}),h()}var d=b('unist-util-visit'),e=b('mdast-util-to-string'),f=b('plur'),a=b('mdast-util-position');g.exports=h},{'mdast-util-position':62,'mdast-util-to-string':63,plur:65,'unist-util-visit':66}],5:[function(f,i,j){'use strict';function h(j,h,f,k){var i=h.toString();(f==='consistent'||typeof f!=='object')&&(f={}),f.unchecked||(f.unchecked=null),f.checked||(f.checked=null),f.unchecked!==null&&e[f.unchecked]!==!0&&h.fail('Invalid unchecked checkbox marker `'+f.unchecked+"`: use either `'\\t'`, or `' '`"),f.checked!==null&&g[f.checked]!==!0&&h.fail('Invalid checked checkbox marker `'+f.checked+"`: use either `'x'`, or `'X'`"),c(j,'listItem',function(c){var e,k,n,l,g,j,m;if(c.checked!==Boolean(c.checked)||a.generated(c))return;e=c.checked?'checked':'unchecked',k=b(c).offset,n=(c.children.length?b(c.children[0]):d(c)).offset,g=i.slice(k,n).trimRight().slice(0,-1),m=g.charAt(g.length-1),j=f[e],j===null?f[e]=m:m!==j&&(l=k+g.length,h.warn(e.charAt(0).toUpperCase()+e.slice(1)+' checkboxes should use `'+j+'` as a marker',{start:h.offsetToPosition(l-1),end:h.offsetToPosition(l)}))}),k()}var c=f('unist-util-visit'),a=f('mdast-util-position'),b=a.start,d=a.end,g={x:!0,X:!0},e={' ':!0,' ':!0};i.exports=h},{'mdast-util-position':62,'unist-util-visit':66}],6:[function(c,f,h){'use strict';function g(g,c,i,h){var f=c.toString();d(g,'listItem',function(d){var i,g,h;if(d.checked!==Boolean(d.checked)||a.generated(d))return;i=b(d).offset,g=(d.children.length?b(d.children[0]):e(d)).offset;while(/[^\S\n]/.test(f.charAt(g)))g++;if(h=f.slice(i,g),h=h.slice(h.indexOf(']')+1),h.length===1)return;c.warn('Checkboxes should be followed by a single character',{start:c.offsetToPosition(g-h.length+1),end:c.offsetToPosition(g)})}),h()}var d=c('unist-util-visit'),a=c('mdast-util-position'),b=a.start,e=a.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],7:[function(b,g,i){'use strict';function h(i,g,b,j){function k(b){var c=d(b).offset,f=e(b).offset;return a.generated(b)?null:b.lang||/^\s*([~`])\1{2,}/.test(h.slice(c,f))?'fenced':'indented'}var h=g.toString();if(b=typeof b!=='string'||b==='consistent'?null:b,f[b]!==!0){g.fail('Invalid code block style `'+b+"`: use either `'consistent'`, `'fenced'`, or `'indented'`");return}c(i,'code',function(c){var a=k(c);if(!a)return;b?b!==a&&g.warn('Code blocks should be '+b,c):b=a}),j()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=a.start,e=a.end,f={null:!0,fenced:!0,indented:!0};g.exports=h},{'mdast-util-position':62,'unist-util-visit':66}],8:[function(c,e,g){'use strict';function f(c,e,i,h){function f(b){var f=a.start(b).offset,h=a.end(b).offset,c;if(a.generated(b))return;c=g.slice(f,h).match(d)[1],c!==c.toLowerCase()&&e.warn('Do not use upper-case characters in definition labels',b)}var g=e.toString();b(c,'definition',f),b(c,'footnoteDefinition',f),h()}var b=c('unist-util-visit'),a=c('mdast-util-position'),d=/^\s*\[((?:\\[\s\S]|[^\[\]])+)\]/;e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],9:[function(c,e,g){'use strict';function f(c,e,i,h){function f(b){var c=a.start(b).offset,f=a.end(b).offset,h;if(a.generated(b))return;h=g.slice(c,f).match(d)[1],/[ \t\n]{2,}/.test(h)&&e.warn('Do not use consecutive white-space in definition labels',b)}var g=e.toString();b(c,'definition',f),b(c,'footnoteDefinition',f),h()}var b=c('unist-util-visit'),a=c('mdast-util-position'),d=/^\s*\[((?:\\[\s\S]|[^\[\]])+)\]/;e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],10:[function(b,e,g){'use strict';function f(f,e,b,g){if(b=typeof b!=='string'||b==='consistent'?null:b,d[b]!==!0){e.fail('Invalid emphasis marker `'+b+"`: use either `'consistent'`, `'*'`, or `'_'`");return}c(f,'emphasis',function(c){var d=e.toString().charAt(a.start(c).offset);if(a.generated(c))return;b?d!==b&&e.warn('Emphasis should use `'+b+'` as a marker',c):b=d}),g()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d={'*':!0,_:!0,null:!0};e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],11:[function(b,f,h){'use strict';function g(j,g,b,k){var i=g.toString(),h=!1,f=[];typeof b==='object'&&!('length'in b)&&(h=Boolean(b.allowEmpty),b=b.flags),typeof b==='object'&&'length'in b&&(f=String(b).split(',')),c(j,'code',function(b){var c=i.slice(d(b).offset,e(b).offset);if(a.generated(b))return;b.lang?f.length&&f.indexOf(b.lang)===-1&&g.warn('Invalid code-language flag',b):/^\ {0,3}([~`])\1{2,}/.test(c)&&!h&&g.warn('Missing code-language flag',b)}),k()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=a.start,e=a.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],12:[function(c,e,g){'use strict';function f(g,e,c,h){var f=e.toString();if(c=typeof c!=='string'||c==='consistent'?null:c,b[c]!==!0){e.fail('Invalid fenced code marker `'+c+"`: use either `'consistent'`, `` '`' ``, or `'~'`");return}d(g,'code',function(g){var d=f.substr(a.start(g).offset,4);if(a.generated(g))return;if(d=d.trimLeft().charAt(0),b[d]!==!0)return;c?d!==c&&e.warn('Fenced code should use '+c+' as a marker',g):c=d}),h()}var d=c('unist-util-visit'),a=c('mdast-util-position'),b={'`':!0,'~':!0,null:!0};e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],13:[function(c,a,d){'use strict';function b(e,c,a,d){var b=c.extension;a=typeof a==='string'?a:'md',b!==''&&b!==a&&c.warn('Invalid extension: use `'+a+'`'),d()}a.exports=b},{}],14:[function(b,e,g){'use strict';function f(e,f,h,g){var b=null;c(e,function(c){var e=d(c).line;if(c.type==='root'||a.generated(c))return;c.type==='definition'?b!==null&&b>e&&f.warn('Move definitions to the end of the file (after the node at line `'+b+'`)',c):b===null&&(b=e)},!0),g()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=a.start;e.exports=f},{'mdast-util-position':62,'unist-util-visit':66}],15:[function(c,a,d){'use strict';function b(e,c,f,d){var a=c.toString(),b=a.length-1;b>0&&a.charAt(b)!=='\n'&&c.warn('Missing newline character at end of file'),d()}a.exports=b},{}],16:[function(a,d,f){'use strict';function e(a,d,f,e){b(a,'heading',function(a){return c.generated(a)?null:(a.depth!==1&&d.warn('First heading level should be `1`',a),!1)}),e()}var b=a('unist-util-visit'),c=a('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],17:[function(b,d,f){'use strict';function e(e,b,g,f){var d=b.toString();c(e,'break',function(c){var e=a.start(c).offset,f=a.end(c).offset;if(a.generated(c))return;d.slice(e,f).length>3&&b.warn('Use two spaces for hard line breaks',c)}),f()}var c=b('unist-util-visit'),a=b('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],18:[function(a,d,f){'use strict';function e(d,e,g,f){var a=null;b(d,'heading',function(b){var d=b.depth;if(c.generated(b))return;a&&d>a+1&&e.warn('Heading levels should increment by one level at a time',b),a=d}),f()}var b=a('unist-util-visit'),c=a('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],19:[function(a,f,h){'use strict';function g(f,g,a,h){a=e.indexOf(a)===-1?null:a,c(f,'heading',function(c){if(d.generated(c))return;a?b(c,a)!==a&&g.warn('Headings should use '+a,c):a=b(c,a)}),h()}var c=a('unist-util-visit'),b=a('mdast-util-heading-style'),d=a('mdast-util-position'),e=['atx','atx-closed','setext'];f.exports=g},{'mdast-util-heading-style':61,'mdast-util-position':62,'unist-util-visit':66}],20:[function(a,b,c){'use strict';b.exports={'no-auto-link-without-protocol':a('./no-auto-link-without-protocol'),'no-literal-urls':a('./no-literal-urls'),'no-consecutive-blank-lines':a('./no-consecutive-blank-lines'),'no-missing-blank-lines':a('./no-missing-blank-lines'),'blockquote-indentation':a('./blockquote-indentation'),'no-blockquote-without-caret':a('./no-blockquote-without-caret'),'code-block-style':a('./code-block-style'),'checkbox-content-indent':a('./checkbox-content-indent'),'checkbox-character-style':a('./checkbox-character-style'),'definition-case':a('./definition-case'),'definition-spacing':a('./definition-spacing'),'no-emphasis-as-heading':a('./no-emphasis-as-heading'),'emphasis-marker':a('./emphasis-marker'),'fenced-code-flag':a('./fenced-code-flag'),'fenced-code-marker':a('./fenced-code-marker'),'file-extension':a('./file-extension'),'final-newline':a('./final-newline'),'no-file-name-articles':a('./no-file-name-articles'),'no-file-name-consecutive-dashes':a('./no-file-name-consecutive-dashes'),'no-file-name-irregular-characters':a('./no-file-name-irregular-characters'),'no-file-name-mixed-case':a('./no-file-name-mixed-case'),'no-file-name-outer-dashes':a('./no-file-name-outer-dashes'),'final-definition':a('./final-definition'),'hard-break-spaces':a('./hard-break-spaces'),'heading-increment':a('./heading-increment'),'no-heading-content-indent':a('./no-heading-content-indent'),'no-heading-indent':a('./no-heading-indent'),'first-heading-level':a('./first-heading-level'),'maximum-heading-length':a('./maximum-heading-length'),'no-heading-punctuation':a('./no-heading-punctuation'),'heading-style':a('./heading-style'),'no-multiple-toplevel-headings':a('./no-multiple-toplevel-headings'),'no-duplicate-headings':a('./no-duplicate-headings'),'no-duplicate-definitions':a('./no-duplicate-definitions'),'no-html':a('./no-html'),'no-inline-padding':a('./no-inline-padding'),'maximum-line-length':a('./maximum-line-length'),'link-title-style':a('./link-title-style'),'list-item-bullet-indent':a('./list-item-bullet-indent'),'list-item-content-indent':a('./list-item-content-indent'),'list-item-indent':a('./list-item-indent'),'list-item-spacing':a('./list-item-spacing'),'ordered-list-marker-style':a('./ordered-list-marker-style'),'ordered-list-marker-value':a('./ordered-list-marker-value'),'no-shortcut-reference-image':a('./no-shortcut-reference-image'),'no-shortcut-reference-link':a('./no-shortcut-reference-link'),'rule-style':a('./rule-style'),'no-shell-dollars':a('./no-shell-dollars'),'strong-marker':a('./strong-marker'),'no-table-indentation':a('./no-table-indentation'),'table-pipe-alignment':a('./table-pipe-alignment'),'table-cell-padding':a('./table-cell-padding'),'table-pipes':a('./table-pipes'),'no-tabs':a('./no-tabs'),'unordered-list-marker-style':a('./unordered-list-marker-style')}},{'./blockquote-indentation':4,'./checkbox-character-style':5,'./checkbox-content-indent':6,'./code-block-style':7,'./definition-case':8,'./definition-spacing':9,'./emphasis-marker':10,'./fenced-code-flag':11,'./fenced-code-marker':12,'./file-extension':13,'./final-definition':14,'./final-newline':15,'./first-heading-level':16,'./hard-break-spaces':17,'./heading-increment':18,'./heading-style':19,'./link-title-style':21,'./list-item-bullet-indent':22,'./list-item-content-indent':23,'./list-item-indent':24,'./list-item-spacing':25,'./maximum-heading-length':26,'./maximum-line-length':27,'./no-auto-link-without-protocol':28,'./no-blockquote-without-caret':29,'./no-consecutive-blank-lines':30,'./no-duplicate-definitions':31,'./no-duplicate-headings':32,'./no-emphasis-as-heading':33,'./no-file-name-articles':34,'./no-file-name-consecutive-dashes':35,'./no-file-name-irregular-characters':36,'./no-file-name-mixed-case':37,'./no-file-name-outer-dashes':38,'./no-heading-content-indent':39,'./no-heading-indent':40,'./no-heading-punctuation':41,'./no-html':42,'./no-inline-padding':43,'./no-literal-urls':44,'./no-missing-blank-lines':45,'./no-multiple-toplevel-headings':46,'./no-shell-dollars':47,'./no-shortcut-reference-image':48,'./no-shortcut-reference-link':49,'./no-table-indentation':50,'./no-tabs':51,'./ordered-list-marker-style':52,'./ordered-list-marker-value':53,'./rule-style':54,'./strong-marker':55,'./table-cell-padding':56,'./table-pipe-alignment':57,'./table-pipes':58,'./unordered-list-marker-style':59}],21:[function(d,f,h){'use strict';function g(g,f,d,j){function h(h){var a=e(h).offset-1,g,j;if(b.generated(h))return;h.type!=='definition'&&a--;while(a){if(g=i.charAt(a),!/\s/.test(g))break;a--}if(!(g in c))return;d?d!==g&&(j=f.offsetToPosition(a+1),f.warn(d===')'?'Titles should use `()` as a quote':'Titles should use `'+d+'` as a quote',j)):d=g}var i=f.toString();if(d=typeof d!=='string'||d==='consistent'?null:d,(d==='()'||d==='(')&&(d=')'),c[d]!==!0){f.fail('Invalid link title style marker `'+d+"`: use either `'consistent'`, `'\"'`, `'\\''`, or `'()'`");return}a(g,'link',h),a(g,'image',h),a(g,'definition',h),j()}var a=d('unist-util-visit'),b=d('mdast-util-position'),c={'"':!0,"'":!0,')':!0,null:!0},e=b.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],22:[function(b,f,h){'use strict';function g(g,b,i,h){var f=b.toString();d(g,'list',function(d){var g=d.children;g.forEach(function(j){var i=j.children[0],g=a(j).offset,k=a(i).offset,h;if(c.generated(d))return;h=f.slice(g,k).match(/^\s*/)[0].length,h!==0&&(g=a(i),b.warn('Incorrect indentation before bullet: remove '+h+' '+e('space',h),{line:g.line,column:g.column-h}))})}),h()}var d=b('unist-util-visit'),c=b('mdast-util-position'),e=b('plur'),a=c.start;f.exports=g},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],23:[function(a,f,h){'use strict';function g(g,a,i,h){var f=a.toString();d(g,'listItem',function(d){var g;d.children.forEach(function(l,n){var j=c(l),h=j.column,k,i,m;if(b.generated(l))return;if(n===0){if(Boolean(d.checked)===d.checked){k=j.offset;while(f.charAt(k)!=='[')k--;h-=j.offset-k}g=h;return}h!==g&&(i=g-h,m=i>0?'add':'remove',i=Math.abs(i),a.warn('Don’t use mixed indentation for children, '+m+' '+i+' '+e('space',i),{line:c(l).line,column:h}))})}),h()}var d=a('unist-util-visit'),b=a('mdast-util-position'),e=a('plur'),c=b.start;f.exports=g},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],24:[function(b,g,i){'use strict';function h(i,g,b,j){var h=g.toString();if(b=typeof b!=='string'?'tab-size':b,f[b]!==!0){g.fail('Invalid list-item indent style `'+b+"`: use either `'tab-size'`, `'space'`, or `'mixed'`");return}d(i,'list',function(d){var f=d.children,i=d.ordered,j=d.start||1;if(c.generated(d))return;f.forEach(function(r,s){var m=r.children[0],l=i?String(j+s).length+1:1,n=Math.ceil(l/4)*4,o=a(r).offset,p=a(m).offset,f,k,c,q;f=h.slice(o,p),f=f.replace(/\[[x ]?\]\s*$/i,''),b==='tab-size'?k=n:b==='space'?k=l+1:k=d.loose?n:l+1,f.length!==k&&(c=k-f.length,q=c>0?'add':'remove',c=Math.abs(c),g.warn('Incorrect list-item indent: '+q+' '+c+' '+e('space',c),a(m)))})}),j()}var d=b('unist-util-visit'),c=b('mdast-util-position'),e=b('plur'),a=c.start,f={'tab-size':!0,mixed:!0,space:!0};g.exports=h},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],25:[function(d,f,h){'use strict';function g(d,f,h,g){e(d,'list',function(g){var d=g.children,e=!0,h=b(g).column,i;if(a.generated(g))return;d.forEach(function(h){var a=h.children,d=a[0],f=a[a.length-1],g=c(f).line-b(d).line>0;g&&(e=!1)}),i=e?'tight':'loose',d.forEach(function(g,k){var a=d[k+1],j=c(g).column>h;if(!a)return;j!==e&&f.warn('List item should be '+i+', isn’t',{start:c(g),end:b(a)})})}),g()}var e=d('unist-util-visit'),a=d('mdast-util-position'),b=a.start,c=a.end;f.exports=g},{'mdast-util-position':62,'unist-util-visit':66}],26:[function(a,e,g){'use strict';function f(e,f,a,g){a=isNaN(a)||typeof a!=='number'?60:a,b(e,'heading',function(b){if(d.generated(b))return;c(b).length>a&&f.warn('Use headings shorter than `'+a+'`',b)}),g()}var b=a('unist-util-visit'),c=a('mdast-util-to-string'),d=a('mdast-util-position');e.exports=f},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],27:[function(e,f,i){'use strict';function g(a){return a.type==='heading'||a.type==='table'||a.type==='code'||a.type==='definition'}function h(k,l,j,q){function p(a,b){a--;while(++ae||h.columne&&l.warn('Line must be at most '+e+' characters',{line:h+1,column:i+1});q()}var b=e('unist-util-visit'),a=e('mdast-util-position'),c=a.start,d=a.end;f.exports=h},{'mdast-util-position':62,'unist-util-visit':66}],28:[function(d,j,k){'use strict';function i(a){return g.test(f(a))}function h(d,f,h,g){e(d,'link',function(d){var e=c(d.children[0]).column,g=b(d.children[d.children.length-1]).column,h=c(d).column,j=b(d).column;if(a.generated(d))return;h===e-1&&j===g+1&&!i(d)&&f.warn('All automatic links must start with a protocol',d)}),g()}var e=d('unist-util-visit'),f=d('mdast-util-to-string'),a=d('mdast-util-position'),c=a.start,b=a.end,g=/^[a-z][a-z+.-]+:\/?/i;j.exports=h},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],29:[function(b,d,f){'use strict';function e(f,b,h,g){var d=b.toString(),e=d.length;c(f,'blockquote',function(c){var g=a.start(c).line,f=c.position&&c.position.indent;if(a.generated(c)||!f||!f.length)return;f.forEach(function(h,i){var a,c=g+i+1,f=b.positionToOffset({line:c,column:h})-1;while(++f')return;if(a!==' '&&a!==' ')break}b.warn('Missing caret in blockquote',{line:c,column:h})})}),g()}var c=b('unist-util-visit'),a=b('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],30:[function(b,f,h){'use strict';function g(f,g,i,h){function b(e,b,f){var a=b.line-e.line,c=a>0?'before':'after';a=Math.abs(a)-f,a>0&&g.warn('Remove '+a+' '+d('line',a)+' '+c+' node',b)}c(f,function(d){var c=d.children;if(a.generated(d))return;c&&c[0]&&(b(a.start(d),a.start(c[0]),0),c.forEach(function(f,h){var d=c[h-1],g=e;if(!d||a.generated(d)||a.generated(f))return;(d.type==='list'&&f.type==='list'||f.type==='code'&&d.type==='list'&&!f.lang)&&g++,b(a.end(d),a.start(f),g)}),b(a.end(d),a.end(c[c.length-1]),1))}),h()}var c=b('unist-util-visit'),a=b('mdast-util-position'),d=b('plur'),e=2;f.exports=g},{'mdast-util-position':62,plur:65,'unist-util-visit':66}],31:[function(c,d,f){'use strict';function e(d,f,h,g){function e(b){var d=c[b.identifier],e;if(a.generated(b))return;d&&d.type&&(e=a.start(d),f.warn('Do not use definitions with the same identifier ('+e.line+':'+e.column+')',b)),c[b.identifier]=b}var c={};b(d,'definition',e),b(d,'footnoteDefinition',e),g()}var a=c('mdast-util-position'),b=c('unist-util-visit');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],32:[function(a,e,g){'use strict';function f(e,f,h,g){var a={};c(e,'heading',function(c){var g=d(c).toUpperCase(),e=a[g],h;if(b.generated(c))return;e&&e.type==='heading'&&(h=b.start(e),f.warn('Do not use headings with similar content ('+h.line+':'+h.column+')',c)),a[g]=c}),g()}var b=a('mdast-util-position'),c=a('unist-util-visit'),d=a('mdast-util-to-string');e.exports=f},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],33:[function(a,e,g){'use strict';function f(a,e,g,f){b(a,'paragraph',function(b,j,k){var f=b.children,a=f[0],g=k.children[j-1],h=k.children[j+1],i;if(d.generated(b))return;(!g||g.type!=='heading')&&h&&h.type==='paragraph'&&f.length===1&&(a.type==='emphasis'||a.type==='strong')&&(i=c(a),i.charAt(i.length-1)===':'&&e.warn('Don’t use emphasis to introduce a section, use a heading',b))}),f()}var b=a('unist-util-visit'),c=a('mdast-util-to-string'),d=a('mdast-util-position');e.exports=f},{'mdast-util-position':62,'mdast-util-to-string':63,'unist-util-visit':66}],34:[function(c,a,d){'use strict';function b(d,a,e,c){var b=a.filename&&a.filename.match(/^(the|an?)\b/i);b&&a.warn('Do not start file names with `'+b[0]+'`'),c()}a.exports=b},{}],35:[function(c,a,d){'use strict';function b(c,a,d,b){a.filename&&/-{2,}/.test(a.filename)&&a.warn('Do not use consecutive dashes in a file name'),b()}a.exports=b},{}],36:[function(c,a,d){'use strict';function b(d,a,e,c){var b=a.filename&&a.filename.match(/[^.a-zA-Z0-9-]/);b&&a.warn('Do not use `'+b[0]+'` in a file name'),c()}a.exports=b},{}],37:[function(c,a,d){'use strict';function b(d,b,e,c){var a=b.filename;a&&!(a===a.toLowerCase()||a===a.toUpperCase())&&b.warn('Do not mix casing in file names'),c()}a.exports=b},{}],38:[function(c,a,d){'use strict';function b(c,a,d,b){a.filename&&/^-|-$/.test(a.filename)&&a.warn('Do not use initial or final dashes in a file name'),b()}a.exports=b},{}],39:[function(c,i,j){'use strict';function h(i,c,k,j){var h=c.toString();f(i,'heading',function(i){var n=i.depth,k=i.children,l=g(i,'atx'),m,o,f,p,j;if(b.generated(i))return;if(l==='atx'||l==='atx-closed'){m=a(i),j=m.offset;while(h.charAt(j)!=='#')j++;j=n+(j-m.offset),f=a(k[0]).column-m.column-1-j,f&&(p=f>0?'Remove':'Add',f=Math.abs(f),c.warn(p+' '+f+' '+e('space',f)+' before this heading’s content',a(k[0])))}l==='atx-closed'&&(o=d(k[k.length-1]),f=d(i).column-o.column-1-n,f&&c.warn('Remove '+f+' '+e('space',f)+' after this heading’s content',o))}),j()}var f=c('unist-util-visit'),g=c('mdast-util-heading-style'),e=c('plur'),b=c('mdast-util-position'),a=b.start,d=b.end;i.exports=h},{'mdast-util-heading-style':61,'mdast-util-position':62,plur:65,'unist-util-visit':66}],40:[function(a,f,h){'use strict';function g(h,f,j,i){var a=f.toString(),g=a.length;c(h,'heading',function(l){var h=e(l),j=h.offset,i=j-1,k,c;if(b.generated(l))return;while(++i1&&b.warn('Do not indent table rows',c)})}),e()}var c=b('unist-util-visit'),a=b('mdast-util-position');d.exports=e},{'mdast-util-position':62,'unist-util-visit':66}],51:[function(c,a,d){'use strict';function b(f,b,g,e){var c=b.toString(),a=-1,d=c.length;while(++ac)return{line:b+1,column:c-(a[b-1]||0)+1};return{}}return b}function h(i,c){var e=String(c).split('\n'),h;if(!c||typeof c.contents!=='string')throw new Error('Missing `file` for mdast-range');e=d(e),h=f(e),c.offsetToPosition=g(e),c.positionToOffset=h,b(i,function(c){var b=c.position;b&&b.start&&a(b.start,h),b&&b.end&&a(b.end,h)})}function i(){return h}var b=e('unist-util-visit');c.exports=i},{'unist-util-visit':66}],61:[function(d,b,e){'use strict';function a(b,a){return b<3?'atx':a==='atx'||a==='setext'?a:null}function c(b,g){var c=b.children[b.children.length-1],d=b.depth,e=b&&b.position&&b.position.end,f=c&&c.position&&c.position.end;return e?c?f.line+1===e.line?'setext':f.column+d'+'\\s*'+')')}function f(b){var a={};return b.replace(e,function(g,c,d,e,f){var b=d||e||f||'';return b==='true'||b===''?b=!0:b==='false'?b=!1:isNaN(b)||(b=Number(b)),a[c]=b,''}),a}function a(a,b){function e(e,i){var g=e.value,c,h;return e.type!=='html'?null:(c=g.match(d),!c||c[1].length!==g.length||c[2]!==a.name?null:(h={type:c[3]||'marker',attributes:c[4]||'',parameters:f(c[4]||''),node:e},b&&b(h,i),h))}var c=a.name,d=g(c);return e}function b(e,b){var c=b.onparse,d=a(b,function(a,b){a.type==='marker'&&c(a,b)});return function(){var a=e.apply(this,arguments);return d(a,this),a}}function i(e,b){var c=b.onstringify,d=a(b,function(a,b){a.type==='marker'&&c(a,b)});return function(a){return d(a,this),e.apply(this,arguments)}}function j(i){function l(l,i,m){var a=k(l),d=a&&a.type;e&&m===e&&(d==='start'&&f++,d==='end'&&f--,d==='end'&&f===0?(b=j(g,b,a,{start:i-b.length-1,end:i,parent:e}),b&&c.apply(e.children,[h,i+1].concat(b)),g=null,e=null,h=null,b=[]):b.push(l)),!e&&d==='start'&&(f=1,h=i,g=a,e=m)}var j=i.onrun,k=a(i),b=[],g=null,e=null,f=0,h;return function(a){d(a,l)}}function k(c,a){var d=c.Parser.prototype.blockTokenizers,e=c.Parser.prototype.inlineTokenizers,f=c.Compiler.prototype;return a.onparse&&(d.html=b(d.html,a),e.tag=b(e.tag,a)),a.onstringify&&(f.html=i(f.html,a)),a.onrun?j(a):null}function l(a){if(!(a&&a.name))throw new Error('Missing `name` in `options`');return function(b){return k(b,a)}}var d=h('unist-util-visit'),c=[].splice,e=new RegExp('\\s*([-a-z09_]+)(?:=(?:"((?:\\\\[\\s\\S]|[^"])+)"|\'((?:\\\\[\\s\\S]|[^\'])+)\'|((?:\\\\[\\s\\S]|[^"\'\\s])+)))?\\s*','gi');m.exports=l},{'unist-util-visit':66}],65:[function(b,a,c){'use strict';a.exports=function(a,b,c){return typeof b==='number'&&(c=b,b=(a.replace(/(?:s|x|z|ch|sh)$/i,'$&e').replace(/y$/i,'ie')+'s').replace(/i?e?s$/i,function(b){var c=a.slice(-1)===a.slice(-1).toLowerCase();return c?b.toLowerCase():b.toUpperCase()})),c===1?a:b}},{}],66:[function(e,a,f){'use strict';function b(b,d){var a=-1,c=b.length;while(++ac)if(d(b[a],a)===!1)return!1;return!0}function d(i,a,d,f){var g,e,h;typeof a==='function'&&(f=d,d=a,a=null),g=f?c:b,h=function(a,b){return g(a,function(a,c){return a&&e(a,c,b)})},e=function(b,c,f){var e;return c=c||(f?0:null),(!a||b.type===a)&&(e=d(b,c,f||null)),b.children&&e!==!1?h(b.children,b):e},e(i)}a.exports=d},{}],67:[function(e,b,f){'use strict';function a(b,c,a){return(b[a]||0)-(c[a]||0)}function c(b,c){return a(b,c,'line')||a(b,c,'column')||-1}function d(a){return a.messages.sort(c),a}b.exports=d},{}]},{},[1])(1)}) diff --git a/test/fixtures/comments-disable-multiple.md b/test/fixtures/comments-disable-multiple.md new file mode 100644 index 00000000..915734b1 --- /dev/null +++ b/test/fixtures/comments-disable-multiple.md @@ -0,0 +1,13 @@ +# Hello + + + +## Hello + +Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello. + + + +### Hello + +Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello. diff --git a/test/index.js b/test/index.js index 8476b423..3836eedf 100644 --- a/test/index.js +++ b/test/index.js @@ -309,6 +309,12 @@ describe('Comments', function () { }); }); + describe('Disable multiple rules at once', function () { + assertFile('comments-disable-multiple.md', [ + 'comments-disable-multiple.md:11:1-11:10: Do not use headings with similar content (5:1)' + ], null, {}); + }); + describe('Inline comments', function () { assertFile('comments-inline.md', [ 'comments-inline.md:1:32-1:38: Do not use HTML in markdown',