22
33const { docsExampleCodeToParsableCode} = require ( "./code-block-utils" ) ;
44
5- /**@typedef {import("../../lib/shared/types").ParserOptions } ParserOptions */
5+ /**@typedef {import("../../lib/shared/types").LanguageOptions } LanguageOptions */
66
77/**
88 * A callback function to handle the opening of container blocks.
99 *@callback OpenHandler
1010 *@param {Object } data Callback data.
1111 *@param {"correct" | "incorrect" } data.type The type of the example.
1212 *@param {string } data.code The example code.
13- *@param {ParserOptions } data.parserOptions Theparser options to be passed to the Playground.
13+ *@param {LanguageOptions | undefined } data.languageOptions Thelanguage options to be passed to the Playground.
1414 *@param {Object } data.codeBlockToken The `markdown-it` token for the code block inside the container.
1515 *@param {Object } data.env Additional Eleventy metadata, if available.
1616 *@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");
3131 *
3232 * - Ensure that the plugin instance only matches container blocks tagged with 'correct' or
3333 * 'incorrect'.
34- * - Parse the optional `parserOptions ` after the correct/incorrect tag.
34+ * - Parse the optional `languageOptions ` after the correct/incorrect tag.
3535 * - Apply common transformations to the code inside the code block, like stripping '⏎' at the end
3636 * of a line or the last newline character.
3737 *
@@ -47,7 +47,7 @@ const { docsExampleCodeToParsableCode } = require("./code-block-utils");
4747 *
4848 * markdownIt()
4949 * .use(markdownItContainer, "rule-example", markdownItRuleExample({
50- * open({ type, code,parserOptions , codeBlockToken, env }) {
50+ * open({ type, code,languageOptions , codeBlockToken, env }) {
5151 * // do something
5252 * }
5353 * close() {
@@ -72,14 +72,14 @@ function markdownItRuleExample({ open, close }) {
7272return typeof text === "string" ?text :"" ;
7373}
7474
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 ;
7777const codeBlockToken = tokens [ index + 1 ] ;
7878
7979// Remove trailing newline and presentational `⏎` characters (https://github.com/eslint/eslint/issues/17627):
8080const code = docsExampleCodeToParsableCode ( codeBlockToken . content ) ;
8181
82- const text = open ( { type, code, parserOptions , codeBlockToken, env} ) ;
82+ const text = open ( { type, code, languageOptions , codeBlockToken, env} ) ;
8383
8484// Return an empty string to avoid appending unexpected text to the output.
8585return typeof text === "string" ?text :"" ;