diff --git a/server/models/renderers.js b/server/models/renderers.js index 2d26e31b..58b51776 100644 --- a/server/models/renderers.js +++ b/server/models/renderers.js @@ -105,7 +105,7 @@ module.exports = class Renderer extends Model { // Build tree const rawCores = _.filter(renderers, renderer => !_.has(renderer, 'dependsOn')).map(core => { - core.children = _.concat([_.cloneDeep(core)], _.filter(renderers, ['dependsOn', core.key])) + core.children = _.filter(renderers, ['dependsOn', core.key]) return core }) diff --git a/server/modules/rendering/html-codehighlighter/definition.yml b/server/modules/rendering/html-codehighlighter/definition.yml new file mode 100644 index 00000000..e6702d39 --- /dev/null +++ b/server/modules/rendering/html-codehighlighter/definition.yml @@ -0,0 +1,8 @@ +key: htmlCodehighlighter +title: Code Highlighting +description: Syntax highlighter for programming code +author: requarks.io +icon: palette +enabledDefault: true +dependsOn: htmlCore +props: {} diff --git a/server/modules/rendering/html-mediaplayers/definition.yml b/server/modules/rendering/html-mediaplayers/definition.yml index 85119dc5..002e8791 100644 --- a/server/modules/rendering/html-mediaplayers/definition.yml +++ b/server/modules/rendering/html-mediaplayers/definition.yml @@ -3,6 +3,6 @@ title: Media Players description: Embed players such as Youtube, Vimeo, Soundcloud, etc. author: requarks.io icon: subscriptions -enabledDefault: false +enabledDefault: true dependsOn: htmlCore props: {} diff --git a/server/modules/rendering/markdown-mermaid/definition.yml b/server/modules/rendering/html-mermaid/definition.yml similarity index 75% rename from server/modules/rendering/markdown-mermaid/definition.yml rename to server/modules/rendering/html-mermaid/definition.yml index 205505b6..b47cc810 100644 --- a/server/modules/rendering/markdown-mermaid/definition.yml +++ b/server/modules/rendering/html-mermaid/definition.yml @@ -1,8 +1,8 @@ -key: markdownMermaid +key: htmlMermaid title: Mermaid description: Generate flowcharts from Mermaid syntax author: requarks.io icon: merge_type enabledDefault: false -dependsOn: markdownCore +dependsOn: htmlCore props: {} diff --git a/server/modules/rendering/markdown-mermaid/renderer.js b/server/modules/rendering/html-mermaid/renderer.js similarity index 100% rename from server/modules/rendering/markdown-mermaid/renderer.js rename to server/modules/rendering/html-mermaid/renderer.js diff --git a/server/modules/rendering/markdown-plantuml/definition.yml b/server/modules/rendering/html-plantuml/definition.yml similarity index 75% rename from server/modules/rendering/markdown-plantuml/definition.yml rename to server/modules/rendering/html-plantuml/definition.yml index 5f36cc29..506ec40a 100644 --- a/server/modules/rendering/markdown-plantuml/definition.yml +++ b/server/modules/rendering/html-plantuml/definition.yml @@ -1,8 +1,8 @@ -key: markdownPlantuml +key: htmlPlantuml title: PlantUML description: Generate diagrams from PlantUML syntax author: requarks.io icon: multiline_chart enabledDefault: false -dependsOn: markdownCore +dependsOn: htmlCore props: {} diff --git a/server/modules/rendering/markdown-plantuml/renderer.js b/server/modules/rendering/html-plantuml/renderer.js similarity index 100% rename from server/modules/rendering/markdown-plantuml/renderer.js rename to server/modules/rendering/html-plantuml/renderer.js diff --git a/server/modules/rendering/markdown-core/definition.yml b/server/modules/rendering/markdown-core/definition.yml index 43cb2c61..46e0bed5 100644 --- a/server/modules/rendering/markdown-core/definition.yml +++ b/server/modules/rendering/markdown-core/definition.yml @@ -44,8 +44,3 @@ props: - Russian - Spanish - Swedish - highlightCode: - type: Boolean - default: true - title: Highlight code blocks - hint: Add syntax coloring to code blocks. diff --git a/server/modules/rendering/markdown-core/renderer.js b/server/modules/rendering/markdown-core/renderer.js index af5637fe..f6d4fa67 100644 --- a/server/modules/rendering/markdown-core/renderer.js +++ b/server/modules/rendering/markdown-core/renderer.js @@ -1,5 +1,4 @@ const md = require('markdown-it') -// const hljs = require('highlight.js') const _ = require('lodash') const quoteStyles = { @@ -26,17 +25,16 @@ module.exports = { typographer: this.config.typographer, quotes: _.get(quoteStyles, this.config.quotes, quoteStyles.English), highlight(str, lang) { - // if (this.config.highlightCode && lang && hljs.getLanguage(lang)) { - // try { - // return '
' + hljs.highlight(lang, str, true).value + '
'
- // } catch (err) {
- // return '' + _.escape(str) + '
'
- // }
- // }
return '' + _.escape(str) + '
'
}
})
+ for (let child of this.children) {
+ console.info(child)
+ const renderer = require(`../${_.kebabCase(child.key)}/renderer.js`)
+ renderer.init(mkdown, child.config)
+ }
+
return mkdown.render(this.input)
}
}
diff --git a/server/modules/rendering/markdown-imsize/definition.yml b/server/modules/rendering/markdown-imsize/definition.yml
new file mode 100644
index 00000000..08b15b6d
--- /dev/null
+++ b/server/modules/rendering/markdown-imsize/definition.yml
@@ -0,0 +1,8 @@
+key: markdownImsize
+title: Image Size
+description: Adds dimensions attributes to images
+author: requarks.io
+icon: insert_photo
+enabledDefault: true
+dependsOn: markdownCore
+props: {}
diff --git a/server/modules/rendering/markdown-imsize/renderer.js b/server/modules/rendering/markdown-imsize/renderer.js
new file mode 100644
index 00000000..33bd80ac
--- /dev/null
+++ b/server/modules/rendering/markdown-imsize/renderer.js
@@ -0,0 +1,11 @@
+const mdImsize = require('markdown-it-imsize')
+
+// ------------------------------------
+// Markdown - Image Size
+// ------------------------------------
+
+module.exports = {
+ init (md, conf) {
+ md.use(mdImsize)
+ }
+}
diff --git a/server/modules/rendering/markdown-supsub/definition.yml b/server/modules/rendering/markdown-supsub/definition.yml
new file mode 100644
index 00000000..32ee33f4
--- /dev/null
+++ b/server/modules/rendering/markdown-supsub/definition.yml
@@ -0,0 +1,18 @@
+key: markdownSupsub
+title: Subscript/Superscript
+description: Parse subscript and superscript tags
+author: requarks.io
+icon: format_size
+enabledDefault: true
+dependsOn: markdownCore
+props:
+ subEnabled:
+ type: Boolean
+ title: Subscript
+ hint: Enable subscript tags
+ default: true
+ supEnabled:
+ type: Boolean
+ title: Supercript
+ hint: Enable supercript tags
+ default: true
diff --git a/server/modules/rendering/markdown-supsub/renderer.js b/server/modules/rendering/markdown-supsub/renderer.js
new file mode 100644
index 00000000..be57ac1f
--- /dev/null
+++ b/server/modules/rendering/markdown-supsub/renderer.js
@@ -0,0 +1,17 @@
+const mdSub = require('markdown-it-sub')
+const mdSup = require('markdown-it-sup')
+
+// ------------------------------------
+// Markdown - Subscript / Superscript
+// ------------------------------------
+
+module.exports = {
+ init (md, conf) {
+ if (conf.subEnabled) {
+ md.use(mdSub)
+ }
+ if (conf.supEnabled) {
+ md.use(mdSup)
+ }
+ }
+}