5

The VB.NET syntax highlighting appears to be broken. See this question: https://stackoverflow.com/questions/33936054/no-console-output-from-memorystream-of-serialized-xml. When language is auto-detected the ' used for the comments seems to start a string (that then does not end correctly) rather than a comment.

If language is specified using the hint <!-- language: lang-vb --> then only things in <> are highlighted (as stings) and nothing else

1
  • 1
    Typing '' (two quotes) is a simple workaround for single-line comments. Commented Nov 26, 2015 at 13:04

1 Answer 1

9

There is nothing broken.

There are multiple tags on that question. One of them is which has off-course the lang-xml language hint. As that tag is waaaaay more popular than VB.NET it comes first. And with that it picks that prettify hint.

To force VB.NET highlighting add the explicit language hint <!-- language: lang-vb --> before the appropriate code-block .

Remember that the hint needs to be on a single line with a blank line above and below it:

lorum ipsum

<!-- language: lang-vb -->

Public Sub VBRocks()
   Print "Rocking" ' this highlighting works
End Sub

or use it with code fences:

```vb
Public Sub VBRocks()
   Print "Rocking" ' this highlighting works
End Sub
```

Do note that the preview of the post can be off in corner cases.


Here is the result in action:

Public Sub VBRocks()
   Print "Rocking" ' this highlighting works
End Sub

code fences:

Public Sub VBRocks()
   Print "Rocking" ' this highlighting works
End Sub
6
  • As I mentioned in my question, I have tried adding the lang-vb, but that seems to remove nearly all the highlighting, except the lines <DataContract()> and <Datamember()> which use the same colouring as the strings. It seems then that what is broken is that the highlighter is preferring the tag language over the language hint. Which makes language hints pretty useless really.
    – Toby
    Commented Nov 26, 2015 at 11:18
  • I see that you've edited the question to add the 'lang-vb' again, and it has worked. However, immediately before the edit showed, I was doing the exact same thing but with the results described in my above comment... :\
    – Toby
    Commented Nov 26, 2015 at 11:21
  • Hmm maybe I did indeed miss the extra new line below the hint. Muchos gracias!
    – Toby
    Commented Nov 26, 2015 at 11:23
  • reading this answer now in 2020, it seems that there is no longer any syntax highlighting for VB.NET? Commented Jun 25, 2020 at 19:34
  • @JohnRDOrazio works for me here on MSO.
    – rene
    Commented Jun 25, 2020 at 19:36
  • 1
    @rene oh ok I see that there wasn't an actual example in action, just an explanation of how. Now that you added the example in action I can see it, thanks Commented Jun 25, 2020 at 19:42

You must log in to answer this question.

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