What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

If for example you add a tag to a question that previously only was tagged with all the C# code will no longer be highlighted properly. This is not quite ideal.

Using <!-- language: c# --> this can be fixed of course but you normally don't know that a question which you answered had its tags changed.

I doubt that there is a good solution to this, maybe i'll just preface every code block with the respective language identifying comment.


So just to clarify, in a question with only the tag respective C# and XAML code blocks get highlighted correctly.

If either or is added everything will be interpreted as the respective language.

If the question is tagged with it highlights as expected again.

share|improve this question
    
Is the syntax highlighting based on the last tag added? If so, a workaround might be to delete the C# tag and re-add it. Admittedly this is a huge kludge. Thanks for pointing out the comment override; didn't know about that. –  Robert Harvey Jun 3 '11 at 18:33
    
I wouldn't know about the precedence (be it order or whatever). Also there was no c# tag begin with, possibly wpf is associated with both C# and XML highlighting. –  H.B. Jun 3 '11 at 18:35
1  
The C# or VB.NET tag should always be included on such a question anyway, unless it's a pure xaml question. –  Robert Harvey Jun 3 '11 at 18:37
    
If the c# tag is added the XAML highlighting breaks :P (if there is no xaml tag) –  H.B. Jun 3 '11 at 18:40
    
I don't know that I've actually seen this problem; I've seen questions with C# and Xaml in them at the same time, and they looked OK to me. For example, this one‌​. But maybe that's because it has both tags. –  Robert Harvey Jun 3 '11 at 18:41
    
Confirmed. If you remove the xaml tag from a question with mixed code, it breaks the xaml formatting. But I think the answer is to add tags for all of the different code types that are present in the post. –  Robert Harvey Jun 3 '11 at 18:47
    
Well, who exactly does that? Further you then only have two tags left to be any more specific about the question's topic. –  H.B. Jun 3 '11 at 18:48
    
Anyone with sufficient rep can fix the tag, or use a code comment override. If someone doesn't have sufficient rep, they can flag a mod, and the mod will do it. Given that the code comment exists, I think there's enough flexibility here for all conceivable situations. –  Robert Harvey Jun 3 '11 at 18:50

2 Answers 2

If for example you add a xaml tag to a question that previously only was tagged with wpf all the C# code will no longer be highlighted properly.

If you're mixing two very different types of code, you should include a tag for each language, prefix code blocks with the appropriate comments, or both.

That's the trade-off. When two languages often appear together and are properly auto-detected by the highlighting script (for instance, html and javascript), we can leave them both set to default and it'll work with only one of the tags. But VB.NET isn't detected, so we can't do that, or we'd screw up the combo.

share|improve this answer

I think this problem is somewhat peculiar to the tag and is perhaps best solved by changing the language hint for that tag from:

[wpf] = default

to:

[wpf] = lang-xml

Then, according to these rules:

the XML language hint will occur by default but if is combined with or the language selection will switch to automatic.

This approach saves one entire tag (out of a maximum of five).

share|improve this answer
1  
If you do this, then combining [wpf] and [vb.net] will probably break syntax highlighting for the vb.net code (note that combining [vb.net] and [xaml] or [xml] will already do this, but that's the trade-off you have to make when you're working with multiple languages - WPF isn't a language and shouldn't imply xaml) –  Shog9 Jun 3 '11 at 19:42

You must log in to answer this question.

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