6

Possible Duplicate:
VB.NET Syntax Highligting does not properly support comment.

When you try to put a code you put it into a code tag, but some programming languages have problems with this, like when you put a ', that represents a comment in Visual Basic language the code that put all the the other code highlighted as a comment and ends when you put one more ' like you can see here:

'Here is a String declaration
Dim test As String
'Here ends a String declaration

Please put something that you have to specify what is the programming language that is in the code tag, to improve the visual element. Thanks.

5
  • 9
    The highlighting is meant to drive people to use the languages it supports better. It is a subliminal form of mind control.
    – jjnguy
    Commented Jul 13, 2009 at 18:07
  • The stackoverflow team didn't write the coloring code btw. It is google's I believe. Pretify is the name I believe.
    – jjnguy
    Commented Jul 13, 2009 at 18:11
  • code.google.com/p/google-code-prettify
    – jjnguy
    Commented Jul 13, 2009 at 18:11
  • See my post here: meta.stackexchange.com/questions/4813/… Commented Jul 13, 2009 at 18:15
  • 5
    The code highlighter doesn't support languages that suck. Now you're asking yourself, who decides what languages suck? Why, the code highlighter, of course. Commented Jul 13, 2009 at 18:24

6 Answers 6

5

One thing Stack Overflow could do is have a mechanism to easily suggest what language you're using in the code, for instance:

#!python

def foo():
    return 10 // 7

print(foo())
#!html
<a href="http://www.python.org/">Python!</a>

This is the approach taken by Trac, and it works quite well.

4

I agree, the code highlighting seems very good for C#, but for VB and others it is quite poor, if not unhelpful. I would love to see this improved.

3

Hello, If it's in Google Code the project of the code highlighting, here is the code highlighting project that i use in my site and it support's the language selection feature, but remember that is a project written in JavaScript. SyntaxHighlighter

7
  • Why the down vote?????? Commented Jul 13, 2009 at 18:22
  • The whole Q&A is spam.
    – GEOCHET
    Commented Jul 13, 2009 at 18:43
  • 1
    The question is legitimate. This answer might be a shameless self-plug for a better syntax highlighter, but it doesn't make the problem with prettify an VB code go away; and it's not spam if SyntaxHighlighter does actually fix the problem posed in the question. Commented Jul 13, 2009 at 19:00
  • @Nathan: +1 because SyntaxHighlighter does look good, but you answer is in serious need of grammar correction. Commented Jul 13, 2009 at 19:02
  • It's because i'm improving my english! Commented Jul 13, 2009 at 19:03
  • I live in Brazil. Commented Jul 13, 2009 at 19:05
  • The syntax highlighter used by SO can support VB syntax. However, it's not built in to the base highlighter, and SO doesn't include the plugin to enable this. SyntaxHighlighter uses plugin "brushes" for every language. So, no advantage - either way, SO needs to decide which languages it'll support and include the necessary plugins. You'd be better off just pushing for the SO Team to enable VB support...
    – Shog9
    Commented Jul 15, 2009 at 0:03
1

I would like to point out that it almost never highlights Perl code correctly.

These all do the same thing, but aren't highlighted the same:

die if //;  # Perl doesn't even have // for comments
die if m''; # the only one, that is even close, to being right
die if m();
die if m::;

Now I know that part of the problem is that Perl is a very difficult to parse language.

That's why I think we should be able to highlight the code manually.

<pre class="prettyprint"><code>
...
<span class="kwd">die</span>
<span class="pln"> </span>
<span class="kwd">if</span>
<span class="pln"> m</span><span class="str">''</span><span class="pun">;</span>
...
</code></pre>

<pre class="prettyprint-correct-perl"><code>
...
<span class="kwd">die</span>
<span class="pln"> </span>
<span class="kwd">if</span>
<!--                      /--higlight m'' together---\   -->
<span class="pln"> </span><span class="str">m''</span><span class="pun">;</span>
...
</code></pre>

Even editors that are designed for highlighting Perl code, can sometimes get it wrong.

2
  • Ugh, who's going to type all that out?
    – John Fouhy
    Commented Aug 24, 2009 at 3:31
  • I would write a program to do it, for my languages of choice. Commented Aug 24, 2009 at 3:58
1

See my answer to the related question here:
VB.NET/VBScript syntax highlighting does not properly support comments

In summary, you can do this as workaround for now:

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

This has pretty much been asked before in other posts where people are requesting more language-specific highlighting features (and the ability to select what language you want).

It can definitely be frustrating when doing VB and trying to put comments, so I end up usually marking up my code with c# comments, even though that won't be very good for anyone doing a full copy/paste job on my content.

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