Skip to content

Latest commit

 

History

History
58 lines (47 loc) · 2.59 KB

development.md

File metadata and controls

58 lines (47 loc) · 2.59 KB

Development

$ cd script
$ npm install
$ cd ..
$ ./test.sh   # run each rule's cases, then compare them with markdownlint and rumdl

Each rule carries a fires and a clean case under tests:. script/compare.mjs runs markdownlint over the same pages, with the rule and options that script/rules.mjs names for each, and fails when the two report different lines. script/compare-rumdl.mjs does the same for the rumdl style, with the rumdl on your PATH. A new rule needs an entry in script/rules.mjs.

A script rule's params are values its script reads by name: one script serves each way of a rule, and a rule that extends it sets its own with params+, as TableColumnStyleAligned does.

A rule that should pass over inline code says so in its scope, with & ~code: what it finds inside a code span is left out. ~comment, ~link, ~url (where a link goes) and ~html (a tag) do the same. Without the ~, each is what the rule reads: raw & code is every code span, raw & url where every link goes, and raw & link.inline every link written [text](to). raw & delimiter is every pair of emphasis markers that made no emphasis, * like this *, from the first to the second: the parser left them as text, so a rule about them reads the pair and needs no pattern to find it.

In doc(...), :heading is a heading of any level, and :is(p, li) any of a group: doc(:heading:has(em)), doc(blockquote :is(p, table)).

A script rule that works a line at a time reads lines, line_starts, line_code, and fences without declaring them: Vale fills them in, the scope's lines and where its fenced code is, so that no script splits the page or follows its fences itself.

The cases are small. script/corpus.mjs holds the styles against the tools on real pages: it lints every Markdown file under the paths it is given three ways, with each tool's defaults, and lists the lines a rule reports that its tool doesn't, and the other way round. A finding the two report a line apart is one they agree on:

$ node script/corpus.mjs ~/src/some-project/docs
$ node script/corpus.mjs --rule MD013 --show 20 ~/src/some-project/docs

script/ml.mjs prints what markdownlint makes of a page on its standard input, for one rule: printf '# A\n\n# B\n' | node script/ml.mjs MD025.

script/fix.mjs does for fixes what corpus.mjs does for findings, on the pages it is given: node script/fix.mjs --rule MD022 --dump out docs writes each page the two fix differently, as each left it.

To move to a newer markdownlint, change its version in script/package.json and run the same steps.