News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Line Numbers Mod

Started by winrules, June 04, 2006, 04:09:43 PM

Previous topic - Next topic

winrules

Link to Mod

This mod will add line numbers to code within [code][/code] tags and [php][/php] tags. Example:


1 <?php
echo 'test';
3 ?>


I just typed them in manually in that example. With this mod they will show up automatically, in orange.


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


sbclansite.com

Looks Interesting mod might give it a try.
The Mod , Modifier :). For Mods/Scripts/GameServer Installations contact me via http://www.forums.sbclansite.com <<Free Image hosting, Free WebHosting and Free Featured Listing available also.
Webhosting @ 1.55$ : http://www.a1whs.com
Free Seo Friendly Directory : http://www.sbclansite.com

Harzem

winrules, you've became a mod-machine :P

Nice and useful mod for programming forums, and I have one, thank you very much!

Tony Reid

I was thinking about creating a mod like this just the other day - glad its already done :)

Heres some thoughts on extending it.....

1) Add a parameter for line numbers to start from.

For example

[code=59]
59 <?
60 phpinfo();
70 ?>
[/code]


CSS would also be a great addition - you could then make it look like a snapshot from a text editor.

Anyhow - well  done, I think this should be in the default install.


Tony Reid

winrules

Quote from: Tony on June 13, 2006, 04:06:53 PM
I was thinking about creating a mod like this just the other day - glad its already done :)

Heres some thoughts on extending it.....

1) Add a parameter for line numbers to start from.

For example

[code=59]
59 <?
60 phpinfo();
70 ?>
[/code]


CSS would also be a great addition - you could then make it look like a snapshot from a text editor.

Anyhow - well  done, I think this should be in the default install.



I may add that to the next version. What do you mean by CSS?


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


Tony Reid

Well if you added a style sheet to it then you could change the look of the code dump...

Kind of like this.....
http://txp-plugins.netcarving.com/plugins/display-code

Tony Reid

winrules

Quote from: Tony on June 13, 2006, 04:27:22 PM
Well if you added a style sheet to it then you could change the look of the code dump...

Kind of like this.....
http://txp-plugins.netcarving.com/plugins/display-code


Oh, I see.


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


jacortina

Yeah, it looks better.

But doesn't it make copy/paste (something people might want to do most especially with code) a lot harder, having to remove those line numbers?

winrules

Quote from: jacortina on June 13, 2006, 09:24:43 PM
Yeah, it looks better.

But doesn't it make copy/paste (something people might want to do most especially with code) a lot harder, having to remove those line numbers?
Yes, In the next version I will make a
Code (noline) Select
for code that shouldn't have line numbers.


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


supastoked

Hi Guys,
Is there any update on this? I noticed on the mod page that the 2 ppl that voted/commented said they were having probs with 1.1 rc3? Also, did you manage to get it so that it uses a list, to improve the copy/paste scenario? I think this is one of the most handy mod's i've come across for smf, so it would be great to see the development continue ;)
Keep up the great work!
Chris

winrules

You shouldn't have any problems with it on RC3. I'll go and update it in a few days.


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


supastoked

hey winrules,
thanks for the reply! i'll keep an eye out for the update :D
cheers,
chris

K3TK3TK3T

how can i make it so that i can highlite all of the code but not the letters?

TAI06GR

Hi Ifouind a Copy/PAste mistake

'type' => 'unparsed_equals_content',
'content' => '<div class="codeheader">' . $txt['smf238'] . ': ($2)</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
// !!! Maybe this can be simplified?
'validate' => isset($disabled['code']) ? null : create_function('&$tag, &$data, $disabled', '
global $context;

if (!isset($disabled[\'code\']))
{
$php_parts = preg_split(\'~(&lt;\?php|\?&gt;)~\', $data[0], -1, PREG_SPLIT_DELIM_CAPTURE);

for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++)
{
// Do PHP code coloring?
if ($php_parts[$php_i] != \'&lt;?php\')
continue;

$php_string = \'\';
while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != \'?&gt;\')
{
$php_string .= $php_parts[$php_i];
$php_parts[$php_i++] = \'\';
}
$php_parts[$php_i] = highlight_php_code($php_string . $php_parts[$php_i]);
}

// Fix the PHP code stuff...
$data[0] = str_replace("<pre style=\"display: inline;\">\t</pre>", "\t", implode(\'\', $php_parts));

$data = addLineNumbers($data);


the Last line shoud be: $data[0] = addLineNumbers($data[0]);

falguni1


Advertisement: