This is a follow-up to a question I answered earlier (Changes to syntax highlighting).
For most questions that have more than one language-related tag and those with fuzzy languages (for instance .net!), there should be an option to specify which language to use in syntax highlighting because sometimes (and quite often too!) the language inference is wrong.
Take for instance the scenario I describe below.
When an answer is given in a language other than the "primary language" (which happens to be C#), the code is still highlighted as C# even if it isn't in that language!
Scenario
- Take any question that has multiple explicit language-related tags.
For example: Webclient.UploadFile which is tagged tagged c#, .net, vb.net and webclient. - Try to answer the question with code that is different from the 'major' language.
In this case, try answering the question with VB.NET code.
Expected Results: Code should be highlighted in VB.NET.
Actual Result: Code was highlighted in C#!
Suggested Solution
There should be a way to explicitly set the language for syntax highlighting.
Edit
It also turns out that asking a question with multiple explicit language-related tags can also give you wrong syntax highlighting!
You can try creating a new question with the following and observe the preview:
//This is C# var someValue = GetValue(); some text to separate the two languages 'This is VB.Net Dim someValue = GetValue()
Tag the question as follows (in the specific order) vb.net, .net c#
You'll notice without fail that the C# code gets highlighted properly and the vb.net code doesn't.
Disclaimer
All observations are based on the preview you get while entering the question or answer so my observed result might not be wholly right.
'This is VB.Net
) does not terminate its opening quotation mark.#!css
or#!vb
in a code block. It's just a detail, but I guess ideas of how specifying might work might better be posted there.