Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

8
  • 2
    Thank you so much. I can see that ```lang-groovy is now working, but not ```groovy. Actually in the past few years I was amazed at how good this worked and even for short and ambiguous snippets did not mess up highlighting due to auto-detection. Ben, ist there any chance to get Groovy supported officially? This was my very first question on Meta, I would not know how to go about making a feature request but also would not be surprised if someone already created one long before me. Would it be a big effort to support it, given the fact that highlight.js already does (as did Prettify)?
    – kriegaex
    Commented Sep 26, 2020 at 2:51
  • Another thought: Auto-detection might work for Groovy because the highlighter detects Java. But there are some syntactic differences, so dedicated Groovy support would be helpful for the big Groovy community on SO.
    – kriegaex
    Commented Sep 26, 2020 at 3:04
  • 3
    Just FYI: our Groovy grammar currently weighs in at 3387 bytes uncompressed if SO chose to add it. Pretty small. Commented Oct 17, 2020 at 21:23
  • After watching this for a while, I noticed that highlight.js seems to guess wrong about which language to highlight more often than Prettify, especially for short code snippets. So for now I manually select Java as the target language, which is kind of suboptimal, like I said. It also means that snippets using java instead of lang-groovy will not automatically be highlighted correctly after maybe in the future Groovy will be supported officially. These facts make it even more plausible to add Groovy support for SO syntax highlighting. Spock, Geb and Grails are quite popular tools.
    – kriegaex
    Commented Oct 20, 2020 at 2:04
  • 2
    @kriegaex what SO needs to do if Java is a decent fit is just map groovy to Java. Highlight.js makes this trivial to do with aliases. This is also future proof in that if stack overflow adds groovy highlighting in the future then they can just change the mapping and the new highlighting will happen. Letting auto detect randomly pick a language every time when it’s known the language is missing is going to result in terrible and very inconsistent highlighting. This is very bad behavior. Commented Oct 21, 2020 at 5:24
  • 1
    Sorry, no. Java and Groovy syntaxes are not the same. Java is just a crutch, workaround. The alias would be better than nothing temporarily, but there is quite some Groovy stuff that is not highlighted correctly in Java mode. If someone invests effort and time here, I guess it should be done right. Also, whenever Groovy highlighting gets fixes, updates or improvements, SO users would automatically profit from it.
    – kriegaex
    Commented Oct 21, 2020 at 5:30
  • 1
    Follow-up suggestion: Stop guessing/auto-detecting a language when you KNOW it will be incorrect
    – tripleee
    Commented Feb 15, 2021 at 5:49
  • Would it perhaps make sense to load the Groovy highlighter e.g. for users who are subscribed to the groovy tag? I'm guessing those are probably more or less the only ones who are going to care passionately about highlighting for this language.
    – tripleee
    Commented Feb 15, 2021 at 5:57