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

This question already has an answer here:

(Descriptions are inside the code samples)

Take a look at this code

Public Sub Show()
    System.Console.WriteLine("Hello")   ' Comment here will fail subsequencing syntax highlighting
    System.Console.WriteLine("This should not be rendered as a comment")
End Sub

Compare to this one

Public Sub Show()
    System.Console.WriteLine("Hello")   ' Ending quote solve the problem for now --> '
    System.Console.WriteLine("This is not rendered as a comment")
    System.Console.WriteLine("Ending quote solve the problem for now")
End Sub
share|improve this question

marked as duplicate by ben is uǝq backwards, hims056, Martijn Pieters, Aziz Shaikh, animuson Oct 5 '13 at 16:18

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.

    
feature request related to this meta.stackexchange.com/questions/4813 –  Timothy Carter Jul 18 '09 at 5:29
    
Unless the issue is to be resolved very soon. Some body should tag #4813 with VB.NET –  Sake Jul 18 '09 at 5:49
    
This is also relevant for vbscript –  Motti Jul 23 '10 at 11:24

3 Answers 3

Until a better solution is found, there are twothree work-arounds:

The correct way to do this now is with a language hint above the code sample, like so:

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

    Public Sub VisualBasicCodeHere()
       'This will be highlighted correctly when used in a real post
    End Sub

Before the language hints were available, you had to use one of the following work-arounds:

  • Put two apostrophes followed by a hash (#) at the front of the comment. This works just like the // method below, but it saves one character and the result look less like a bastardized attempt at C#.

    ''# You're commenting!
    Dim c As New Comment()
    
  • Put an extra apostrophe at the end, plus add more if needed to account for appostrophes in the comment text itself. It's nice because the comment stands out consistently, but not as nice because the comment is still colored like a string literal and you need to watch for the extra apostrophes.

    'You''re commenting!'
    Dim c As New Comment()
    
  • Put two apostrophes followed by two forward slashes at the front of the comment. It's nice because you don't have to worry about extra apostrophes in the comment and because the comment is colored correctly, but bad because it adds a bunch of extra junk to the front that's harder to clean out.

    ''// You're commenting!
    Dim c As New Comment()
    

A lot of old, and even some new, posts still have these tricks to try to get the highlighting right, so it's worth keeping the list around, but anything new you see and any time you edit, the language hint is the way to go.

share|improve this answer
    
+1 for sharing these workarounds, especially the {''#} method –  Dubs May 18 '10 at 15:48

Based on Google Prettify

http://code.google.com/p/google-code-prettify/

I believe there's a suggestion out there somewhere to support the optional language-specific packs that can be used with prettify (essentially overriding the default detection method)

We just deployed the latest trunk of prettify.js ; revision 83

http://code.google.com/p/google-code-prettify/source/browse/trunk/src/prettify.js

share|improve this answer
3  
Yes, support the optional language-specific packs! The guess-method doesn't work. –  Svante Oct 20 '09 at 20:16
1  
Adding the language packs doesn't override the default detection method, it just gives it more options to choose from. –  Herb Caudill Dec 19 '09 at 12:25

Possible solution: Since most questions are tagged for a specific language. Isn't it possible to use those tags as a hint for the highlighter? In most cases this will suffice.

In some cases there may be some trouble like tags 'mysql' and 'php' on one question, or "Please help me translate this language 'X' code into language 'Y'". But even then, the highlighter should be smart enough to find out which of those two or three languages it is.

I found this question not because of VB, but because of Delphi, which has similar problems and is also always highlighted wrong, especially since it uses { } for block comments. :)

share|improve this answer
    
That already happens. If the language hint for a given tag is missing or incorrect, that can be addressed by requesting it here on Meta. I'm unfamiliar with what support Prettify has for Delphi, though. –  Tim Stone Jan 11 '12 at 22:26

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