Convert tables to markdown

This commit is contained in:
Will Boyd
2020-12-22 13:18:49 -05:00
parent f27afacc7f
commit 86d793071d
3 changed files with 9 additions and 0 deletions
+5
View File
@@ -1572,6 +1572,11 @@
"jsdom": "^16.2.0"
}
},
"turndown-plugin-gfm": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/turndown-plugin-gfm/-/turndown-plugin-gfm-1.0.2.tgz",
"integrity": "sha512-vwz9tfvF7XN/jE0dGoBei3FXWuvll78ohzCZQuOb+ZjWrs3a0XhQVomJEb2Qh4VHTPNRO4GPZh0V7VRbiWwkRg=="
},
"tweetnacl": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
+1
View File
@@ -28,6 +28,7 @@
"request": "^2.88.2",
"request-promise-native": "^1.0.8",
"turndown": "^6.0.0",
"turndown-plugin-gfm": "^1.0.2",
"xml2js": "^0.4.23"
},
"devDependencies": {
+3
View File
@@ -1,4 +1,5 @@
const turndown = require('turndown');
const turndownPluginGfm = require('turndown-plugin-gfm');
function initTurndownService() {
const turndownService = new turndown({
@@ -7,6 +8,8 @@ function initTurndownService() {
codeBlockStyle: 'fenced'
});
turndownService.use(turndownPluginGfm.tables);
// preserve embedded tweets
turndownService.addRule('tweet', {
filter: node => node.nodeName === 'BLOCKQUOTE' && node.getAttribute('class') === 'twitter-tweet',