From 80d9f8b0207adcce405d61c31f1fae81e6569d7c Mon Sep 17 00:00:00 2001 From: Benoit Schweblin Date: Wed, 11 Apr 2018 15:52:07 +0100 Subject: [PATCH] Added new extensions in markdown sample --- src/components/Layout.vue | 2 ++ src/components/common/base.scss | 4 +++ src/data/markdownSample.md | 19 +++++++++---- src/services/markdownConversionSvc.js | 40 ++++++++++++--------------- src/services/utils.js | 1 + 5 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/components/Layout.vue b/src/components/Layout.vue index 611d5cb9..e3bcf1e0 100644 --- a/src/components/Layout.vue +++ b/src/components/Layout.vue @@ -62,6 +62,7 @@ import StickyComment from './gutters/StickyComment'; import CurrentDiscussion from './gutters/CurrentDiscussion'; import FindReplace from './FindReplace'; import editorSvc from '../services/editorSvc'; +import markdownConversionSvc from '../services/markdownConversionSvc'; export default { components: { @@ -105,6 +106,7 @@ export default { saveSelection: () => editorSvc.saveSelection(true), }, created() { + markdownConversionSvc.init(); // Needs to be inited before mount this.updateBodySize(); window.addEventListener('resize', this.updateBodySize); window.addEventListener('keyup', this.saveSelection); diff --git a/src/components/common/base.scss b/src/components/common/base.scss index 7aee98e5..3cf60a5f 100644 --- a/src/components/common/base.scss +++ b/src/components/common/base.scss @@ -60,6 +60,10 @@ ol ol { margin: 0; } +dt { + font-weight: bold; +} + a { color: $link-color; text-decoration: underline; diff --git a/src/data/markdownSample.md b/src/data/markdownSample.md index 889779d3..8f6f6ac1 100644 --- a/src/data/markdownSample.md +++ b/src/data/markdownSample.md @@ -15,6 +15,8 @@ Styling **Strong** __strong__ +==Marked text.== + ~~Mistaken text.~~ > Quoted text. @@ -31,9 +33,12 @@ Lists * Item + Item -1. Item -2. Item -3. Item +1. Item 1 +2. Item 2 +3. Item 3 + +- [ ] Incomplete item +- [x] Complete item Links @@ -43,6 +48,8 @@ A [link](http://example.com). An image: ![Alt](img.jpg) +A sized image: ![Alt](img.jpg =60x50) + Code --------------------------- @@ -81,9 +88,9 @@ Definition lists Markdown : Text-to-HTML conversion tool -Classeur -: French translation for "Binder" -: A Markdown editing app +Authors +: John +: Luke Footnotes --------------------------- diff --git a/src/services/markdownConversionSvc.js b/src/services/markdownConversionSvc.js index 1e2dc1a0..01c16c34 100644 --- a/src/services/markdownConversionSvc.js +++ b/src/services/markdownConversionSvc.js @@ -3,6 +3,7 @@ import Prism from 'prismjs'; import MarkdownIt from 'markdown-it'; import markdownGrammarSvc from './markdownGrammarSvc'; import extensionSvc from './extensionSvc'; +import utils from './utils'; const htmlSectionMarker = '\uF111\uF222\uF333\uF444'; const diffMatchPatch = new DiffMatchPatch(); @@ -103,25 +104,23 @@ function hashArray(arr, valueHash, valueArray) { return String.fromCharCode.apply(null, hash); } -// Default options for the markdown converter and the grammar -const defaultOptions = { - abbr: true, - breaks: true, - deflist: true, - del: true, - fence: true, - footnote: true, - linkify: true, - math: true, - sub: true, - sup: true, - table: true, - typographer: true, - insideFences, -}; +export default { + defaultOptions: null, + defaultConverter: null, + defaultPrismGrammars: null, -const markdownConversionSvc = { - defaultOptions, + init() { + const defaultProperties = { extensions: utils.computedPresets.default }; + + // Default options for the markdown converter and the grammar + this.defaultOptions = { + ...extensionSvc.getOptions(defaultProperties), + insideFences, + }; + + this.defaultConverter = this.createConverter(this.defaultOptions); + this.defaultPrismGrammars = markdownGrammarSvc.makeGrammars(this.defaultOptions); + }, /** * Creates a converter and init it with extensions. @@ -270,8 +269,3 @@ const markdownConversionSvc = { ).join(''); }, }; - -markdownConversionSvc.defaultConverter = markdownConversionSvc.createConverter(defaultOptions); -markdownConversionSvc.defaultPrismGrammars = markdownGrammarSvc.makeGrammars(defaultOptions); - -export default markdownConversionSvc; diff --git a/src/services/utils.js b/src/services/utils.js index b09417f0..a0ffda71 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -66,6 +66,7 @@ Object.keys(presets).forEach((key) => { }); export default { + computedPresets, cleanTrashAfter: 7 * 24 * 60 * 60 * 1000, // 7 days origin, oauth2RedirectUri: `${origin}/oauth2/callback`,