For… what?!
TiddlyWikis are a brilliant way of managing your own information. For me I find that anything that I’ve learnt and won’t be able to continue using for long before moving onto something else goes into a tiddlywiki – anything that I’ll need to access from anywhere goes onto this website!. If you’ve not heard of them before I highly recommend taking a look at the website https://tiddlywiki.com/ because unless you’re able to remember everything that you’ve looked at you’d likely benefit from having a one file wiki site that allows you to arrange information in very flexible ways.
Highlight.js
As a lot of the information I personally store in my wikis has a code component getting something to be able to markup my code in the different languages that I might be using (C#, SQL, VB.Net, XQuery, XML, etc..). This is where Highlight.js comes in, firstly you’ll want to install it from the plugin manager, instructions for that can be found here. Once you’ve got the plugin installed you can apply code markup for a number of different languages simply by using the following syntax, awesome right?:
```sql ```
what about Visual Basic*?! *insert needed language here
For my purposes I’ve needed VB highlighting and sadly Highlight.js doesn’t think that VB is important enough to include in the common language pack (you could argue that VB is on the way out – I wouldn’t disagree too strongly) and there are so many others that Highlight.js is capable of but isn’t available through the plugin manager, so here’s the how to for installing any number of new languages to use in your wiki!
the step by step
- Go to the following page https://highlightjs.org/download/ and select the languages that you’d like to be able to use
- Click “download” and open the file “highlight.pack.js” in a text editor
- Remove the initial comment which reads something like /*! highlight.js v9.13.1 | BSD3 License | git.io/hljslicense */
- On it’s own line at the beginning of the file put in the following text:
- var hljs = require(“$:/plugins/tiddlywiki/highlight/highlight.js”);
- On its own line at the end of the file put the following:
- exports.hljs = hljs;
- It’s worth making a copy of your wiki at this point in case something goes wrong!
- Navigate to the plugins section of your wiki, select contents and then open the tiddler named
- $:/plugins/tiddlywiki/highlight/highlight.js
- It might be a good idea to check out which languages that you actually have now and how to get hold of them – I’d suggest searching in your text file for the following “hljs.registerLanguage(” and taking a note of the strings that follow, if you skip this step then you can go into the tiddler $:/plugins/tiddlywiki/highlight/highlight.js and search for the same
- Save everything and close/re-open your wiki and you should now be able to use the newly selected languages.
So there you have it – I’ve been using the wrong highlighting pattern for articles for far too long and it’s definitely worth taking the time to get your tiddlywiki set up properly in the first instance rather than labouring under workarounds when the actual solution isn’t difficult at all!.