Reimplement MD026/no-trailing-punctuation using micromark tokens, ignore trailing GitHub emoji codes, improve tests (fixes #457).

This commit is contained in:
David Anson 2023-06-24 15:45:51 -07:00
parent 272c15ed39
commit c06506c317
9 changed files with 157 additions and 32 deletions

View file

@ -0,0 +1,25 @@
# headings-with-emoji
## Known Issues :bug:
## Love :heartpulse:
## :tada:
## :checkered_flag:
## :clock930:
## :t-rex:
## Boba:bubble_tea:
<!-- markdownlint-disable heading-style -->
## Fix the :bug: ##
Another :heartpulse:
--------------------
:eyes:
------

View file

@ -12,6 +12,8 @@
## Copyright 2004 &#x000A9;
## Copyright 2004 &#X000A9;
## Copyright 2005 &#169;
## Copyright 2006 &#169; ##

View file

@ -1283,3 +1283,21 @@ Empty bracket pairs: [text3[]][]
};
return markdownlint(options).then(() => null);
});
test("endOfLineHtmlEntityRe", async(t) => {
const { characterEntities } = await import("character-entities");
const entities = Object.keys(characterEntities);
t.plan(entities.length);
for (const entity of entities) {
t.true(helpers.endOfLineHtmlEntityRe.test(`-&${entity};`), entity);
}
});
test("endOfLineGemojiCodeRe", async(t) => {
const { gemoji } = await import("gemoji");
const emojis = gemoji.flatMap((i) => i.names);
t.plan(emojis.length);
for (const emoji of emojis) {
t.true(helpers.endOfLineGemojiCodeRe.test(`-:${emoji}:`), emoji);
}
});

View file

@ -14772,6 +14772,40 @@ Generated by [AVA](https://avajs.dev).
`,
}
## headings-with-emoji.md
> Snapshot 1
{
errors: [],
fixed: `# headings-with-emoji␊
## Known Issues :bug:␊
## Love :heartpulse:␊
## :tada:␊
## :checkered_flag:␊
## :clock930:␊
## :t-rex:␊
## Boba:bubble_tea:␊
<!-- markdownlint-disable heading-style -->
## Fix the :bug: ##␊
Another :heartpulse:␊
--------------------␊
:eyes:␊
------␊
`,
}
## headings-with-html-entities.md
> Snapshot 1
@ -14789,7 +14823,7 @@ Generated by [AVA](https://avajs.dev).
deleteCount: 1,
editColumn: 31,
},
lineNumber: 22,
lineNumber: 24,
ruleDescription: 'Trailing punctuation in heading',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md026.md',
ruleNames: [
@ -14808,7 +14842,7 @@ Generated by [AVA](https://avajs.dev).
deleteCount: 1,
editColumn: 34,
},
lineNumber: 24,
lineNumber: 26,
ruleDescription: 'Trailing punctuation in heading',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md026.md',
ruleNames: [
@ -14827,7 +14861,7 @@ Generated by [AVA](https://avajs.dev).
deleteCount: 1,
editColumn: 31,
},
lineNumber: 26,
lineNumber: 28,
ruleDescription: 'Trailing punctuation in heading',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md026.md',
ruleNames: [
@ -14850,6 +14884,8 @@ Generated by [AVA](https://avajs.dev).
## Copyright 2004 &#x000A9;
## Copyright 2004 &#X000A9;
## Copyright 2005 &#169;
## Copyright 2006 &#169; ##␊