Skip to content

Commit 0d36f59

Browse files
committed
Create turndown service & use gfm turndown plugin
1 parent a3f7d22 commit 0d36f59

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

browser/components/CodeEditor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { ipcRenderer, remote, clipboard } = require('electron')
2121
import normalizeEditorFontFamily from 'browser/lib/normalizeEditorFontFamily'
2222
const spellcheck = require('browser/lib/spellcheck')
2323
const buildEditorContextMenu = require('browser/lib/contextMenuBuilder')
24-
import TurndownService from 'turndown'
24+
import { createTurndownService } from '../lib/turndown'
2525
import {languageMaps} from '../lib/CMLanguageList'
2626
import snippetManager from '../lib/SnippetManager'
2727
import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-generator'
@@ -102,7 +102,7 @@ export default class CodeEditor extends React.Component {
102102

103103
this.editorActivityHandler = () => this.handleEditorActivity()
104104

105-
this.turndownService = new TurndownService()
105+
this.turndownService = createTurndownService()
106106
}
107107

108108
handleSearch (msg) {

browser/lib/turndown.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const TurndownService = require('turndown')
2+
const { gfm } = require('turndown-plugin-gfm')
3+
4+
export const createTurndownService = function () {
5+
const turndown = new TurndownService()
6+
turndown.use(gfm)
7+
return turndown
8+
}

browser/main/lib/dataApi/createNoteFromUrl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const http = require('http')
22
const https = require('https')
3-
const TurndownService = require('turndown')
3+
const { createTurndownService } = require('../../../lib/turndown')
44
const createNote = require('./createNote')
55

66
import { push } from 'connected-react-router'
@@ -16,7 +16,7 @@ function validateUrl (str) {
1616

1717
function createNoteFromUrl (url, storage, folder, dispatch = null, location = null) {
1818
return new Promise((resolve, reject) => {
19-
const td = new TurndownService()
19+
const td = createTurndownService()
2020

2121
if (!validateUrl(url)) {
2222
reject({result: false, error: 'Please check your URL is in correct format. (Example, https://www.google.com)'})

0 commit comments

Comments
 (0)