Request for Syntax Highlighting

For everything that's not in any way related to PureBasic. General chat etc...
Zach
Addict
Addict
Posts: 1677
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Request for Syntax Highlighting

Post by Zach »

Hi, Fred/Freak..

Is it possible to install a syntax highlighting plugin, as many other forums have been using for a while now? I think that would be really nice, and make code snippets a little more nice/fun/easy to read..
I know there are various Hilighters out there, some even have API's and stuff.. But I can't find one that produces BBcode, they all seem to output HTML/CSS

But I thought it would be easiest to ask directly for a phpBB MOD to be installed. Plus no one knows the language better than you guys and writing the definition should be easy :mrgreen:

If not, that's cool.
I just thought I would ask.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Request for Syntax Highlighting

Post by MachineCode »

So, I'd have to read your code in your personal color choices? How does that make it easier to read, especially if I'm color blind? There's a reason the "code" tags were designed to be mono-spaced and mono-color.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Request for Syntax Highlighting

Post by Tenaja »

A "real" syntax highlighter would let the users select their own colors...

I like this idea, though, even if it only allows pasting of colored text. Even Syntax-Highlighted text in unfavorable colors is easier to read than black/white.
Zach
Addict
Addict
Posts: 1677
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Request for Syntax Highlighting

Post by Zach »

Where did I say you had to read code in MY colors?
The highlighter is a board plugins, and would need a definition file. The colors would be defined by the people implementing the syntax definitions, obviously Fred & Freak


Ten, selecting your own colors would be cool. But that's not really what it is about (If there is a phpBB MOD that let you do this, that would be cool). You also don't have to do anything different than we currently do on the Forums. There is no pasting of colored text involved. The plugin simply colors code enclosed within the CODE tags, based on the Syntax detected (or defaulted) and the Colors defined for it by the board Admin
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: Request for Syntax Highlighting

Post by xorc1zt »

there is already a syntax colors by default but only for php.

Code: Select all

<?php

$hello = "Hello world";

print $hello;
?> 
the best code highlighters

http://code.google.com/p/google-code-prettify/
http://softwaremaniacs.org/soft/highlight/en/
http://alexgorbatchev.com/SyntaxHighlighter/
http://qbnz.com/highlighter/index.php (this one support purebasic)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Request for Syntax Highlighting

Post by Danilo »

xorc1zt wrote:http://qbnz.com/highlighter/index.php (this one support purebasic)
I use this "GeSHi - Generic Syntax Highlighter" on my private website with the Drupal CMS
and the "GeSHi Filter" module. GeSHi is just some PHP scripts, i think it should be possible to
add it to the PHPBB forum.
I use:

Code: Select all

pb, vb, vbnet, asm, c, cpp, csharp, java, javascript, pascal, php, python, ruby, css, drupal6, sql, mysql, xml

So for PureBasic I just write [pb] and [/pb], for C# it is [csharp] and [/csharp] etc.
Looks like the following screenshot:

Image

You can edit the colors in geshi/geshi/purebasic.php


Copying works, the line numbers are not selected (very important):
Image



There is a little fix required for geshi/geshi.php (the main file):

Replace the following (round about line 2137):

Code: Select all

    function parse_code () {
        // Start the timer
        $start_time = microtime();

        // Replace all newlines to a common form.
        $code = str_replace("\r\n", "\n", $this->source);
        $code = str_replace("\r", "\n", $code);
with:

Code: Select all

    function parse_code () {
        // Start the timer
        $start_time = microtime();

        // Replace all newlines to a common form.
        $code = str_replace("\r\n", "\n", $this->source);
        $code = str_replace("\r", "\n", $code);
        // by Danilo
        $code = str_replace(">"  ,">" ,$code);
        $code = str_replace("<"  ,"<" ,$code);
        $code = str_replace("&" ,"&" ,$code);
        $code = str_replace("&#39"  ,"'" ,$code);
        $code = str_replace(""","\"",$code);
        $code = str_replace("&nbsp;"," " ,$code);
Works fine after adding the little fix. I also think it makes codes more readable, hence I am using it.
Even if it does not use your personal favorite colors, you can see the differences in Keywords, Strings,
Functions names, numbers etc. more easily.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Request for Syntax Highlighting

Post by c4s »

Take a look at this, it's amazing: http://www.purebasic.fr/english/viewtop ... 17&t=39499
On the second page of that thread you'll also find a code folding add-on. I can't use the PB forum without those extremely useful add-ons anymore... Seriously, I highly recommend both! 8)


Edit:
Zach, I just reread your post and saw that you've already referred to it?! Yes of course, it would be much better if this functionality would already come with the forum itself!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Request for Syntax Highlighting

Post by MachineCode »

Zach wrote:Where did I say you had to read code in MY colors?
Well, you didn't say it would "make code snippets a little more nice/fun/easy for me to read". ;)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Zach
Addict
Addict
Posts: 1677
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Request for Syntax Highlighting

Post by Zach »

Sorry, I really don't see how you could misinterpret what I meant.. A board plugin of this nature, would obviously be applied board-wide, using whatever settings the Admins chose for it..
User avatar
Derren
Enthusiast
Enthusiast
Posts: 318
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: Request for Syntax Highlighting

Post by Derren »

And if you use the GM script you can choose our own colors.
I think Stargate even wrote a .prefs to javascript converter, so you don't have any work.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Request for Syntax Highlighting

Post by Danilo »

Danilo wrote:
xorc1zt wrote:http://qbnz.com/highlighter/index.php (this one support purebasic)
[...]
GeSHi is just some PHP scripts, i think it should be possible to add it to the PHPBB forum.
- geshi-phpbb - phpBB Syntax Highlighting MOD beta (now unsupported, see HERE)

- manual instructions: GeSHi in phpBB3 (3.0.1) einbinden (german language, maybe for freak ;))
- How do I use GeSHi?
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Request for Syntax Highlighting

Post by MachineCode »

Zach wrote:Sorry, I really don't see how you could misinterpret what I meant.. A board plugin of this nature, would obviously be applied board-wide, using whatever settings the Admins chose for it..
Again, "applied board-wide" implies it's for everyone, regardless of whether they want it. You should say "applied user-wide" instead.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Request for Syntax Highlighting

Post by c4s »

MachineCode wrote:Again, "applied board-wide" implies it's for everyone, regardless of whether they want it. You should say "applied user-wide" instead.
Come on... I'm sure there would be an option to disable it. And if not, the forum would finally have a useful addition that 99.9% of the board users wouldn't want to disable anyway.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Request for Syntax Highlighting

Post by MachineCode »

Yes, I'm sure I'm the 0.01% that would disable it. :)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Post Reply