4

Possible Duplicate:
Interface options for specifying language prettify

It seems that questions tagged both C# and VB.NET have C# syntax highlighting applied (possibly because it is first alphabetically?) but people can post code answers in either language.

Therefore any VB.NET answers seem to receive horrible syntax highlighting.

Is there some way to force an answer (or even the question) to use a specific highlighting?

EDIT:

An answer has been provided which details how this can be achieved, but shouldn't this be a bit simpler? Could we have a new button next to the code button that allows selection of a language syntax to override the tag hinted one?

Or as @jonathan pointed out when there is more than one language tag hinted just let prettify work it out i.e. Don't use a hint at all?

0

1 Answer 1

8

Yes, this is possible.

Insert <!-- language: lang-or-tag-here --> before code blocks, specifying the language where indicated.

Most the people don't use this only because they just don't know about it.

9
  • Thanks for the answer this seems to work but is a) not obvious and b) a little clunky to be doing all the time - shouldn't we have a better way of doing this?
    – Matt Wilko
    Apr 19, 2012 at 16:39
  • @Matt Definitely should, but I don't know how to make system both more concise and flexible than now. If you know, and sure that this will work make a feature-request, please.
    – om-nom-nom
    Apr 19, 2012 at 16:45
  • I swear some code highlighting systems can detect automatically based only on the code itself, and not with any tags. I'm surprised the SE one uses the tags at all
    – Jonathan.
    Apr 19, 2012 at 17:20
  • @Jonathan. I don't believe you basing only on promises :) Imagine how many languages are here, on stackoverflow, and how closely they intersect in keywords. Such systems could probably work well with large listings, but I think they will fail on small ones. Moreover, it would be odd if the system will highlight the same word in one text, and will not highlight in other. With tag based system we have predictable highlighting. Correct me if I wrong. And please, post some links.
    – om-nom-nom
    Apr 19, 2012 at 17:28
  • 1
    @om-nom-nom, my point was meant to be that if a question was tagged in multiple languages, you could use such a system (that already exists) to actually determine the language (out of the tags) rather than just use the first alphabetically.
    – Jonathan.
    Apr 19, 2012 at 17:30
  • @Jonathan. oh, if so, I do agree with you
    – om-nom-nom
    Apr 19, 2012 at 17:31
  • @om-nom-nom, and here is the highlighter I was referring to (I was under the assumption it was the one being used by SE atm).
    – Jonathan.
    Apr 19, 2012 at 17:32
  • @Jonathan. I believe this is the syntax highlighter being used by SO, but it uses code hints based on the tags see this meta 'question' and when there are multiple tags on a question (I assume) it using the first one alphabetically whereas it should not use the hint in this case and let prettify work it out?
    – Matt Wilko
    Apr 20, 2012 at 7:52
  • @matt precisely what it should do.
    – Jonathan.
    Apr 20, 2012 at 9:22

Not the answer you're looking for? Browse other questions tagged .