Page 7 of 7

Re: Syntax Highlighter

Posted: Sat Mar 20, 2010 11:47 am
by Markstar
Hi!
UseLess wrote:Greetings,

1. The latter.
:D That's great! I shall keep an eye out on the other page in hope of finding new versions there in the future (even though you said no future versions will be released, so I'm still a little confused about this). :P
2. Select will include the line numbers, if shown, which is why, in the version I use, I removed the 'select' option and left the 'download' option so the code can be downloaded with the layout intact with no line numbers or anything else included. It's also handier if you specify a filename so the downloaded code can be opened directly in a appropriate application. But if you want to stick with the select option then I'd suggest using another select script that doesn't include the line numbers.
Ups...I just saw that when I click on [ Select ], it would (correctly) only select the code itself. But since actually copies everything to the clipboard I do have to think about which option makes more sense. But I think I still want line numbers, so you are right (of course), [ Select ] makes less sense then and [ Download ] seems to be the better option, since I can't code an alternative "Select" script myself and I can't find any on the net.
3. In the 'if ... else ...' where the lines parameter is checked change the 'else' default 'no line numbers' to whatever lines you want 'normal' or 'fancy'.
I'm sorry, I don't know which if-clause you are referring to. :oops:
Bogey said to change the $params variable, which then appears in two successive "if($tag_valid"-clauses (which, btw, I don't understand why they are separate instead of just one). I don't see a "no line numbers" option anywhere. :oops:
4. Reminder sent...
Got it. Thank you!

Re: Syntax Highlighter

Posted: Sat Mar 20, 2010 3:05 pm
by UseLess
Greetings,

The 'if' clause I'm referring to starts on line 420 and ends on line 446, to change the default behaviour to always show line numbers change the 'else' part like so:

Option 1 normal line numbers:

Code: Select all

else
{							
	// Make line type not empty as a syntax is specified
	$line_type = 'not empty';
	$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
}
Option 2 fancy line numbers

Code: Select all

else
{							
	// Make line type not empty as a syntax is specified
	$line_type = 'not empty';
	$fancy = ( isset($item['params']['fancy']) ? trim(htmlspecialchars($item['params']['fancy'])) : 5);
	$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, $fancy);
}
If you don't specify a language then you should always get line numbers, i.e. using the [syntax] tag with no options, you should also be able to highlight lines by using the 'highlight' parameter. The highlight parameter does not work when a language is specifed, this was changed in a later version to use GeSHi as it has it's own highlighter.

If you do speciafy a language with either: lang=php or use the lang tag option then line numbers won't be shown by default, making the above change will change the default behaviour.

Re: Syntax Highlighter

Posted: Mon Mar 22, 2010 3:13 pm
by Markstar
It's working perfectly now and I have it set up the same way as you now. :D

Thank you, UseLess!

Re: Syntax Highlighter

Posted: Wed May 05, 2010 3:28 pm
by Kevin49
Greetings everybody,
I'm truly willing to put this mod on my phpbb3 (very last version).
I've followed the installation guide and installed Geshi on my forum.
However, I encounter the following php error (at the top of my forum) after typing (example) :

Code: Select all

[code=java]code
[/code]

The error is the following :

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 599: include_once(./includes/geshi/geshi.php) [function.include-once]: failed to open stream: No such file or directory
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 599: include_once() [function.include]: Failed opening './includes/geshi/geshi.php' for inclusion (include_path='.:/usr/local/lib/php')
geshi n'a pas pu ĂȘtre![phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3542)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4368: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3542)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4369: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3542)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4370: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3542)
Any Idea?
Thanks ;)

Re: Syntax Highlighter

Posted: Wed May 05, 2010 10:45 pm
by UseLess
Greetings,

Have you tried using:

Code: Select all

[syntax=java]code[/syntax]
because unless you've altered the class to override the code tag using the code tag will only work with the 'code=php' option. And the '=java' is stripped out anyway, well it is on my 3.0.7 installation.

If the option to add the languages as tags is enabled, use the [version /] tag to check this, then you could use:

Code: Select all

[java]code[/java]

Re: Syntax Highlighter

Posted: Thu May 06, 2010 3:08 pm
by Kevin49
Thank you for this answer. Indeed using [java]code[/java] works!
unless you've altered the class to override the code tag using the code tag
Um... Is there any tips on how doing this please?