I think it makes things quite difficult for users to have to copy text that has a bunch of pound signs in it.
Currently, if line numbers are enabled then copying text from the code box places a pound sign (#) on each line where the line number would have resided. I request that this be changed so that copying the text does not show the line numbers. Using the loop you are doing for adding the <li> tags to each line of the code you could instead add <span> tags to each line with a class defined to specify the line number, such as <span class="1"> then add some css like span.1:before {content:"1. "}
So the resulting code would look something like:
<style type="text/css">
div.geshifilter span.1:before {content:"1. "}
div.geshifilter span.2:before {content:"2. "}
div.geshifilter span.3:before {content:"3. "}
div.geshifilter span.4:before {content:"4. "}
div.geshifilter span.5:before {content:"5. "}
</style>
<div class="geshifilter">
<pre class="geshifilter-javascript">
<span class="1" style="font-family: monospace; font-weight: normal;">CODE_FROM_LINE_1</span>
<span class="2" style="font-family: monospace; font-weight: normal;">CODE_FROM_LINE_2</span>
<span class="3" style="font-family: monospace; font-weight: normal;">CODE_FROM_LINE_3</span>
<span class="4" style="font-family: monospace; font-weight: normal;">CODE_FROM_LINE_4</span>
<span class="5" style="font-family: monospace; font-weight: normal;">CODE_FROM_LINE_5</span>
</pre>
</div>
In turn, the line numbers would not copy when copying the text from the code box.
Comments
Comment #1
soxofaan commentedthe
<li>stuff is done by the GeSHi library,the GeSHi filter module is just a wrapper around that library and its features.
Moreover, I think your solution with CSS is not very scalable as it requires a dedicated CSS rule for every possible line number.
Comment #2
nicholas.alipaz commentedok, well thanks for reading anyhow. Still a big bother to me that I can't enable the line numbers on my site since we do a lot of copy/paste. I will have to look into a solution.
Comment #3
nicholas.alipaz commentedWell, I have posted in Geshi forum on sourceforge regarding this. I also reworked my idea and came up with this:
One could add to the stylesheet something like:
Then change the output of the line numbered format to be pretty much identical to that of no line numbers. One exception, add
<i>tags around each line. You could really use any tag you feel appropriate, that is just what I used in my testing.Like:
Comment #4
soxofaan commentedbe welcome to provide the link to that thread
Well, I think those CSS features are not well supported by today's (popular) browsers unfortunately.
In any case, this issue is a "by design" for the GeSHi filter module, as the feature should be provided by the GeSHi library.
Comment #5
nicholas.alipaz commentedhttp://sourceforge.net/forum/forum.php?thread_id=3078352&forum_id=393202
Comment #6
Jean-Philippe Fleury commentedsubscribing.
Comment #7
leprechau commentedFeel free to use the workaround I propsed for 'text file downloads' to resolve this issue also:
http://drupal.org/node/221707#comment-2196722
-- Aaron
Comment #8
soxofaan commentedThis issue has long been fixed yet by #518828: Table container (introduces a "table" container)
requires at least GeSHi 1.0.8
also see http://qbnz.com/highlighter/geshi-doc.html#the-code-container