PDA

View Full Version : Forum Code Syntax Coloring



ErosOlmi
08-01-2011, 03:49
I'm testing a new way of code Syntax Coloring in forum posts.

Syntax coloring is performed at client-side level (not server side) so speed is influenced by your local computer.

I'm using SyntaxHighlighter 3.0.83 (http://alexgorbatchev.com/SyntaxHighlighter/)

Currently it just support very very few of the many thinBasic keywords because first I need to test it deeply.

Syntax coloring is activated with the usual BBC CODE Tag without any other needs.
Syntax coloring is active in forum, articles, blogs, support area and I think in all other places.

Example:


'---This is a single line comment
function helloSyntaxHighlighter()
Dim MyLong as long
dim MyString as string

MyLong = 1
MyLong = not MyLong

MyString = "abcdeXXX" '---This is a comment inside a code line
End function

Copy Source code
In order to copy source code it into your editor, just double click on any part of the code and than use standard CTRL+C. Just that simple.

More info when I will advance more in understanding SyntaxHighlighter JavaScript code.

Eros

John Spikowski
08-01-2011, 07:35
I noticed the new syntax highlighting when I reviewed a ScriptBasic post I made. Is there a way to turn off syntax highlighting if the code your posting isn't thinBasic?

danbaron
08-01-2011, 08:25
I made a test below. I think already, it's much better - line numbers, too.

I see that at first it is all in black. Then, it changes to color. I guess that is what you meant.

:p


Function fillnewasciitable()
Dim track(256) As Byte
Integer i, r
For i = 1 To 256
track(i) = FALSE
Next
For i = 1 To 256
Do
r = getrandomquad(1, 256)
If track(r) = TRUE Then Iterate Do
If i = r Then
If i < 256 Then
Iterate Do
Else
newasciitable(256) = newasciitable(255)
newasciitable(255) = 256
End If
End If
track(r) = TRUE
Exit Do
Loop
newasciitable(i) = r
Next
End Function

ErosOlmi
08-01-2011, 10:57
I noticed the new syntax highlighting when I reviewed a ScriptBasic post I made. Is there a way to turn off syntax highlighting if the code your posting isn't thinBasic?

Yes, you are right.
I will check what I can do.

ErosOlmi
08-01-2011, 10:59
I see that at first it is all in black. Then, it changes to color. I guess that is what you meant.

It because the coloring system works at client side (your computer) and not server side (the web server). So mainly the server send to the client the source code wrapped into a special tag that has a special CSS class. Local page JavaScript intercept that special class and change source code formatting on the fly in your local page.

John Spikowski
08-01-2011, 11:22
You are still sending the .js and embeded JavaScript in the response to my browsers GET request. How about making it so you have to enter a code=tb to enable the syntax highlighting otherwise default to the way it was. (no syntax highlighting)

ErosOlmi
08-01-2011, 11:37
vBulletin configuration is quite complex. It has an internal script that is interpreted before emitting html code to the client. Also nothing is pre-coded but all parts of the page is templated with thousands of variables. This to permit different country translations be possible.

I have to understand it and see what I can do.

Petr Schreiber
08-01-2011, 11:39
Hi Eros,

thanks a lot for this addition, it boosts the readability 100% up for me.


Petr

zak
08-01-2011, 12:02
I agree colors are making our world more enjoyable and readable

http://img29.imageshack.us/img29/2917/candleskf.jpg

Michael Hartlef
08-01-2011, 14:07
Great addition. Make code much more readable. Thank you