[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.

[DISC] Syntax Highlighting 0.4.1 (DISCONTINUED)

Postby 0racle » Fri Aug 13, 2004 2:07 am

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] gives you.

Image

Language packs will be available for may popular languages, and administrators will be able to define their own languages. Syntax Highlighting will come with over 40 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.

Image

This mod is powered by GeSHi - 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 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.

You can download version 0.4.1 of this mod here (186K), or .tar.gz (130K), or .tar.bz2 (109K)

Archive
Syntax Highlighting 0.4.0 (368K)
Syntax Highlighting 0.3.0 (132K)
Syntax Highlighting 0.2.0 (117K)
Syntax Highlighting 0.1.0 (58K)


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.

Image

Enjoy! :D

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

Mod file header:
Code: Select all
##############################################################
## MOD Title: Syntax Highlighting
## MOD Author: 0racle < nigel@geshi.org > (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.
User avatar
0racle
Registered User
 
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong

Postby Zypher » Fri Aug 13, 2004 2:11 am

Cool, i will be using this!
- Zypher

~Beware of the Darkness Within!~

Fully Loaded
User avatar
Zypher
Registered User
 
Posts: 381
Joined: Fri Mar 12, 2004 7:04 am
Location: Australia

Postby 0racle » Fri Aug 13, 2004 10:29 pm

[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.
User avatar
0racle
Registered User
 
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong

Postby Krisiun » Fri Aug 13, 2004 11:19 pm

Great MOD. :wink:
Krisiun
Registered User
 
Posts: 124
Joined: Mon Feb 03, 2003 12:46 pm
Location: Porto Alegre - Brazil

Postby FX » Sat Aug 14, 2004 8:31 am

Good, i will try this mod 8)
FX
Registered User
 
Posts: 254
Joined: Thu Aug 01, 2002 9:29 pm
Location: France

Postby Zypher » Sat Aug 14, 2004 9:31 am

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

~Beware of the Darkness Within!~

Fully Loaded
User avatar
Zypher
Registered User
 
Posts: 381
Joined: Fri Mar 12, 2004 7:04 am
Location: Australia

Postby Krisiun » Sun Aug 15, 2004 9:11 am

One suggestion...

Incorporate this alterations in the MOD:

:arrow: http://www.forumimages.com/forum/viewtopic.php?t=1574
Krisiun
Registered User
 
Posts: 124
Joined: Mon Feb 03, 2003 12:46 pm
Location: Porto Alegre - Brazil

Postby webmedic » Sun Aug 15, 2004 2:24 pm

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.
User avatar
webmedic
Registered User
 
Posts: 323
Joined: Tue May 28, 2002 2:37 am

Postby 0racle » Sun Aug 15, 2004 10:44 pm

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
0racle
Registered User
 
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong

Postby webmedic » Mon Aug 16, 2004 12:19 am

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
User avatar
webmedic
Registered User
 
Posts: 323
Joined: Tue May 28, 2002 2:37 am

Postby 0racle » Mon Aug 16, 2004 12:44 am

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
0racle
Registered User
 
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong

Postby webmedic » Mon Aug 16, 2004 12:51 am

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

Postby webmedic » Mon Aug 16, 2004 12:55 am

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.
User avatar
webmedic
Registered User
 
Posts: 323
Joined: Tue May 28, 2002 2:37 am

Postby 0racle » Mon Aug 16, 2004 1:06 am

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
0racle
Registered User
 
Posts: 304
Joined: Fri Jul 25, 2003 6:28 am
Location: Somewhere I Belong

Postby webmedic » Mon Aug 16, 2004 2:30 am

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.
User avatar
webmedic
Registered User
 
Posts: 323
Joined: Tue May 28, 2002 2:37 am

Next

Return to [2.0.x] MODs in Development

Who is online

Users browsing this forum: No registered users and 5 guests