Przeglądaj źródła

feat: Optional linebreaks + mathjax processing

NGPixel 8 lat temu
rodzic
commit
919afb46e2

+ 9 - 0
config.sample.yml

@@ -134,6 +134,15 @@ git:
   # Whether to use user email as author in commits
   # Whether to use user email as author in commits
   showUserEmail: true
   showUserEmail: true
 
 
+# ---------------------------------------------------------------------
+# Features
+# ---------------------------------------------------------------------
+# You can enable / disable specific features below
+
+features:
+  linebreaks: true
+  mathjax: true
+
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # External Logging
 # External Logging
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------

+ 9 - 0
npm/configs/config.docker.yml

@@ -132,6 +132,15 @@ git:
   # Whether to use user email as author in commits
   # Whether to use user email as author in commits
   showUserEmail: true
   showUserEmail: true
 
 
+# ---------------------------------------------------------------------
+# Features
+# ---------------------------------------------------------------------
+# You can enable / disable specific features below
+
+features:
+  linebreaks: true
+  mathjax: true
+
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # External Logging
 # External Logging
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------

+ 9 - 0
npm/configs/config.heroku.yml

@@ -132,6 +132,15 @@ git:
   # Whether to use user email as author in commits
   # Whether to use user email as author in commits
   showUserEmail: $(WIKI_SHOW_USER_EMAIL)
   showUserEmail: $(WIKI_SHOW_USER_EMAIL)
 
 
+# ---------------------------------------------------------------------
+# Features
+# ---------------------------------------------------------------------
+# You can enable / disable specific features below
+
+features:
+  linebreaks: true
+  mathjax: true
+
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------
 # External Logging
 # External Logging
 # ---------------------------------------------------------------------
 # ---------------------------------------------------------------------

+ 1 - 0
server/app/data.yml

@@ -49,6 +49,7 @@ defaults:
       serverEmail: wiki@example.com
       serverEmail: wiki@example.com
       showUserEmail: true
       showUserEmail: true
     features:
     features:
+      linebreaks: true
       mathjax: true
       mathjax: true
     externalLogging:
     externalLogging:
       bugsnap: false
       bugsnap: false

+ 10 - 2
server/libs/markdown.js

@@ -21,6 +21,7 @@ const mdRemove = require('remove-markdown')
 
 
 var mkdown = md({
 var mkdown = md({
   html: true,
   html: true,
+  breaks: appconfig.features.linebreaks,
   linkify: true,
   linkify: true,
   typography: true,
   typography: true,
   highlight(str, lang) {
   highlight(str, lang) {
@@ -53,7 +54,10 @@ var mkdown = md({
     tabWidth: 4
     tabWidth: 4
   })
   })
   .use(mdAttrs)
   .use(mdAttrs)
-  .use(mdMathjax)
+
+if (appconfig.features.mathjax) {
+  mkdown.use(mdMathjax)
+}
 
 
 // Rendering rules
 // Rendering rules
 
 
@@ -296,7 +300,11 @@ const parseContent = (content) => {
 
 
   // Mathjax Post-processor
   // Mathjax Post-processor
 
 
-  return processMathjax(cr.html())
+  if (appconfig.features.mathjax) {
+    return processMathjax(cr.html())
+  } else {
+    return Promise.resolve(cr.html())
+  }
 }
 }
 
 
 /**
 /**