From e127a52edf8123b6c14fdc03c890d0756b232bea Mon Sep 17 00:00:00 2001 From: Yahya Batulu <46069238+ByPikod@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:55:15 +0300 Subject: [PATCH] Fixed rule finder Old code was failed to find function after code compiled and obfuscated. That because of code was trying to access function by its name "dynamically". But compiling removes function names and code occurs error. --- src/plugin.ts | 8 ++++---- tsconfig.json | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index e6f3219..f62d427 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -63,10 +63,10 @@ export function alertPlugin (md: MarkdownIt): void { md.renderer.rules.blockquote_close = renderBlockquoteClose // Find actual blockquote function - const actualBlockquote = md.block.ruler - .getRules('') - .find((val: RuleBlock) => val.name === 'blockquote') - if (actualBlockquote === undefined) throw new Error('Blockquote rule not found!') + const ruler = (md.block.ruler as any) + const rule = ruler.__rules__.find((rule: any) => rule.name === 'blockquote') + const actualBlockquote = rule.fn as RuleBlock + if (typeof actualBlockquote !== 'function') throw new Error('Blockquote rule not found!') // Change it with the custom one md.block.ruler.at( diff --git a/tsconfig.json b/tsconfig.json index fe95ca9..b5b36ac 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ }, "include": [ "src/**/*.ts", + "typings/**/*.d.ts" ], "exclude": [ "node_modules",