2
2
3
3
const { docsExampleCodeToParsableCode } = require ( "./code-block-utils" ) ;
4
4
5
- /** @typedef {import("../../lib/shared/types").ParserOptions } ParserOptions */
5
+ /** @typedef {import("../../lib/shared/types").LanguageOptions } LanguageOptions */
6
6
7
7
/**
8
8
* A callback function to handle the opening of container blocks.
9
9
* @callback OpenHandler
10
10
* @param {Object } data Callback data.
11
11
* @param {"correct" | "incorrect" } data.type The type of the example.
12
12
* @param {string } data.code The example code.
13
- * @param {ParserOptions } data.parserOptions The parser options to be passed to the Playground.
13
+ * @param {LanguageOptions | undefined } data.languageOptions The language options to be passed to the Playground.
14
14
* @param {Object } data.codeBlockToken The `markdown-it` token for the code block inside the container.
15
15
* @param {Object } data.env Additional Eleventy metadata, if available.
16
16
* @returns {string | undefined } If a text is returned, it will be appended to the rendered output
@@ -31,7 +31,7 @@ const { docsExampleCodeToParsableCode } = require("./code-block-utils");
31
31
*
32
32
* - Ensure that the plugin instance only matches container blocks tagged with 'correct' or
33
33
* 'incorrect'.
34
- * - Parse the optional `parserOptions ` after the correct/incorrect tag.
34
+ * - Parse the optional `languageOptions ` after the correct/incorrect tag.
35
35
* - Apply common transformations to the code inside the code block, like stripping '⏎' at the end
36
36
* of a line or the last newline character.
37
37
*
@@ -47,7 +47,7 @@ const { docsExampleCodeToParsableCode } = require("./code-block-utils");
47
47
*
48
48
* markdownIt()
49
49
* .use(markdownItContainer, "rule-example", markdownItRuleExample({
50
- * open({ type, code, parserOptions , codeBlockToken, env }) {
50
+ * open({ type, code, languageOptions , codeBlockToken, env }) {
51
51
* // do something
52
52
* }
53
53
* close() {
@@ -72,14 +72,14 @@ function markdownItRuleExample({ open, close }) {
72
72
return typeof text === "string" ? text : "" ;
73
73
}
74
74
75
- const { type, parserOptionsJSON } = / ^ \s * (?< type > \S + ) ( \s + (?< parserOptionsJSON > \S .* ?) ) ? \s * $ / u. exec ( tagToken . info ) . groups ;
76
- const parserOptions = { sourceType : "module" , ... ( parserOptionsJSON && JSON . parse ( parserOptionsJSON ) ) } ;
75
+ const { type, languageOptionsJSON } = / ^ \s * (?< type > \S + ) ( \s + (?< languageOptionsJSON > \S .* ?) ) ? \s * $ / u. exec ( tagToken . info ) . groups ;
76
+ const languageOptions = languageOptionsJSON ? JSON . parse ( languageOptionsJSON ) : void 0 ;
77
77
const codeBlockToken = tokens [ index + 1 ] ;
78
78
79
79
// Remove trailing newline and presentational `⏎` characters (https://github.com/eslint/eslint/issues/17627):
80
80
const code = docsExampleCodeToParsableCode ( codeBlockToken . content ) ;
81
81
82
- const text = open ( { type, code, parserOptions , codeBlockToken, env } ) ;
82
+ const text = open ( { type, code, languageOptions , codeBlockToken, env } ) ;
83
83
84
84
// Return an empty string to avoid appending unexpected text to the output.
85
85
return typeof text === "string" ? text : "" ;
0 commit comments