Page 1 of 2

Line numbers in syntax tags?

Posted: Fri Jan 19, 2007 5:33 pm
by daedalus__
Would this be a huge deal to implement?

It sure would be neat.

Posted: Fri Jan 19, 2007 5:55 pm
by Luke
sure would

Posted: Fri Jan 19, 2007 5:56 pm
by Kieran Huggins
The Ninja Space Goat wrote:sure would
be neat? or a huge deal? :?: :twisted:

Posted: Fri Jan 19, 2007 6:28 pm
by Ambush Commander
Make sure it gets implemented properly though. I don't want to be copy-pasting code and having the line numbers tag-along for the ride.

Posted: Fri Jan 19, 2007 7:30 pm
by aaronhall
It appears that this was implemented at some point (see the last post in this thread). I'm guessing that it was dumped because of the size of the formatted code. Evil Walrus uses Geshi, as does PHPDN, and it isn't difficult at all to implement line numbers... and it has an option that doesn't include the line numbers when you copy (at the expense of more formatting).

Posted: Sat Jan 20, 2007 4:02 am
by m3mn0n
Indeed we did have that.

It was neat in that is also allowed you to specify a starting number for the counting, so it didn't always read from 1-x.

Would be cool to have, but what would be cooler is if more rookies used the syntax highlighting to begin with. ;)

Posted: Sat Jan 20, 2007 4:07 am
by Ollie Saunders
How about an algorithm that searches for possible PHP code not wrapped in

Code: Select all

tags and displays a confirmation alert: "This message appears to contain PHP code, please ensure you have used the appropriate

Code: Select all

tags. Post anyway?"

Posted: Sat Jan 20, 2007 4:39 am
by aaronhall
ole wrote:How about an algorithm that searches for possible PHP code not wrapped in

Code: Select all

tags and displays a confirmation alert: "This message appears to contain PHP code, please ensure you have used the appropriate

Code: Select all

tags. Post anyway?"[/quote]

[syntax="php"]if(strpos($post_body, "ahhh!!1 helpz! my script iz broked!! rofl") !== false)...
[/syntax]

Posted: Sat Jan 20, 2007 8:02 am
by feyd
aaronhall wrote:It appears that this was implemented at some point (see the last post in this thread). I'm guessing that it was dumped because of the size of the formatted code. Evil Walrus uses Geshi, as does PHPDN, and it isn't difficult at all to implement line numbers... and it has an option that doesn't include the line numbers when you copy (at the expense of more formatting).
Unless there's some weird settings, it's not entirely possible to block copying of the line numbers unless you do some very wishful tricks using a table, but then you encounter problems if code wraps lines.

I went through this when building the previous php highlighter with all its neat features..

Posted: Sat Jan 20, 2007 8:03 am
by Kieran Huggins
aaronhall wrote:
ole wrote:How about an algorithm that searches for possible PHP code not wrapped in

Code: Select all

tags and displays a confirmation alert: "This message appears to contain PHP code, please ensure you have used the appropriate

Code: Select all

tags. Post anyway?"[/quote]

[syntax="php"]if(strpos($post_body, "ahhh!!1 helpz! my script iz broked!! rofl") !== false)...


1 |\|33d3d th4t l0lz

You made me squirt hot tea out of my nose, aaron.. jerk![/syntax]

Posted: Sat Jan 20, 2007 11:24 am
by Ollie Saunders
I'm not sure if this is valid or if it will work in IE (I'm on my Mac atm) but seems good in Firefox

Code: Select all

<style>
pre.code, pre.code p {
   margin:0; padding:0;
   font-family:monospace;
}
pre.code p:before {
   content:attr(l);
   margin-right:5px;
   padding-right:5px;
   border-right:1px solid #000;
}
pre.code p {
   display:inline;
}
pre.code p:hover {
   color:#33a;
}
</style>
<pre class="code"><p l="001"><?php</p>
<p l="020">$foo   = 5; // whitespace preserved</p>
<p l="030">$bar = 6;   // minimal mark-up</p>
<p l="400">echo $foo + $bar, '<br />';</p>
</pre>
Stick it in your browser and have a look.

Posted: Sat Jan 20, 2007 11:30 am
by Ambush Commander
Opera will select the line numbers.

Posted: Sat Jan 20, 2007 11:32 am
by Ollie Saunders
That, is one of many reasons why I don't use Opera. :)

Posted: Sat Jan 20, 2007 11:34 am
by Ambush Commander
Actually, I find that behavior preferable. For instance, if you're using content before and after to style <q> tags, they'll look okay in Firefox but then disappear mysteriously if you try to copy paste them. Opera does the more correct behavior.

Posted: Sat Jan 20, 2007 2:44 pm
by aaronhall
feyd wrote:
aaronhall wrote:It appears that this was implemented at some point (see the last post in this thread). I'm guessing that it was dumped because of the size of the formatted code. Evil Walrus uses Geshi, as does PHPDN, and it isn't difficult at all to implement line numbers... and it has an option that doesn't include the line numbers when you copy (at the expense of more formatting).
Unless there's some weird settings, it's not entirely possible to block copying of the line numbers unless you do some very wishful tricks using a table, but then you encounter problems if code wraps lines.

I went through this when building the previous php highlighter with all its neat features..
Hmmm... I went back to check their demo highlighter with the "fancy line numbers" option enabled, and the line numbers still copied. I could have sworn that they hacked it so that the line numbers wouldn't copy. Anyway, if they do copy, that's the deal breaker for me.. (though it would be sooo nice to have line numbers)