From 919afb46e28b05499fd0dfe73c2d8c64694d37e1 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sat, 24 Jun 2017 16:08:55 -0400 Subject: [PATCH] feat: Optional linebreaks + mathjax processing --- config.sample.yml | 9 +++++++++ npm/configs/config.docker.yml | 9 +++++++++ npm/configs/config.heroku.yml | 9 +++++++++ server/app/data.yml | 1 + server/libs/markdown.js | 12 ++++++++++-- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/config.sample.yml b/config.sample.yml index fed0b54d..e4ef3bc2 100644 --- a/config.sample.yml +++ b/config.sample.yml @@ -134,6 +134,15 @@ git: # Whether to use user email as author in commits showUserEmail: true +# --------------------------------------------------------------------- +# Features +# --------------------------------------------------------------------- +# You can enable / disable specific features below + +features: + linebreaks: true + mathjax: true + # --------------------------------------------------------------------- # External Logging # --------------------------------------------------------------------- diff --git a/npm/configs/config.docker.yml b/npm/configs/config.docker.yml index 6b51c11b..7bd1fa3b 100644 --- a/npm/configs/config.docker.yml +++ b/npm/configs/config.docker.yml @@ -132,6 +132,15 @@ git: # Whether to use user email as author in commits showUserEmail: true +# --------------------------------------------------------------------- +# Features +# --------------------------------------------------------------------- +# You can enable / disable specific features below + +features: + linebreaks: true + mathjax: true + # --------------------------------------------------------------------- # External Logging # --------------------------------------------------------------------- diff --git a/npm/configs/config.heroku.yml b/npm/configs/config.heroku.yml index f32b7745..5ef4904b 100644 --- a/npm/configs/config.heroku.yml +++ b/npm/configs/config.heroku.yml @@ -132,6 +132,15 @@ git: # Whether to use user email as author in commits showUserEmail: $(WIKI_SHOW_USER_EMAIL) +# --------------------------------------------------------------------- +# Features +# --------------------------------------------------------------------- +# You can enable / disable specific features below + +features: + linebreaks: true + mathjax: true + # --------------------------------------------------------------------- # External Logging # --------------------------------------------------------------------- diff --git a/server/app/data.yml b/server/app/data.yml index 40b07881..8ee8dd9f 100644 --- a/server/app/data.yml +++ b/server/app/data.yml @@ -49,6 +49,7 @@ defaults: serverEmail: wiki@example.com showUserEmail: true features: + linebreaks: true mathjax: true externalLogging: bugsnap: false diff --git a/server/libs/markdown.js b/server/libs/markdown.js index d0f31d32..dfadaae2 100644 --- a/server/libs/markdown.js +++ b/server/libs/markdown.js @@ -21,6 +21,7 @@ const mdRemove = require('remove-markdown') var mkdown = md({ html: true, + breaks: appconfig.features.linebreaks, linkify: true, typography: true, highlight(str, lang) { @@ -53,7 +54,10 @@ var mkdown = md({ tabWidth: 4 }) .use(mdAttrs) - .use(mdMathjax) + +if (appconfig.features.mathjax) { + mkdown.use(mdMathjax) +} // Rendering rules @@ -296,7 +300,11 @@ const parseContent = (content) => { // Mathjax Post-processor - return processMathjax(cr.html()) + if (appconfig.features.mathjax) { + return processMathjax(cr.html()) + } else { + return Promise.resolve(cr.html()) + } } /**