Skip to content

Commit 025bac2

Browse files
committed
Pass token to renderers
1 parent 9816cfd commit 025bac2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @typedef {import("markdown-it/lib/parser_inline.mjs").RuleInline} RuleInline
55
* @typedef {import("markdown-it/lib/rules_block/state_block.mjs").default} StateBlock
66
* @typedef {import("markdown-it/lib/rules_inline/state_inline.mjs").default} StateInline
7+
* @typedef {import("markdown-it/lib/token.mjs").default} Token
78
*/
89

910
/** @type {import("mathup").default | undefined} */
@@ -244,10 +245,10 @@ function defaultBlockRenderer(options = {}) {
244245
* @typedef {object} PluginOptions
245246
* @property {string} [inlineOpen]
246247
* @property {string} [inlineClose]
247-
* @property {(src: string) => string} [inlineRenderer]
248+
* @property {(src: string, token: Token) => string} [inlineRenderer]
248249
* @property {string} [blockOpen]
249250
* @property {string} [blockClose]
250-
* @property {(src: string) => string} [blockRenderer]
251+
* @property {(src: string, token: Token) => string} [blockRenderer]
251252
* @property {import("mathup").Options} [defaultRendererOptions]
252253
* @typedef {import("markdown-it").PluginWithOptions<PluginOptions>} Plugin
253254
*/
@@ -276,8 +277,8 @@ export default function markdownItMath(
276277
});
277278

278279
md.renderer.rules.math_inline = (tokens, idx) =>
279-
inlineRenderer(tokens[idx].content);
280+
inlineRenderer(tokens[idx].content, tokens[idx]);
280281

281282
md.renderer.rules.math_block = (tokens, idx) =>
282-
`${blockRenderer(tokens[idx].content)}\n`;
283+
`${blockRenderer(tokens[idx].content, tokens[idx])}\n`;
283284
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "index.js",
77
"types": "types/index.js",
88
"scripts": {
9-
"clean": "rm -fr types/",
9+
"clean": "rm -fr coverage/ types/",
1010
"check": "tsc --noEmit",
1111
"lint": "eslint .",
1212
"lint:fix": "eslint --fix .",
@@ -48,7 +48,6 @@
4848
"globals": "^16.0.0",
4949
"markdown-it": "^14.1.0",
5050
"prettier": "3.5.3",
51-
"rollup": "^4.34.9",
5251
"texzilla": "^1.0.2",
5352
"typescript": "^5.8.2"
5453
},

0 commit comments

Comments
 (0)