From 437268370661087dbe31323efb18dfe1a518da33 Mon Sep 17 00:00:00 2001 From: flu0r1ne Date: Wed, 21 Jul 2021 03:59:15 -0500 Subject: Dynamic markdown page generation with preloading --- utils/markedOptions.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 utils/markedOptions.js (limited to 'utils/markedOptions.js') diff --git a/utils/markedOptions.js b/utils/markedOptions.js new file mode 100644 index 0000000..ebc7a6f --- /dev/null +++ b/utils/markedOptions.js @@ -0,0 +1,12 @@ +const hljs = require('highlight.js'); + +function highlight(code, lang) { + const language = hljs.getLanguage(lang) ? lang : 'plaintext'; + + const highlighted = hljs.highlight(code, { language }).value; + return highlighted; +} + +module.exports = { + highlight +}; \ No newline at end of file -- cgit v1.2.3