Page 1 of 1
Request for Syntax Highlighting
Posted: Thu Apr 19, 2012 11:14 pm
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
If not, that's cool.
I just thought I would ask.
Re: Request for Syntax Highlighting
Posted: Thu Apr 19, 2012 11:23 pm
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.
Re: Request for Syntax Highlighting
Posted: Thu Apr 19, 2012 11:26 pm
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.
Re: Request for Syntax Highlighting
Posted: Thu Apr 19, 2012 11:52 pm
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
Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 3:17 am
by xorc1zt
Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 6:51 am
by Danilo
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:
You can edit the colors in geshi/geshi/purebasic.php
Copying works, the line numbers are not selected (very important):
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("'" ,"'" ,$code);
$code = str_replace(""","\"",$code);
$code = str_replace(" "," " ,$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.
Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 9:32 am
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!
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!
Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 1:23 pm
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".

Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 2:37 pm
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..
Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 4:59 pm
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.
Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 7:31 pm
by Danilo
Danilo wrote:
[...]
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?
Re: Request for Syntax Highlighting
Posted: Fri Apr 20, 2012 10:47 pm
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.
Re: Request for Syntax Highlighting
Posted: Sat Apr 21, 2012 10:05 am
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.
Re: Request for Syntax Highlighting
Posted: Sat Apr 21, 2012 10:50 am
by MachineCode
Yes, I'm sure I'm the 0.01% that would disable it.
