[MODDB] Syntax Highlighter - 1.0.12

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!
Ideas Centre
User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

[MODDB] Syntax Highlighter - 1.0.12

Post by UseLess »

Modification Name: Syntax Highlighter
Author: UseLess
Modification Description: Syntax highlighting (using GeShi) with support for 132 programming/scripting languages
Modification Version: 1.0.12
Styles: Prosilver
Languages: English
Demo URL: Here
Home Page: http://www.phpbbstyles.co.uk/info/
Download link: http://www.phpbbstyles.co.uk/info/viewt ... p?f=6&t=39

MODDB Post: http://www.phpbb.com/community/viewtopi ... &t=1697035

The Long Description:

Due to a recent suggestion by mrbaseball34 the mod has been altered a little. You now have a choice of how you want the output to be shown. By using the BBCode tag [syntax] on it's own you will get the output displayed with line numbers, there is no syntax highlighting, and you can also specify the following options:

Basic Syntax allowed options
  • start = " x " - Line number to start at
  • filename = " filename for code when downloaded "
  • highlight = " line numbers to highlight seperated with , or - for consecutive lines " - NOT used if a language is specified
  • You may also use [ highlight ] ... [ /highlight ] to highlight part of a line, to highlight a full line use the option above
Note: By using [syntax=php] your specifying a language so the above options become invalid.

If you specify a language, for syntax highlighting, by using the following option: lang=mysql then the following options may be specified:

Language Syntax allowed options
  • lang = " php | delphi | css | mysql | html4strict " - over 130 languages supported
  • start = " x " - Line number to start at
  • filename = " filename for code when downloaded "
  • lines = " geshi-n | n | geshi-f | n " - how lines are to be shown, with line numbers and with fancy line numbers
  • fancy = " 5 " - Specifies that every 5th line is to be fancy, only used if the lines option is set to 'geshi-f' or 'f'
By default if a language is specified then it will be shown without line numbers, if you want line numbers then add a lines option.

You may now also use the language as a BBCode tag, this is disabled by default, so you can use:

Code: Select all

[delphi] ... [/delphi]
or you can also specify options:

Code: Select all

[delphi filename=test.pas lines=geshi-f fancy=3] ... [/delphi]
or
[delphi filename=test.pas lines=f fancy=3] ... [/delphi]
You can replace 'delphi' in the above examples with any of the supported languages, i.e.:

Code: Select all

[php] ... [/php]
[z80] ... [/z80]
[html4strict] ... [/html4strict]
If you do not wish to specify any other attributes then you may use the 1st format below. If you wish to specify 1 or more attributes then you must use the 2nd format and specify 'lang="delphi"' with 'delphi' being the syntax to use or use the language as the tag.

There is also an option to download the code, if a filename is specified this will be used instead of the default code id.

Usage

Code: Select all

[syntax="php"] code in here [/syntax]
[syntax lang="php" filename="file.php" start="10" lines=n] code in here [/syntax]
Notes
  1. The Demo site uses the Full BBCode parser which has more BBCode tags, however the Syntax Highlighting is the same.
  2. There is an 'install.txt' file located in the 'contrib' dir for those that are not fans of the ModX format
  3. There is an 'update.txt' file located in the 'contrib' dir for those that want to update from a previous version
  4. Quickest way to install the mod is to copy the contents of the 'root' dir to the root of your forum.
  5. Then make the alterations to the 3 files
  6. Then refresh the Theme data from the ACP
  7. Then clear the cache, or you could just refresh the Template data from the ACP.
Thanks are due to:
  • CyberAlien - for releasing the original BBCode parser to the public.
  • baboon - for (at time of posting this) a part complete Spanish translation
  • mrbaseball34 - for the idea to use the language as a BBCode tag
  • Bigwebmaster - for pointing out some errors I'd missed... and the fact that 'debug mode' is there for a reason.
