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 vb.net 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.
1 Answer 1
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.
So:
vbnet
tries to use the highlighting of the tag vbnet (which does not exist)lang-vbnet
uses the vbnet highlighting. For the list of aviable langs see herevb.net
uses the highlighting of vb.net which was assigned to vbnet. (I hope. If not, request it here on meta as feature-request.)
Not a bug IMHO.
-
Also note that the tag based selection does not work if there are incompatible tags like sql and vb.net.Johannes Kuhn– Johannes Kuhn2013年05月13日 21:04:56 +00:00Commented May 13, 2013 at 21:04
-
2The
vb.net
tag is missing its assignation tolang-vbnet
.<!-- language: vb.net -->
doesn't work. That's what I meant by "I get the same results for both versions when I replacevbnet
withvb.net
." So there is a problem here. Maybe "bug" is the wrong term for this type of problem, but thevb.net
tag is missing its link to thelang-vbnet
parser.Rory O'Kane– Rory O'Kane2013年05月13日 21:09:11 +00:00Commented May 13, 2013 at 21:09 -
Ok, this is a different thing. Maybe feature-request would be better than bug?Johannes Kuhn– Johannes Kuhn2013年05月13日 21:10:38 +00:00Commented May 13, 2013 at 21:10
-
Okay, I changed the tag to feature-request.Rory O'Kane– Rory O'Kane2013年05月13日 21:14:44 +00:00Commented May 13, 2013 at 21:14
Explore related questions
See similar questions with these tags.
vb
andvbs
, novbnet
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 evenlang-vbfoo
highlights as Visual Basic - the suffix is ignored. Still, using thevb
highlighter for vb.net is better than no highlighting at all.Call MyFun
into it, the code is not highlighted at all. The code should be highlighted using thevb
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.lang-vb
highlighting. In the question above, with the (nonexistent)lang-vb.net
parser,Cast
andOf XmlNode
are colored blue; I assumed that was how they were supposed to be highlighted. But now I see that with thelang-vb
parser, they are not highlighted; instead, keywords likeCall
are highlighted in dark blue. So vb.net does have highlighting, it just doesn’t highlight things I thought it would.