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

This question already has an answer here:

When I manually specify the language of a code block as VB.NET like this:

<!-- language: vbnet -->

    theNodeList.Cast(Of XmlNode)()
theNodeList.Cast(Of XmlNode)()

the code is not highlighted. But this variation works:

<!-- language: lang-vbnet -->

    theNodeList.Cast(Of XmlNode)()
theNodeList.Cast(Of XmlNode)()

I get the same results for both versions when I replace vbnet with vb.net:

<!-- language: vb.net -->

    theNodeList.Cast(Of XmlNode)()
theNodeList.Cast(Of XmlNode)()
<!-- language: lang-vb.net -->

    theNodeList.Cast(Of XmlNode)()
theNodeList.Cast(Of XmlNode)()

In the first version, the language is specified through the tag. In the second version, it's specified through the syntax highlighting parser name. The problem is that the tag isn't automatically setting the correct parser for (unlike most other language tags). This old comment indicates that a diamond moderator has the power to fix this. Or perhaps the parser is correctly set for the tag, but there's a bug in Stack Overflow with tags with periods in their names.

The tags on a question shouldn't affect whether this problem appears, since the comment should override all tags. That makes this question different from VB.NET code highlighting problem resurging, where there were multiple tags on a question, and a code block with no comment was being assigned the wrong default language.

share|improve this question

marked as duplicate by Shog9 Aug 16 '13 at 15:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The funny thing is that big PHP frameworks (like Symfony or cakePHP) links to PHP and vbnet, the language tag, does not even link to vbnet xD –  Hugo Dozois May 14 '13 at 5:39
According to the source code of prettify, we only have vb and vbs, no vbnet –  Johannes Kuhn May 14 '13 at 8:18
@JohannesKuhn Ah. I tried vbnet because that's Vim's name for its VB.NET syntax highlighter, and then I saw it seem to work. But it looks like even lang-vbfoo highlights as Visual Basic - the suffix is ignored. Still, using the vb highlighter for vb.net is better than no highlighting at all. –  Rory O'Kane May 14 '13 at 16:14
FWIW, highlighting is correctly configured for vb.net. If there are multiple language tags, you'll need to set the highlight explicitly, which is described here: meta.stackexchange.com/questions/63800/… –  Shog9 Aug 16 '13 at 15:03
@Shog9 I don’t see how highlighting is correctly configured. If I create a new question with the vb.net tag and paste some code like Call MyFun into it, the code is not highlighted at all. The code should be highlighted using the vb highlighter, which is the closest approximation for vb.net we have, and better than nothing. You can see that the code looks better when you manually add <!-- language: lang-vb --> – but you shouldn’t have to manually add that; the vb.net tag should do that for you. –  Rory O'Kane Aug 16 '13 at 15:12
Can you give me an example of it not working, @Rory? Looks right here. –  Shog9 Aug 16 '13 at 15:15
@Shog9 It looks like I was confusing the unknown-language highlighting with the lang-vb highlighting. In the question above, with the (nonexistent) lang-vb.net parser, Cast and Of XmlNode are colored blue; I assumed that was how they were supposed to be highlighted. But now I see that with the lang-vb parser, they are not highlighted; instead, keywords like Call are highlighted in dark blue. So vb.net does have highlighting, it just doesn’t highlight things I thought it would. –  Rory O'Kane Aug 16 '13 at 15:28
add comment

1 Answer

The reason for this behavior is simple: if it starts with lang- then it uses that language.

Otherwise it uses the assigned highlighting for THAT tag.


  • vbnet tries to use the highlighting of the tag (which does not exist)
  • lang-vbnet uses the vbnet highlighting. For the list of aviable langs see here
  • vb.net uses the highlighting of which was assigned to vbnet. (I hope. If not, request it here on meta as .)

Not a bug IMHO.

share|improve this answer
Also note that the tag based selection does not work if there are incompatible tags like sql and vb.net. –  Johannes Kuhn May 13 '13 at 21:04
The vb.net tag is missing its assignation to lang-vbnet. <!-- language: vb.net --> doesn't work. That's what I meant by "I get the same results for both versions when I replace vbnet with vb.net." So there is a problem here. Maybe "bug" is the wrong term for this type of problem, but the vb.net tag is missing its link to the lang-vbnet parser. –  Rory O'Kane May 13 '13 at 21:09
Ok, this is a different thing. Maybe feature-request would be better than bug? –  Johannes Kuhn May 13 '13 at 21:10
Okay, I changed the tag to feature-request. –  Rory O'Kane May 13 '13 at 21:14
add comment

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