From 494e1558495a900315e6fe72a001b79a518a8a08 Mon Sep 17 00:00:00 2001 From: confused-Techie Date: Sun, 7 Jan 2024 21:15:48 -0800 Subject: [PATCH] Ensure `pack` is available within `md.renderer.rules.image` --- src/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils.js b/src/utils.js index 08d3f23..30dd18b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -42,6 +42,9 @@ function addCustomMarkdownHandling () { let defaultImageRender = md.renderer.rules.image; md.renderer.rules.image = function(tokens, idx, options, env, self) { + // HACK: Get the `pack` object from an outer scope so that we don't have + // to redefine this handler on every request. + let pack = currentPackage; let token = tokens[idx]; let aIndex = token.attrIndex('src');