mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-06-05 15:09:59 +09:00
Merge pull request #157 from lonekorean/links-divs-figures
Restore fix for divs in links, figure tweak
This commit is contained in:
+7
-7
@@ -37,12 +37,12 @@ function initTurndownService() {
|
||||
});
|
||||
|
||||
// <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, '');
|
||||
// }
|
||||
// });
|
||||
turndownService.addRule('div', {
|
||||
filter: (node) => {
|
||||
return node.nodeName === 'DIV' && node.closest('a') !== null;
|
||||
},
|
||||
replacement: (content) => content
|
||||
});
|
||||
|
||||
// preserve embedded scripts (for tweets, codepens, gists, etc.)
|
||||
turndownService.addRule('script', {
|
||||
@@ -79,7 +79,7 @@ function initTurndownService() {
|
||||
return result.replace('\n\n\n\n', '\n\n'); // collapse quadruple newlines
|
||||
} else {
|
||||
// does not contain <figcaption>, do not preserve
|
||||
return content;
|
||||
return '\n' + content + '\n';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user