Hero Image

Figured out how to add NIM and other languages to syle sheet in GRAV

Today I managed to figure out how to make GRAV extend its syntax highlighting for things like NIM, Perl, etc. which aren't in its default config. Alas the editor (the nice gui one) doesn't seem to report them correctly, but the display is nicely updated. I can just use appropriate code fences with the right word, and POOF pretty code samples from most of my favourite languages:

Nim example:

var x, y = 3  # assigns 3 to the variables `x` and `y`
echo "x ", x  # outputs "x 3"
echo "y ", y  # outputs "y 3"
x = 42        # changes `x` to 42 without changing `y`
echo "x ", x  # outputs "x 42"
echo "y ", y  # outputs "y 3"

Perl example:

#!/usr/bin/env perl -w
$_="Hello my name is thomas";
print "$_ is done!\n";
while (<>) {
  say ("Hello thomas\n");

Sql example:

select * from TABLE_1

Here is how I did it:

I went to this website and chose my favourite languages. Download the .zip file and transfer to your grav server. Once that is done, make sure you have the highlight plugin installed. Final steps are to copy the hilight.min.js (which is helpfully created for you when you complete the download process) over the file (or keep it if you are worried in the grav webroot /user/plugins/highlight/js directory. Rename the file from highlight.min.js to highlightjs-pack.js. Thats it. They may not show up in the gui correctly, but it works fine otherwise. Only rub is each update might blow it away. Eventually I will figure out how to make it incorporate between updates.

Happily this lets me do nim properly and it no longer looks ugly. I am getting the hang of this new theme (the pay one, its GREAT) and helps the GRAV people eat.