Skip to content

Commit

Permalink
placeholder improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko committed Mar 16, 2021
1 parent c4f8b25 commit a626eff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/convert-html-to-md.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { JSDOM } from 'jsdom';
const {EOL} = require('os');

import { getTurndownService } from './utils/turndown-service';
import { NoteData } from './models/NoteData';
Expand Down Expand Up @@ -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<YARLE_NEWLINE_PLACEHOLDER>/g,'');
const newLinePlaceholder = new RegExp(`${EOL}?<YARLE_NEWLINE_PLACEHOLDER>`, 'g');
contentInMd = contentInMd.replace(newLinePlaceholder,'');
return contentInMd && contentInMd !== 'undefined' ? { content: contentInMd } : {content: ''};
};

0 comments on commit a626eff

Please sign in to comment.