From 21d579a00b0b24093179f0b2d63eb0ffeb5ce070 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Fri, 24 Jul 2020 11:31:31 +0200 Subject: [PATCH 1/2] Add Github Flavoured Markdown extension to filter Convert HTML tables and strikethrough --- package-lock.json | 5 +++++ package.json | 3 ++- src/filter/index.js | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index a8ff0a42d..0fbf49f54 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2303,6 +2303,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", diff --git a/package.json b/package.json index 64f728466..87d56ea86 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "node-schedule": "^1.3.2", "sib-api-v3-sdk": "^7.2.3", "simple-git": "^2.6.0", - "turndown": "^6.0.0" + "turndown": "^6.0.0", + "turndown-plugin-gfm": "^1.0.2" } } diff --git a/src/filter/index.js b/src/filter/index.js index 3f251dccd..6ab0d27cb 100644 --- a/src/filter/index.js +++ b/src/filter/index.js @@ -1,8 +1,10 @@ import TurndownService from 'turndown'; +import turndownPluginGithubFlavouredMarkdown from 'turndown-plugin-gfm'; import jsdom from 'jsdom'; const { JSDOM } = jsdom; const turndownService = new TurndownService(); +turndownService.use(turndownPluginGithubFlavouredMarkdown.gfm); export default async function filter(content, selector, filterNames, filterFunctions) { From 0c97f5bb9bc62a2c15a8e92d6ea17c871786d1b6 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Fri, 24 Jul 2020 11:54:57 +0200 Subject: [PATCH 2/2] Support multiline table cells in markdown Official plugin is not maintained, the joplin-turndown-plugin-gfm fork contains fixes for HTML tables conversions See https://github.com/domchristie/turndown-plugin-gfm/issues/3 --- package-lock.json | 10 +++++----- package.json | 4 ++-- src/filter/index.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0fbf49f54..5838a96a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1201,6 +1201,11 @@ "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" }, + "joplin-turndown-plugin-gfm": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/joplin-turndown-plugin-gfm/-/joplin-turndown-plugin-gfm-1.0.12.tgz", + "integrity": "sha512-qL4+1iycQjZ1fs8zk3jSRk7cg3ROBUHk7GKtiLAQLFzLPKErnILUvz5DLszSQvz3s1sTjPbywLDISVUtBY6HaA==" + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -2303,11 +2308,6 @@ "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", diff --git a/package.json b/package.json index 87d56ea86..a92b0eb94 100644 --- a/package.json +++ b/package.json @@ -42,12 +42,12 @@ "dotenv": "^8.2.0", "http-proxy-agent": "^4.0.1", "https-proxy-agent": "^5.0.0", + "joplin-turndown-plugin-gfm": "^1.0.12", "jsdom": "^16.2.2", "node-fetch": "^2.6.0", "node-schedule": "^1.3.2", "sib-api-v3-sdk": "^7.2.3", "simple-git": "^2.6.0", - "turndown": "^6.0.0", - "turndown-plugin-gfm": "^1.0.2" + "turndown": "^6.0.0" } } diff --git a/src/filter/index.js b/src/filter/index.js index 6ab0d27cb..04e50d935 100644 --- a/src/filter/index.js +++ b/src/filter/index.js @@ -1,5 +1,5 @@ import TurndownService from 'turndown'; -import turndownPluginGithubFlavouredMarkdown from 'turndown-plugin-gfm'; +import turndownPluginGithubFlavouredMarkdown from 'joplin-turndown-plugin-gfm'; import jsdom from 'jsdom'; const { JSDOM } = jsdom;