Fix range calculation in MD033/no-inline-html during re-parse of tabbed content.

This commit is contained in:
David Anson 2023-01-21 18:57:09 -08:00
parent 48a92d41a4
commit c53df8b720
7 changed files with 65 additions and 6 deletions

View file

@ -4953,11 +4953,13 @@ module.exports = {
var options = { var options = {
"extensions": [{ "extensions": [{
"disable": { "disable": {
"null": ["htmlFlow"] "null": ["codeIndented", "htmlFlow"]
} }
}] }]
}; };
var flowTokens = parse(token.text, options); // Use lines instead of token.text for accurate columns
var lines = params.lines.slice(token.startLine - 1, token.endLine).join("\n");
var flowTokens = parse(lines, options);
pending.push([token.startLine - 1, flowTokens]); pending.push([token.startLine - 1, flowTokens]);
} }
} }

View file

@ -42,12 +42,15 @@ module.exports = {
"extensions": [ "extensions": [
{ {
"disable": { "disable": {
"null": [ "htmlFlow" ] "null": [ "codeIndented", "htmlFlow" ]
} }
} }
] ]
}; };
const flowTokens = parse(token.text, options); // Use lines instead of token.text for accurate columns
const lines =
params.lines.slice(token.startLine - 1, token.endLine).join("\n");
const flowTokens = parse(lines, options);
pending.push( pending.push(
[ token.startLine - 1, flowTokens ] [ token.startLine - 1, flowTokens ]
); );

View file

@ -1,5 +1,6 @@
{ {
"default": true, "default": true,
"MD010": false,
"MD033": { "MD033": {
"allowed_elements": [ "allowed_elements": [
"strong" "strong"

View file

@ -105,3 +105,14 @@ And neither is <foo_bar>.
Nor <123abc>. Nor <123abc>.
Text Text
<details>
{MD033:109}
<details>
- Item
<details>
{MD033:116}

View file

@ -139,8 +139,7 @@ test("https://github.com/dotnet/docs", (t) => {
const rootDir = "./test-repos/dotnet-docs"; const rootDir = "./test-repos/dotnet-docs";
const globPatterns = [ join(rootDir, "**/*.md") ]; const globPatterns = [ join(rootDir, "**/*.md") ];
const configPath = join(rootDir, ".markdownlint-cli2.jsonc"); const configPath = join(rootDir, ".markdownlint-cli2.jsonc");
const ignoreRes = [ /^test-repos\/dotnet-docs\/docs\/core\/compatibility\/core-libraries\/5.0\/code-access-security-apis-obsolete.md: \d+: MD033\/.*$\r?\n?/gm ]; return lintTestRepo(t, globPatterns, configPath);
return lintTestRepo(t, globPatterns, configPath, ignoreRes);
}); });
test("https://github.com/electron-electron", (t) => { test("https://github.com/electron-electron", (t) => {

View file

@ -16645,6 +16645,38 @@ Generated by [AVA](https://avajs.dev).
'no-inline-html', 'no-inline-html',
], ],
}, },
{
errorContext: null,
errorDetail: 'Element: details',
errorRange: [
1,
9,
],
fixInfo: null,
lineNumber: 109,
ruleDescription: 'Inline HTML',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md033.md',
ruleNames: [
'MD033',
'no-inline-html',
],
},
{
errorContext: null,
errorDetail: 'Element: details',
errorRange: [
2,
9,
],
fixInfo: null,
lineNumber: 116,
ruleDescription: 'Inline HTML',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md033.md',
ruleNames: [
'MD033',
'no-inline-html',
],
},
], ],
fixed: `# Detailed HTML Results␊ fixed: `# Detailed HTML Results␊
@ -16753,6 +16785,17 @@ Generated by [AVA](https://avajs.dev).
Nor <123abc>.␊ Nor <123abc>.␊
Text␊ Text␊
<details>
{MD033:109}␊
<details>
- Item␊
<details>
{MD033:116}␊
`, `,
} }