Change HTML comment content sanitization to avoid breaking list item indent, respect table cell content rules (fixes #563).

This commit is contained in:
David Anson 2022-10-14 20:59:42 -07:00
parent 7f8962c882
commit f0bb4c639b
8 changed files with 593 additions and 63 deletions

View file

@ -15276,12 +15276,351 @@ Generated by [AVA](https://avajs.dev).
`,
}
## html-comment-in-code-and-table.md
> Snapshot 1
{
errors: [
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
1,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 2,
insertText: '{MD038}',
},
lineNumber: 3,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
3,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 4,
insertText: '{MD038}',
},
lineNumber: 15,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
3,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 4,
insertText: '{MD038}',
},
lineNumber: 19,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
5,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 6,
insertText: '{MD038}',
},
lineNumber: 39,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
],
fixed: `# HTML Comment in Code and Table␊
\`{MD038}\`␊
<!-- \`ignored \` -->
\`\`\`text␊
<!-- \`ignored \` -->
\`\`\`␊
<!-- \`ignored \` -->
| Table |␊
|------------|␊
| \`{MD038}\` |␊
* item␊
\`{MD038}\`␊
* item␊
<!-- \`ignored \` -->
* item␊
\`\`\`text␊
<!-- \`ignored \` -->
\`\`\`␊
* item␊
<!-- \`ignored \` -->
* item␊
| Table |␊
|------------|␊
| \`{MD038}\` |␊
<!-- markdownlint-configure-file {␊
"code-block-style": false␊
} -->␊
`,
}
## html-comment-in-list-item.md
> Snapshot 1
{
errors: [
{
errorContext: null,
errorDetail: null,
errorRange: [
25,
1,
],
fixInfo: {
editColumn: 26,
insertText: `␊
`,
},
lineNumber: 55,
ruleDescription: 'Files should end with a single newline character',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md047',
ruleNames: [
'MD047',
'single-trailing-newline',
],
},
],
fixed: `# HTML Comment in List Item␊
- item␊
<!--
-->␊
- item␊
x<!--
-->␊
- item␊
<!--
-->x␊
- item␊
x<!--
x␊
-->x␊
- item␊
\`\`\`html␊
<!--
-->␊
\`\`\`␊
- item␊
\`\`\`html␊
x<!--
-->␊
\`\`\`␊
- item␊
\`\`\`html␊
<!--
-->x␊
\`\`\`␊
- item␊
\`\`\`html␊
x<!--
x␊
-->x␊
\`\`\`␊
- item␊
Placeholder issue {MD047}␊
`,
}
## html-comment-in-markdown-table.md
> Snapshot 1
{
errors: [],
errors: [
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
3,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 4,
insertText: '{MD038}',
},
lineNumber: 16,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
3,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 4,
insertText: '{MD038}',
},
lineNumber: 22,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
3,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 4,
insertText: '{MD038}',
},
lineNumber: 28,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
11,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 12,
insertText: '{MD038}',
},
lineNumber: 40,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
11,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 12,
insertText: '{MD038}',
},
lineNumber: 46,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
{
errorContext: '`{MD038} `',
errorDetail: null,
errorRange: [
11,
10,
],
fixInfo: {
deleteCount: 8,
editColumn: 12,
insertText: '{MD038}',
},
lineNumber: 52,
ruleDescription: 'Spaces inside code span elements',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038',
ruleNames: [
'MD038',
'no-space-in-code',
],
},
],
fixed: `# HTML Comment in Markdown Table␊
\`\`\`xml␊
@ -15291,14 +15630,50 @@ Generated by [AVA](https://avajs.dev).
| Table |␊
|-------|␊
| <!-- |␊
|comment|␊
| cell |␊
| --> |␊
| Table |␊
|-------|␊
| <!-- \\
\\␊
--> |␊
| Table |␊
|------------|␊
| <!-- |␊
| \`{MD038}\` |␊
| --> |␊
| Table |␊
|----------------|␊
| <!--
\`{MD038}\` --> |␊
| cell |␊
| Table |␊
|----------------|␊
| <!-- \\
\`{MD038}\` --> |␊
| cell |␊
| Table | Table |␊
|-------|-------|␊
| cell | <!-- |␊
| cell | cell |␊
| cell | --> |␊
| Table | Table |␊
|-------|------------|␊
| cell | <!-- |␊
| cell | \`{MD038}\` |␊
| cell | --> |␊
| Table | Table |␊
|-------|----------------|␊
| cell | <!--
| cell | \`{MD038}\` --> |␊
| cell | cell |␊
| Table | Table |␊
|-------|----------------|␊
| cell | <!-- \\
| cell | \`{MD038}\` --> |␊
| cell | cell |␊
`,
}