Fix for awful markdown links with <div>

This commit is contained in:
Will Boyd
2025-02-23 16:18:40 -05:00
parent db5430117e
commit 94c93d045c
+8
View File
@@ -34,6 +34,14 @@ function initTurndownService() {
replacement: (content, node) => '\n\n' + node.outerHTML
});
// <div> within <a> 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',