From a626eff1717a46170933bbc0075842a9e815eec6 Mon Sep 17 00:00:00 2001 From: Akos Balasko Date: Tue, 16 Mar 2021 23:38:38 +0100 Subject: [PATCH] placeholder improvement --- src/convert-html-to-md.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/convert-html-to-md.ts b/src/convert-html-to-md.ts index 71149cf1..769f5b23 100644 --- a/src/convert-html-to-md.ts +++ b/src/convert-html-to-md.ts @@ -1,4 +1,5 @@ import { JSDOM } from 'jsdom'; +const {EOL} = require('os'); import { getTurndownService } from './utils/turndown-service'; import { NoteData } from './models/NoteData'; @@ -42,6 +43,7 @@ export const convertHtml2Md = (yarleOptions: YarleOptions, { htmlContent }: Note const contentNode = new JSDOM(content).window.document .getElementsByTagName('en-note').item(0) as any as HTMLElement; let contentInMd = getTurndownService(yarleOptions).turndown(fixSublists(contentNode)); - contentInMd = contentInMd.replace(/\n/g,''); + const newLinePlaceholder = new RegExp(`${EOL}?`, 'g'); + contentInMd = contentInMd.replace(newLinePlaceholder,''); return contentInMd && contentInMd !== 'undefined' ? { content: contentInMd } : {content: ''}; };