Updates
  • updated to version 1.0.12 changes:
    • Now works in MCP when viewing reported posts preview
    • Fixed other issues when DEBUG mode was enabled
    • added method to remove the link stuff added by phpBB
  • updated to version 1.0.11 changes:
    • if the basic tag is used, i.e. [syntax] then the mod will add line numbers, as it previously did
    • changed 'syntax=' to 'lang='
    • if either [syntax=<lang name>] or [syntax lang=<lang name>] is used then, by default, no line numbers will be shown, see below for line number option
    • added lines option can be either 'lines=geshi-n' for normal geshi generated line numbers or 'lines=geshi-f' for fancy lines also generated by geshi
    • added fancy option which can only be used with the 'geshi-f' above to specify which lines should be fancy, i.e. if 5 is specified then every 5th line will be fancy
  • updated to version 1.0.9 changes:
    • issues pointed out by phpBB.com MOD team resolved and resubmitted for validation
    • to update to latest version:

      Code: Select all

      download latest version
      unzip archive
      upload the following to remote server:
      includes/hooks/hook_syntax_highlighter.php
      language/en/mods/useless_xs_bbcode.php
      styles/prosilver/theme/ul_syntaxhighlighter.css
  • updated to version 1.0.8 changes:
    • updated GeSHi to version 1.0.8.4
    • to update see post below
  • updated to version 1.0.7 fixed various issues (see install.xml history section for details)
  • Updated GeSHi to version 1.0.8.3 (now supports 132 languages) changed mod version to 0.0.3
  • Changed status to RC and updated version to 1.0.4, made the following changes
    • fixed bug in bbc_download.php
    • altered CSS
    • Removed static text and added them to 'language/en/common.php'
  • Changed name of CSS Class to avoid possible future conflicts
Last edited by UseLess on Fri Jul 17, 2009 6:24 am, edited 13 times in total.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [Dev] Syntax Highlighter - 0.0.3

Post by UseLess »

Greetings,

Found a bug... ;)

To fix it open 'bbc_download.php' and do a search/replace with the following:

Code: Select all

search for: $xs_bbcode->
replace with: $sh_bbcode->
You should end up with 3 replacements.

You'll then be able to download the contents of a syntax tag... ;)

Edit: If downloading Verion 1.0.4 the above change is not required as it's already been done.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [RC] Syntax Highlighter - 1.0.4

Post by UseLess »

Greetings,

If your using Custom BBCodes page by Stokerpiller then the following change allows the mod to support this mod.

Code: Select all

# 
#-----[ OPEN ]-------------------------------------------------------
#

boardbbcodes.php

# 
#-----[ FIND ]-------------------------------------------------------
#

$db->sql_freeresult($result);

# 
#-----[ AFTER, ADD ]-------------------------------------------------
# 

if( class_exists('SyntaxHighlighter') )
{
	$sh_bbcodes = $sh_bbcode->allowed_bbcode;
	foreach($sh_bbcodes as $key => $value)
	{
		$template->assign_block_vars('bbcodes', array(
			'BBCODE_NAME'		=> $key,
			'BBCODE_HELPLINE'	=> $value['bbcode_helpline'],
			'S_BBCODE_DISPLAY'	=> $value['display_on_posting'],
			'BBCODE_USAGE'	=> $value['bbcode_match'],
			'BBCODE_TPL'	=> $value['bbcode_tpl'],
		));
	}		
}

# 
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------------- 
# 
# EoM
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [RC] Syntax Highlighter - 1.0.5

Post by UseLess »

Greetings,

As there seems to be no problems with this mod, well there are no replies ... ;) , it has now been submitted for validation.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

armatec
Registered User
Posts: 50
Joined: Sat Mar 14, 2009 7:44 pm

Re: [RC] Syntax Highlighter - 1.0.5

Post by armatec »

Useing firebug i get this error

Code: Select all

SXBB[id].resize is not a function
http://www.mysite.com/phpbb3/classes/scripts/select_expand_bbcodes.js
Line 197
and the BBcode is not working

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [RC] Syntax Highlighter - 1.0.5

Post by UseLess »

Greetings,

I use firefox along with firebug and I get no errors at all, what settings are you using for firebug?

Are you getting any error messages when using the syntax tag?

Do you see this post: http://www.phpbbstyles.co.uk/info/viewt ... p?f=4&t=41 ok?
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

armatec
Registered User
Posts: 50
Joined: Sat Mar 14, 2009 7:44 pm

Re: [RC] Syntax Highlighter - 1.0.5

