Skip to content

Groovy code highlighting does not take effect #2498

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

Open
zhang13690 opened this issue Nov 28, 2024 · 3 comments
Open

Groovy code highlighting does not take effect #2498

zhang13690 opened this issue Nov 28, 2024 · 3 comments
Labels
C-bug Category: A bug, incorrect or unintended behavior

Comments

@zhang13690
Copy link

Problem

When I used the markdown syntax of “```groovy ... ```“ to put in Groovy code, I found that the code was not highlighted during preview. Other programming languages don't seem to have this problem. May I ask why?

Steps

No response

Possible Solution(s)

It may be related to highlight.js, but when I tried using the official file of this js separately, I found that there was no problem with highlighting in Groovy.

Notes

No response

Version

mdbook v0.4.43
@zhang13690 zhang13690 added the C-bug Category: A bug, incorrect or unintended behavior label Nov 28, 2024
@slightlybelowzen
Copy link

There's only a certain subset of languages it supports out of the box, https://rust-lang.github.io/mdBook/format/theme/syntax-highlighting.html#supported-languages.

You'd have to add your own highlight.js file for groovy to work.

@szabgab
Copy link
Contributor

szabgab commented Feb 27, 2025

Following up on @slightlybelowzen , the built-in highlighting is implemented in src/theme/highlight.js which is an old copy from https://highlightjs.org

As I understand you could download a new version of highlight.js that includes Groovy from there and use that or you could go to the longer route and send a PR to upgrade the highlight.js in mdbook including all the currently supported languages. Thought first you might want to verify that the core developers are even interested in such an upgrade.

Going over all the issues mentioning highlight, it seems people are suggesting switching from highlight.js to other tools.

@szabgab
Copy link
Contributor

szabgab commented Mar 1, 2025

A solution:

  • Go to https://highlightjs.org/
  • Check the languages for which you'd like to have support in your book.
  • Click on download
  • Wait for some 10 seconds till the download starts and save the highlight.zip file
  • unizp it in some empty folder
  • move the highlight.min.js file to src/highlight.js in your book
  • make sure you mark your code snippets with groovy (as you do above)

I applied this to my Groovy Maven that was just extracted from my old site that used a home-grown system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: A bug, incorrect or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants