mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Reimplement MD044/proper-names using micromark tokens.
This commit is contained in:
parent
e8a85c91f2
commit
5bff33d41b
9 changed files with 182 additions and 495 deletions
|
|
@ -1253,180 +1253,6 @@ test("expandTildePath", (t) => {
|
|||
t.is(helpers.expandTildePath("~/dir/file", null), "~/dir/file");
|
||||
});
|
||||
|
||||
test("urlFe", (t) => {
|
||||
t.plan(1);
|
||||
const input = `
|
||||
Text ftp://example.com text
|
||||
Text ftps://example.com text
|
||||
Text http://example.com text
|
||||
Text https://example.com text
|
||||
Text https://example.com/ text
|
||||
Text https://example.com/path text
|
||||
Text https://example.com/path/ text
|
||||
Text https://example.com/path/file.txt text
|
||||
Text https://example.com/path/file.txt?query=string text
|
||||
Text https://example.com/path/file.txt#hash text
|
||||
Text https://example.com/path/file.txt?query=string#hash text
|
||||
Text https://example.com/path# text
|
||||
Text https://example.com/path- text
|
||||
Text https://example.com/path() text
|
||||
Text https://example.com/path(path) text
|
||||
Text https://example.com/path(path)path text
|
||||
Text https://example.com/path-(path) text
|
||||
Text https://example.com/path(() text
|
||||
Text https://example.com/path()) text
|
||||
Text https://example.com/path(()) text
|
||||
Text https://example.com/path((())) text
|
||||
Text https://example.com/path()() text
|
||||
Text (https://example.com/path) text
|
||||
Text <https://example.com/path> text
|
||||
Text >https://example.com/path< text
|
||||
Text [https://example.com/path] text
|
||||
Text "https://example.com/path" text
|
||||
Text 'https://example.com/path' text
|
||||
Text \`https://example.com/path\` text
|
||||
Text ‘https://example.com/path’ text
|
||||
Text “https://example.com/path” text
|
||||
Text «https://example.com/path» text
|
||||
Text [link](https://example.com/path) text
|
||||
Text [link](https://example.com/path ) text
|
||||
Text [link]( https://example.com/path) text
|
||||
Text [link]( https://example.com/path ) text
|
||||
Text <code>https://example.com/path</code> text
|
||||
Text <a href="https://example.com/path">link</a> text
|
||||
Text <a href="https://example.com/path">https://example.com/path</a> text
|
||||
Text *https://example.com* text
|
||||
Text **https://example.com** text
|
||||
Text _https://example.com_ text
|
||||
Text __https://example.com__ text
|
||||
Text https://example.com. text
|
||||
Text https://example.com, text
|
||||
Text https://example.com; text
|
||||
Text https://example.com: text
|
||||
Text https://example.com? text
|
||||
Text https://example.com! text
|
||||
Text https://example.com。 text
|
||||
Text https://example.com, text
|
||||
Text https://example.com; text
|
||||
Text https://example.com: text
|
||||
Text https://example.com! text
|
||||
Text https://example.com,text
|
||||
Text https://example.com.path text
|
||||
Text https://example.com?path text
|
||||
Text https://example.com!text
|
||||
Text https://example.com.. text
|
||||
Text https://example.com... text
|
||||
Text https://example.com.co text
|
||||
Text <https://example.com/path text> text
|
||||
Text <https://example.com/path.path> text
|
||||
Text <https://example.com/path,path> text
|
||||
Text <https://example.com/path;path> text
|
||||
Text <https://example.com/path:path> text
|
||||
Text <https://example.com/path?path> text
|
||||
Text <https://example.com/path!path> text
|
||||
[https://example.com/path](https://example.com/path)
|
||||
[ https://example.com/path](https://example.com/path)
|
||||
[https://example.com/path ](https://example.com/path)
|
||||
https://example.com/ text https://example.com/path text https://example.com/
|
||||
https://example.com
|
||||
https://example.com
|
||||
https://example.com
|
||||
`.split(helpers.newLineRe);
|
||||
const expected = `
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text text
|
||||
Text ) text
|
||||
Text ) text
|
||||
Text )) text
|
||||
Text text
|
||||
Text () text
|
||||
Text <> text
|
||||
Text >< text
|
||||
Text [] text
|
||||
Text "" text
|
||||
Text '' text
|
||||
Text \`\` text
|
||||
Text ‘’ text
|
||||
Text “” text
|
||||
Text «» text
|
||||
Text [link]() text
|
||||
Text [link]( ) text
|
||||
Text [link]( ) text
|
||||
Text [link]( ) text
|
||||
Text <code></code> text
|
||||
Text <a href="">link</a> text
|
||||
Text <a href=""></a> text
|
||||
Text ** text
|
||||
Text **** text
|
||||
Text __ text
|
||||
Text ____ text
|
||||
Text . text
|
||||
Text , text
|
||||
Text ; text
|
||||
Text : text
|
||||
Text ? text
|
||||
Text ! text
|
||||
Text 。 text
|
||||
Text , text
|
||||
Text ; text
|
||||
Text : text
|
||||
Text ! text
|
||||
Text ,text
|
||||
Text text
|
||||
Text text
|
||||
Text !text
|
||||
Text .. text
|
||||
Text ... text
|
||||
Text text
|
||||
Text < text> text
|
||||
Text <> text
|
||||
Text <> text
|
||||
Text <> text
|
||||
Text <> text
|
||||
Text <> text
|
||||
Text <> text
|
||||
[]()
|
||||
[ ]()
|
||||
[ ]()
|
||||
text text
|
||||
|
||||
|
||||
|
||||
`.split(helpers.newLineRe);
|
||||
const actual = [];
|
||||
for (let line of input) {
|
||||
const urlRanges = [];
|
||||
let match = null;
|
||||
while ((match = helpers.funcExpExec(helpers.urlFe, line)) !== null) {
|
||||
// @ts-ignore
|
||||
urlRanges.push([ match.index, match[0].length ]);
|
||||
}
|
||||
urlRanges.reverse();
|
||||
for (const range of urlRanges) {
|
||||
const [ index, length ] = range;
|
||||
line = line.slice(0, index) + line.slice(index + length);
|
||||
}
|
||||
actual.push(line);
|
||||
}
|
||||
t.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test("getReferenceLinkImageData().shortcuts", (t) => {
|
||||
t.plan(1);
|
||||
const options = {
|
||||
|
|
|
|||
|
|
@ -49,13 +49,17 @@ HTML <u>javascript</u> {MD044}
|
|||
javascript is code {MD044}
|
||||
node.js is runtime {MD044}
|
||||
|
||||
```js
|
||||
```javascript
|
||||
javascript is code {MD044} {MD046:52}
|
||||
node.js is runtime {MD044}
|
||||
```
|
||||
|
||||
Upload the code (to github) {MD044}
|
||||
|
||||
Image of . {MD044}
|
||||
|
||||
Image of .
|
||||
|
||||
Link to [github](https://github.com/). {MD044}
|
||||
|
||||
Link to [GitHub](https://github.com/).
|
||||
|
|
@ -88,7 +92,7 @@ Text referencing mULTIPLEcASE name.
|
|||
<img src="img/javascript/image.png" error="{MD044}">
|
||||
|
||||
<script type="text/javascript">
|
||||
{MD044:90}
|
||||
{MD044:94}
|
||||
javascript {MD044}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -35165,7 +35165,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 17,
|
||||
insertText: '<https://github.com/DavidAnson/MARKDOWNLINT>',
|
||||
},
|
||||
lineNumber: 65,
|
||||
lineNumber: 69,
|
||||
ruleDescription: 'Bare URL used',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md034.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35553,6 +35553,26 @@ Generated by [AVA](https://avajs.dev).
|
|||
'proper-names',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: null,
|
||||
errorDetail: 'Expected: GitHub; Actual: github',
|
||||
errorRange: [
|
||||
12,
|
||||
6,
|
||||
],
|
||||
fixInfo: {
|
||||
deleteCount: 6,
|
||||
editColumn: 12,
|
||||
insertText: 'GitHub',
|
||||
},
|
||||
lineNumber: 59,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
'MD044',
|
||||
'proper-names',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: null,
|
||||
errorDetail: 'Expected: GitHub; Actual: github',
|
||||
|
|
@ -35565,7 +35585,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 10,
|
||||
insertText: 'GitHub',
|
||||
},
|
||||
lineNumber: 59,
|
||||
lineNumber: 63,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35585,7 +35605,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 7,
|
||||
insertText: 'Node.js',
|
||||
},
|
||||
lineNumber: 68,
|
||||
lineNumber: 72,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35605,7 +35625,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 1,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 69,
|
||||
lineNumber: 73,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35625,7 +35645,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 10,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 71,
|
||||
lineNumber: 75,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35645,7 +35665,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 1,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 74,
|
||||
lineNumber: 78,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35665,7 +35685,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 1,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 77,
|
||||
lineNumber: 81,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35685,7 +35705,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 2,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 80,
|
||||
lineNumber: 84,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35705,7 +35725,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 18,
|
||||
insertText: 'multiplecase',
|
||||
},
|
||||
lineNumber: 85,
|
||||
lineNumber: 89,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35725,7 +35745,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 15,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 88,
|
||||
lineNumber: 92,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35745,7 +35765,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 20,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 90,
|
||||
lineNumber: 94,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35765,7 +35785,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 1,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 92,
|
||||
lineNumber: 96,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35785,7 +35805,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
editColumn: 24,
|
||||
insertText: 'JavaScript',
|
||||
},
|
||||
lineNumber: 95,
|
||||
lineNumber: 99,
|
||||
ruleDescription: 'Proper names should have the correct capitalization',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md044.md',
|
||||
ruleNames: [
|
||||
|
|
@ -35858,13 +35878,17 @@ Generated by [AVA](https://avajs.dev).
|
|||
JavaScript is code {MD044}␊
|
||||
Node.js is runtime {MD044}␊
|
||||
␊
|
||||
\`\`\`js␊
|
||||
\`\`\`javascript␊
|
||||
JavaScript is code {MD044} {MD046:52}␊
|
||||
Node.js is runtime {MD044}␊
|
||||
\`\`\`␊
|
||||
␊
|
||||
Upload the code (to GitHub) {MD044}␊
|
||||
␊
|
||||
Image of . {MD044}␊
|
||||
␊
|
||||
Image of .␊
|
||||
␊
|
||||
Link to [GitHub](https://github.com/). {MD044}␊
|
||||
␊
|
||||
Link to [GitHub](https://github.com/).␊
|
||||
|
|
@ -35897,7 +35921,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
<img src="img/JavaScript/image.png" error="{MD044}">␊
|
||||
␊
|
||||
<script type="text/JavaScript">␊
|
||||
{MD044:90}␊
|
||||
{MD044:94}␊
|
||||
JavaScript {MD044}␊
|
||||
</script>␊
|
||||
␊
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue