You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(if hooks is defined it expects provideLexer and provideParser functions to be defined as well)
To Reproduce
import{marked}from"marked";constoptions={hooks: {postprocess: (html)=>html,},};// Run markedconsole.log(marked.parse("# Test",options));// TypeError: opt.hooks.provideLexer is not a function
Note that when providing options using the use function, it works:
We really want to get away from people adding options to parse. The same thing will happen if you try to pass a partial tokenizer or renderer object to parse. The reason is that the logic in marked.use to combine all of these partial objects and extensions is very slow so we want people to do it once at the beginning rather than in a loop when they call parse on different markdown strings.
If your goal is to pass different hooks depending on the markdown string you can use different marked instances
Marked version:
15.0.7
Describe the bug
When providing only subset of hooks it fails on:
marked/src/Instance.ts
Line 297 in 7fee000
hooks
is defined it expectsprovideLexer
andprovideParser
functions to be defined as well)To Reproduce
Note that when providing options using the
use
function, it works:Expected behavior
I think it should be possible to provide only subset of hooks when using
parse
function as well.The text was updated successfully, but these errors were encountered: