Description
Hi there!
I've started to use mdBook for writing the documentation for my new software project, and I'm very happy with it so far!
Because this project is a little programming language, I wanted to easily add a language definition for highlight.js to highlight source code in the resulting book, but without forking highlight.js and doing too much individual customization (I'm also not that familiar with npm and all these JS tools). I did several attempts, like overriding head.hbs
or adding a additional-js
in the book.toml
, but the result didn't work as expected, because the initialization of highlight.js is in book.js
and therefore runs in between, and I didn't want to entirely override this.
Therefore I decided for a different solution: This injects my language definition from a separate source file into a copy of the minimized highlight.js integrated with mdbook. This place of the injection is currently managed by the /*GENERATE...*/ ... /*ETARENEG*/
comments in theme/book.js
and an awk-script that is invoked from a Makefile.
The idea for this issue is now the following: Some people might extend files like theme/book.js
ortheme/highlight.js
, as in my case, so this could also be solved by providing the possibility of inserting the original source code of the theme file by some kind of "super call" and add further stuff before or below.
Therefore, I could also resolve my problem by defining the theme/highlight.js
file in my book like this, in case mdbook provides some kind of "super-call" for the theme file:
console.log("Defining default hljs");
<<<mdbook-super>>>
console.log("Now I can do further stuff, like defining my language");
The <<<mdbook-super>>>
(or any other, special identifier) will be replaced by the mdbook default template code.
What do you think? Stupid, or worth a pull request?