Line numbers in syntax tags?

We know you have an opinion on how things should be run around here. These are suggestions for the forums, and the website.This forum is not a place to ask for suggestions to your own coding (or otherwise) problems.

Moderator: General Moderators

User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Line numbers in syntax tags?

Post by daedalus__ »

Would this be a huge deal to implement?

It sure would be neat.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

sure would
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

The Ninja Space Goat wrote:sure would
be neat? or a huge deal? :?: :twisted:
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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).
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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. ;)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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?"
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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]
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post 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.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Opera will select the line numbers.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

That, is one of many reasons why I don't use Opera. :)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post 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)
Post Reply