Syntax highlighting is provided within the browser, courtesy of highlight.js
.
RGBASM syntax is highlighted via a plugin, but this requires a custom build of highlight.js
.
Here are the steps to generate a new highlight.js
:
-
Clone
highlight.js
anywhere, and go into that directory.You will probably want to target a specific version by checking out its tag.
-
Run
npm install
to install its dependencies. -
Within the
extras/
directory, clonehighlightjs-rgbasm
; ensure the directory is calledrgbasm
, otherwise the build tool won't pick it up. -
You can work on and make modifications to
highlightjs-rgbasm
! -
To make the custom build of
highlight.js
, within thehighlight.js
directory, runnode tools/build.js -t browser <languages>...
, with<languages>...
being the list of languages to enable support for. The languages identifiers are the same that you would use for highlighting (```rgbasm
, for example). -
Copy
build/highlight.min.js
astheme/highlight.js
in Pan Docs' source. Alternatively, for debugging, you can usebuild/highlight.js
for a non-minified version, but please don't commit that.
mdbook watch
and mdbook serve
do not watch for changes to files in the theme/
directory, you must trigger the build by either restarting the command, or manually changing one of the watched files.
Example:
$ git clone git@github.com:highlightjs/highlight.js.git
$ cd highlight.js
$ git checkout 10.7.2
$ npm install
$ git clone git@github.com:gbdev/highlightjs-rgbasm.git extras/rgbasm
$ node tools/build.js -t browser rgbasm shell makefile
$ cp build/highlight.min.js ../gb-asm-tutorial/theme/highlight.js