mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02: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 = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue