mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-16 05:03:38 +09:00
Add support for enlighter code blocks
This commit is contained in:
@@ -44,6 +44,15 @@ function initTurndownService() {
|
||||
}
|
||||
});
|
||||
|
||||
// preserve enlighter code blocks
|
||||
turndownService.addRule('enlighter', {
|
||||
filter: node => node.nodeName === 'PRE' && node.getAttribute('class') === 'EnlighterJSRAW',
|
||||
replacement: (content, node) => {
|
||||
const language = node.getAttribute('data-enlighter-language') ?? '';
|
||||
return '\n' + '```' + language + '\n' + content + '\n' + '```' + '\n';
|
||||
}
|
||||
});
|
||||
|
||||
// iframe boolean attributes do not need to be set to empty string
|
||||
turndownService.addRule('iframe', {
|
||||
filter: 'iframe',
|
||||
|
||||
Reference in New Issue
Block a user