Added turndown settings

This commit is contained in:
Benoit Schweblin 2018-02-25 15:41:25 +00:00
parent 0b74d48bc8
commit 57f45f0c5f
3 changed files with 19 additions and 13 deletions

View File

@ -28,13 +28,9 @@ import TurndownService from 'turndown/lib/turndown.browser.umd';
import htmlSanitizer from '../../libs/htmlSanitizer'; import htmlSanitizer from '../../libs/htmlSanitizer';
import MenuEntry from './common/MenuEntry'; import MenuEntry from './common/MenuEntry';
import providerUtils from '../../services/providers/providerUtils'; import providerUtils from '../../services/providers/providerUtils';
import store from '../../store';
const turndownService = new TurndownService({ const turndownService = new TurndownService(store.getters['data/computedSettings'].turndown);
headingStyle: 'atx',
hr: '----------',
bulletListMarker: '-',
codeBlockStyle: 'fenced',
});
const readFile = file => new Promise((resolve) => { const readFile = file => new Promise((resolve) => {
if (file) { if (file) {

View File

@ -59,6 +59,19 @@ pandoc:
toc: true toc: true
tocDepth: 3 tocDepth: 3
# HTML to Markdown converter options
# See https://github.com/domchristie/turndown
turndown:
headingStyle: atx
hr: ----------
bulletListMarker: '-'
codeBlockStyle: fenced
fence: '```'
emDelimiter: _
strongDelimiter: '**'
linkStyle: inlined
linkReferenceStyle: full
# Default content for new files # Default content for new files
newFileContent: | newFileContent: |

View File

@ -1,13 +1,7 @@
import DiffMatchPatch from 'diff-match-patch'; import DiffMatchPatch from 'diff-match-patch';
import TurndownService from 'turndown/lib/turndown.browser.umd'; import TurndownService from 'turndown/lib/turndown.browser.umd';
import htmlSanitizer from '../../libs/htmlSanitizer'; import htmlSanitizer from '../../libs/htmlSanitizer';
import store from '../../store';
const turndownService = new TurndownService({
headingStyle: 'atx',
hr: '----------',
bulletListMarker: '-',
codeBlockStyle: 'fenced',
});
function cledit(contentElt, scrollEltOpt) { function cledit(contentElt, scrollEltOpt) {
const scrollElt = scrollEltOpt || contentElt; const scrollElt = scrollEltOpt || contentElt;
@ -114,6 +108,7 @@ function cledit(contentElt, scrollEltOpt) {
function focus() { function focus() {
selectionMgr.restoreSelection(); selectionMgr.restoreSelection();
contentElt.focus();
} }
function addMarker(marker) { function addMarker(marker) {
@ -337,6 +332,8 @@ function cledit(contentElt, scrollEltOpt) {
adjustCursorPosition(); adjustCursorPosition();
}); });
const turndownService = new TurndownService(store.getters['data/computedSettings'].turndown);
contentElt.addEventListener('paste', (evt) => { contentElt.addEventListener('paste', (evt) => {
undoMgr.setCurrentMode('single'); undoMgr.setCurrentMode('single');
evt.preventDefault(); evt.preventDefault();