You can add code syntax highlighting with this block. We use highlightjs javascript library to perform language detection and for syntax highlighting.
The following block definition ๐
```@nitoku.public/highlight
function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
` class="${cls}"`;
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
}
export $initHighlight;
```
Will render the following highlighted javascript code ๐
The block doesn't include all the languages by default. Otherwise it'd be too big. If you don't see the language you need in the "Common" section. you need to add it on the block configuration
List of languages:
https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.6/build/languages/
List of styles:
https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.15.6/build/styles/
ย
The following block definition ๐ for Mathematica language and style mono
```@nitoku.public/highlight
language : mathematica
style : mono-blue
(* ::Package:: *)
(* Mathematica Package *)
BeginPackage["SomePkg`"]
Begin["`Private`"]
SomeFn[ns_List] := Fold[Function[{x, y}, x + y], 0, Map[# * 2 &, ns]];
Print[$ActivationKey];
End[] (* End Private Context *)
EndPackage[]
```
Will render the following highlighted Mathematica code ๐
ย
ย