mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Exclude htmlFlow content by default for filterByTypes, opt in as needed.
This commit is contained in:
parent
ea9659841e
commit
12502f6571
18 changed files with 206 additions and 129 deletions
|
|
@ -5,3 +5,9 @@
|
|||
## Heading 2
|
||||
|
||||
#### Heading 4 {MD001}
|
||||
|
||||
<p>
|
||||
###### Not heading
|
||||
</p>
|
||||
|
||||
<!-- markdownlint-disable-file no-inline-html -->
|
||||
|
|
|
|||
|
|
@ -63,15 +63,40 @@ test("getMicromarkEvents/filterByPredicate", async(t) => {
|
|||
t.deepEqual(tokenTypes, eventTypes);
|
||||
});
|
||||
|
||||
test("filterByTypes", async(t) => {
|
||||
t.plan(8);
|
||||
const filtered = filterByTypes(
|
||||
await testTokens,
|
||||
[ "atxHeadingText", "codeText", "htmlText", "setextHeadingText" ]
|
||||
);
|
||||
test("filterByTypes, htmlFlow false", async(t) => {
|
||||
t.plan(7);
|
||||
const tokens = await testTokens;
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../micromark/micromark.cjs").TokenType[] */
|
||||
const types = [ "atxHeadingText", "codeText", "htmlText", "setextHeadingText" ];
|
||||
const filtered = filterByTypes(tokens, types);
|
||||
// Using flat tokens
|
||||
for (const token of filtered) {
|
||||
t.true(token.type.endsWith("Text"));
|
||||
}
|
||||
// Not using flat tokens
|
||||
t.deepEqual(
|
||||
filtered,
|
||||
filterByTypes([ ...tokens], types)
|
||||
)
|
||||
});
|
||||
|
||||
test("filterByTypes, htmlFlow true", async(t) => {
|
||||
t.plan(9);
|
||||
const tokens = await testTokens;
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../micromark/micromark.cjs").TokenType[] */
|
||||
const types = [ "atxHeadingText", "codeText", "htmlText", "setextHeadingText" ];
|
||||
// Using flat tokens
|
||||
const filtered = filterByTypes(tokens, types, true);
|
||||
for (const token of filtered) {
|
||||
t.true(token.type.endsWith("Text"));
|
||||
}
|
||||
// Not using flat tokens
|
||||
t.deepEqual(
|
||||
filtered,
|
||||
filterByTypes([ ...tokens], types, true)
|
||||
)
|
||||
});
|
||||
|
||||
test("filterByPredicate/filterByTypes", async(t) => {
|
||||
|
|
@ -79,6 +104,6 @@ test("filterByPredicate/filterByTypes", async(t) => {
|
|||
const tokens = await testTokens;
|
||||
const byPredicate = filterByPredicate(tokens, () => true);
|
||||
const allTypes = new Set(byPredicate.map(((token) => token.type)));
|
||||
const byTypes = filterByTypes(tokens, [ ...allTypes.values() ]);
|
||||
const byTypes = filterByTypes(tokens, [ ...allTypes.values() ], true);
|
||||
t.deepEqual(byPredicate, byTypes);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ Uppercase image tag with alt attribute set
|
|||
|
||||
Uppercase image tag with no alt set <IMG SRC="cat.png" /> {MD045}
|
||||
|
||||
<p>
|
||||
<img src="image.png" /> {MD045}
|
||||
</p>
|
||||
|
||||
<!-- markdownlint-restore no-inline-html -->
|
||||
|
||||
[notitle]: image.jpg
|
||||
|
|
|
|||
|
|
@ -16101,6 +16101,12 @@ Generated by [AVA](https://avajs.dev).
|
|||
## Heading 2␊
|
||||
␊
|
||||
#### Heading 4 {MD001}␊
|
||||
␊
|
||||
<p>␊
|
||||
###### Not heading␊
|
||||
</p>␊
|
||||
␊
|
||||
<!-- markdownlint-disable-file no-inline-html -->␊
|
||||
`,
|
||||
}
|
||||
|
||||
|
|
@ -39577,6 +39583,22 @@ Generated by [AVA](https://avajs.dev).
|
|||
'no-alt-text',
|
||||
],
|
||||
},
|
||||
{
|
||||
errorContext: null,
|
||||
errorDetail: null,
|
||||
errorRange: [
|
||||
3,
|
||||
23,
|
||||
],
|
||||
fixInfo: null,
|
||||
lineNumber: 68,
|
||||
ruleDescription: 'Images should have alternate text (alt text)',
|
||||
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md045.md',
|
||||
ruleNames: [
|
||||
'MD045',
|
||||
'no-alt-text',
|
||||
],
|
||||
},
|
||||
],
|
||||
fixed: `# Images with and without alternate text␊
|
||||
␊
|
||||
|
|
@ -39644,6 +39666,10 @@ Generated by [AVA](https://avajs.dev).
|
|||
␊
|
||||
Uppercase image tag with no alt set <IMG SRC="cat.png" /> {MD045}␊
|
||||
␊
|
||||
<p>␊
|
||||
<img src="image.png" /> {MD045}␊
|
||||
</p>␊
|
||||
␊
|
||||
<!-- markdownlint-restore no-inline-html -->␊
|
||||
␊
|
||||
[notitle]: image.jpg␊
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue