From 94c93d045c6d2ca01c6b0c458059ed0a148a7a47 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sun, 23 Feb 2025 16:18:40 -0500 Subject: [PATCH] Fix for awful markdown links with
--- src/translator.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/translator.js b/src/translator.js index a317f4b..2642106 100644 --- a/src/translator.js +++ b/src/translator.js @@ -34,6 +34,14 @@ function initTurndownService() { replacement: (content, node) => '\n\n' + node.outerHTML }); + //
within can cause extra whitespace that wreck markdown links, so this removes them + turndownService.addRule('a', { + filter: 'a', + replacement: (content) => { + return content.replace(/<\/?div[^>]*>/gi, ''); + } + }); + // preserve embedded scripts (for tweets, codepens, gists, etc.) turndownService.addRule('script', { filter: 'script',