Skip to content

Commit

Permalink
Fixed rule finder
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ByPikod committed Oct 26, 2023
1 parent 7bb8a21 commit e127a52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"include": [
"src/**/*.ts",
"typings/**/*.d.ts"
],
"exclude": [
"node_modules",
Expand Down

0 comments on commit e127a52

Please sign in to comment.