Skip to content

Commit

Permalink
Swtich markdown parser to: turndown.
Browse files Browse the repository at this point in the history
  • Loading branch information
jia6y committed Oct 4, 2023
1 parent 99c03ca commit d51a4b3
Show file tree
Hide file tree
Showing 6 changed files with 25,303 additions and 9 deletions.
18 changes: 11 additions & 7 deletions lib/flomo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { parse, HTMLElement } from 'node-html-parser';
//import { NodeHtmlMarkdown} from 'node-html-markdown';
//import DOMPurify from 'dompurify';
import showdown from 'showdown';
import turndown from 'turndown';

export class Flomo {
memos: Record<string, string>[];
Expand All @@ -22,13 +21,17 @@ export class Flomo {
const extrtactTitle = (item: string) => { return item.replace(/(-|:|\s)/gi, "_") }
const extractContent = (content: string) => {
//return NodeHtmlMarkdown.translate(content, {bulletMarker: '-',}).replace('\[', '[').replace('\]', ']')
return (new showdown.Converter({metadata: false})).makeMarkdown(content)
//return NodeHtmlMarkdown.translate(content, {bulletMarker: '-',}).replace('\[', '[').replace('\]', ']')
//return (new showdown.Converter({metadata: false})).makeMarkdown(content)
//return NodeHtmlMarkdown.translate(content, {bulletMarker: '-'})
return (new turndown()).turndown(content)
.replace(/\\\[/g, '[')
.replace(/\\\]/g, ']')
.replace(/\\#/g, '#')
.replace(/\<\!--\s--\>/g, '')
.replace(/^\s*[\r\n]/gm,'')
.replace(/!\[null\]\(<file\//gi, "\n![](<flomo/");
//replace(/\\#/g, '#')
.replace(/!\[\]\(file\//gi, "\n![](flomo/")
//.replace(/\<\!--\s--\>/g, '')
//.replace(/^\s*[\r\n]/gm,'')
//.replace(/!\[null\]\(<file\//gi, "\n![](<flomo/");
}

memoNodes.forEach(i => {
Expand Down Expand Up @@ -58,4 +61,5 @@ export class Flomo {

}


}
Loading

0 comments on commit d51a4b3

Please # to comment.