mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-11 10:46:15 +09:00
Remove style contents, excessive line breaks
This commit is contained in:
@@ -14,6 +14,8 @@ function initTurndownService() {
|
|||||||
|
|
||||||
turndownService.use(turndownPluginGfm.tables);
|
turndownService.use(turndownPluginGfm.tables);
|
||||||
|
|
||||||
|
turndownService.remove(['style']); // <style> contents get dumped as plain text, would rather remove
|
||||||
|
|
||||||
// preserve embedded tweets
|
// preserve embedded tweets
|
||||||
turndownService.addRule('tweet', {
|
turndownService.addRule('tweet', {
|
||||||
filter: node => node.nodeName === 'BLOCKQUOTE' && node.getAttribute('class') === 'twitter-tweet',
|
filter: node => node.nodeName === 'BLOCKQUOTE' && node.getAttribute('class') === 'twitter-tweet',
|
||||||
@@ -132,5 +134,8 @@ export function getPostContent(content) {
|
|||||||
// clean up extra spaces in list items
|
// clean up extra spaces in list items
|
||||||
content = content.replace(/(-|\d+\.) +/g, '$1 ');
|
content = content.replace(/(-|\d+\.) +/g, '$1 ');
|
||||||
|
|
||||||
|
// collapse excessive newlines (can happen with a lot of <div>)
|
||||||
|
content = content.replace(/(\r?\n){3,}/g, '\n\n');
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user