From 23008bc1e152998aec0c5b74ac20b1c10c12a386 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 18 Sep 2016 16:42:27 +0800 Subject: [PATCH] Update to support wiki markup syntax highlighting in view using prism --- bower.json | 3 ++- public/js/extra.js | 14 ++++++++++---- public/views/foot.ejs | 2 ++ public/views/head.ejs | 1 + public/views/pretty.ejs | 3 +++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index dfa8b364..f3314a33 100644 --- a/bower.json +++ b/bower.json @@ -58,7 +58,8 @@ "visibilityjs": "^1.2.3", "pdfobject": "pdfobject2#*", "gist-embed": "*", - "keymaster": "^1.6.3" + "keymaster": "^1.6.3", + "prism": "^1.5.1" }, "resolutions": { "jquery": "~3.1.0" diff --git a/public/js/extra.js b/public/js/extra.js index 8fa99ce2..77f298f9 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -755,11 +755,17 @@ function highlightRender(code, lang) { return '
' + code + '
'; } var reallang = lang.replace(/\=$|\=\d+$|\=\+$/, ''); - var languages = hljs.listLanguages(); - if (languages.indexOf(reallang) == -1) { - var result = hljs.highlightAuto(code); + if (reallang == "tiddlywiki" || reallang == "mediawiki") { + var result = { + value: Prism.highlight(code, Prism.languages.wiki) + }; } else { - var result = hljs.highlight(reallang, code); + var languages = hljs.listLanguages(); + if (languages.indexOf(reallang) == -1) { + var result = hljs.highlightAuto(code); + } else { + var result = hljs.highlight(reallang, code); + } } var showlinenumbers = /\=$|\=\d+$|\=\+$/.test(lang); if (showlinenumbers) { diff --git a/public/views/foot.ejs b/public/views/foot.ejs index c1197605..9fa79d55 100644 --- a/public/views/foot.ejs +++ b/public/views/foot.ejs @@ -50,6 +50,8 @@ + + diff --git a/public/views/head.ejs b/public/views/head.ejs index 5fed27be..5d8e44b6 100644 --- a/public/views/head.ejs +++ b/public/views/head.ejs @@ -34,6 +34,7 @@ + diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs index 1de3610c..2546b1ac 100644 --- a/public/views/pretty.ejs +++ b/public/views/pretty.ejs @@ -31,6 +31,7 @@ + @@ -115,6 +116,8 @@ + +