5
5
/**
6
6
* A callback function to handle the opening of container blocks.
7
7
* @callback OpenHandler
8
- * @param {"correct" | "incorrect" } type The type of the example.
9
- * @param {string } code The example code.
10
- * @param {ParserOptions } parserOptions The parser options to be passed to the Playground.
11
- * @param {Object } codeBlockToken The `markdown-it` token for the code block inside the container.
8
+ * @param {Object } data Callback data.
9
+ * @param {"correct" | "incorrect" } data.type The type of the example.
10
+ * @param {string } data.code The example code.
11
+ * @param {ParserOptions } data.parserOptions The parser options to be passed to the Playground.
12
+ * @param {Object } data.codeBlockToken The `markdown-it` token for the code block inside the container.
13
+ * @param {Object } data.env Additional Eleventy metadata, if available.
12
14
* @returns {string | undefined } If a text is returned, it will be appended to the rendered output
13
15
* of `markdown-it`.
14
16
*/
43
45
*
44
46
* markdownIt()
45
47
* .use(markdownItContainer, "rule-example", markdownItRuleExample({
46
- * open(type, code, parserOptions, codeBlockToken) {
48
+ * open({ type, code, parserOptions, codeBlockToken, env } ) {
47
49
* // do something
48
50
* }
49
51
* close() {
@@ -58,7 +60,7 @@ function markdownItRuleExample({ open, close }) {
58
60
validate ( info ) {
59
61
return / ^ \s * (?: i n ) ? c o r r e c t (? ! \S ) / u. test ( info ) ;
60
62
} ,
61
- render ( tokens , index ) {
63
+ render ( tokens , index , options , env ) {
62
64
const tagToken = tokens [ index ] ;
63
65
64
66
if ( tagToken . nesting < 0 ) {
@@ -77,7 +79,7 @@ function markdownItRuleExample({ open, close }) {
77
79
. replace ( / \n $ / u, "" )
78
80
. replace ( / ⏎ (? = \n ) / gu, "" ) ;
79
81
80
- const text = open ( type , code , parserOptions , codeBlockToken ) ;
82
+ const text = open ( { type, code, parserOptions, codeBlockToken, env } ) ;
81
83
82
84
// Return an empty string to avoid appending unexpected text to the output.
83
85
return typeof text === "string" ? text : "" ;
0 commit comments