-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture and verify (for regression purposes) the markdown-it token st…
…ream for markdownItPlugin tests.
- Loading branch information
1 parent
6a515c0
commit 5d000b1
Showing
13 changed files
with
1,567 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
test/markdownItPlugins/custom-rule-assert-markdown-it-tokens.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @ts-check | ||
|
||
import { deepEqual } from "node:assert"; | ||
import { readFileSync, writeFileSync } from "node:fs"; | ||
import { resolve } from "node:path"; | ||
import { __dirname } from "../esm-helpers.mjs"; | ||
|
||
/** @type {import("markdownlint").Rule} */ | ||
export default { | ||
"names": [ "assert-markdown-it-tokens" ], | ||
"description": "Rule that asserts markdown-it tokens", | ||
"tags": [ "test" ], | ||
"parser": "markdownit", | ||
"function": (params) => { | ||
const file = resolve( | ||
__dirname(import.meta), | ||
params.config.file | ||
); | ||
const actual = params.parsers.markdownit.tokens; | ||
const expected = JSON.parse( | ||
readFileSync( | ||
file, | ||
"utf8" | ||
) | ||
); | ||
writeFileSync( | ||
file, | ||
JSON.stringify( | ||
actual, | ||
null, | ||
2 | ||
), | ||
"utf8" | ||
); | ||
deepEqual(actual, expected); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
[ | ||
{ | ||
"type": "heading_open", | ||
"tag": "h1", | ||
"attrs": null, | ||
"map": [ | ||
0, | ||
1 | ||
], | ||
"nesting": 1, | ||
"level": 0, | ||
"children": null, | ||
"content": "", | ||
"markup": "#", | ||
"info": "", | ||
"meta": null, | ||
"block": true, | ||
"hidden": false, | ||
"line": "# Heading", | ||
"lineNumber": 1 | ||
}, | ||
{ | ||
"type": "inline", | ||
"tag": "", | ||
"attrs": null, | ||
"map": [ | ||
0, | ||
1 | ||
], | ||
"nesting": 0, | ||
"level": 1, | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"tag": "", | ||
"attrs": null, | ||
"map": null, | ||
"nesting": 0, | ||
"level": 0, | ||
"children": null, | ||
"content": "Heading", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": false, | ||
"hidden": false, | ||
"lineNumber": 1, | ||
"line": "# Heading" | ||
} | ||
], | ||
"content": "Heading", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": true, | ||
"hidden": false, | ||
"line": "# Heading", | ||
"lineNumber": 1 | ||
}, | ||
{ | ||
"type": "heading_close", | ||
"tag": "h1", | ||
"attrs": null, | ||
"map": null, | ||
"nesting": -1, | ||
"level": 0, | ||
"children": null, | ||
"content": "", | ||
"markup": "#", | ||
"info": "", | ||
"meta": null, | ||
"block": true, | ||
"hidden": false | ||
}, | ||
{ | ||
"type": "paragraph_open", | ||
"tag": "p", | ||
"attrs": null, | ||
"map": [ | ||
2, | ||
3 | ||
], | ||
"nesting": 1, | ||
"level": 0, | ||
"children": null, | ||
"content": "", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": true, | ||
"hidden": false, | ||
"line": "Text [ link ](https://example.com)", | ||
"lineNumber": 3 | ||
}, | ||
{ | ||
"type": "inline", | ||
"tag": "", | ||
"attrs": null, | ||
"map": [ | ||
2, | ||
3 | ||
], | ||
"nesting": 0, | ||
"level": 1, | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"tag": "", | ||
"attrs": null, | ||
"map": null, | ||
"nesting": 0, | ||
"level": 0, | ||
"children": null, | ||
"content": "Text", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": false, | ||
"hidden": false, | ||
"lineNumber": 3, | ||
"line": "Text [ link ](https://example.com)" | ||
}, | ||
{ | ||
"type": "link_open", | ||
"tag": "a", | ||
"attrs": [ | ||
[ | ||
"href", | ||
"https://example.com" | ||
] | ||
], | ||
"map": null, | ||
"nesting": 1, | ||
"level": 0, | ||
"children": null, | ||
"content": "", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": false, | ||
"hidden": false, | ||
"lineNumber": 3, | ||
"line": "Text [ link ](https://example.com)" | ||
}, | ||
{ | ||
"type": "text", | ||
"tag": "", | ||
"attrs": null, | ||
"map": null, | ||
"nesting": 0, | ||
"level": 1, | ||
"children": null, | ||
"content": "link", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": false, | ||
"hidden": false, | ||
"lineNumber": 3, | ||
"line": "Text [ link ](https://example.com)" | ||
}, | ||
{ | ||
"type": "link_close", | ||
"tag": "a", | ||
"attrs": null, | ||
"map": null, | ||
"nesting": -1, | ||
"level": 0, | ||
"children": null, | ||
"content": "", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": false, | ||
"hidden": false, | ||
"lineNumber": 3, | ||
"line": "Text [ link ](https://example.com)" | ||
} | ||
], | ||
"content": "Text [ link ](https://example.com)", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": true, | ||
"hidden": false, | ||
"line": "Text [ link ](https://example.com)", | ||
"lineNumber": 3 | ||
}, | ||
{ | ||
"type": "paragraph_close", | ||
"tag": "p", | ||
"attrs": null, | ||
"map": null, | ||
"nesting": -1, | ||
"level": 0, | ||
"children": null, | ||
"content": "", | ||
"markup": "", | ||
"info": "", | ||
"meta": null, | ||
"block": true, | ||
"hidden": false | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.