UNPKG

@nolebase/markdown-it-element-transform

Version:
25 lines (22 loc) 676 B
'use strict'; const ElementTransform = (md, options) => { if (!options || !options.transform) throw new Error("The `transform` option is required"); md.core.ruler.push( "token_transform", (state) => { const transformFunc = options.transform === void 0 ? function() { } : options.transform; state.tokens.forEach((token) => { if (token.children && token.children.length) { token.children.forEach((token2) => { transformFunc(token2, state, state.env); }); } transformFunc(token, state, state.env); }); return false; } ); }; exports.ElementTransform = ElementTransform;