<p>Visual Basic code does not render correctly with <a href="https://code.google.com/archive/p/google-code-prettify" rel="nofollow noreferrer">prettify.js</a> from Google.</p>
<p>on Stack Overflow:</p>
<pre><code>Partial Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'set page title
        Page.Title = &quot;Something&quot;
    End Sub

End Class
</code></pre>
<p>in Visual Studio...</p>
<p><img src="https://i.stack.imgur.com/Fl1CM.jpg" alt="Visual Basic in Visual Studio" /></p>
<p>I found this in the <a href="https://web.archive.org/web/20160428230325/http://google-code-prettify.googlecode.com:80/svn/trunk/README.html" rel="nofollow noreferrer">README</a> document:</p>
<blockquote>
<p>How do I specify which language my
code is in?</p>
<p>You don't need to specify the language
since prettyprint() will guess. You
can specify a language by specifying
the language extension along with the
prettyprint class like so:</p>
<pre><code>&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
  The lang-* class specifies the language file extensions.
  Supported file extensions include
    &quot;c&quot;, &quot;cc&quot;, &quot;cpp&quot;, &quot;cs&quot;, &quot;cyc&quot;, &quot;java&quot;, &quot;bsh&quot;, &quot;csh&quot;, &quot;sh&quot;,
    &quot;cv&quot;, &quot;py&quot;, &quot;perl&quot;, &quot;pl&quot;, &quot;pm&quot;, &quot;rb&quot;, &quot;js&quot;,
    &quot;html&quot;, &quot;html&quot;, &quot;xhtml&quot;, &quot;xml&quot;, &quot;xsl&quot;.
&lt;/pre&gt;
</code></pre>
</blockquote>
<p>I see no <em>lang-vb</em> or <em>lang-basic</em> option.  Does anyone know if one exists as an add-in?</p>
<hr />
<p>Note: This is related to the <a href="https://web.archive.org/web/20080914043525/http://stackoverflow.uservoice.com:80/pages/general/suggestions/18775" rel="nofollow noreferrer">VB.NET code blocks</a> suggestion for Stack Overflow.</p>

