Skip to content
Snippets Groups Projects
Commit fde94cfa authored by Martin Mareš's avatar Martin Mareš
Browse files

Enable highlighting of code blocks using highlight.js

parent 5fc3aa93
Branches
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ install: .allow-install ...@@ -7,6 +7,7 @@ install: .allow-install
js: js/package-lock.json js: js/package-lock.json
( cd js && node_modules/.bin/browserify -o ../static/bundle.js owl.js --standalone owl --plugin tinyify ) ( cd js && node_modules/.bin/browserify -o ../static/bundle.js owl.js --standalone owl --plugin tinyify )
cp js/node_modules/katex/dist/katex.min.css static/ cp js/node_modules/katex/dist/katex.min.css static/
cp js/node_modules/highlight.js/styles/github.css static/
rm -rf static/fonts && cp -a js/node_modules/katex-fonts/fonts static/ rm -rf static/fonts && cp -a js/node_modules/katex-fonts/fonts static/
js/package-lock.json: js/package.json js/package-lock.json: js/package.json
......
var md = require('markdown-it')() const md = require('markdown-it')()
var mk = require('markdown-it-katexx')
md.set({ md.set({
html: false, html: false,
typographer: true, typographer: true,
}); })
const mk = require('markdown-it-katexx')
md.use(mk);
md.use(mk) const hljs = require('highlight.js/lib/core')
hljs.registerLanguage('plaintext', require('highlight.js/lib/languages/plaintext'))
hljs.registerLanguage('c', require('highlight.js/lib/languages/c'))
hljs.registerLanguage('cpp', require('highlight.js/lib/languages/cpp'))
hljs.registerLanguage('python', require('highlight.js/lib/languages/python'))
hljs.registerLanguage('haskell', require('highlight.js/lib/languages/haskell'))
hljs.registerLanguage('prolog', require('highlight.js/lib/languages/prolog'))
const mhl = require('markdown-it-highlightjs/core')
md.use(mhl, {
auto: false,
code: true,
inline: false,
hljs: hljs,
});
exports.render_md = function () { exports.render_md = function () {
console.log('Owl: Rendering Markdown'); console.log('Owl: Rendering Markdown');
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"katex": "^0.12.0", "katex": "^0.12.0",
"katex-fonts": "katex/katex-fonts", "katex-fonts": "katex/katex-fonts",
"markdown-it": ">=11.0", "markdown-it": ">=11.0",
"markdown-it-highlightjs": ">=3.4.0",
"markdown-it-katexx": ">=3.2.0", "markdown-it-katexx": ">=3.2.0",
"browserify": ">=16.5", "browserify": ">=16.5",
"tinyify": "browserify/tinyify" "tinyify": "browserify/tinyify"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment