Line numbers in syntax tags?
Moderator: General Moderators
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Line numbers in syntax tags?
Would this be a huge deal to implement?
It sure would be neat.
It sure would be neat.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
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).
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
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 appropriateCode: Select all
tags. Post anyway?"- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
ole wrote:How about an algorithm that searches for possible PHP code not wrapped inCode: Select all
tags and displays a confirmation alert: "This message appears to contain PHP code, please ensure you have used the appropriate[/syntax]Code: Select all
tags. Post anyway?"[/quote] [syntax="php"]if(strpos($post_body, "ahhh!!1 helpz! my script iz broked!! rofl") !== false)...
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.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).
I went through this when building the previous php highlighter with all its neat features..
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
aaronhall wrote:ole wrote:How about an algorithm that searches for possible PHP code not wrapped inCode: Select all
tags and displays a confirmation alert: "This message appears to contain PHP code, please ensure you have used the appropriateCode: 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]
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
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
Stick it in your browser and have a look.
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>- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
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)feyd wrote: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.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).
I went through this when building the previous php highlighter with all its neat features..