mirror of
https://github.com/markedjs/marked
synced 2024-11-22 00:05:53 +00:00
fix: fix recursion-like stack overflow error caused by the old render… (#3380)
Co-authored-by: tylerccwang <tylerccwang@tencent.com>
This commit is contained in:
parent
829453b48e
commit
89af0b85b1
@ -153,13 +153,13 @@ export class Marked {
|
||||
}
|
||||
const rendererProp = prop as Exclude<keyof _Renderer, 'options' | 'parser'>;
|
||||
let rendererFunc = pack.renderer[rendererProp] as GenericRendererFunction;
|
||||
if (!pack.useNewRenderer) {
|
||||
// TODO: Remove this in next major version
|
||||
rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer) as GenericRendererFunction;
|
||||
}
|
||||
const prevRenderer = renderer[rendererProp] as GenericRendererFunction;
|
||||
// Replace renderer with func to run extension, but fall back if false
|
||||
renderer[rendererProp] = (...args: unknown[]) => {
|
||||
if (!pack.useNewRenderer) {
|
||||
// TODO: Remove this in next major version
|
||||
rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer) as GenericRendererFunction;
|
||||
}
|
||||
let ret = rendererFunc.apply(renderer, args);
|
||||
if (ret === false) {
|
||||
ret = prevRenderer.apply(renderer, args);
|
||||
|
Loading…
Reference in New Issue
Block a user