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

soxofaan’s picture

Status: Active » Closed (works as designed)

the <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.

nicholas.alipaz’s picture

ok, 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.

nicholas.alipaz’s picture

Well, 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:

div.javascript i{counter-increment: lnumber;display:block;}
div.javascript i:before{content: counter(lnumber) ". ";}

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:

<div class="javascript" style="...">
<i><span class="co1">// Testing</span></i><br>
&nbsp; <i><span class="kw3">alert</span><span class="br0">(</span><span class="st0">"hello world!"</span><span class="br0">)</span><span class="sy0">;</span></i>
</div>
soxofaan’s picture

Well, I have posted in Geshi forum on sourceforge regarding this

be welcome to provide the link to that thread

One could add to the stylesheet something like:...

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.

nicholas.alipaz’s picture

Jean-Philippe Fleury’s picture

subscribing.

leprechau’s picture

Feel free to use the workaround I propsed for 'text file downloads' to resolve this issue also:

http://drupal.org/node/221707#comment-2196722

-- Aaron

soxofaan’s picture

Status: Closed (works as designed) » Closed (duplicate)

This 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