It is currently Thu Jun 20, 2013 6:00 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Request for Syntax Highlighting
PostPosted: Thu Apr 19, 2012 11:14 pm 
Offline
Addict
Addict

Joined: Sun Dec 12, 2010 12:36 am
Posts: 1309
Location: Waterloo, WI - USA
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Thu Apr 19, 2012 11:23 pm 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1480
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!


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Thu Apr 19, 2012 11:26 pm 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
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.


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Thu Apr 19, 2012 11:52 pm 
Offline
Addict
Addict

Joined: Sun Dec 12, 2010 12:36 am
Posts: 1309
Location: Waterloo, WI - USA
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

_________________
Image


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 3:17 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Jul 09, 2011 7:57 am
Posts: 276
there is already a syntax colors by default but only for php.

Code:
<?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)

_________________
http://www.mediafire.com/pbstuff


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 6:51 am 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 1291
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:
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:
    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:
    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("&gt;"  ,">" ,$code);
        $code = str_replace("&lt;"  ,"<" ,$code);
        $code = str_replace("&amp;" ,"&" ,$code);
        $code = str_replace("&#39"  ,"'" ,$code);
        $code = str_replace("&quot;","\"",$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.


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 9:32 am 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1579
Location: Germany
Take a look at this, it's amazing: viewtopic.php?f=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!


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 1:23 pm 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1480
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!


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 2:37 pm 
Offline
Addict
Addict

Joined: Sun Dec 12, 2010 12:36 am
Posts: 1309
Location: Waterloo, WI - USA
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..

_________________
Image


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 4:59 pm 
Offline
User
User
User avatar

Joined: Sat Jul 23, 2011 1:13 am
Posts: 61
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.

_________________
PB 4.6b3 - Win7 32


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 7:31 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 1291
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?


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Fri Apr 20, 2012 10:47 pm 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1480
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!


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Sat Apr 21, 2012 10:05 am 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1579
Location: Germany
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.


Top
 Profile  
 
 Post subject: Re: Request for Syntax Highlighting
PostPosted: Sat Apr 21, 2012 10:50 am 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1480
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye