[DISC] Syntax Highlighting 0.4.1 (DISCONTINUED)

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
0racle
Registered User
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong
Contact:

[DISC] Syntax Highlighting 0.4.1 (DISCONTINUED)

Post by 0racle »

IMPORTANT NOTICE

I am *not* maintaining this MOD anymore! The last version available is 0.4.1. It goes to you complete with bugs etc.


It does work in terms of syntax highlighting, although the ACP is shoddy and there are some extra features (like a dropdown for languages on posting.php) missing/unimplemented.

------

Syntax highlighting will allow users to use [syntax="language"]...[/syntax] to highlight code in just about any installed language, making for far more interesting posts than what boring

Code: Select all

 gives you.

[img]http://qbnz.com/highlighter/images/screenshots/small1.png[/img]

Language packs will be available for may popular languages, and administrators will be able to define their own languages. Syntax Highlighting will come with [b]over 40[/b] installed languages, including php, html, css, java, c, c++, asm, perl, sql, python, css, xml and much more.

This mod takes only around 10 minutes to install, requires no in-line adding or removal, and additions to the DB are optional.

[img]http://qbnz.com/highlighter/images/screenshots/small2.png[/img]

This mod is powered by [url=http://qbnz.com/highlighter/]GeSHi[/url] - my generic syntax highlighting project. Being familiar with GeSHi will help you understand how this mod works so you can add your own twist to the highlighting - adding line numbers, changing the styles and more! 

Current languages supported are [b]php, c, java, sql, css, quickbasic, asm, ada, apache, nsis, pascal, html, perl, python, lisp, lua, c++, asp, bash, actionscript, xml, vb, openoffice.org basic, visual foxpro and many more[/b].

You can download version [b]0.4.1[/b] of this mod [url=http://prdownloads.sourceforge.net/geshi-phpbb/syntax_highlighting_0.4.1.zip?download]here[/url] (186K), or [url=http://prdownloads.sourceforge.net/geshi-phpbb/syntax_highlighting_0.4.1.tar.gz?download].tar.gz[/url] (130K), or [url=http://prdownloads.sourceforge.net/geshi-phpbb/syntax_highlighting_0.4.1.tar.bz2?download].tar.bz2[/url] (109K)

[size=84][b]Archive[/b]
[url=http://prdownloads.sourceforge.net/geshi-phpbb/syntax_highlighting_0.4.0.zip?download]Syntax Highlighting 0.4.0[/url] (368K)
[url=http://prdownloads.sourceforge.net/geshi-phpbb/syntax_highlighting_0.3.0.zip?download]Syntax Highlighting 0.3.0[/url] (132K)
[url=http://qbnz.com/phpBB/downloads/?id=2]Syntax Highlighting 0.2.0[/url] (117K)
[url=http://qbnz.com/phpBB/downloads/?id=1]Syntax Highlighting 0.1.0[/url] (58K)[/size]

Remember that this mod is ALPHA - it's not recommended you use this in a live environment, but you may at your own risk. I see no security worries with it.

Also, it would be helpful if you posted in this thread any bugs/gripes/etc that you find with this mod.

[img]http://qbnz.com/highlighter/images/screenshots/small3.png[/img]

Enjoy! :D

[NOTE: Mod has been bumped back down to ALPHA!]

Mod file header:
[code]##############################################################
## MOD Title: Syntax Highlighting
## MOD Author: 0racle < [email protected] > (Nigel McNie) http://qbnz.com/highlighter
## MOD Description: Adds [syntax="language"] bbcode to syntax-highlight many languages using GeSHi engine
##                  Better description would be useful. Note on installable by EM. Note on required
##                  BBCode mods.
## MOD Version: 0.4.1
##
## Installation Level: TODO(Easy/Intermediate/Advanced)
## Installation Time: TODOx Minutes
## Files To Edit: includes/bbcode.php,
##      includes/constants.php,
##      language/lang_english/lang_admin.php,
##      templates/subSilver/overall_header.tpl,
##      templates/subSilver/simple_header.tpl,
##      templates/subSilver/bbcode.tpl
## Included Files: (N/A, or list of included files)
##      admin/admin_syntax.php,
##      cache/syntax/index.htm,
##      cache/syntax/cache.txt,
##      includes/geshi.php,
##      includes/geshi/*.php,
##      includes/functions_syntax.php,
##		includes/functions_syntax_cache.php,
##      templates/subSilver/admin/admin_syntax_body.tpl,
##      templates/subSilver/geshi.css,
##      templates/subSilver/geshi-dark.css
## License: http://opensource.org/licenses/gpl-license.php GNU Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
##   -  This MOD REQUIRES that you have installed the Multi BBCodes MOD, as per phpBB BBCode
##      MOD requirements. You can get this MOD from [here].
##
##   -  I also STRONGLY RECOMMEND you install the BBCode Organizer MOD, available [here]
##
##   -  This MOD *has* been installed by easymod by me successfully. No guarantees for you,
##      this is alpha software. Please tell me about your experiences with easymod!
##
##   -  There is a script - install_syntax.php - that will automatically run the SQL needed
##      to get this MOD going in advanced mode. Run if a) easymod doesn't do the SQL for you,
##      b) you can't do the SQL any other way, and c) if you do run it, run it AFTER ALL
##      FILE MODIFICATIONS. It's mentioned in a DIY instruction below so you won't forget.
##
##   -  HOW TO USE AT YOUR FORUM
##      To highlight code in a certain language, you do this:
##      [syntax="language"]
##      // code...
##      [/syntax]
##      Where language is a language you have a language file for. The quotemarks are
##      optional. For example, this mod comes with language files for php and sql among
##      others, so you could go:
##      [syntax="php"]// a php comment[/syntax]
##      [syntax=sql]-- a sql comment[/syntax]
##
##   -  You can highlight certain lines "extra" if you want to prove a point - start a line
##      in a syntax block with >>> and end it with <<<, and that line will be highlighted
##      to stand out.
##
##   -  This mod comes in two "modes" - simple and advanced. In general, you want the advanced
##      mode. To enable advanced mode, all you have to do is run the SQL that this mod
##      specifies (in the final release there will be a file available that you only have to
##      point your browser at to run the SQL). But if you can't run SQL for some reason,
##      then you can still run this mod fine - just install everything except the SQL. To
##      configure in simple mode, open includes/bbcode.php and change values as needed. Note
##      that if you do change values, you'll need to clear the cache (which you can do in the
##      ACP, even in simple mode).
##
##   -  Language files are in includes/geshi/. To control which languages can be used
##      for highlighting, use the ACP (Syntax Highlighting, under General Admin). If you're
##      in simple mode, you can only control whether a language is highlighted or not,
##      whereas if you're in advanced mode you can control what string the users must use
##      to trigger the highlighting, and what is displayed when viewing syntax-highlighted
##      code.
##
##   -  Unfortunately nested syntax blocks *will* break down. This Is Not My Fault!
##      phpBB does NOT support marking lowest level block for regexp bbcode, so I can't
##      do anything about this. Simple solution: don't do this:
##      [syntax="language"]...[syntax="language2"]...[/syntax]...[/syntax]
##      As it is, destroying smilies and BBCode inside the syntax blocks is somewhat
##      of a hack at the moment...
##
##   -  The default stylesheet (geshi.css) supplied with this mod works well with
##      templates with *light* colours (subSilver, subOracle etc). However, if you're
##      using a dark template, you might want to use geshi-dark.css. Of course, you
##      can play around with the stylesheets to make your own colour scheme...
##      The dark stylesheet is awful, I know. If you fix it up, send it to me and I'll
##      include it with the full version.
##
##   -  Remember to CHMOD the cache/syntax directory to 777, and the cache/syntax/cache.txt
##      file to 666!!!
##
##   -  I suggest you do all your configuration as soon as you install the MOD - that way
##      you won't have to clear the cache when it already has lotsa stuff in it.
##
##   -  And finally, this is ALPHA software. No warranty etc. etc. Please report bugs you
##      find by posting in the phpBB dev thread for this MOD, by email to me or by the sf.net
##      bugtracker for this MOD.
##
##############################################################
## MOD History:
##
##   2004-08-13 - Version 0.1.0
##      - Initial Release
##
##   2004-10-28 - Version 0.2.0
##      - GeSHi upgraded to 1.0.2
##       * Support for nearly 30 languages
##      - geshi-dark.css stylesheet added for dark forums
##      - Cache directory used to speed page rendering
##
##   2004-11-13 - Version 0.3.0
##      - Custom GeSHi 1.0.2 used
##      - Configuration can be done via the ACP
##       * Control of the cache directory
##       * Which languages are supported
##       * What is displayed for various languages
##       * Whether to use line numbering/function to URL conversion
##      - Better handling of bbcode inside [syntax] blocks
##      - Support for >>> ... <<< to extra-highlight a line
##      - Automatic cache control - the cache can be kept to a certain size or have items
##        older than a certain date removed automatically
##      - Support for a "simple mode" which can be used if the user can't run SQL
##
##   2005-08-15 - Version 0.4.0
##      - GeSHi upgraded to 1.0.7.1
##       * Added languages are c_mac, csharp, diff, div, d, eiffel, gml, matlab,
##         mpasm, objc, oracle8, vbnet and vhdl, making a total of 43
##      - Install SQL file added
##       * Can be run after all file alterations to run the SQL needed to install this MOD
##         in advanced mode
##
##   2005-08-23 - Version 0.4.1
##      - Added missing function clear_cache() (reported by Logman)
##      - Minor bugfix to function to obtain cache directory size (index.htm, not .html)
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
Last edited by 0racle on Sun Oct 02, 2005 7:41 am, edited 12 times in total.
Zypher
Registered User
Posts: 381
Joined: Fri Mar 12, 2004 7:04 am
Location: Australia
Contact:

Post by Zypher »

Cool, i will be using this!
- Zypher

~Beware of the Darkness Within!~

Fully Loaded
0racle
Registered User
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong
Contact:

Post by 0racle »

[added the MOD header]

I've also created a stylesheet for darker styles, though it probably needs change. I'll add it/post it if anyone wants it.
Krisiun
Registered User
Posts: 124
Joined: Mon Feb 03, 2003 12:46 pm
Location: Porto Alegre - Brazil
Contact:

Post by Krisiun »

Great MOD. :wink:
FX
Registered User
Posts: 254
Joined: Thu Aug 01, 2002 9:29 pm
Location: France
Contact:

Post by FX »

Good, i will try this mod 8)
Zypher
Registered User
Posts: 381
Joined: Fri Mar 12, 2004 7:04 am
Location: Australia
Contact:

Post by Zypher »

do add, i mean there is no harm in it, or will there... :?
- Zypher

~Beware of the Darkness Within!~

Fully Loaded
Krisiun
Registered User
Posts: 124
Joined: Mon Feb 03, 2003 12:46 pm
Location: Porto Alegre - Brazil
Contact:

Post by Krisiun »

One suggestion...

Incorporate this alterations in the MOD:

:arrow: http://www.forumimages.com/forum/viewtopic.php?t=1574
User avatar
webmedic
Registered User
Posts: 323
Joined: Tue May 28, 2002 2:37 am
Contact:

Post by webmedic »

I just wish I could get it working at all. for some reason it jsut completely ignors the bboce as though it didn't exist. I went back over my modifiactions to make sure and it is done correctly. Oh well.
0racle
Registered User
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong
Contact:

Post by 0racle »

webmedic wrote: I just wish I could get it working at all. for some reason it jsut completely ignors the bboce as though it didn't exist. I went back over my modifiactions to make sure and it is done correctly. Oh well.


Hmmm, link? Maybe I can find out the problem for you.
Krisiun wrote: One suggestion...

Incorporate this alterations in the MOD:


What do you mean? It's up to that MOD author to add this mod to his MOD - I don't know how his MOD works. Though you could tell him about this MOD and see if he will do it.
User avatar
webmedic
Registered User
Posts: 323
Joined: Tue May 28, 2002 2:37 am
Contact:

Post by webmedic »

0racle wrote:
webmedic wrote:I just wish I could get it working at all. for some reason it jsut completely ignors the bboce as though it didn't exist. I went back over my modifiactions to make sure and it is done correctly. Oh well.
Hmmm, link? Maybe I can find out the problem for you.

sure http://www.webmedic.net

Like I siad though it's like it doesn't even see it as a bbcode. I rechecked throguh it and it still doesn't work.

I dont think i have any posts using it yet on my site since it wasn't working.

I guess here would be a good place ot start testing it:

http://www.webmedic.net/index.php?c=5
0racle
Registered User
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong
Contact:

Post by 0racle »

I found the problem: check your test board ;)

Basically, I don't think you were surrounding the language in quotemarks ;)

ie:

[syntax="php"]...[/syntax]

instead of:

[syntax=php]...[/syntax]

Have fun :D
User avatar
webmedic
Registered User
Posts: 323
Joined: Tue May 28, 2002 2:37 am
Contact:

Post by webmedic »

um really I hadn't thought of that. I'm sorry to hae bugged you. I was really wondering why it was not working though.

Thanks again.
User avatar
webmedic
Registered User
Posts: 323
Joined: Tue May 28, 2002 2:37 am
Contact:

Post by webmedic »

thanks also I didn't look really closely but is here a way to do the line number also? I know that geshi will do line numbers.

I'm sure i can get that part figured out though.

Thank you.
0racle
Registered User
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong
Contact:

Post by 0racle »

In the function geshi_highlight (in bbcode.php)

Add, after the line $geshi = new GeSHi(...);

$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);

Then in the stylesheet, you'll have to add classes .li1 and .li2 with appropriate styles.

HOWEVER: Adding line numbers means that if you try to highlight the code by selecting it with your mouse (after you've posted it this is), the line numbers will be selected too, because they're not in a table by default. This is a feature of GeSHi that I'll implement an option to work around in the next version, but for now I don't really reccomend you use line numbers if people are going to try copy/pasting the code.
User avatar
webmedic
Registered User
Posts: 323
Joined: Tue May 28, 2002 2:37 am
Contact:

Post by webmedic »

Yes I already added it and then thought of that afterword. I was also curious about word wrap. I have just added some really long lines and it is stretching the page all over the place.
Locked

Return to “[2.0.x] MODs in Development”