Syntax highlighting
A technique to highlight and differentiate individual parts of a (programming) languages syntax.
It can separate strings from numbers, function definitions from variables or other keywords.
It generally makes programming a much more pleasurable task, as it give you an additional layer of encoding on top of the plain text aspect.
I’m testing the highlighting here:
var hljs = require('highlight.js'); // https://highlightjs.org/
// Actual default values
var md = require('markdown-it')({
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' +
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
}
});
References
PrismJS https://github.com/PrismJS/prism
Highlight JS