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.

10
  • 5
    Honestly, I'd recommend simply adding the language any time you consciously think about it. If you use the code fence syntax (my personal preference) you can easily set the language. That being said, give it a shot! I have a sibling post on Meta Stack Overflow that explains how autohighlighting is changed (at 5000 ft anyways).
    – Ben Kelly StaffMod
    Commented Sep 9, 2020 at 14:33
  • @BenKelly you think it's OK to force us to manually set the lang on each of 10 code snippets in a question, say? even then, it's erratic, works for some snippets, doesn't work for others. examples here.
    – Will Ness
    Commented Sep 26, 2020 at 17:01
  • This was marked as bash, @BenKelly, but Prettify didn't pick it up. I'll try to find the post again now, and edit it. Can't remember where it was.
    – TRiG
    Commented Sep 26, 2020 at 20:08
  • Yup. It works. stackoverflow.com/a/6482403/209139
    – TRiG
    Commented Sep 26, 2020 at 20:11
  • @WillNess I think right now there is some confusion about which languages SO actually supports (with the new Highlight.js support). You can find a complete list on the post where they talk about how highlighting works. meta.stackexchange.com/questions/184108/… If a language isn't listed there no amount of proper tagging it will help. Some people are confused because Highlight.js supports a particular language but SO do not. Commented Oct 20, 2020 at 1:38
  • @JoshGoebel in e.g. pastebin.com it just works. in SO, it doesn't. I'll let the paid stuff worry about the rest. :)
    – Will Ness
    Commented Oct 20, 2020 at 6:06
  • @WillNess Single purpose sites are always simpler. :-) If SO fixes their core implementation a bit and then people pitch in to report remaining issues I imagine things can improve greatly. I don't think going back to Prettify is an option, so unless they want to switch to something else or roll their own the best outcome for all is to improve Highlight.js and fix any obvious bugs. :-) Are you super familiar with Prettify? When I took a look (at the original code) it just looked to be a very simple pattern matcher/highlighter... is that all there is to it? Commented Oct 20, 2020 at 18:20
  • @JoshGoebel pastebin supports lots of languages too; how good, I have no idea. but e.g. Haskell looks super nice there. SO could just use what they are using, and if that's in-house, just buy the thing. no, I know absolutely nothing about implementing this thing. (on a completely tangential note, what are the chances for someone (me) to see a new, somewhat unusual/remarkable surname for the first time in their life, twice in one day! I do mean yours and someone from 1980s named Randy Goebel whom I saw mentioned today in connection with "Waterloo Prolog".... what are the chances!!? :) )
    – Will Ness
    Commented Oct 20, 2020 at 18:57
  • (.... by pure chance, I mean). what a coincidence, huh!?
    – Will Ness
    Commented Oct 20, 2020 at 19:12
  • @WillNess pastebin.com is server-side looks like... I imagine it was very important for SO to let the clients do the heavy work of highlighting vs doing it on their own servers... and for simple (small footprint) JS based highlighting the two big players I know of are Highlight.js and Prism. I assume they would have also considered Prism, though I'd be curious to know what led them to choose us over Prism. (we do try and be a bit more ambitious than Prism in our highlighting) Commented Oct 20, 2020 at 19:33