Post by armatec »

on your site i get no errors at all and i see its working but with my site it dose not work

Code: Select all

function SXBB_evalSize(cmd)
{
 for( var id in SXBB ) SXBB[id].resize(cmd);
}

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [RC] Syntax Highlighter - 1.0.5

Post by UseLess »

Greetings,

Try disabling firebug for the moment, this will only stop the javascript problem you having, and then see if it works... however, the tag will still work even without the javascript you just won't have the options to 'expand/contract' the syntax block.

What output are you getting when using the tag? A link to a post on your forum will help here.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

armatec
Registered User
Posts: 50
Joined: Sat Mar 14, 2009 7:44 pm

Re: [RC] Syntax Highlighter - 1.0.5

Post by armatec »

Bug is present with both firebug and in IE when i use [syntax syntax="php" filename="file.php" start="10" highlight="10-15,20,22,24"] code in here [/syntax]
it displays as

Code: Select all

[syntax syntax="php" filename="file.php" start="10" highlight="10-15,20,22,24"] code in here [/syntax]
Dude im so sorry i forgot to Clear the cache and its now showing but that error is still there
Last edited by armatec on Sun Apr 26, 2009 10:51 am, edited 1 time in total.

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [RC] Syntax Highlighter - 1.0.5

Post by UseLess »

Greetings,

Are you using 'code' tags as well as 'syntax' tags?

You should use (which won't work here obviously):
[syntax syntax="php" filename="file.php" start="10" highlight="10-15,20,22,24"] code in here [/syntax]

Which results in: http://www.phpbbstyles.co.uk/info/viewt ... p?f=4&t=43
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

armatec
Registered User
Posts: 50
Joined: Sat Mar 14, 2009 7:44 pm

Re: [RC] Syntax Highlighter - 1.0.5

Post by armatec »

every thing is working now except there is not [ Expand ] option and i get that same js error
Image

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [RC] Syntax Highlighter - 1.0.5

Post by UseLess »

Greetings,

The 'expand/contract' options are only shown if there is more than 4 lines in the syntax block... it's the same on my site the link to the example above does not show the expand option where as the link further up to the 'asp' example does.

What options have you enabled for firebug?

As with all the options for the console turned on I still do not get the error you get with regard to 'SXBB[id].resize'.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

armatec
Registered User
Posts: 50
Joined: Sat Mar 14, 2009 7:44 pm

Re: [RC] Syntax Highlighter - 1.0.5

Post by armatec »

i have not tweeks with firebug so its just stock settings but its not jsut firebug its also in IE

Ok i got rid of the error
changed

Code: Select all

<script type="text/javascript" src="{T_TEMPLATE_PATH}/xs_bbcode_fn.js"></script>
<script language="JavaScript" type="text/javascript" src="./classes/scripts/select_expand_bbcodes.js"></script> 
to

Code: Select all

<script language="JavaScript" type="text/javascript" src="./classes/scripts/select_expand_bbcodes.js"></script> 
<script type="text/javascript" src="{T_TEMPLATE_PATH}/xs_bbcode_fn.js"></script>
but is still see no expand

User avatar
UseLess
Registered User
Posts: 521
Joined: Mon Jul 22, 2002 7:26 pm
Location: North East UK

Re: [RC] Syntax Highlighter - 1.0.5

Post by UseLess »

Greetings,

Really strange... I've tried IE 6 and 7, Firefox and Opera and none of them show the error.

I even turned on the option in IE to 'Display a notification about every script error' and still no error.

And I have the files loaded in this order on my local test forum;

Code: Select all

<script type="text/javascript" src="{T_TEMPLATE_PATH}/xs_bbcode_fn.js"></script>
<script type="text/javascript" src="./classes/scripts/select_expand_bbcodes.js"></script>
If your still not seeing the 'expand/contract' options then try clearing the template cache.
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles

armatec
Registered User
Posts: 50
Joined: Sat Mar 14, 2009 7:44 pm

Re: [RC] Syntax Highlighter - 1.0.5

Post by armatec »

i think i found where i was going wroung your mod also dose not support code_repository_1-0-2 im just uninstalling now and il let you know

Locked

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