Skip to content

Commit b9d0e09

Browse files
authored
Optionally pass token directly to renderer
This simple patch passes token itself to custom renderer function as a second parameter. This is useful to handle `token.attrs` or whatever else in custom renderer, if some other plugin changes those. This doesn't change existing API, only extends it. Let me know if you want me to add a minimal testcase.
1 parent 79f46a1 commit b9d0e09

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ module.exports = function math_plugin(md, options) {
235235
blockClose = options.blockClose || '$$$';
236236
var inlineRenderer = options.inlineRenderer ?
237237
function(tokens, idx) {
238-
return options.inlineRenderer(tokens[idx].content);
238+
return options.inlineRenderer(tokens[idx].content, tokens[idx]);
239239
} :
240240
makeMathRenderer(options.renderingOptions);
241241
var blockRenderer = options.blockRenderer ?
242242
function(tokens, idx) {
243-
return options.blockRenderer(tokens[idx].content) + '\n';
243+
return options.blockRenderer(tokens[idx].content, tokens[idx]) + '\n';
244244
} :
245245
makeMathRenderer(Object.assign({ display: 'block' },
246246
options.renderingOptions));

0 commit comments

Comments
 (0)