From 8a7c7867c79315c6c30a3d57648ab4e863bec3e1 Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 4 May 2021 15:35:41 -0400 Subject: [PATCH 01/13] :sparkles: Markdown Node --- .../nodes/Markdown/Markdown.node.ts | 181 ++++++++++++++++++ .../nodes-base/nodes/Markdown/markdown.svg | 6 + packages/nodes-base/package.json | 3 + 3 files changed, 190 insertions(+) create mode 100644 packages/nodes-base/nodes/Markdown/Markdown.node.ts create mode 100644 packages/nodes-base/nodes/Markdown/markdown.svg diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts new file mode 100644 index 0000000000000..4478d2f60f201 --- /dev/null +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -0,0 +1,181 @@ +import { + IExecuteFunctions, +} from 'n8n-core'; + +import { + IDataObject, + INodeExecutionData, + INodeType, + INodeTypeDescription, +} from 'n8n-workflow'; + +//@ts-expect-error +import * as showdown from 'showdown'; + +//@ts-expect-error +import * as jsdom from 'jsdom'; + +const dom = new jsdom.JSDOM(); + +const converter = new showdown.Converter(); + +import { + set, +} from 'lodash'; + +export class Markdown implements INodeType { + description: INodeTypeDescription = { + displayName: 'Markdown', + name: 'markdown', + icon: 'file:markdown.svg', + group: ['output'], + version: 1, + subtitle: '={{$parameter["mode"]==="markdownToHtml" ? "Markdown to HTML" : "HTML to Markdown"}}', + description: 'Move data between Markdown and HTML.', + defaults: { + name: 'Markdown', + color: '#000000', + }, + inputs: ['main'], + outputs: ['main'], + credentials: [], + properties: [ + { + displayName: 'Mode', + name: 'mode', + type: 'options', + options: [ + { + name: 'Markdown to HTML', + value: 'markdownToHtml', + description: 'Move data from MarkdoWN to HTML', + }, + { + name: 'HTML to Markdown', + value: 'htmlToMarkdown', + description: 'Move data from HTML to Markdown.', + }, + ], + default: 'htmlToMarkdown', + description: 'From and to where data should be moved.', + }, + { + displayName: 'HTML', + name: 'html', + type: 'string', + displayOptions: { + show: { + mode: [ + 'htmlToMarkdown', + ], + }, + }, + default: '', + required: true, + description: 'The HTML to be converted.', + }, + { + displayName: 'Markdown', + name: 'markdown', + type: 'string', + displayOptions: { + show: { + mode: [ + 'markdownToHtml', + ], + }, + }, + default: '', + required: true, + description: 'The Markdown to be converted.', + }, + { + displayName: 'Destination Key', + name: 'destinationKey', + type: 'string', + displayOptions: { + show: { + mode: [ + 'markdownToHtml', + 'htmlToMarkdown', + ], + }, + }, + default: 'data', + required: true, + placeholder: '', + description: 'The name the JSON key to copy data to. It is also possible
to define deep keys by using dot-notation like for example:
"level1.level2.newKey"', + }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Option', + default: {}, + options: [ + { + displayName: 'Flavor', + name: 'flavor', + type: 'options', + options: [ + { + name: 'Github', + value: 'github', + description: 'GFM (GitHub Flavored Markdown)', + }, + { + name: 'Vanilla', + value: 'vanilla', + description: 'Showdown base flavor', + }, + { + name: 'Original', + value: 'original', + description: `Original markdown flavor as in John Gruber's spec`, + }, + ], + displayOptions: { + show: { + '/mode': [ + 'htmlToMarkdown', + ], + }, + }, + default: 'vanilla', + }, + ], + }, + ], + }; + + async execute(this: IExecuteFunctions): Promise { + const items = this.getInputData(); + const returnData: INodeExecutionData[] = []; + const length = items.length as unknown as number; + const newItem: INodeExecutionData = { json: {} }; + const mode = this.getNodeParameter('mode', 0) as string; + + for (let i = 0; i < length; i++) { + if (mode === 'htmlToMarkdown') { + const options = this.getNodeParameter('options', i) as IDataObject; + const destinationKey = this.getNodeParameter('destinationKey', i) as string; + converter.setFlavor(options.flavor as showdown.Flavor || 'vanilla'); + const html = this.getNodeParameter('html', i) as string; + const md = converter.makeMarkdown(html, dom.window.document); + newItem.json = JSON.parse(JSON.stringify(items[i].json)); + set(newItem.json, destinationKey, md); + returnData.push(newItem); + } + + if (mode === 'markdownToHtml') { + const markdown = this.getNodeParameter('markdown', i) as string; + const html = converter.makeHtml(markdown); + const destinationKey = this.getNodeParameter('destinationKey', i) as string; + newItem.json = JSON.parse(JSON.stringify(items[i].json)); + set(newItem.json, destinationKey, html); + returnData.push(newItem); + } + } + return this.prepareOutputData(returnData); + } +} diff --git a/packages/nodes-base/nodes/Markdown/markdown.svg b/packages/nodes-base/nodes/Markdown/markdown.svg new file mode 100644 index 0000000000000..24f62fb3298bf --- /dev/null +++ b/packages/nodes-base/nodes/Markdown/markdown.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 6056f40f71320..cb623cfd865fb 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -420,6 +420,7 @@ "dist/nodes/Mailjet/Mailjet.node.js", "dist/nodes/Mailjet/MailjetTrigger.node.js", "dist/nodes/Mandrill/Mandrill.node.js", + "dist/nodes/Markdown/Markdown.node.js", "dist/nodes/Matrix/Matrix.node.js", "dist/nodes/Mattermost/Mattermost.node.js", "dist/nodes/Mautic/Mautic.node.js", @@ -607,6 +608,7 @@ "iconv-lite": "^0.6.2", "imap-simple": "^4.3.0", "iso-639-1": "^2.1.3", + "jsdom": "^16.5.3", "jsonwebtoken": "^8.5.1", "kafkajs": "^1.14.0", "lodash.get": "^4.4.2", @@ -630,6 +632,7 @@ "request": "^2.88.2", "rhea": "^1.0.11", "rss-parser": "^3.7.0", + "showdown": "^1.9.1", "snowflake-sdk": "^1.5.3", "ssh2-sftp-client": "^5.2.1", "tmp-promise": "^3.0.2", From 511b44d606299295f91bbf87dd276e53d5f6b238 Mon Sep 17 00:00:00 2001 From: sirdavidoff <1670123+sirdavidoff@users.noreply.github.com> Date: Mon, 10 May 2021 19:18:37 +0200 Subject: [PATCH 02/13] Tweaked wording --- .../nodes/Markdown/Markdown.node.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index 4478d2f60f201..6fd25a8224218 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -31,7 +31,7 @@ export class Markdown implements INodeType { group: ['output'], version: 1, subtitle: '={{$parameter["mode"]==="markdownToHtml" ? "Markdown to HTML" : "HTML to Markdown"}}', - description: 'Move data between Markdown and HTML.', + description: 'Convert data between Markdown and HTML.', defaults: { name: 'Markdown', color: '#000000', @@ -48,16 +48,16 @@ export class Markdown implements INodeType { { name: 'Markdown to HTML', value: 'markdownToHtml', - description: 'Move data from MarkdoWN to HTML', + description: 'Convert data from Markdown to HTML.', }, { name: 'HTML to Markdown', value: 'htmlToMarkdown', - description: 'Move data from HTML to Markdown.', + description: 'Convert data from HTML to Markdown.', }, ], default: 'htmlToMarkdown', - description: 'From and to where data should be moved.', + description: 'What to convert between.', }, { displayName: 'HTML', @@ -104,7 +104,7 @@ export class Markdown implements INodeType { default: 'data', required: true, placeholder: '', - description: 'The name the JSON key to copy data to. It is also possible
to define deep keys by using dot-notation like for example:
"level1.level2.newKey"', + description: 'The field to put the output in. Specify nested fields
using dots, e.g."level1.level2.newKey"', }, { displayName: 'Options', @@ -114,24 +114,24 @@ export class Markdown implements INodeType { default: {}, options: [ { - displayName: 'Flavor', + displayName: 'Markdown Flavor', name: 'flavor', type: 'options', options: [ { name: 'Github', value: 'github', - description: 'GFM (GitHub Flavored Markdown)', + description: 'GitHub Flavored Markdown (
more info)', }, { - name: 'Vanilla', + name: 'Default', value: 'vanilla', - description: 'Showdown base flavor', + description: 'Defaults defined by Showdown library (more info)', }, { name: 'Original', value: 'original', - description: `Original markdown flavor as in John Gruber's spec`, + description: `As first defined by John Gruber (more info)`, }, ], displayOptions: { From 418e52be858aae3873bab54acf107908e4fb8ede Mon Sep 17 00:00:00 2001 From: ricardo Date: Mon, 14 Mar 2022 15:10:30 -0400 Subject: [PATCH 03/13] :arrow_up: Bump showdown to latest version --- packages/nodes-base/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 39f815c093b24..fa662faa90b2b 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -761,8 +761,8 @@ "request": "^2.88.2", "rhea": "^1.0.11", "rss-parser": "^3.7.0", + "showdown": "^2.0.3", "simple-git": "^2.36.2", - "showdown": "^1.9.1", "snowflake-sdk": "^1.5.3", "ssh2-sftp-client": "^7.0.0", "tmp-promise": "^3.0.2", From aacccd6ae2212762b1c0960b4325fe7bac923621 Mon Sep 17 00:00:00 2001 From: ricardo Date: Mon, 14 Mar 2022 15:17:24 -0400 Subject: [PATCH 04/13] :zap: Small improvement --- packages/nodes-base/nodes/Markdown/Markdown.node.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index 6fd25a8224218..0a0eaaca92183 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -118,16 +118,16 @@ export class Markdown implements INodeType { name: 'flavor', type: 'options', options: [ - { - name: 'Github', - value: 'github', - description: 'GitHub Flavored Markdown (more info)', - }, { name: 'Default', value: 'vanilla', description: 'Defaults defined by Showdown library (more info)', }, + { + name: 'Github', + value: 'github', + description: 'GitHub Flavored Markdown (more info)', + }, { name: 'Original', value: 'original', From ced39efd5bfcd9f290e8c1e85e9fbea360d799af Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 15 Mar 2022 14:43:33 -0400 Subject: [PATCH 05/13] :shirt: Fix linting issue --- packages/nodes-base/nodes/Markdown/Markdown.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index 0a0eaaca92183..f3c259fab56e1 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -104,7 +104,7 @@ export class Markdown implements INodeType { default: 'data', required: true, placeholder: '', - description: 'The field to put the output in. Specify nested fields
using dots, e.g."level1.level2.newKey"', + description: 'The field to put the output in. Specify nested fields
using dots, e.g."level1.level2.newKey"', }, { displayName: 'Options', From 7a01ca149845131f0dbea774d9d7640c2338cf70 Mon Sep 17 00:00:00 2001 From: ricardo Date: Wed, 16 Mar 2022 17:20:30 -0400 Subject: [PATCH 06/13] :zap: Small improvements --- .../nodes-base/nodes/Markdown/Markdown.node.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index f3c259fab56e1..d1ca6c504844b 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -48,12 +48,12 @@ export class Markdown implements INodeType { { name: 'Markdown to HTML', value: 'markdownToHtml', - description: 'Convert data from Markdown to HTML.', + description: 'Convert data from Markdown to HTML', }, { name: 'HTML to Markdown', value: 'htmlToMarkdown', - description: 'Convert data from HTML to Markdown.', + description: 'Convert data from HTML to Markdown', }, ], default: 'htmlToMarkdown', @@ -72,7 +72,7 @@ export class Markdown implements INodeType { }, default: '', required: true, - description: 'The HTML to be converted.', + description: 'The HTML to be converted', }, { displayName: 'Markdown', @@ -87,7 +87,7 @@ export class Markdown implements INodeType { }, default: '', required: true, - description: 'The Markdown to be converted.', + description: 'The Markdown to be converted', }, { displayName: 'Destination Key', @@ -124,14 +124,14 @@ export class Markdown implements INodeType { description: 'Defaults defined by Showdown library (more info)', }, { - name: 'Github', + name: 'GitHub', value: 'github', - description: 'GitHub Flavored Markdown (more info)', + description: 'GitHub Flavored Markdown (more info)', }, { name: 'Original', value: 'original', - description: `As first defined by John Gruber (more info)`, + description: `As first defined by John Gruber (more info)`, }, ], displayOptions: { From b66132e8901e8389ea9ce99bfca00bb117dd5701 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Tue, 5 Apr 2022 14:22:57 +0300 Subject: [PATCH 07/13] :hammer: added options, added continue on fail, some clean up --- .../nodes/Markdown/Markdown.node.ts | 333 +++++++++++++++--- packages/nodes-base/package.json | 2 + 2 files changed, 290 insertions(+), 45 deletions(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index d1ca6c504844b..31d40dc28167f 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -7,21 +7,14 @@ import { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; -//@ts-expect-error -import * as showdown from 'showdown'; +import { Converter, Flavor } from 'showdown'; -//@ts-expect-error -import * as jsdom from 'jsdom'; +import { JSDOM } from 'jsdom'; -const dom = new jsdom.JSDOM(); - -const converter = new showdown.Converter(); - -import { - set, -} from 'lodash'; +import { set } from 'lodash'; export class Markdown implements INodeType { description: INodeTypeDescription = { @@ -31,7 +24,7 @@ export class Markdown implements INodeType { group: ['output'], version: 1, subtitle: '={{$parameter["mode"]==="markdownToHtml" ? "Markdown to HTML" : "HTML to Markdown"}}', - description: 'Convert data between Markdown and HTML.', + description: 'Convert data between Markdown and HTML', defaults: { name: 'Markdown', color: '#000000', @@ -57,7 +50,6 @@ export class Markdown implements INodeType { }, ], default: 'htmlToMarkdown', - description: 'What to convert between.', }, { displayName: 'HTML', @@ -72,7 +64,7 @@ export class Markdown implements INodeType { }, default: '', required: true, - description: 'The HTML to be converted', + description: 'The HTML to be converted to markdown', }, { displayName: 'Markdown', @@ -87,7 +79,7 @@ export class Markdown implements INodeType { }, default: '', required: true, - description: 'The Markdown to be converted', + description: 'The Markdown to be converted to html', }, { displayName: 'Destination Key', @@ -104,14 +96,23 @@ export class Markdown implements INodeType { default: 'data', required: true, placeholder: '', - description: 'The field to put the output in. Specify nested fields
using dots, e.g."level1.level2.newKey"', + description: 'The field to put the output in. Specify nested fields
using dots, e.g."level1.level2.newKey".', }, + + //============= HTML to Markdown Options =============== { displayName: 'Options', name: 'options', type: 'collection', placeholder: 'Add Option', default: {}, + displayOptions: { + show: { + 'mode': [ + 'htmlToMarkdown', + ], + }, + }, options: [ { displayName: 'Markdown Flavor', @@ -131,18 +132,238 @@ export class Markdown implements INodeType { { name: 'Original', value: 'original', - description: `As first defined by John Gruber (more info)`, + description: `As first defined by John Gruber (more info)`, }, ], - displayOptions: { - show: { - '/mode': [ - 'htmlToMarkdown', - ], - }, - }, default: 'vanilla', }, + { + displayName: 'Omit Trailing Newline', + name: 'omitExtraWLInCodeBlocks', + type: 'boolean', + default: false, + description: 'Whether to omit the trailing newline in a code block', + }, + ], + }, + //============= Markdown to HTML Options =============== + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Option', + default: {}, + displayOptions: { + show: { + 'mode': [ + 'markdownToHtml', + ], + }, + }, + options: [ + { + displayName: 'Add Blank To Links', + name: 'openLinksInNewWindow', + type: 'boolean', + default: false, + description: 'Whether to open all links in new windows (by adding the attribute target="_blank" to tags)', + }, + { + displayName: 'Automatic Linking To URLs', + name: 'simplifiedAutoLink', + type: 'boolean', + default: false, + description: 'Whether to enable automatic linking to urls', + }, + { + displayName: 'Backslash Escapes HTML Tags', + name: 'backslashEscapesHTMLTags', + type: 'boolean', + default: false, + description: 'Whether to support for HTML Tag escaping ex: \
foo\, and tags instead of an HTML fragment', + }, + { + displayName: 'Customized Header ID', + name: 'customizedHeaderId', + type: 'boolean', + default: false, + description: 'Whether to use text in curly braces as header id', + }, + { + displayName: 'Emoji Support', + name: 'emoji', + type: 'boolean', + default: false, + description: 'Whether to enable emoji support. Ex: this is a :smile: emoji For more info on available emojis, see https://github.com/showdownjs/showdown/wiki/Emojis.', + }, + { + displayName: 'Encode Emails', + name: 'encodeEmails', + type: 'boolean', + default: true, + description: 'Whether to enable e-mail addresses encoding through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities', + }, + { + displayName: 'Exclude Trailing Punctuation From URLs', + name: 'excludeTrailingPunctuationFromURLs', + type: 'boolean', + default: false, + description: 'Whether to exclude trailing punctuation from autolinking urls. Punctuation excluded: . ! ? ( ). Only applies if simplifiedAutoLink option is set to true.', + }, + { + displayName: 'GitHub Code Blocks', + name: 'ghCodeBlocks', + type: 'boolean', + default: true, + description: 'Whether to enable support for GFM code block style', + }, + { + displayName: 'GitHub Compatible Header IDs', + name: 'ghCompatibleHeaderId', + type: 'boolean', + default: false, + description: 'Whether to generate header ids compatible with github style (spaces are replaced with dashes and a bunch of non alphanumeric chars are removed)', + }, + { + displayName: 'GitHub Mention Link', + name: 'ghMentionsLink', + type: 'string', + default: 'https://github.com/{u}', + description: 'Whether to change the link generated by @mentions. Showdown will replace {u} with the username. Only applies if ghMentions option is enabled.', + }, + { + displayName: 'GitHub Mentions', + name: 'ghMentions', + type: 'boolean', + default: false, + description: 'Whether to enable github @mentions, which link to the username mentioned', + }, + { + displayName: 'GitHub Task Lists', + name: 'tasklists', + type: 'boolean', + default: false, + description: 'Whether to enable support for GFM tasklists', + }, + { + displayName: 'Header Level Start', + name: 'headerLevelStart', + type: 'number', + default: 1, + description: 'Whether to set the header starting level', + }, + { + displayName: 'Mandatory Space Before Header', + name: 'requireSpaceBeforeHeadingText', + type: 'boolean', + default: false, + description: 'Whether to make adding a space between # and the header text mandatory', + }, + { + displayName: 'Middle Word Asterisks', + name: 'literalMidWordAsterisks', + type: 'boolean', + default: false, + description: 'Whether to stop showdown from interpreting asterisks in the middle of words as and and instead treat them as literal asterisks', + }, + { + displayName: 'Middle Word Underscores', + name: 'literalMidWordUnderscores', + type: 'boolean', + default: false, + description: 'Whether to stop showdown from interpreting underscores in the middle of words as and and instead treat them as literal underscores', + }, + { + displayName: 'No Header ID', + name: 'noHeaderId', + type: 'boolean', + default: false, + description: 'Whether to disable the automatic generation of header ids', + }, + { + displayName: 'Parse Image Dimensions', + name: 'parseImgDimensions', + type: 'boolean', + default: false, + description: 'Whether to enable support for setting image dimensions from within markdown syntax', + }, + { + displayName: 'Prefix Header ID', + name: 'prefixHeaderId', + type: 'string', + default: 'section', + description: 'Add a prefix to the generated header ids', + }, + { + displayName: 'Raw Header ID', + name: 'rawHeaderId', + type: 'boolean', + default: false, + description: 'Whether to remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-)', + }, + { + displayName: 'Raw Prefix Header ID', + name: 'rawPrefixHeaderId', + type: 'boolean', + default: false, + description: 'Whether to prevent showdown from modifying the prefix', + }, + { + displayName: 'Simple Line Breaks', + name: 'simpleLineBreaks', + type: 'boolean', + default: false, + description: 'Whether to parse line breaks as
, like GitHub does, without needing 2 spaces at the end of the line', + }, + { + displayName: 'Smart Indentation Fix', + name: 'smartIndentationFix', + type: 'boolean', + default: false, + description: 'Whether to try to smartly fix indentation problems related to es6 template strings in the midst of indented code', + }, + { + displayName: 'Spaces Indented Sublists', + name: 'disableForced4SpacesIndentedSublists', + type: 'boolean', + default: false, + description: 'Whether to disable the requirement of indenting sublists by 4 spaces for them to be nested, effectively reverting to the old behavior where 2 or 3 spaces were enough', + }, + { + displayName: 'Split Adjacent Blockquotes', + name: 'splitAdjacentBlockquotes', + type: 'boolean', + default: false, + description: 'Whether to split adjacent blockquote blocks', + }, + { + displayName: 'Strikethrough', + name: 'strikethrough', + type: 'boolean', + default: false, + description: 'Whether to enable support for strikethrough syntax', + }, + { + displayName: 'Tables Header ID', + name: 'tablesHeaderId', + type: 'boolean', + default: false, + description: 'Whether to add an ID property to table headers tags', + }, + { + displayName: 'Tables Support', + name: 'tables', + type: 'boolean', + default: false, + description: 'Whether to enable support for tables syntax', + }, ], }, ], @@ -150,32 +371,54 @@ export class Markdown implements INodeType { async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); - const returnData: INodeExecutionData[] = []; - const length = items.length as unknown as number; - const newItem: INodeExecutionData = { json: {} }; + const returnData: IDataObject[] = []; + + const converter = new Converter(); + const mode = this.getNodeParameter('mode', 0) as string; + const { length } = items; for (let i = 0; i < length; i++) { - if (mode === 'htmlToMarkdown') { - const options = this.getNodeParameter('options', i) as IDataObject; - const destinationKey = this.getNodeParameter('destinationKey', i) as string; - converter.setFlavor(options.flavor as showdown.Flavor || 'vanilla'); - const html = this.getNodeParameter('html', i) as string; - const md = converter.makeMarkdown(html, dom.window.document); - newItem.json = JSON.parse(JSON.stringify(items[i].json)); - set(newItem.json, destinationKey, md); - returnData.push(newItem); - } + try { + if (mode === 'htmlToMarkdown') { + const options = this.getNodeParameter('options', i) as IDataObject; + const destinationKey = this.getNodeParameter('destinationKey', i) as string; + + converter.setFlavor(options.flavor as Flavor || 'vanilla'); + Object.keys(options).filter(key => key !== 'flavor').forEach( key => converter.setOption(key, options[key])); + + const html = this.getNodeParameter('html', i) as string; + const dom = new JSDOM(html); + + const markdownFromHTML = converter.makeMarkdown(dom.window.document.body.outerHTML, dom.window.document ); + + const newItem = JSON.parse(JSON.stringify(items[i].json)); + set(newItem, destinationKey, markdownFromHTML); + + returnData.push(newItem); + } + + if (mode === 'markdownToHtml') { + const markdown = this.getNodeParameter('markdown', i) as string; + const destinationKey = this.getNodeParameter('destinationKey', i) as string; + const options = this.getNodeParameter('options', i) as IDataObject; + + Object.keys(options).forEach( key => converter.setOption(key, options[key])); + const htmlFromMarkdown = converter.makeHtml(markdown); + + const newItem = JSON.parse(JSON.stringify(items[i].json)); + set(newItem, destinationKey, htmlFromMarkdown); - if (mode === 'markdownToHtml') { - const markdown = this.getNodeParameter('markdown', i) as string; - const html = converter.makeHtml(markdown); - const destinationKey = this.getNodeParameter('destinationKey', i) as string; - newItem.json = JSON.parse(JSON.stringify(items[i].json)); - set(newItem.json, destinationKey, html); - returnData.push(newItem); + returnData.push(newItem) + } + } catch (error) { + if (this.continueOnFail()) { + returnData.push({ error: (error as JsonObject).message }); + continue; + } + throw error; } } - return this.prepareOutputData(returnData); + return [this.helpers.returnJsonArray(returnData)]; } } diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index c77f36856c80d..29776aa05d55a 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -696,6 +696,7 @@ "@types/gm": "^1.18.2", "@types/imap-simple": "^4.2.0", "@types/jest": "^27.4.0", + "@types/jsdom": "^16.2.14", "@types/jsonwebtoken": "^8.5.2", "@types/lodash.set": "^4.3.6", "@types/mailparser": "^2.7.3", @@ -708,6 +709,7 @@ "@types/nodemailer": "^6.4.0", "@types/redis": "^2.8.11", "@types/request-promise-native": "~1.0.15", + "@types/showdown": "^1.9.4", "@types/ssh2-sftp-client": "^5.1.0", "@types/tmp": "^0.2.0", "@types/uuid": "^8.3.2", From 039d5e263fcad65b38db01b2b65ea69e2245b771 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Tue, 5 Apr 2022 14:24:57 +0300 Subject: [PATCH 08/13] :zap: removed test code --- packages/nodes-base/nodes/Markdown/Markdown.node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index 31d40dc28167f..3437e201e90a9 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -388,9 +388,9 @@ export class Markdown implements INodeType { Object.keys(options).filter(key => key !== 'flavor').forEach( key => converter.setOption(key, options[key])); const html = this.getNodeParameter('html', i) as string; - const dom = new JSDOM(html); + const dom = new JSDOM(); - const markdownFromHTML = converter.makeMarkdown(dom.window.document.body.outerHTML, dom.window.document ); + const markdownFromHTML = converter.makeMarkdown(html, dom.window.document ); const newItem = JSON.parse(JSON.stringify(items[i].json)); set(newItem, destinationKey, markdownFromHTML); From 66d73a2a5b47dbad43844f5f745465526020acaa Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Tue, 5 Apr 2022 14:28:32 +0300 Subject: [PATCH 09/13] :zap: added missing semicolumn --- packages/nodes-base/nodes/Markdown/Markdown.node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index 3437e201e90a9..d282defc2243c 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -409,7 +409,7 @@ export class Markdown implements INodeType { const newItem = JSON.parse(JSON.stringify(items[i].json)); set(newItem, destinationKey, htmlFromMarkdown); - returnData.push(newItem) + returnData.push(newItem); } } catch (error) { if (this.continueOnFail()) { From 9c4e40d8675cf52a0603effc5575f30cd1cf260c Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Tue, 12 Apr 2022 15:20:51 +0300 Subject: [PATCH 10/13] :hammer: wip --- package-lock.json | 110 ++++++++++ .../nodes/Markdown/Markdown.node.ts | 202 ++++++++++++++++-- packages/nodes-base/package.json | 1 + 3 files changed, 293 insertions(+), 20 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0ab55ad483e6b..092235eac277e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "@types/inquirer": "^6.5.0", "@types/jest": "^27.4.0", "@types/jmespath": "^0.15.0", + "@types/jsdom": "^16.2.14", "@types/json-diff": "^0.5.1", "@types/jsonwebtoken": "^8.5.2", "@types/localtunnel": "^1.9.0", @@ -70,6 +71,7 @@ "@types/quill": "^2.0.1", "@types/redis": "^2.8.11", "@types/request-promise-native": "~1.0.15", + "@types/showdown": "^1.9.4", "@types/snowflake-sdk": "^1.5.1", "@types/ssh2-sftp-client": "^5.1.0", "@types/superagent": "4.1.13", @@ -152,6 +154,7 @@ "jest": "^27.4.7", "jmespath": "^0.16.0", "jquery": "^3.4.1", + "jsdom": "^16.5.3", "jshint": "^2.9.7", "json-diff": "^0.5.4", "jsonwebtoken": "^8.5.1", @@ -182,6 +185,7 @@ "mqtt": "4.2.6", "mssql": "^6.2.0", "mysql2": "~2.3.0", + "node-html-markdown": "^1.1.3", "node-notifier": ">=8.0.1", "node-ssh": "^12.0.0", "nodelinter": "^0.1.9", @@ -213,6 +217,7 @@ "rss-parser": "^3.7.0", "sass": "^1.26.5", "sass-loader": "^8.0.2", + "showdown": "^2.0.3", "simple-git": "^3.5.0", "snowflake-sdk": "^1.5.3", "source-map-support": "^0.5.9", @@ -13895,6 +13900,16 @@ "resolved": "https://registry.npmjs.org/@types/jmespath/-/jmespath-0.15.0.tgz", "integrity": "sha1-SgFikJaoYjHIkaDi3szBX1PJKR0=" }, + "node_modules/@types/jsdom": { + "version": "16.2.14", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-16.2.14.tgz", + "integrity": "sha512-6BAy1xXEmMuHeAJ4Fv4yXKwBDTGTOseExKE3OaHiNycdHdZw59KfYzrt0DkDluvwmik1HRt6QS7bImxUmpSy+w==", + "dependencies": { + "@types/node": "*", + "@types/parse5": "*", + "@types/tough-cookie": "*" + } + }, "node_modules/@types/json-diff": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@types/json-diff/-/json-diff-0.5.2.tgz", @@ -14306,6 +14321,11 @@ "@types/node": "*" } }, + "node_modules/@types/showdown": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@types/showdown/-/showdown-1.9.4.tgz", + "integrity": "sha512-50ehC3IAijfkvoNqmQ+VL73S7orOxmAK8ljQAFBv8o7G66lAZyxQj1L3BAv2dD86myLXI+sgKP1kcxAaxW356w==" + }, "node_modules/@types/snowflake-sdk": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@types/snowflake-sdk/-/snowflake-sdk-1.6.2.tgz", @@ -42767,6 +42787,26 @@ "which": "bin/which" } }, + "node_modules/node-html-markdown": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-html-markdown/-/node-html-markdown-1.1.3.tgz", + "integrity": "sha512-iB5Nb8eQjeKHr1k9ot0FkVo5uah6IvYzSbOiNPbmtMt8OWf8os9TCsGEg1Xf51xwYLW461AvKl74HVjiMxvblg==", + "dependencies": { + "node-html-parser": "^4.1.5" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/node-html-parser": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-4.1.5.tgz", + "integrity": "sha512-NLgqUXtftqnBqIjlRjYSaApaqE7TTxfTiH4VqKCjdUJKFOtUzRwney83EHz2qYc0XoxXAkYdmLjENCuZHvsIFg==", + "dependencies": { + "css-select": "^4.1.3", + "he": "1.2.0" + } + }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -49767,6 +49807,29 @@ "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==" }, + "node_modules/showdown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/showdown/-/showdown-2.0.3.tgz", + "integrity": "sha512-jHytkv5c5YFTAOYIIaTT1zLL/aC+7C1FiP0CIGQozhHnnFSbor1oYkaNqWFL6CpB3zJNPPSxJrAlsHgzN14knQ==", + "dependencies": { + "commander": "^9.0.0" + }, + "bin": { + "showdown": "bin/showdown.js" + }, + "funding": { + "type": "individual", + "url": "http://example.com/donate" + } + }, + "node_modules/showdown/node_modules/commander": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.1.0.tgz", + "integrity": "sha512-i0/MaqBtdbnJ4XQs4Pmyb+oFQl+q0lsAmokVUH92SlSw4fkeAcG3bVon+Qt7hmtF+u3Het6o4VgrcY3qAoEB6w==", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -69000,6 +69063,16 @@ "resolved": "https://registry.npmjs.org/@types/jmespath/-/jmespath-0.15.0.tgz", "integrity": "sha1-SgFikJaoYjHIkaDi3szBX1PJKR0=" }, + "@types/jsdom": { + "version": "16.2.14", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-16.2.14.tgz", + "integrity": "sha512-6BAy1xXEmMuHeAJ4Fv4yXKwBDTGTOseExKE3OaHiNycdHdZw59KfYzrt0DkDluvwmik1HRt6QS7bImxUmpSy+w==", + "requires": { + "@types/node": "*", + "@types/parse5": "*", + "@types/tough-cookie": "*" + } + }, "@types/json-diff": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@types/json-diff/-/json-diff-0.5.2.tgz", @@ -69408,6 +69481,11 @@ "@types/node": "*" } }, + "@types/showdown": { + "version": "1.9.4", + "resolved": "https://registry.npmjs.org/@types/showdown/-/showdown-1.9.4.tgz", + "integrity": "sha512-50ehC3IAijfkvoNqmQ+VL73S7orOxmAK8ljQAFBv8o7G66lAZyxQj1L3BAv2dD86myLXI+sgKP1kcxAaxW356w==" + }, "@types/snowflake-sdk": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@types/snowflake-sdk/-/snowflake-sdk-1.6.2.tgz", @@ -91748,6 +91826,23 @@ } } }, + "node-html-markdown": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-html-markdown/-/node-html-markdown-1.1.3.tgz", + "integrity": "sha512-iB5Nb8eQjeKHr1k9ot0FkVo5uah6IvYzSbOiNPbmtMt8OWf8os9TCsGEg1Xf51xwYLW461AvKl74HVjiMxvblg==", + "requires": { + "node-html-parser": "^4.1.5" + } + }, + "node-html-parser": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-4.1.5.tgz", + "integrity": "sha512-NLgqUXtftqnBqIjlRjYSaApaqE7TTxfTiH4VqKCjdUJKFOtUzRwney83EHz2qYc0XoxXAkYdmLjENCuZHvsIFg==", + "requires": { + "css-select": "^4.1.3", + "he": "1.2.0" + } + }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -97316,6 +97411,21 @@ "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==" }, + "showdown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/showdown/-/showdown-2.0.3.tgz", + "integrity": "sha512-jHytkv5c5YFTAOYIIaTT1zLL/aC+7C1FiP0CIGQozhHnnFSbor1oYkaNqWFL6CpB3zJNPPSxJrAlsHgzN14knQ==", + "requires": { + "commander": "^9.0.0" + }, + "dependencies": { + "commander": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.1.0.tgz", + "integrity": "sha512-i0/MaqBtdbnJ4XQs4Pmyb+oFQl+q0lsAmokVUH92SlSw4fkeAcG3bVon+Qt7hmtF+u3Het6o4VgrcY3qAoEB6w==" + } + } + }, "side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index d282defc2243c..4db9f94d3ca4d 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -12,6 +12,8 @@ import { import { Converter, Flavor } from 'showdown'; +import { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } from 'node-html-markdown' + import { JSDOM } from 'jsdom'; import { set } from 'lodash'; @@ -70,6 +72,9 @@ export class Markdown implements INodeType { displayName: 'Markdown', name: 'markdown', type: 'string', + typeOptions: { + alwaysOpenEditWindow: true, + }, displayOptions: { show: { mode: [ @@ -115,34 +120,184 @@ export class Markdown implements INodeType { }, options: [ { - displayName: 'Markdown Flavor', - name: 'flavor', - type: 'options', + displayName: 'Bullet Marker', + name: 'bulletMarker', + type: 'string', + default: '*', + description: 'Specify bullet marker, default *', + }, + { + displayName: 'Code Block Fence', + name: 'codeFence', + type: 'string', + default: '```', + description: 'Specify code block fence, default ```', + }, + { + displayName: 'Emphasis Delimiter', + name: 'emDelimiter', + type: 'string', + default: '_', + description: 'Specify emphasis delimiter, default _', + }, + { + displayName: 'Ignored Elements', + name: 'ignore', + type: 'string', + default: '', + description: 'Supplied elements will be ignored (ignores inner text does not parse children)', + placeholder: 'e.g. h1, p ...', + hint: 'Comma separated elements', + }, + { + displayName: 'Max Consecutive New Lines', + name: 'maxConsecutiveNewlines', + type: 'number', + default: 3, + description: 'Specify max consecutive new lines allowed', + }, + { + displayName: 'Keep Images With Data', + name: 'keepDataImages', + type: 'boolean', + default: false, + description: 'Whether to keep images with data: URI (Note: These can be up to 1MB each), e.g. ', + }, + { + displayName: 'Global Escape Pattern', + name: 'globalEscape', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + description: 'Setting this will override the default escape settings, you might want to use textReplace option instead', options: [ { - name: 'Default', - value: 'vanilla', - description: 'Defaults defined by Showdown library (
more info)', + name: 'value', + displayName: 'Value', + values: [ + { + displayName: 'Pattern', + name: 'pattern', + type: 'string', + default: '', + description: 'RegEx for pattern', + }, + { + displayName: 'Replacement', + name: 'replacement', + type: 'string', + default: '', + description: 'String replacement', + }, + ] }, + ], + }, + { + displayName: 'Line Start Escape Pattern', + name: 'lineStartEscape', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + description: 'Setting this will override the default escape settings, you might want to use textReplace option instead', + options: [ { - name: 'GitHub', - value: 'github', - description: 'GitHub Flavored Markdown (more info)', + name: 'value', + displayName: 'Value', + values: [ + { + displayName: 'Pattern', + name: 'pattern', + type: 'string', + default: '', + description: 'RegEx for pattern', + }, + { + displayName: 'Replacement', + name: 'replacement', + type: 'string', + default: '', + description: 'String replacement', + }, + ] }, + ], + }, + { + displayName: 'Text Replacement Pattern', + name: 'textReplace', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, + }, + default: {}, + description: 'User-defined text replacement pattern (Replaces matching text retrieved from nodes)', + options: [ { - name: 'Original', - value: 'original', - description: `As first defined by John Gruber (more info)`, + name: 'values', + displayName: 'Values', + values: [ + { + displayName: 'Pattern', + name: 'pattern', + type: 'string', + default: '', + description: 'RegEx for pattern', + }, + { + displayName: 'Replacement', + name: 'replacement', + type: 'string', + default: '', + description: 'String replacement', + }, + ] }, ], - default: 'vanilla', }, { - displayName: 'Omit Trailing Newline', - name: 'omitExtraWLInCodeBlocks', + displayName: 'Place URLs At The Bottom', + name: 'useLinkReferenceDefinitions', type: 'boolean', default: false, - description: 'Whether to omit the trailing newline in a code block', + description: 'Whether to Place URLS at the bottom and format links using link reference definitions', + }, + { + displayName: 'Strong Delimiter', + name: 'strongDelimiter', + type: 'string', + default: '**', + description: 'Specify strong delimiter, default **', + }, + { + displayName: 'Style For Code Block', + name: 'codeBlockStyle', + type: 'options', + default: 'fence', + description: 'Specify style for code block, default "fence"', + options: [ + { + name: 'fence', + value: 'fence', + }, + { + name: 'indented', + value: 'indented', + }, + ] + }, + { + displayName: 'Treat As Blocks', + name: 'blockElements', + type: 'string', + default: '', + description: 'Supplied elements will be treated as blocks (surrounded with blank lines)', + placeholder: 'e.g. p, div, ...', + hint: 'Comma separated elements', }, ], }, @@ -383,16 +538,23 @@ export class Markdown implements INodeType { if (mode === 'htmlToMarkdown') { const options = this.getNodeParameter('options', i) as IDataObject; const destinationKey = this.getNodeParameter('destinationKey', i) as string; + const markdownOptions = { + ...options, + ignore: options.ignore ? (options.ignore as string).split(',') : undefined, + blockElements: options.blockElements ? (options.blockElements as string).split(',') : undefined, + } as NodeHtmlMarkdownOptions; - converter.setFlavor(options.flavor as Flavor || 'vanilla'); - Object.keys(options).filter(key => key !== 'flavor').forEach( key => converter.setOption(key, options[key])); + console.log(markdownOptions); const html = this.getNodeParameter('html', i) as string; - const dom = new JSDOM(); - const markdownFromHTML = converter.makeMarkdown(html, dom.window.document ); + const markdownFromHTML = NodeHtmlMarkdown.translate( + html, + markdownOptions, + ); const newItem = JSON.parse(JSON.stringify(items[i].json)); + set(newItem, destinationKey, markdownFromHTML); returnData.push(newItem); diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 6e8787f2fdd88..9685bf98b31eb 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -760,6 +760,7 @@ "mssql": "^6.2.0", "mysql2": "~2.3.0", "n8n-core": "~0.113.0", + "node-html-markdown": "^1.1.3", "node-ssh": "^12.0.0", "nodemailer": "^6.5.0", "pdf-parse": "^1.1.1", From b1bce48ba41da10da0d7acae71e6515dec4ec2b0 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Tue, 12 Apr 2022 17:15:09 +0300 Subject: [PATCH 11/13] :hammer: replaced library for converting html to markdown, added options --- package-lock.json | 209 ------------------ .../nodes/Markdown/Markdown.node.ts | 55 +++-- packages/nodes-base/package.json | 2 - 3 files changed, 33 insertions(+), 233 deletions(-) diff --git a/package-lock.json b/package-lock.json index 092235eac277e..5b549196b4f01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,6 @@ "@types/inquirer": "^6.5.0", "@types/jest": "^27.4.0", "@types/jmespath": "^0.15.0", - "@types/jsdom": "^16.2.14", "@types/json-diff": "^0.5.1", "@types/jsonwebtoken": "^8.5.2", "@types/localtunnel": "^1.9.0", @@ -154,7 +153,6 @@ "jest": "^27.4.7", "jmespath": "^0.16.0", "jquery": "^3.4.1", - "jsdom": "^16.5.3", "jshint": "^2.9.7", "json-diff": "^0.5.4", "jsonwebtoken": "^8.5.1", @@ -13900,16 +13898,6 @@ "resolved": "https://registry.npmjs.org/@types/jmespath/-/jmespath-0.15.0.tgz", "integrity": "sha1-SgFikJaoYjHIkaDi3szBX1PJKR0=" }, - "node_modules/@types/jsdom": { - "version": "16.2.14", - "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-16.2.14.tgz", - "integrity": "sha512-6BAy1xXEmMuHeAJ4Fv4yXKwBDTGTOseExKE3OaHiNycdHdZw59KfYzrt0DkDluvwmik1HRt6QS7bImxUmpSy+w==", - "dependencies": { - "@types/node": "*", - "@types/parse5": "*", - "@types/tough-cookie": "*" - } - }, "node_modules/@types/json-diff": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@types/json-diff/-/json-diff-0.5.2.tgz", @@ -16334,24 +16322,6 @@ "node": ">=6" } }, - "node_modules/@vue/cli-plugin-unit-jest/node_modules/fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - }, - "engines": { - "node": ">= 4.0" - } - }, "node_modules/@vue/cli-plugin-unit-jest/node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -20177,24 +20147,6 @@ "node": ">=6" } }, - "node_modules/babel-jest/node_modules/fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - }, - "engines": { - "node": ">= 4.0" - } - }, "node_modules/babel-jest/node_modules/is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -30024,19 +29976,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/fstream": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", @@ -31463,24 +31402,6 @@ "node": ">=0.10.0" } }, - "node_modules/glob-watcher/node_modules/fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - }, - "engines": { - "node": ">= 4.0" - } - }, "node_modules/glob-watcher/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -36080,24 +36001,6 @@ "node": ">=6" } }, - "node_modules/jest-environment-jsdom-fifteen/node_modules/fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - }, - "engines": { - "node": ">= 4.0" - } - }, "node_modules/jest-environment-jsdom-fifteen/node_modules/html-encoding-sniffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", @@ -55604,24 +55507,6 @@ "node": ">=0.10.0" } }, - "node_modules/watchpack-chokidar2/node_modules/fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - }, - "engines": { - "node": ">= 4.0" - } - }, "node_modules/watchpack-chokidar2/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -56229,24 +56114,6 @@ "node": ">=6" } }, - "node_modules/webpack-dev-server/node_modules/fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - }, - "engines": { - "node": ">= 4.0" - } - }, "node_modules/webpack-dev-server/node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -69063,16 +68930,6 @@ "resolved": "https://registry.npmjs.org/@types/jmespath/-/jmespath-0.15.0.tgz", "integrity": "sha1-SgFikJaoYjHIkaDi3szBX1PJKR0=" }, - "@types/jsdom": { - "version": "16.2.14", - "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-16.2.14.tgz", - "integrity": "sha512-6BAy1xXEmMuHeAJ4Fv4yXKwBDTGTOseExKE3OaHiNycdHdZw59KfYzrt0DkDluvwmik1HRt6QS7bImxUmpSy+w==", - "requires": { - "@types/node": "*", - "@types/parse5": "*", - "@types/tough-cookie": "*" - } - }, "@types/json-diff": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@types/json-diff/-/json-diff-0.5.2.tgz", @@ -71084,16 +70941,6 @@ "locate-path": "^3.0.0" } }, - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -74117,16 +73964,6 @@ "locate-path": "^3.0.0" } }, - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -81887,12 +81724,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "optional": true - }, "fstream": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", @@ -82996,16 +82827,6 @@ "to-regex-range": "^2.1.0" } }, - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -86575,16 +86396,6 @@ "locate-path": "^3.0.0" } }, - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - }, "html-encoding-sniffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", @@ -101939,16 +101750,6 @@ "to-regex-range": "^2.1.0" } }, - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -102725,16 +102526,6 @@ "locate-path": "^3.0.0" } }, - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index 4db9f94d3ca4d..a3040ab0cb14b 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -12,11 +12,9 @@ import { import { Converter, Flavor } from 'showdown'; -import { NodeHtmlMarkdown, NodeHtmlMarkdownOptions } from 'node-html-markdown' +import { NodeHtmlMarkdown } from 'node-html-markdown'; -import { JSDOM } from 'jsdom'; - -import { set } from 'lodash'; +import { isEmpty, set } from 'lodash'; export class Markdown implements INodeType { description: INodeTypeDescription = { @@ -168,7 +166,7 @@ export class Markdown implements INodeType { name: 'globalEscape', type: 'fixedCollection', typeOptions: { - multipleValues: true, + multipleValues: false, }, default: {}, description: 'Setting this will override the default escape settings, you might want to use textReplace option instead', @@ -191,7 +189,7 @@ export class Markdown implements INodeType { default: '', description: 'String replacement', }, - ] + ], }, ], }, @@ -200,7 +198,7 @@ export class Markdown implements INodeType { name: 'lineStartEscape', type: 'fixedCollection', typeOptions: { - multipleValues: true, + multipleValues: false, }, default: {}, description: 'Setting this will override the default escape settings, you might want to use textReplace option instead', @@ -223,7 +221,7 @@ export class Markdown implements INodeType { default: '', description: 'String replacement', }, - ] + ], }, ], }, @@ -234,7 +232,7 @@ export class Markdown implements INodeType { typeOptions: { multipleValues: true, }, - default: {}, + default: [], description: 'User-defined text replacement pattern (Replaces matching text retrieved from nodes)', options: [ { @@ -255,7 +253,7 @@ export class Markdown implements INodeType { default: '', description: 'String replacement', }, - ] + ], }, ], }, @@ -288,7 +286,7 @@ export class Markdown implements INodeType { name: 'indented', value: 'indented', }, - ] + ], }, { displayName: 'Treat As Blocks', @@ -527,9 +525,6 @@ export class Markdown implements INodeType { async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; - - const converter = new Converter(); - const mode = this.getNodeParameter('mode', 0) as string; const { length } = items; @@ -538,13 +533,29 @@ export class Markdown implements INodeType { if (mode === 'htmlToMarkdown') { const options = this.getNodeParameter('options', i) as IDataObject; const destinationKey = this.getNodeParameter('destinationKey', i) as string; - const markdownOptions = { - ...options, - ignore: options.ignore ? (options.ignore as string).split(',') : undefined, - blockElements: options.blockElements ? (options.blockElements as string).split(',') : undefined, - } as NodeHtmlMarkdownOptions; - console.log(markdownOptions); + const textReplaceOption = this.getNodeParameter('options.textReplace.values', i, []) as IDataObject[]; + options.textReplace = !isEmpty(textReplaceOption) ? + textReplaceOption.map(entry => [entry.pattern, entry.replacement]) : undefined; + + const lineStartEscapeOption = this.getNodeParameter('options.lineStartEscape.value', i, {}) as IDataObject; + options.lineStartEscape = !isEmpty(lineStartEscapeOption) ? + [lineStartEscapeOption.pattern, lineStartEscapeOption.replacement] : undefined; + + const globalEscapeOption = this.getNodeParameter('options.globalEscape.value', i, {}) as IDataObject; + options.globalEscape = !isEmpty(globalEscapeOption) ? + [globalEscapeOption.pattern, globalEscapeOption.replacement] : undefined; + + options.ignore = options.ignore ? (options.ignore as string).split(',') : undefined; + options.blockElements = options.blockElements ? (options.blockElements as string).split(',') : undefined; + + const markdownOptions = {} as IDataObject; + + Object.keys(options).forEach( option => { + if (options[option]) { + markdownOptions[option] = options[option]; + } + }); const html = this.getNodeParameter('html', i) as string; @@ -554,9 +565,7 @@ export class Markdown implements INodeType { ); const newItem = JSON.parse(JSON.stringify(items[i].json)); - set(newItem, destinationKey, markdownFromHTML); - returnData.push(newItem); } @@ -565,6 +574,8 @@ export class Markdown implements INodeType { const destinationKey = this.getNodeParameter('destinationKey', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; + const converter = new Converter(); + Object.keys(options).forEach( key => converter.setOption(key, options[key])); const htmlFromMarkdown = converter.makeHtml(markdown); diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 9685bf98b31eb..133ecd88236b2 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -696,7 +696,6 @@ "@types/gm": "^1.18.2", "@types/imap-simple": "^4.2.0", "@types/jest": "^27.4.0", - "@types/jsdom": "^16.2.14", "@types/jsonwebtoken": "^8.5.2", "@types/lodash.set": "^4.3.6", "@types/mailparser": "^2.7.3", @@ -745,7 +744,6 @@ "imap-simple": "^4.3.0", "isbot": "^3.3.4", "iso-639-1": "^2.1.3", - "jsdom": "^16.5.3", "jsonwebtoken": "^8.5.1", "kafkajs": "^1.14.0", "lodash.get": "^4.4.2", From 9d5dbf5776bb4ec3012717d5d700c2e48debe7e7 Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Wed, 13 Apr 2022 09:00:44 +0300 Subject: [PATCH 12/13] :zap: lock file fix --- package-lock.json | 275 +++++++++++++++++++++++++++++++--------------- 1 file changed, 187 insertions(+), 88 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5b549196b4f01..0ab55ad483e6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,7 +70,6 @@ "@types/quill": "^2.0.1", "@types/redis": "^2.8.11", "@types/request-promise-native": "~1.0.15", - "@types/showdown": "^1.9.4", "@types/snowflake-sdk": "^1.5.1", "@types/ssh2-sftp-client": "^5.1.0", "@types/superagent": "4.1.13", @@ -183,7 +182,6 @@ "mqtt": "4.2.6", "mssql": "^6.2.0", "mysql2": "~2.3.0", - "node-html-markdown": "^1.1.3", "node-notifier": ">=8.0.1", "node-ssh": "^12.0.0", "nodelinter": "^0.1.9", @@ -215,7 +213,6 @@ "rss-parser": "^3.7.0", "sass": "^1.26.5", "sass-loader": "^8.0.2", - "showdown": "^2.0.3", "simple-git": "^3.5.0", "snowflake-sdk": "^1.5.3", "source-map-support": "^0.5.9", @@ -14309,11 +14306,6 @@ "@types/node": "*" } }, - "node_modules/@types/showdown": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@types/showdown/-/showdown-1.9.4.tgz", - "integrity": "sha512-50ehC3IAijfkvoNqmQ+VL73S7orOxmAK8ljQAFBv8o7G66lAZyxQj1L3BAv2dD86myLXI+sgKP1kcxAaxW356w==" - }, "node_modules/@types/snowflake-sdk": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@types/snowflake-sdk/-/snowflake-sdk-1.6.2.tgz", @@ -16322,6 +16314,24 @@ "node": ">=6" } }, + "node_modules/@vue/cli-plugin-unit-jest/node_modules/fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + }, + "engines": { + "node": ">= 4.0" + } + }, "node_modules/@vue/cli-plugin-unit-jest/node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -20147,6 +20157,24 @@ "node": ">=6" } }, + "node_modules/babel-jest/node_modules/fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + }, + "engines": { + "node": ">= 4.0" + } + }, "node_modules/babel-jest/node_modules/is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -29976,6 +30004,19 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/fstream": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", @@ -31402,6 +31443,24 @@ "node": ">=0.10.0" } }, + "node_modules/glob-watcher/node_modules/fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + }, + "engines": { + "node": ">= 4.0" + } + }, "node_modules/glob-watcher/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -36001,6 +36060,24 @@ "node": ">=6" } }, + "node_modules/jest-environment-jsdom-fifteen/node_modules/fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + }, + "engines": { + "node": ">= 4.0" + } + }, "node_modules/jest-environment-jsdom-fifteen/node_modules/html-encoding-sniffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", @@ -42690,26 +42767,6 @@ "which": "bin/which" } }, - "node_modules/node-html-markdown": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/node-html-markdown/-/node-html-markdown-1.1.3.tgz", - "integrity": "sha512-iB5Nb8eQjeKHr1k9ot0FkVo5uah6IvYzSbOiNPbmtMt8OWf8os9TCsGEg1Xf51xwYLW461AvKl74HVjiMxvblg==", - "dependencies": { - "node-html-parser": "^4.1.5" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/node-html-parser": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-4.1.5.tgz", - "integrity": "sha512-NLgqUXtftqnBqIjlRjYSaApaqE7TTxfTiH4VqKCjdUJKFOtUzRwney83EHz2qYc0XoxXAkYdmLjENCuZHvsIFg==", - "dependencies": { - "css-select": "^4.1.3", - "he": "1.2.0" - } - }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -49710,29 +49767,6 @@ "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==" }, - "node_modules/showdown": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/showdown/-/showdown-2.0.3.tgz", - "integrity": "sha512-jHytkv5c5YFTAOYIIaTT1zLL/aC+7C1FiP0CIGQozhHnnFSbor1oYkaNqWFL6CpB3zJNPPSxJrAlsHgzN14knQ==", - "dependencies": { - "commander": "^9.0.0" - }, - "bin": { - "showdown": "bin/showdown.js" - }, - "funding": { - "type": "individual", - "url": "http://example.com/donate" - } - }, - "node_modules/showdown/node_modules/commander": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.1.0.tgz", - "integrity": "sha512-i0/MaqBtdbnJ4XQs4Pmyb+oFQl+q0lsAmokVUH92SlSw4fkeAcG3bVon+Qt7hmtF+u3Het6o4VgrcY3qAoEB6w==", - "engines": { - "node": "^12.20.0 || >=14" - } - }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -55507,6 +55541,24 @@ "node": ">=0.10.0" } }, + "node_modules/watchpack-chokidar2/node_modules/fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + }, + "engines": { + "node": ">= 4.0" + } + }, "node_modules/watchpack-chokidar2/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -56114,6 +56166,24 @@ "node": ">=6" } }, + "node_modules/webpack-dev-server/node_modules/fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "deprecated": "fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "dependencies": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + }, + "engines": { + "node": ">= 4.0" + } + }, "node_modules/webpack-dev-server/node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -69338,11 +69408,6 @@ "@types/node": "*" } }, - "@types/showdown": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@types/showdown/-/showdown-1.9.4.tgz", - "integrity": "sha512-50ehC3IAijfkvoNqmQ+VL73S7orOxmAK8ljQAFBv8o7G66lAZyxQj1L3BAv2dD86myLXI+sgKP1kcxAaxW356w==" - }, "@types/snowflake-sdk": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/@types/snowflake-sdk/-/snowflake-sdk-1.6.2.tgz", @@ -70941,6 +71006,16 @@ "locate-path": "^3.0.0" } }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -73964,6 +74039,16 @@ "locate-path": "^3.0.0" } }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", @@ -81724,6 +81809,12 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, "fstream": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", @@ -82827,6 +82918,16 @@ "to-regex-range": "^2.1.0" } }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -86396,6 +86497,16 @@ "locate-path": "^3.0.0" } }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "html-encoding-sniffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", @@ -91637,23 +91748,6 @@ } } }, - "node-html-markdown": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/node-html-markdown/-/node-html-markdown-1.1.3.tgz", - "integrity": "sha512-iB5Nb8eQjeKHr1k9ot0FkVo5uah6IvYzSbOiNPbmtMt8OWf8os9TCsGEg1Xf51xwYLW461AvKl74HVjiMxvblg==", - "requires": { - "node-html-parser": "^4.1.5" - } - }, - "node-html-parser": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-4.1.5.tgz", - "integrity": "sha512-NLgqUXtftqnBqIjlRjYSaApaqE7TTxfTiH4VqKCjdUJKFOtUzRwney83EHz2qYc0XoxXAkYdmLjENCuZHvsIFg==", - "requires": { - "css-select": "^4.1.3", - "he": "1.2.0" - } - }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -97222,21 +97316,6 @@ "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==" }, - "showdown": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/showdown/-/showdown-2.0.3.tgz", - "integrity": "sha512-jHytkv5c5YFTAOYIIaTT1zLL/aC+7C1FiP0CIGQozhHnnFSbor1oYkaNqWFL6CpB3zJNPPSxJrAlsHgzN14knQ==", - "requires": { - "commander": "^9.0.0" - }, - "dependencies": { - "commander": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.1.0.tgz", - "integrity": "sha512-i0/MaqBtdbnJ4XQs4Pmyb+oFQl+q0lsAmokVUH92SlSw4fkeAcG3bVon+Qt7hmtF+u3Het6o4VgrcY3qAoEB6w==" - } - } - }, "side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -101750,6 +101829,16 @@ "to-regex-range": "^2.1.0" } }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -102526,6 +102615,16 @@ "locate-path": "^3.0.0" } }, + "fsevents": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", From d0105966acf79b1078ddb805f75b6aa0ac068bda Mon Sep 17 00:00:00 2001 From: Michael Kret Date: Wed, 13 Apr 2022 10:34:39 +0300 Subject: [PATCH 13/13] :hammer: clean up --- .../nodes/Markdown/Markdown.node.ts | 229 +++++++++--------- 1 file changed, 120 insertions(+), 109 deletions(-) diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index a3040ab0cb14b..8a5bec5415e4e 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,11 +8,11 @@ import { JsonObject, } from 'n8n-workflow'; -import { Converter, Flavor } from 'showdown'; +import { Converter } from 'showdown'; import { NodeHtmlMarkdown } from 'node-html-markdown'; -import { isEmpty, set } from 'lodash'; +import { isEmpty, set } from 'lodash'; export class Markdown implements INodeType { description: INodeTypeDescription = { @@ -57,9 +55,7 @@ export class Markdown implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'htmlToMarkdown', - ], + mode: ['htmlToMarkdown'], }, }, default: '', @@ -75,9 +71,7 @@ export class Markdown implements INodeType { }, displayOptions: { show: { - mode: [ - 'markdownToHtml', - ], + mode: ['markdownToHtml'], }, }, default: '', @@ -90,16 +84,14 @@ export class Markdown implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'markdownToHtml', - 'htmlToMarkdown', - ], + mode: ['markdownToHtml', 'htmlToMarkdown'], }, }, default: 'data', required: true, placeholder: '', - description: 'The field to put the output in. Specify nested fields
using dots, e.g."level1.level2.newKey".', + description: + 'The field to put the output in. Specify nested fields using dots, e.g."level1.level2.newKey".', }, //============= HTML to Markdown Options =============== @@ -111,9 +103,7 @@ export class Markdown implements INodeType { default: {}, displayOptions: { show: { - 'mode': [ - 'htmlToMarkdown', - ], + mode: ['htmlToMarkdown'], }, }, options: [ @@ -138,29 +128,6 @@ export class Markdown implements INodeType { default: '_', description: 'Specify emphasis delimiter, default _', }, - { - displayName: 'Ignored Elements', - name: 'ignore', - type: 'string', - default: '', - description: 'Supplied elements will be ignored (ignores inner text does not parse children)', - placeholder: 'e.g. h1, p ...', - hint: 'Comma separated elements', - }, - { - displayName: 'Max Consecutive New Lines', - name: 'maxConsecutiveNewlines', - type: 'number', - default: 3, - description: 'Specify max consecutive new lines allowed', - }, - { - displayName: 'Keep Images With Data', - name: 'keepDataImages', - type: 'boolean', - default: false, - description: 'Whether to keep images with data: URI (Note: These can be up to 1MB each), e.g. ', - }, { displayName: 'Global Escape Pattern', name: 'globalEscape', @@ -169,7 +136,8 @@ export class Markdown implements INodeType { multipleValues: false, }, default: {}, - description: 'Setting this will override the default escape settings, you might want to use textReplace option instead', + description: + 'Setting this will override the default escape settings, you might want to use textReplace option instead', options: [ { name: 'value', @@ -193,6 +161,24 @@ export class Markdown implements INodeType { }, ], }, + { + displayName: 'Ignored Elements', + name: 'ignore', + type: 'string', + default: '', + description: + 'Supplied elements will be ignored (ignores inner text does not parse children)', + placeholder: 'e.g. h1, p ...', + hint: 'Comma separated elements', + }, + { + displayName: 'Keep Images With Data', + name: 'keepDataImages', + type: 'boolean', + default: false, + description: + 'Whether to keep images with data: URI (Note: These can be up to 1MB each), e.g. .', + }, { displayName: 'Line Start Escape Pattern', name: 'lineStartEscape', @@ -201,7 +187,8 @@ export class Markdown implements INodeType { multipleValues: false, }, default: {}, - description: 'Setting this will override the default escape settings, you might want to use textReplace option instead', + description: + 'Setting this will override the default escape settings, you might want to use textReplace option instead', options: [ { name: 'value', @@ -225,6 +212,45 @@ export class Markdown implements INodeType { }, ], }, + { + displayName: 'Max Consecutive New Lines', + name: 'maxConsecutiveNewlines', + type: 'number', + default: 3, + description: 'Specify max consecutive new lines allowed', + }, + { + displayName: 'Place URLs At The Bottom', + name: 'useLinkReferenceDefinitions', + type: 'boolean', + default: false, + description: + 'Whether to Place URLS at the bottom and format links using link reference definitions', + }, + { + displayName: 'Strong Delimiter', + name: 'strongDelimiter', + type: 'string', + default: '**', + description: 'Specify strong delimiter, default **', + }, + { + displayName: 'Style For Code Block', + name: 'codeBlockStyle', + type: 'options', + default: 'fence', + description: 'Specify style for code block, default "fence"', + options: [ + { + name: 'Fence', + value: 'fence', + }, + { + name: 'Indented', + value: 'indented', + }, + ], + }, { displayName: 'Text Replacement Pattern', name: 'textReplace', @@ -233,7 +259,8 @@ export class Markdown implements INodeType { multipleValues: true, }, default: [], - description: 'User-defined text replacement pattern (Replaces matching text retrieved from nodes)', + description: + 'User-defined text replacement pattern (Replaces matching text retrieved from nodes)', options: [ { name: 'values', @@ -257,43 +284,13 @@ export class Markdown implements INodeType { }, ], }, - { - displayName: 'Place URLs At The Bottom', - name: 'useLinkReferenceDefinitions', - type: 'boolean', - default: false, - description: 'Whether to Place URLS at the bottom and format links using link reference definitions', - }, - { - displayName: 'Strong Delimiter', - name: 'strongDelimiter', - type: 'string', - default: '**', - description: 'Specify strong delimiter, default **', - }, - { - displayName: 'Style For Code Block', - name: 'codeBlockStyle', - type: 'options', - default: 'fence', - description: 'Specify style for code block, default "fence"', - options: [ - { - name: 'fence', - value: 'fence', - }, - { - name: 'indented', - value: 'indented', - }, - ], - }, { displayName: 'Treat As Blocks', name: 'blockElements', type: 'string', default: '', - description: 'Supplied elements will be treated as blocks (surrounded with blank lines)', + description: + 'Supplied elements will be treated as blocks (surrounded with blank lines)', placeholder: 'e.g. p, div, ...', hint: 'Comma separated elements', }, @@ -308,9 +305,7 @@ export class Markdown implements INodeType { default: {}, displayOptions: { show: { - 'mode': [ - 'markdownToHtml', - ], + mode: ['markdownToHtml'], }, }, options: [ @@ -319,7 +314,8 @@ export class Markdown implements INodeType { name: 'openLinksInNewWindow', type: 'boolean', default: false, - description: 'Whether to open all links in new windows (by adding the attribute target="_blank" to tags)', + description: + 'Whether to open all links in new windows (by adding the attribute target="_blank" to tags)', }, { displayName: 'Automatic Linking To URLs', @@ -333,14 +329,15 @@ export class Markdown implements INodeType { name: 'backslashEscapesHTMLTags', type: 'boolean', default: false, - description: 'Whether to support for HTML Tag escaping ex: \
foo\foo, and tags instead of an HTML fragment', + description: + 'Whether to output a complete html document, including , and tags instead of an HTML fragment', }, { displayName: 'Customized Header ID', @@ -354,21 +351,24 @@ export class Markdown implements INodeType { name: 'emoji', type: 'boolean', default: false, - description: 'Whether to enable emoji support. Ex: this is a :smile: emoji For more info on available emojis, see https://github.com/showdownjs/showdown/wiki/Emojis.', + description: + 'Whether to enable emoji support. Ex: this is a :smile: emoji For more info on available emojis, see https://github.com/showdownjs/showdown/wiki/Emojis.', }, { displayName: 'Encode Emails', name: 'encodeEmails', type: 'boolean', default: true, - description: 'Whether to enable e-mail addresses encoding through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities', + description: + 'Whether to enable e-mail addresses encoding through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities', }, { displayName: 'Exclude Trailing Punctuation From URLs', name: 'excludeTrailingPunctuationFromURLs', type: 'boolean', default: false, - description: 'Whether to exclude trailing punctuation from autolinking urls. Punctuation excluded: . ! ? ( ). Only applies if simplifiedAutoLink option is set to true.', + description: + 'Whether to exclude trailing punctuation from autolinking urls. Punctuation excluded: . ! ? ( ). Only applies if simplifiedAutoLink option is set to true.', }, { displayName: 'GitHub Code Blocks', @@ -382,14 +382,16 @@ export class Markdown implements INodeType { name: 'ghCompatibleHeaderId', type: 'boolean', default: false, - description: 'Whether to generate header ids compatible with github style (spaces are replaced with dashes and a bunch of non alphanumeric chars are removed)', + description: + 'Whether to generate header ids compatible with github style (spaces are replaced with dashes and a bunch of non alphanumeric chars are removed)', }, { displayName: 'GitHub Mention Link', name: 'ghMentionsLink', type: 'string', default: 'https://github.com/{u}', - description: 'Whether to change the link generated by @mentions. Showdown will replace {u} with the username. Only applies if ghMentions option is enabled.', + description: + 'Whether to change the link generated by @mentions. Showdown will replace {u} with the username. Only applies if ghMentions option is enabled.', }, { displayName: 'GitHub Mentions', @@ -424,14 +426,16 @@ export class Markdown implements INodeType { name: 'literalMidWordAsterisks', type: 'boolean', default: false, - description: 'Whether to stop showdown from interpreting asterisks in the middle of words as and and instead treat them as literal asterisks', + description: + 'Whether to stop showdown from interpreting asterisks in the middle of words as and and instead treat them as literal asterisks', }, { displayName: 'Middle Word Underscores', name: 'literalMidWordUnderscores', type: 'boolean', default: false, - description: 'Whether to stop showdown from interpreting underscores in the middle of words as and and instead treat them as literal underscores', + description: + 'Whether to stop showdown from interpreting underscores in the middle of words as and and instead treat them as literal underscores', }, { displayName: 'No Header ID', @@ -445,7 +449,8 @@ export class Markdown implements INodeType { name: 'parseImgDimensions', type: 'boolean', default: false, - description: 'Whether to enable support for setting image dimensions from within markdown syntax', + description: + 'Whether to enable support for setting image dimensions from within markdown syntax', }, { displayName: 'Prefix Header ID', @@ -459,7 +464,8 @@ export class Markdown implements INodeType { name: 'rawHeaderId', type: 'boolean', default: false, - description: 'Whether to remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-)', + description: + 'Whether to remove only spaces, \' and " from generated header ids (including prefixes), replacing them with dashes (-)', }, { displayName: 'Raw Prefix Header ID', @@ -473,21 +479,24 @@ export class Markdown implements INodeType { name: 'simpleLineBreaks', type: 'boolean', default: false, - description: 'Whether to parse line breaks as
, like GitHub does, without needing 2 spaces at the end of the line', + description: + 'Whether to parse line breaks as
, like GitHub does, without needing 2 spaces at the end of the line', }, { displayName: 'Smart Indentation Fix', name: 'smartIndentationFix', type: 'boolean', default: false, - description: 'Whether to try to smartly fix indentation problems related to es6 template strings in the midst of indented code', + description: + 'Whether to try to smartly fix indentation problems related to es6 template strings in the midst of indented code', }, { displayName: 'Spaces Indented Sublists', name: 'disableForced4SpacesIndentedSublists', type: 'boolean', default: false, - description: 'Whether to disable the requirement of indenting sublists by 4 spaces for them to be nested, effectively reverting to the old behavior where 2 or 3 spaces were enough', + description: + 'Whether to disable the requirement of indenting sublists by 4 spaces for them to be nested, effectively reverting to the old behavior where 2 or 3 spaces were enough', }, { displayName: 'Split Adjacent Blockquotes', @@ -535,23 +544,28 @@ export class Markdown implements INodeType { const destinationKey = this.getNodeParameter('destinationKey', i) as string; const textReplaceOption = this.getNodeParameter('options.textReplace.values', i, []) as IDataObject[]; - options.textReplace = !isEmpty(textReplaceOption) ? - textReplaceOption.map(entry => [entry.pattern, entry.replacement]) : undefined; + options.textReplace = !isEmpty(textReplaceOption) + ? textReplaceOption.map((entry) => [entry.pattern, entry.replacement]) + : undefined; const lineStartEscapeOption = this.getNodeParameter('options.lineStartEscape.value', i, {}) as IDataObject; - options.lineStartEscape = !isEmpty(lineStartEscapeOption) ? - [lineStartEscapeOption.pattern, lineStartEscapeOption.replacement] : undefined; + options.lineStartEscape = !isEmpty(lineStartEscapeOption) + ? [lineStartEscapeOption.pattern, lineStartEscapeOption.replacement] + : undefined; const globalEscapeOption = this.getNodeParameter('options.globalEscape.value', i, {}) as IDataObject; - options.globalEscape = !isEmpty(globalEscapeOption) ? - [globalEscapeOption.pattern, globalEscapeOption.replacement] : undefined; + options.globalEscape = !isEmpty(globalEscapeOption) + ? [globalEscapeOption.pattern, globalEscapeOption.replacement] + : undefined; - options.ignore = options.ignore ? (options.ignore as string).split(',') : undefined; - options.blockElements = options.blockElements ? (options.blockElements as string).split(',') : undefined; + options.ignore = options.ignore + ? (options.ignore as string).split(',').map(element => element.trim()) : undefined; + options.blockElements = options.blockElements + ? (options.blockElements as string).split(',').map(element => element.trim()) : undefined; const markdownOptions = {} as IDataObject; - Object.keys(options).forEach( option => { + Object.keys(options).forEach((option) => { if (options[option]) { markdownOptions[option] = options[option]; } @@ -559,10 +573,7 @@ export class Markdown implements INodeType { const html = this.getNodeParameter('html', i) as string; - const markdownFromHTML = NodeHtmlMarkdown.translate( - html, - markdownOptions, - ); + const markdownFromHTML = NodeHtmlMarkdown.translate(html, markdownOptions); const newItem = JSON.parse(JSON.stringify(items[i].json)); set(newItem, destinationKey, markdownFromHTML); @@ -576,7 +587,7 @@ export class Markdown implements INodeType { const converter = new Converter(); - Object.keys(options).forEach( key => converter.setOption(key, options[key])); + Object.keys(options).forEach((key) => converter.setOption(key, options[key])); const htmlFromMarkdown = converter.makeHtml(markdown); const newItem = JSON.parse(JSON.stringify(items[i].json));