-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Language Syntax Highlighting #657
Comments
cc. @Marwes - I know you're starting to use mdBook for Gluon as well. |
I tried to use highlight.js to get syntax highlighting on http://gluon-lang.org/try/ a couple of weeks ago by dynamically adding the necessary definitions. Unfortunately all the distributions of highlight.js are minified so it weren't feasible. Not sure how mdbook does it now, but to get highlighting for custom languages I think a full custom build of highlight.js may be needed. |
Yeah, I'm thinking that it might require you to use a custom fork, which is a little disappointing. Might have to include it as a submodule. 😭 |
I'm guessing this would also be a problem for LALRPOP too. |
I've actually wanted this in the past when documenting some legacy code at work, but I'm not sure how we'd actually do it. A while back we threw around the idea of using a build system for our frontend code, but decided against it (@mattico, should we revisit this?).
Looking at the highlight JS README, it seems like you can just include a link to your pre-compiled language and it should be picked up automatically.
|
Hmm, maybe if you built it with the For now I've gone with the hacky approach! See brendanzab/pikelet#21. |
It's annoying, but that |
I mean, if we really wanted to head down the rabbit hole we could always fork highlight.js and update it to modern JS 😱 |
What about using https://github.com/trishume/syntect instead? And don't force the readers to run more JS than is necessary. |
I’ve tried using a patched version of highlight.js in the past, but it’s a pain to keep it up to date. Instead I’m using a version of highlight.js sorced from npm, rather than the minified version included in mdBook. This requires stubbing out the global `hljs` object in `theme/highlight.js` to avoid any method not found exceptions coming from mdBook’s generated book.js file. Ideally there’d be an easier way to do this in mdBook itself (see rust-lang/mdBook#657).
I found a quick and dirty way. We can just reload |
@raviqqe Thank you for sharing your fix. This was the only thing I was able to find that worked for custom highlight. But since that is not mentioned in |
I'm currently using mdBook for the documentation of my Pikelet language. I want to be able to add my own, custom language to highlight.js.
What would be the best way to do this? At the moment the languages seem to be minified into the highlight.js code. Will I need to provide a custom rebuild of highlight.js instead? Would we be able to have support for custom languages in the future?
The text was updated successfully, but these errors were encountered: