Page 6 of 7

Re: Syntax Highlighter

Posted: Tue Feb 16, 2010 6:21 am
by Bogey
Mardag wrote:Thanks for the MOD :) It's great. I've got 3 questions:

1) At first, I had line numbers and now they are gone. What happened?
The numbered lines are not the default params. To get numbered lines you got to declare it in the params of the bbCode

[syntax lang="php" lines="geshi-f"]<?php echo 'Hello World'; ?>[/syntax]

To get the numbered lines by default, do the following:

OPEN: includes/hooks/hook_syntax_highlighter.php
FIND:

Code: Select all

	var $params = array();
REPLACE WITH:

Code: Select all

	var $params = array('lines' => 'f');
Mardag wrote:2) Why can't I use the MOD using for example [php]<?php echo ""; ?>[/php]? I have to use [syntax=php]<?php echo ""; ?> [/syntax] instead.
You can... do be able to do that:

OPEN: includes/hooks/hook_syntax_highlighter.php
FIND:

Code: Select all

	var $auto_add_tags = false;
REPLACE WITH:

Code: Select all

	var $auto_add_tags = true;
annab wrote:Isn't syntax highlighting already built into phpbb3? I use the normal code=php and it works just fine.
Not only is this highlighter has more languages, it is more advanced... I would prefer that phpBB has this by default rather then what they have.
tvrsh wrote:Hello, I have some little problem with this mod.
When I press Select button it select all the code, but with "Parsed in ... seconds, using GeSHi ...".
So when I paste this selected code somewhere there is one unnecessary string with Geshi info.

And one more question: How can I replace "Using ... Syntax Highlighting" string to string with Syntax, Select, Expand buttons. So it became like this:
Syntax: [ Download ] [ Show ] [ Select ] [ Toggle ] Using %1$s Syntax Highlighting

some code

Parsed in 0.022 seconds, using GeSHi 1.0.8.4
I eliminated that line altogether and replaced Syntax: with the name of the language that is being highlighted. Here is how you do that.

OPEN: includes/hooks/hook_syntax_highlighter.php
FIND:

Code: Select all

$header = '<div style="text-align: center; width: auto; font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 12px; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;">' . sprintf($user->lang['XS_BBC_USING_SYNTAX'], '<span style="color: #900;">' . $syntax . '</span>') . '</div>';
REPLACE WITH:

Code: Select all

//$header = '<div style="text-align: center; width: auto; font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 12px; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;">' . sprintf($user->lang['XS_BBC_USING_SYNTAX'], '<span style="color: #900;">' . $syntax . '</span>') . '</div>';
(Or just delete that line altogether).

And to replace the Syntax: with the language name being highlighted, you would:

OPEN: includes/hooks/hook_syntax_highlighter.php
FIND:

Code: Select all

$str .= '<div class="syntax-header" id="codehdr2_' . $code_id . '" style="position: relative;"><b>' . $user->lang['XS_BBC_SYNTAX'] . '</b>:' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [ <a href="javascript:void(0)" onclick="xs_show_hide(\'code_' . $code_id . '\', \'code2_' . $code_id . '\', \'\'); xs_show_hide(\'codehdr_' . $code_id . '\', \'codehdr2_' . $code_id . '\', \'\')">' . $user->lang['XS_BBC_HIDE'] . '</a> ]' . ( ($load_expand == true) ? '<script type="text/javascript">SXBB[id].writeCmd();</script>' : '') . '</div>';
REPLACE WITH:

Code: Select all

$str .= '<div class="syntax-header" id="codehdr2_' . $code_id . '" style="position: relative;"><b>' . strtoupper($syntax) . '</b>:' . (empty($item['params']['file']) ? '' : ' (' . htmlspecialchars($item['params']['file']) . ')') . $download_text . ' [ <a href="javascript:void(0)" onclick="xs_show_hide(\'code_' . $code_id . '\', \'code2_' . $code_id . '\', \'\'); xs_show_hide(\'codehdr_' . $code_id . '\', \'codehdr2_' . $code_id . '\', \'\')">' . $user->lang['XS_BBC_HIDE'] . '</a> ]' . ( ($load_expand == true) ? '<script type="text/javascript">SXBB[id].writeCmd();</script>' : '') . '</div>';
For all of you who might not have noticed, all of the options used for this highlighter is in includes/hooks/hook_syntax_highlighter.php. So if you want to change, add or remove something, you would be editing that file.

Re: Syntax Highlighter

Posted: Sat Feb 20, 2010 5:39 pm
by tvrsh
Bogey, thank you.

Re: Syntax Highlighter

Posted: Sat Feb 20, 2010 6:03 pm
by Bogey
tvrsh wrote:Bogey, thank you.
Yup :)

Re: Syntax Highlighter

Posted: Wed Mar 03, 2010 11:02 pm
by CherryJimbo
Is it possible to change the size of the compressed box? So that when its compressed, more than just 4 lines are visible?

Re: Syntax Highlighter

Posted: Wed Mar 10, 2010 4:05 pm
by tvrsh
CherryJimbo wrote:Is it possible to change the size of the compressed box? So that when its compressed, more than just 4 lines are visible?
OPEN: includes/hooks/hook_syntax_highlighter.php

FIND:

Code: Select all

        $load_expand = ( (count($temp_text) <= 4) ? false : true); 
And change 4 to your amount of lines.

Re: Syntax Highlighter

Posted: Wed Mar 10, 2010 4:25 pm
by CherryJimbo
I already have that set to 11, and all it does is, if the number of code lines is more than 11, it puts them into that compressed box. What I want to do is actually change how many lines that compressed box shows.

Re: Syntax Highlighter

Posted: Thu Mar 11, 2010 10:16 pm
by UseLess
Greetings,

Code: Select all

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

classes/scripts/select_expand_bbcodes.js

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

	this.size = this.min = 70;	// --- Adjust MINIMUM_BLOCK_HEIGHT here :-)

# 
#-----[ IN-LINE FIND ]----------------------------------------------- 
# 

70

# 
#-----[ IN-LINE REPLACE WITH ]--------------------------------------- 
# 

150

# 
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------------- 
# 
# EoM
The 150 will then show 11 lines...

Re: Syntax Highlighter

Posted: Thu Mar 11, 2010 11:51 pm
by CherryJimbo
Thank you very much, exactly what I was after :)

Re: Syntax Highlighter

Posted: Fri Mar 12, 2010 5:05 pm
by UseLess
Greetings,

There's a new version available here: http://www.phpbbstyles.co.uk/info/viewt ... ?f=16&t=86 for testing before it gets submitted for validation.

If you find any issues with it then either register/post on my forum or if you don't wish to register then use this: http://www.phpbbstyles.co.uk/contacts.php to let me know what the issue is.

PLEASE: Do not post in this topic if you find any issues with the latest version use the methods previously mentioned to let me know about any issues.

If you do wish to register and want to report an issue you can do so by replying to the post here and there is a Help Generator you can use to generate your post.

Re: Syntax Highlighter

Posted: Sun Mar 14, 2010 3:41 pm
by UseLess
Greetings,

After having read the changes to the mod validation requirements I have decided not to update this mod.

Support will be provided for the last release version which is 1.0.12 but 1.0.14 will not be released and will not be submitted for validation by the phpBB MOD Team.

Re: Syntax Highlighter

Posted: Sun Mar 14, 2010 5:14 pm
by euer GEHIRN
UseLess wrote:Greetings,

After having read the changes to the mod validation requirements I have decided not to update this mod.

Support will be provided for the last release version which is 1.0.12 but 1.0.14 will not be released and will not be submitted for validation by the phpBB MOD Team.
hmmm .. this is a shame. :cry: but thx for

Re: Syntax Highlighter

Posted: Fri Mar 19, 2010 12:16 pm
by Markstar
Hi,
this MOD is great and I have it working in 3.0.6. I read the whole thread because I had some questions and pretty much all of them were answered on page 6 - thanks Bogey, tvrsh and of course UseLess! :D

Just a few more questions remain:
1) Very sad to hear that you have decided not to release new versions of Syntax Highlighter. :cry:
You did link to another page but I could not find any downloads... so are you really not offering new versions anymore? Doesn't that mean Syntax Highlighter is dead? :o

2) How do I get the "[ Select ]" button on all code boxes and not only the "expanded ones" (where $load_expand is true)? Manually setting $load_expand to true works, but of course boxes with less code are too big then. :? Is there some other way?

3) I can't get the line numbers to work, neither by using [syntax="cpp" lines="geshi-f"]code[/syntax] nor by changing $params (I tried 'f' and 'n'). Does it work for everybody else? Could it be because I have $auto_add_tags = true? I would really like to have line numbers enabled by default. :)


Thank you in advance!

Edit: I tried to register at the http://www.phpbbstyles.co.uk but even though I completed the registration (even though I never heard of Nick Cutter before), I never got a confirmation email. :|

Re: Syntax Highlighter

Posted: Fri Mar 19, 2010 1:18 pm
by UseLess
Greetings,

1. No.

2. No sure I follow you here. The select option works but it will also select all the numbers and header/footer text. It's easier to use the 'download' option to download the contents of the syntax block.

3. [syntax lang="cpp" lines="f"] < cpp code in here >[/syntax] will work...

4. Check your junk mail folder.

Re: Syntax Highlighter

Posted: Fri Mar 19, 2010 2:34 pm
by Markstar
Thank you for your quick reply!
UseLess wrote:Greetings,

1. No.
Sorry...was that a "no" to the "will you offer future versions" or "no" to "is SH dead"? :oops:
2. No sure I follow you here. The select option works but it will also select all the numbers and header/footer text. It's easier to use the 'download' option to download the contents of the syntax block.
The reason I'm asking is that I have disabled [ Download ] and I just want the user to be able to copy the code to the clipboard. I moved the GeSHi notice to the phpBB footer, so [ Select ] should not include anything other than the code itself.
3. [syntax lang="cpp" lines="f"] < cpp code in here >[/syntax] will work...
Yes, that works. :) Now I would really like to make this the standard view so that the line numbers are always shown, without users having to set the option when posting.
4. Check your junk mail folder.
I have, 2 new messages in there, but they really were junk. :?

Thanks for your help!

Re: Syntax Highlighter

Posted: Fri Mar 19, 2010 3:54 pm
by UseLess
Greetings,

1. The latter.

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.

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

4. Reminder sent...