From 0755c538ed7940b8877ae5353be96dc2b987aa50 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Fri, 3 Jan 2020 01:07:29 -0500 Subject: [PATCH] fix: html rendering order param + decodeEntities --- server/modules/rendering/html-core/renderer.js | 8 +++++--- server/modules/rendering/html-security/definition.yml | 1 + server/modules/rendering/html-twemoji/definition.yml | 2 ++ server/modules/rendering/html-twemoji/renderer.js | 9 +++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server/modules/rendering/html-core/renderer.js b/server/modules/rendering/html-core/renderer.js index 233ccf19..eb5564c3 100644 --- a/server/modules/rendering/html-core/renderer.js +++ b/server/modules/rendering/html-core/renderer.js @@ -8,7 +8,9 @@ const URL = require('url').URL module.exports = { async render() { - const $ = cheerio.load(this.input) + const $ = cheerio.load(this.input, { + decodeEntities: false + }) if ($.root().children().length < 1) { return '' @@ -230,9 +232,9 @@ module.exports = { // STEP: POST // -------------------------------- - for (let child of _.filter(this.children, ['step', 'post'])) { + for (let child of _.sortBy(_.filter(this.children, ['step', 'post']), ['order'])) { const renderer = require(`../${_.kebabCase(child.key)}/renderer.js`) - output = renderer.init(output, child.config) + output = await renderer.init(output, child.config) } return output diff --git a/server/modules/rendering/html-security/definition.yml b/server/modules/rendering/html-security/definition.yml index 38f043cb..4046926c 100644 --- a/server/modules/rendering/html-security/definition.yml +++ b/server/modules/rendering/html-security/definition.yml @@ -6,6 +6,7 @@ icon: mdi-fire enabledDefault: true dependsOn: htmlCore step: post +order: 99999 props: safeHTML: type: Boolean diff --git a/server/modules/rendering/html-twemoji/definition.yml b/server/modules/rendering/html-twemoji/definition.yml index d2113894..aedb9c0a 100644 --- a/server/modules/rendering/html-twemoji/definition.yml +++ b/server/modules/rendering/html-twemoji/definition.yml @@ -5,4 +5,6 @@ author: requarks.io icon: mdi-emoticon-happy-outline enabledDefault: true dependsOn: htmlCore +step: post +order: 10 props: {} diff --git a/server/modules/rendering/html-twemoji/renderer.js b/server/modules/rendering/html-twemoji/renderer.js index 94884009..9ba10539 100644 --- a/server/modules/rendering/html-twemoji/renderer.js +++ b/server/modules/rendering/html-twemoji/renderer.js @@ -1,9 +1,14 @@ +// const twemoji = require('twemoji') + // ------------------------------------ // HTML - Twemoji // ------------------------------------ module.exports = { - init ($, conf) { - + init (input, conf) { + // TODO: Must limit to text nodes only (exclude code blocks, already processed emojis, etc.) + // + // return twemoji.parse(input) + return input } }