[{'answer_id': 31860, 'author': 'Konrad Rudolph', 'author_id': 1968, 'author_profile': 'https://Stackoverflow.com/users/1968', 'pm_score': 4, 'selected': True, 'text': '<p>/EDIT: I\'ve rewritten the whole posting.</p>\n\n<p>Below is a pretty complete solution to the VB highlighting problem. If SO has got nothing better, <em>please</em> use it. VB syntax highlighting is definitely wanted.</p>\n\n<p>I\'ve also added a code example with some complex code literals that gets highlighted correctly. However, I haven\'t even tried to get XLinq right. Might still work, though. The <a href="http://msdn.microsoft.com/en-us/library/ksh7h19t.aspx" rel="nofollow noreferrer">keywords list</a> is taken from the MSDN. Contextual keywords are not included. Did you know the <code>GetXmlNamespace</code> operator?</p>\n\n<p>The algorithm knows literal type characters. It should also be able to handle identifier type characters but I haven\'t tested these. Note that the code works on <strong>HTML</strong>. As a consequence, &amp;, &lt; and &gt; are required to be read as named (!) entities, not single characters.</p>\n\n<p>Sorry for the long regex.</p>\n\n<pre><code>var highlightVB = function(code) {\n    var regex = /("(?:""|[^"])+"c?)|(\'.*$)|#.+?#|(&amp;amp;[HO])?\\d+(\\.\\d*)?(e[+-]?\\d+)?U?([SILDFR%@!#]|&amp;amp;)?|\\.\\d+[FR!#]?|\\s+|\\w+|&amp;amp;|&amp;lt;|&amp;gt;|([-+*/\\\\^$@!#%&amp;&lt;&gt;()\\[\\]{}.,:=]+)/gi;\n\n    var lines = code.split("\\n");\n    for (var i = 0; i &lt; lines.length; i++) {\n        var line = lines[i];\n\n        var tokens;\n        var result = "";\n\n        while (tokens = regex.exec(line)) {\n            var tok = getToken(tokens);\n            switch (tok.charAt(0)) {\n                case \'"\':\n                    if (tok.charAt(tok.length - 1) == "c")\n                        result += span("char", tok);\n                    else\n                        result += span("string", tok);\n                    break;\n                case "\'":\n                    result += span("comment", tok);\n                    break;\n                case \'#\':\n                    result += span("date", tok);\n                    break;\n                default:\n                    var c1 = tok.charAt(0);\n\n                    if (isDigit(c1) ||\n                        tok.length &gt; 1 &amp;&amp; c1 == \'.\' &amp;&amp; isDigit(tok.charAt(1)) ||\n                        tok.length &gt; 5 &amp;&amp; (tok.indexOf("&amp;amp;") == 0 &amp;&amp;\n                        tok.charAt(5) == \'H\' || tok.charAt(5) == \'O\')\n                    )\n                        result += span("number", tok);\n                    else if (isKeyword(tok))\n                        result += span("keyword", tok);\n                    else\n                        result += tok;\n                    break;\n            }\n        }\n\n        lines[i] = result;\n    }\n\n    return lines.join("\\n");\n}\n\nvar keywords = [\n    "addhandler", "addressof", "alias", "and", "andalso", "as", "boolean", "byref",\n    "byte", "byval", "call", "case", "catch", "cbool", "cbyte", "cchar", "cdate",\n    "cdec", "cdbl", "char", "cint", "class", "clng", "cobj", "const", "continue",\n    "csbyte", "cshort", "csng", "cstr", "ctype", "cuint", "culng", "cushort", "date",\n    "decimal", "declare", "default", "delegate", "dim", "directcast", "do", "double",\n    "each", "else", "elseif", "end", "endif", "enum", "erase", "error", "event",\n    "exit", "false", "finally", "for", "friend", "function", "get", "gettype",\n    "getxmlnamespace", "global", "gosub", "goto", "handles", "if", "if",\n    "implements", "imports", "in", "inherits", "integer", "interface", "is", "isnot",\n    "let", "lib", "like", "long", "loop", "me", "mod", "module", "mustinherit",\n    "mustoverride", "mybase", "myclass", "namespace", "narrowing", "new", "next",\n    "not", "nothing", "notinheritable", "notoverridable", "object", "of", "on",\n    "operator", "option", "optional", "or", "orelse", "overloads", "overridable",\n    "overrides", "paramarray", "partial", "private", "property", "protected",\n    "public", "raiseevent", "readonly", "redim", "rem", "removehandler", "resume",\n    "return", "sbyte", "select", "set", "shadows", "shared", "short", "single",\n    "static", "step", "stop", "string", "structure", "sub", "synclock", "then",\n    "throw", "to", "true", "try", "trycast", "typeof", "variant", "wend", "uinteger",\n    "ulong", "ushort", "using", "when", "while", "widening", "with", "withevents",\n    "writeonly", "xor", "#const", "#else", "#elseif", "#end", "#if"\n]\n\nvar isKeyword = function(token) {\n    return keywords.indexOf(token.toLowerCase()) != -1;\n}\n\nvar isDigit = function(c) {\n    return c &gt;= \'0\' &amp;&amp; c &lt;= \'9\';\n}\n\nvar getToken = function(tokens) {\n    for (var i = 0; i &lt; tokens.length; i++)\n        if (tokens[i] != undefined)\n            return tokens[i];\n    return null;\n}\n\nvar span = function(class, text) {\n    return "&lt;span class=\\"" + class + "\\"&gt;" + text + "&lt;/span&gt;";\n}\n</code></pre>\n\n<p>Code for testing:</p>\n\n<pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load\n    \'set page title\n    Page.Title = "Something"\n    Dim r As String = "Say ""Hello"""\n    Dim i As Integer = 1234\n    Dim d As Double = 1.23\n    Dim s As Single = .123F\n    Dim l As Long = 123L\n    Dim ul As ULong = 123UL\n    Dim c As Char = "x"c\n    Dim h As Integer = &amp;amp;H0\n    Dim t As Date = #5/31/1993 1:15:30 PM#\n    Dim f As Single = 1.32e-5F\nEnd Sub\n</code></pre>\n'}, {'answer_id': 149726, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 0, 'selected': False, 'text': "<p>In the meantime, you can put an extra comment character at the end of your comments to get it to look okay.  For example:</p>\n\n<pre><code>Sub TestMethod()\n    'Method body goes here'\nEnd Sub\n</code></pre>\n\n<p>You also need to escape internal comment characters in the normal vb-fashion:</p>\n\n<pre><code>Sub TestMethod2()\n    'Here''s another comment'\nEnd Sub\n</code></pre>\n\n<p>Prettify still treats it as a string literal rather than a comment, but at least it looks okay.</p>\n\n<p>Another method I've seen is to start comments with an extra <code>'//</code>, like this:</p>\n\n<pre><code>Sub TestMethod3()\n    ''// one final comment\nEnd Sub\n</code></pre>\n\n<p>Then it's handled like a comment, but you have to deal with C-style comment markers</p>\n"}, {'answer_id': 885802, 'author': 'Mark Nold', 'author_id': 4134, 'author_profile': 'https://Stackoverflow.com/users/4134', 'pm_score': 2, 'selected': False, 'text': '<p>Prettify does support VB comments as of the 8th of January 2009.</p>\n\n<p>To get vb syntax highlighting working correctly you need three things;</p>\n\n<pre><code>&lt;script type="text/javascript" src="/External/css/prettify/prettify.js"&gt;&lt;/script&gt;\n&lt;script type="text/javascript" src="/External/css/prettify/lang-vb.js"&gt;&lt;/script&gt;\n</code></pre>\n\n<p>and a PRE block around your code eg:</p>\n\n<pre><code>&lt;PRE class="prettyprint lang-vb"&gt;\n Function SomeVB() as string\n   \' do stuff\n   i = i + 1\n End Function\n&lt;/PRE&gt;\n</code></pre>\n\n<p>Stackoverflow is missing the lang-vb.js inclusion, and the ability to specify which language via Markdown, ie: <code>class="prettyprint lang-vb"</code> which is why it doesn\'t work here.</p>\n\n<p>for details on the issue: see <a href="http://code.google.com/p/google-code-prettify/issues/detail?id=68" rel="nofollow noreferrer">the Prettify issues log</a></p>\n'}]
['https://Stackoverflow.com/questions/31097', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/83/']