feat: rendering pipeline logic
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
key: htmlSecurity
|
||||
title: Security
|
||||
description: Filter and strips potentially dangerous content
|
||||
author: requarks.io
|
||||
icon: whatshot
|
||||
enabledDefault: true
|
||||
dependsOn: htmlCore
|
||||
props: {}
|
@@ -1,31 +0,0 @@
|
||||
key: markdownCore
|
||||
title: Core
|
||||
description: Basic Markdown Parser
|
||||
author: requarks.io
|
||||
input: markdown
|
||||
output: html
|
||||
icon: crop_free
|
||||
props:
|
||||
linkify:
|
||||
type: Boolean
|
||||
default: true
|
||||
title: Automatically convert links
|
||||
hint: Links will automatically be converted to clickable links.
|
||||
linebreaks:
|
||||
type: Boolean
|
||||
default: true
|
||||
title: Automatically convert line breaks
|
||||
hint: Add linebreaks within paragraphs.
|
||||
highlightCode:
|
||||
type: Boolean
|
||||
default: true
|
||||
title: Highlight code blocks
|
||||
hint: Add syntax coloring to code blocks.
|
||||
codeTheme:
|
||||
type: String
|
||||
default: light
|
||||
title: Code Color Theme
|
||||
hint: Color theme for code blocks
|
||||
enum:
|
||||
- light
|
||||
- dark
|
@@ -1 +0,0 @@
|
||||
module.exports = {}
|
@@ -1 +0,0 @@
|
||||
module.exports = {}
|
5
server/modules/rendering/html-core/renderer.js
Normal file
5
server/modules/rendering/html-core/renderer.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
async render() {
|
||||
return this.input
|
||||
}
|
||||
}
|
18
server/modules/rendering/html-security/definition.yml
Normal file
18
server/modules/rendering/html-security/definition.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
key: htmlSecurity
|
||||
title: Security
|
||||
description: Filter and strips potentially dangerous content
|
||||
author: requarks.io
|
||||
icon: whatshot
|
||||
enabledDefault: true
|
||||
dependsOn: htmlCore
|
||||
props:
|
||||
stripJS:
|
||||
type: Boolean
|
||||
title: Strip Javascript
|
||||
default: false
|
||||
hint: Javascript code within code blocks won't be affected
|
||||
filterBadWords:
|
||||
type: Boolean
|
||||
title: Filter Bad Words
|
||||
default: false
|
||||
hint: Replace bad words with asterisks
|
@@ -5,10 +5,6 @@ const mdAbbr = require('markdown-it-abbr')
|
||||
// ------------------------------------
|
||||
|
||||
module.exports = {
|
||||
key: 'markdown/abbreviations',
|
||||
title: 'Abbreviations',
|
||||
dependsOn: [],
|
||||
props: [],
|
||||
init (md, conf) {
|
||||
md.use(mdAbbr)
|
||||
}
|
51
server/modules/rendering/markdown-core/definition.yml
Normal file
51
server/modules/rendering/markdown-core/definition.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
key: markdownCore
|
||||
title: Core
|
||||
description: Basic Markdown Parser
|
||||
author: requarks.io
|
||||
input: markdown
|
||||
output: html
|
||||
icon: crop_free
|
||||
props:
|
||||
allowHTML:
|
||||
type: Boolean
|
||||
default: true
|
||||
title: Allow HTML
|
||||
hint: Enable HTML tags in content
|
||||
linkify:
|
||||
type: Boolean
|
||||
default: true
|
||||
title: Automatically convert links
|
||||
hint: Links will automatically be converted to clickable links.
|
||||
linebreaks:
|
||||
type: Boolean
|
||||
default: true
|
||||
title: Automatically convert line breaks
|
||||
hint: Add linebreaks within paragraphs.
|
||||
typographer:
|
||||
type: Boolean
|
||||
default: false
|
||||
title: Typographer
|
||||
hint: Enable some language-neutral replacement + quotes beautification
|
||||
quotes:
|
||||
type: String
|
||||
default: English
|
||||
title: Quotes style
|
||||
hint: When typographer is enabled. Double + single quotes replacement pairs. e.g. «»„“ for Russian, „“‚‘ for German, etc.
|
||||
enum:
|
||||
- Chinese
|
||||
- English
|
||||
- French
|
||||
- German
|
||||
- Greek
|
||||
- Japanese
|
||||
- Hungarian
|
||||
- Polish
|
||||
- Portuguese
|
||||
- Russian
|
||||
- Spanish
|
||||
- Swedish
|
||||
highlightCode:
|
||||
type: Boolean
|
||||
default: true
|
||||
title: Highlight code blocks
|
||||
hint: Add syntax coloring to code blocks.
|
42
server/modules/rendering/markdown-core/renderer.js
Normal file
42
server/modules/rendering/markdown-core/renderer.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const md = require('markdown-it')
|
||||
// const hljs = require('highlight.js')
|
||||
const _ = require('lodash')
|
||||
|
||||
const quoteStyles = {
|
||||
Chinese: '””‘’',
|
||||
English: '“”‘’',
|
||||
French: ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'],
|
||||
German: '„“‚‘',
|
||||
Greek: '«»‘’',
|
||||
Japanese: '「」「」',
|
||||
Hungarian: '„”’’',
|
||||
Polish: '„”‚‘',
|
||||
Portuguese: '«»‘’',
|
||||
Russian: '«»„“',
|
||||
Spanish: '«»‘’',
|
||||
Swedish: '””’’'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
async render() {
|
||||
const mkdown = md({
|
||||
html: this.config.allowHTML,
|
||||
breaks: this.config.linebreaks,
|
||||
linkify: this.config.linkify,
|
||||
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 '<pre class="hljs"><code>' + hljs.highlight(lang, str, true).value + '</code></pre>'
|
||||
// } catch (err) {
|
||||
// return '<pre><code>' + _.escape(str) + '</code></pre>'
|
||||
// }
|
||||
// }
|
||||
return '<pre><code>' + _.escape(str) + '</code></pre>'
|
||||
}
|
||||
})
|
||||
|
||||
return mkdown.render(this.input)
|
||||
}
|
||||
}
|
@@ -5,10 +5,6 @@ const mdEmoji = require('markdown-it-emoji')
|
||||
// ------------------------------------
|
||||
|
||||
module.exports = {
|
||||
key: 'markdown/emoji',
|
||||
title: 'Emoji',
|
||||
dependsOn: [],
|
||||
props: [],
|
||||
init (md, conf) {
|
||||
md.use(mdEmoji)
|
||||
}
|
@@ -5,4 +5,9 @@ author: requarks.io
|
||||
icon: space_bar
|
||||
enabledDefault: true
|
||||
dependsOn: markdownCore
|
||||
props: {}
|
||||
props:
|
||||
tabWidth:
|
||||
type: Number
|
||||
title: Tab Width
|
||||
hint: Amount of spaces for each tab
|
||||
default: 4
|
@@ -6,10 +6,6 @@ const _ = require('lodash')
|
||||
// ------------------------------------
|
||||
|
||||
module.exports = {
|
||||
key: 'markdown/expand-tabs',
|
||||
title: 'Expand Tabs',
|
||||
dependsOn: [],
|
||||
props: ['tabWidth'],
|
||||
init (md, conf) {
|
||||
md.use(mdExpandTabs, {
|
||||
tabWidth: _.toInteger(conf.tabWidth || 4)
|
@@ -5,10 +5,6 @@ const mdFootnote = require('markdown-it-footnote')
|
||||
// ------------------------------------
|
||||
|
||||
module.exports = {
|
||||
key: 'markdown/footnotes',
|
||||
title: 'Footnotes',
|
||||
dependsOn: [],
|
||||
props: [],
|
||||
init (md, conf) {
|
||||
md.use(mdFootnote)
|
||||
}
|
@@ -5,10 +5,6 @@ const mdMathjax = require('markdown-it-mathjax')()
|
||||
// ------------------------------------
|
||||
|
||||
module.exports = {
|
||||
key: 'markdown/mathjax',
|
||||
title: 'Mathjax Preprocessor',
|
||||
dependsOn: [],
|
||||
props: [],
|
||||
init (md, conf) {
|
||||
md.use(mdMathjax)
|
||||
}
|
@@ -5,10 +5,6 @@ const mdTaskLists = require('markdown-it-task-lists')
|
||||
// ------------------------------------
|
||||
|
||||
module.exports = {
|
||||
key: 'markdown/task-lists',
|
||||
title: 'Task Lists',
|
||||
dependsOn: [],
|
||||
props: [],
|
||||
init (md, conf) {
|
||||
md.use(mdTaskLists)
|
||||
}
|
Reference in New Issue
Block a user