瀏覽代碼

fix: html rendering order param + decodeEntities

NGPixel 5 年之前
父節點
當前提交
0755c538ed

+ 5 - 3
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

+ 1 - 0
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

+ 2 - 0
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: {}

+ 7 - 2
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
   }
 }