Refactor to move reparse of micromark htmlFlow token content into core micromarkParse implementation for simplicity and sharing.

This commit is contained in:
David Anson 2023-07-21 22:49:08 -07:00
parent 9646590496
commit e86fb7699d
11 changed files with 307 additions and 84 deletions

View file

@ -26,7 +26,7 @@ function consoleLogTokens(tokens, depth = 0) {
const files = process.argv.slice(2);
for (const file of files) {
const content = await readFile(file);
const content = await readFile(file, "utf8");
consoleLogTokens(parse(content));
const results = await markdownlint({
"files": [ file ]

View file

@ -9,6 +9,8 @@ const { markdownlint } = require("../lib/markdownlint").promises;
const helpers = require("../helpers");
const constants = require("../lib/constants");
const numericalSortCompareFn = (a, b) => a - b;
/**
* Create a test function for the specified test file.
*
@ -53,7 +55,7 @@ function createTestForFile(file) {
}
}
for (const list of Object.values(expected)) {
list.sort();
list.sort(numericalSortCompareFn);
}
const actual = {};
for (const error of errors) {
@ -69,7 +71,7 @@ function createTestForFile(file) {
);
}
for (const list of Object.values(actual)) {
list.sort();
list.sort(numericalSortCompareFn);
}
t.deepEqual(actual, expected, "Too few or too many issues found.");
// Create snapshot

View file

@ -2624,6 +2624,99 @@ Generated by [AVA](https://avajs.dev).
],
endColumn: 5,
endLine: 45,
htmlFlowChildren: [
{
children: [
{
children: [
{
children: [
{
children: [],
endColumn: 4,
endLine: 43,
startColumn: 1,
startLine: 43,
text: '<p>',
type: 'htmlTextData',
},
],
endColumn: 4,
endLine: 43,
startColumn: 1,
startLine: 43,
text: '<p>',
type: 'htmlText',
},
{
children: [],
endColumn: 1,
endLine: 44,
startColumn: 4,
startLine: 43,
text: `␊
`,
type: 'lineEnding',
},
{
children: [],
endColumn: 11,
endLine: 44,
startColumn: 1,
startLine: 44,
text: 'HTML block',
type: 'data',
},
{
children: [],
endColumn: 1,
endLine: 45,
startColumn: 11,
startLine: 44,
text: `␊
`,
type: 'lineEnding',
},
{
children: [
{
children: [],
endColumn: 5,
endLine: 45,
startColumn: 1,
startLine: 45,
text: '</p>',
type: 'htmlTextData',
},
],
endColumn: 5,
endLine: 45,
startColumn: 1,
startLine: 45,
text: '</p>',
type: 'htmlText',
},
],
endColumn: 5,
endLine: 45,
startColumn: 1,
startLine: 43,
text: `<p>
HTML block␊
</p>`,
type: 'paragraph',
},
],
endColumn: 5,
endLine: 45,
startColumn: 1,
startLine: 43,
text: `<p>
HTML block␊
</p>`,
type: 'content',
},
],
startColumn: 1,
startLine: 43,
text: `<p>
@ -3131,6 +3224,47 @@ Generated by [AVA](https://avajs.dev).
],
endColumn: 35,
endLine: 51,
htmlFlowChildren: [
{
children: [
{
children: [
{
children: [
{
children: [],
endColumn: 35,
endLine: 51,
startColumn: 1,
startLine: 51,
text: '<!-- markdownlint-disable-file -->',
type: 'htmlTextData',
},
],
endColumn: 35,
endLine: 51,
startColumn: 1,
startLine: 51,
text: '<!-- markdownlint-disable-file -->',
type: 'htmlText',
},
],
endColumn: 35,
endLine: 51,
startColumn: 1,
startLine: 51,
text: '<!-- markdownlint-disable-file -->',
type: 'paragraph',
},
],
endColumn: 35,
endLine: 51,
startColumn: 1,
startLine: 51,
text: '<!-- markdownlint-disable-file -->',
type: 'content',
},
],
startColumn: 1,
startLine: 51,
text: '<!-- markdownlint-disable-file -->',

View file

@ -16,7 +16,8 @@ Generated by [AVA](https://avajs.dev).
`test-repos/dotnet-docs/docs/azure/sdk/includes/assign-local-dev-group-to-role-azure-portal-4.md: 5: MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "<br>"]␊
test-repos/dotnet-docs/docs/azure/sdk/includes/assign-managed-identity-to-role-azure-portal-4.md: 5: MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "<br>"]␊
test-repos/dotnet-docs/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-4.md: 5: MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "<br>"]`
test-repos/dotnet-docs/docs/azure/sdk/includes/assign-service-principal-to-role-azure-portal-4.md: 5: MD032/blanks-around-lists Lists should be surrounded by blank lines [Context: "<br>"]␊
test-repos/dotnet-docs/docs/core/compatibility/core-libraries/5.0/code-access-security-apis-obsolete.md: 431: MD033/no-inline-html Inline HTML [Element: StrongName]`
## https://github.com/electron/electron