Feature #3382

Ability to select only source code without line numbers

Added by Gregor Bader about 8 years ago. Updated almost 3 years ago.

Status:NewStart date:2009-05-18
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Text formatting
Target version:Candidate for next major release
Resolution:

Description

Currently if you use

<pre><code class="ruby">
  Place you code here.
</code>

to insert code into somewhere you are not able to copy/paste only the code! The line numbers are selected, too!
Perhaps update of coderay could solve this?
require 'rubygems'
require 'coderay'
tokens = CodeRay.scan <<-'CODE', :ruby
  puts %[Hello, world!]
  puts "Here\'s some #@@weird #{ { :code => "for you" } }" 
CODE
print tokens.div(:line_numbers => :table, :css => :class)

code_table_line_numbers.png (79.6 KB) Eric Thomas, 2010-04-06 15:34

syntax_highlighter.png - Screenshot of 3 updates (49.4 KB) Eric Thomas, 2010-04-14 06:05

syntax_highlighter_patch.diff Magnifier - Line Number patch (5.07 KB) Eric Thomas, 2010-04-14 06:05


Related issues

Related to Redmine - Feature #4267: <code> block improvements New 2009-11-23
Related to Redmine - Feature #4264: Update CodeRay to 1.0 final Closed
Duplicated by Redmine - Feature #8578: Code selection shouldn't get line numbers Closed 2011-06-09
Duplicated by Redmine - Feature #9613: Line numbers copied in repository file view Closed 2011-11-20
Duplicated by Redmine - Feature #14469: change source code browser's html layout Closed
Blocked by Redmine - Feature #8255: Consider updating CodeRay to 1.0 RC-x Closed

Associated revisions

Revision 8541
Added by Etienne Massip over 5 years ago

Prevent selection of line numbers when selecting file/code contents (#3382).

History

#1 Updated by Nelson LaQuet about 8 years ago

+1

This bugs me as well

#2 Updated by Abhi Beckert almost 8 years ago

I have personally hacked app/views/wiki/show.rhtml to have this at the end of the page:

<script type="text/javascript">
  if ($$('.CodeRay .no').length > 0) {
    document.write('<p><a href="javascript:$$(\'.CodeRay .no\').each(function(el) { el.hide(); });">Hide Line No\'s in code snippets</a></p>');
  }
</script>

This will create a Hide Line No's in code snippet link, I add it above the attachment html, after the page content (note: it must be after the content, or it won't work).

#3 Updated by Josh Galvez about 7 years ago

I notice that on the coderay website, their examples can be copied without line numbers.
http://coderay.rubychan.de/

#4 Updated by Josh Galvez about 7 years ago

at r3608 you need to add:

<script type="text/javascript">
  if ($$('.syntaxhl .no').length > 0) {
      document.write('<p class="other-formats"><a href="javascript:$$(\'.syntaxhl .no\').each(function(el) { el.hide(); });">Hide Line No\'s in code snippets</a></p>');
  }
</script>

I put it in app/views/issues/show.rhtml, immediately before: <% other_formats_links do |f| %>

#5 Updated by Kornelius Kalnbach about 7 years ago

Yes, CodeRay allows copy-friendly, line-numbered code via the :line_numbers => :table option. It has problems, too, but it's the preferred method.

#6 Updated by Eric Thomas about 7 years ago

Has anybody tried a fix for this.

Kornelius's fix should be in lib/redmine/syntax_highlighting.rb, changing

def highlight_by_language(text, language)
  ::CodeRay.scan(text, language).html(:line_numbers => :inline)
end

to

def highlight_by_language(text, language)
  ::CodeRay.scan(text, language).html(:line_numbers => :table)
end

however, the current stylesheet doesn't define anything for table attributes for the syntax CSS class so rendering produces something like the attached screenshot.

#7 Updated by Kornelius Kalnbach about 7 years ago

By the way, CodeRay 1.0 will have the :line_number_anchors option, too. Maybe it helps to find a solution. There's no release date for 1.0 set yet.

#8 Updated by Eric Thomas about 7 years ago

So I sort of got this to work...

Please look at the screenshot first:
  • The first update it highlighting the text without the numbers
  • The second update shows it with the line numbers toggled.
  • The third is it wrapped inside a pre tag (the other two aren't, but should be), and there's a little bit of space around the table on the top and right side, and a lot of space under the table.

I have provided a patch. However, the CSS is not set up properly.
For some reason, I could not get the .syntaxhl table to work, so I had to use table.CodeRay as the identifier.

#9 Updated by Kornelius Kalnbach about 7 years ago

Would it be helpful to add an option for the name of the CSS class to the HTML encoder? It would default to ".CodeRay", but could be changed to ".syntaxhl" for Redmine.

#10 Updated by Eric Thomas about 7 years ago

Kornelius Kalnbach wrote:

Would it be helpful to add an option for the name of the CSS class to the HTML encoder? It would default to ".CodeRay", but could be changed to ".syntaxhl" for Redmine.

That wouldn't quite make any sense sense it would say <table class="CodeRay"> Can any CSS expert chime in here? The output right now with the inline option is:

<pre><code class="ruby syntaxhl"><span class="CodeRay">....</span></code></pre>

By using the table option:

<pre><code class="ruby syntaxhl"><table class="CodeRay">...</table></code></pre>

So the only thing that changed was changing the span to table. Trying to do the following doesn't take effect, not sure why.

.syntax table {
  some random attributes....
}

#11 Updated by Eric Thomas about 7 years ago

Whoops for some reason what I said got picked up by the parser :)

Kornelius, if one were to change it to syntaxhl then it would declare the class for both the code/span tag which would be redundant.

Can any CSS experts help out here?

#12 Updated by Andrew Brock over 6 years ago

@Eric,

I've tested your patch and I would put it onto my Redmine production machine except for one thing. For code snippets of > 30 lines the line numbers don't match up with the code anymore. At ~35 lines the line number is roughly one line before the line it references and at roughly 70 lines the line numbers are two lines ahead of the code.

I should note that I'm patching against an already heavily modified snapshot of my production install so it could be that.

Unfortunately I'm not a CSS expert (or even a novice) so I can't help in that area.

#13 Updated by Etienne Massip almost 6 years ago

  • Target version set to Candidate for next major release

#14 Updated by Not Needed over 5 years ago

what's the status on this?

#15 Updated by Etienne Massip over 5 years ago

  • Target version changed from Candidate for next major release to 1.4.0

Fixed with r8541, requires a browser supporting the user-select CSS3 rule.

From what I know and see, FF supports it well now, Chrome still copy the line numbers and IE10 should support it but not tried.

#16 Updated by Etienne Massip over 5 years ago

  • Target version changed from 1.4.0 to Candidate for next major release

This actually is a temporary fix as the css3-ui specification has dropped the user-select property.

#17 Updated by Not Needed over 5 years ago

For now I have added the code below to scm.css on elemen .syntaxhl .no and works, even in chrome.

        user-select: none;
        -moz-user-select: none;
        -o-user-select: none;
        -ms-user-select: none;
        -webkit-user-select: none;

Basically, in a future version of redmine, CodeRay should be updated, since they've incoperated a solution that works without -user-select. Take a look at the example-page: [[http://coderay.rubychan.de/rays#n7]]. An even better solution would be if it were possible to install your own highlighters.

#18 Updated by Etienne Massip over 5 years ago

Not Needed wrote:

For now I have added the code below to scm.css on elemen .syntaxhl .no and works, even in chrome.

In my version of Chromium (17 and some bananas (French expression)), the selection is visually Ok but copying & pasting in a text editor would paste line numbers too.

Besides, it seems that Firefox has recently updated its code and, according to MDN definition of none value, could copy Chrome behaviour.

So I plan to revert this change.

Basically, in a future version of redmine, CodeRay should be updated, since they've incoperated a solution that works without -user-select. Take a look at the example-page: [[http://coderay.rubychan.de/rays#n7]]. An even better solution would be if it were possible to install your own highlighters.

CodeRay version 1.0 has been integrated into Redmine and already allow this.
The problem with the way CodeRay displays rays is that it doesn't allow line wrapping because it basically renders a table containing a tr and a th for line numbers and a td for code.

That would be a regression.

There is a way to fix this issue properly but this requires that CodeRay fixes this issue first.

#19 Updated by rm user almost 5 years ago

Any update on this?

I'm on 1.3 stable redmine still. Is there a workaround for FF 13 & latest Chrome?

Tried suggested fix with user-select but it didn't work out.

Thanks

#20 Updated by Roger Hunwicks almost 5 years ago

For me, the user-select fix doesn't look like it is working, but in fact it does.

What I mean is that when I select text I get the full table, including the line numbers, but when I paste it I get just the code, which is what I want.

#21 Updated by rm user almost 5 years ago

Roger Hunwicks wrote:

For me, the user-select fix doesn't look like it is working, but in fact it does.

What I mean is that when I select text I get the full table, including the line numbers, but when I paste it I get just the code, which is what I want.

I got this working, but FF still selects numbers tho :( If you copy from FF text is correct however.

Would be good to have final solution, examples on Coderays website works just fine for me.

#22 Updated by rm user almost 5 years ago

Chrome selects text just fine with this hack, but on copy it copies numbers as well.

Firefox copies without numbers but with blank lines between code lines. When you select in Firefox numbers also selected.

Such a nasty bug... Almost 3 years and still no fix! :(

#23 Updated by Kornelius Kalnbach almost 5 years ago

Hi, CodeRay maintainer here ;) Sorry, I have to catch up to this…so, we have:

  • :line_numbers => :table, which successfully prevents you from selecting the line numbers while copying on all browsers (right?)
  • :line_numbers => :inline, which allows line breaking, but behaves strange on some browsers when it comes to line number selection/copying

I try to mark this piece of code with my mouse completely:

One :line
another "line" 
  • In Firefox, it marks the "2" (bad), but doesn't copy it (good).
  • In Chrome and Safari, it doesn't mark the numbers (good), but copies it (wrong - WTF Webkit?).
  • I did not try IE.

I would suggest using :table. Unfortunately, the table implementation CodeRay uses does not allow lines to be wrapped. But what is the benefit in line wrapping anyway?

#24 Updated by rm user almost 5 years ago

Kornelius Kalnbach wrote:

I try to mark this piece of code with my mouse completely:

[...]

  • In Firefox, it marks the "2" (bad), but doesn't copy it (good).
  • In Chrome and Safari, it doesn't mark the numbers (good), but copies it (wrong - WTF Webkit?).
  • I did not try IE.

in IE it selects numbers and does copy numbers.

I would suggest using :table. Unfortunately, the table implementation CodeRay uses does not allow lines to be wrapped. But what is the benefit in line wrapping anyway?

Thanks for the update, but it's not working for me with table directive in redmine, I'm having same result as you, probably due wrapping. Also copying in firefox adds additional blank lines between lines..

#25 Updated by Etienne Massip almost 5 years ago

Kornelius Kalnbach wrote:

Hi, CodeRay maintainer here ;) Sorry, I have to catch up to this…so, we have:

  • :line_numbers => :table, which successfully prevents you from selecting the line numbers while copying on all browsers (right?)
  • :line_numbers => :inline, which allows line breaking, but behaves strange on some browsers when it comes to line number selection/copying

I try to mark this piece of code with my mouse completely:

[...]

  • In Firefox, it marks the "2" (bad), but doesn't copy it (good).
  • In Chrome and Safari, it doesn't mark the numbers (good), but copies it (wrong - WTF Webkit?).
  • I did not try IE.

Whatever, user-select, which BTW is no more part of CSS3 specification, is supposed to work this way (having only a visual effect ).

I would suggest using :table. Unfortunately, the table implementation CodeRay uses does not allow lines to be wrapped. But what is the benefit in line wrapping anyway?

Well, it is common use with Redmine to browse code contents in files that can be easily big enough so that wrapping lines is pretty more confortable than paging down to the bottom of the file were we'd find the horizontal scroller and paging up back to the line.

I've done some trials to keep wrapping with :inline and have only code selected but nothing really worked for now, if you have some suggestion...

#26 Updated by rm user almost 5 years ago

Etienne Massip wrote:

Kornelius Kalnbach wrote:

Hi, CodeRay maintainer here ;) Sorry, I have to catch up to this…so, we have:

  • :line_numbers => :table, which successfully prevents you from selecting the line numbers while copying on all browsers (right?)
  • :line_numbers => :inline, which allows line breaking, but behaves strange on some browsers when it comes to line number selection/copying

I try to mark this piece of code with my mouse completely:

[...]

  • In Firefox, it marks the "2" (bad), but doesn't copy it (good).
  • In Chrome and Safari, it doesn't mark the numbers (good), but copies it (wrong - WTF Webkit?).
  • I did not try IE.

Whatever, user-select, which BTW is no more part of CSS3 specification, is supposed to work this way (having only a visual effect ).

I would suggest using :table. Unfortunately, the table implementation CodeRay uses does not allow lines to be wrapped. But what is the benefit in line wrapping anyway?

Well, it is common use with Redmine to browse code contents in files that can be easily big enough so that wrapping lines is pretty more confortable than paging down to the bottom of the file were we'd find the horizontal scroller and paging up back to the line.

I've done some trials to keep wrapping with :inline and have only code selected but nothing really worked for now, if you have some suggestion...

I did some more testings:

  • Opera - doesn't copy line numbers / DOES select
  • Firefox - doesn't copy line numbers, BUT does insert blank lines between lines / DOES select
  • Chrome - DOES copy line numbers / doesn't select
  • IE - DOES copy line numbers / DOES select

Any idea how to make it work in ALL browsers?

Thanks

#27 Updated by Kornelius Kalnbach almost 5 years ago

wrapping lines is pretty more confortable than paging down to the bottom of the file were we'd find the horizontal scroller and paging up back to the line.

Your computer/os/mouse/trackpad doesn't support horizontal scrolling? Wow…never thought about that. It's super easy on a Mac.

Well, I don't see how we can have both. table allows for selecting lines without numbers, but not for line wrapping (because the line number column would not match with the code lines any more). inline could wrap, but copies line numbers because user-select is non-standard and doesn't work as needed.

Seems to come down to a decision which is less problematic: Either you leave the line numbers out, or you stick with horizontal scrolling.

#28 Updated by rm user almost 5 years ago

Kornelius Kalnbach wrote:

wrapping lines is pretty more confortable than paging down to the bottom of the file were we'd find the horizontal scroller and paging up back to the line.

Your computer/os/mouse/trackpad doesn't support horizontal scrolling? Wow…never thought about that. It's super easy on a Mac.

Well, I don't see how we can have both. table allows for selecting lines without numbers, but not for line wrapping (because the line number column would not match with the code lines any more). inline could wrap, but copies line numbers because user-select is non-standard and doesn't work as needed.

Seems to come down to a decision which is less problematic: Either you leave the line numbers out, or you stick with horizontal scrolling.

thanks for the update Kornelius!

what about github? does it use line-wrapping ? really need it solved, this issue has been for 4 years - so sucks :(

EDIT: yes, github DOES not use line-wrapping. (example: https://github.com/kubitron/redmine_git_hosting/blob/master/init.rb). Any idea how to hack redmine to make it work without wrapping and using tables? I did change coderay to line-numbers => :table but it didn't work for me still the same effect.. I'm on redmine 1.4.

Redmine really lacks of user feedback (or ignores it?). Quite sure lots of redmine users would find helpful proper code highlighting even without wrapping.. Or maybe integrate into core a switch which gives you opportunity to select what to use line-wrapping or not..
Maybe someone could write a plugin to make redmine 'not wrap lines' ? (i'm not good in ruby unfortunately).

#29 Updated by Naomasa Takasaki almost 5 years ago

Hello everyone.

I hacked and solved this problem.

Correct this file.
file:
[redminedir]/app/views/repositories/_link_to_functions.rhtml

<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
----add under here-----
<script type="text/javascript">
function row_hidden(){
var elements = document.getElementsByClassName("line-num");
for (var i=0;i<elements.length; i++){
elements[i].style.visibility='hidden';
}
}
function row_visible(){
var elements = document.getElementsByClassName("line-num");
for (var i=0;i<elements.length; i++){
elements[i].style.visibility='visible';
}
}
</script>

| row number:
<a href="#" onclick="row_visible();">show</a>/
<a href="#" onclick="row_hidden();">hide</a>

#30 Updated by rm user almost 5 years ago

Naomasa Takasaki wrote:

Hello everyone.

I hacked and solved this problem.

Correct this file.
file:
[redminedir]/app/views/repositories/_link_to_functions.rhtml

<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
----add under here-----
<script type="text/javascript">
function row_hidden(){
var elements = document.getElementsByClassName("line-num");
for (var i=0;i<elements.length; i++){
elements[i].style.visibility='hidden';
}
}
function row_visible(){
var elements = document.getElementsByClassName("line-num");
for (var i=0;i<elements.length; i++){
elements[i].style.visibility='visible';
}
}
</script>

| row number:
<a href="#" onclick="row_visible();">show</a>/
<a href="#" onclick="row_hidden();">hide</a>

thanks for this it worked, except, there is blank lines between copied lines.

any idea how to fix this?

#31 Updated by Naomasa Takasaki almost 5 years ago

thanks for this it worked, except, there is blank lines between copied lines.
any idea how to fix this?

Please wait. I try correction of the code.
Probably i will remove line-num tags.

and In a Chrome Browser, a blank and a row number are nothing and commit the code.

#32 Updated by rm user almost 5 years ago

Naomasa Takasaki wrote:

thanks for this it worked, except, there is blank lines between copied lines.
any idea how to fix this?

Please wait. I try correction of the code.
Probably i will remove line-num tags.

and In a Chrome Browser, a blank and a row number are nothing and commit the code.

Yes, in chrome it works just fine - happens for me in Firefox.

Chrome stips ALL blank lines, even blank lines in original code.

Opera - works fine.

IE 9 - 4 blank lines between code lines

#33 Updated by Naomasa Takasaki almost 5 years ago

please try this code.
this code was tested using IE8,Chrome,Firefox,safari and redmine 1.2.1.

[redmine dir]/app/views/repositories/_link_to_functions.rhtml

<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
---add under here---
<script type="text/javascript">
function row_hidden(){
var syntaxhl_on  = document.getElementById("syntaxhl_on");
var syntaxhl_off = document.getElementById("syntaxhl_off");
syntaxhl_on.style.display='none';
syntaxhl_off.style.display='block';
}

function row_visible(){
var syntaxhl_on  = document.getElementById("syntaxhl_on");
var syntaxhl_off = document.getElementById("syntaxhl_off");
syntaxhl_on.style.display='block';
syntaxhl_off.style.display='none';
}
</script>

| row number:
<a href="#" onclick="row_visible();">show</a>/
<a href="#" onclick="row_hidden();">hide</a>
---add above here---
</p>
<% end %>

[redmine dir]/app/views/common/_file.rhtml

<div class="autoscroll">
<table class="filecontent syntaxhl">
<tbody>
<% line_num = 1 %>
<% syntax_highlight(filename, to_utf8(content)).each_line do |line| %>
<tr><th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th><td class="line-code"><pre><%= line %></pre></td></tr>
<% line_num += 1 %>
<% end %>
</tbody>
</table>
</div>


<div class="autoscroll">
<div id="syntaxhl_on" style="display:block">
<table class="filecontent syntaxhl">
<tbody>
<% line_num = 1 %>
<% syntax_highlight(filename, to_utf8(content)).each_line do |line| %>
<tr><th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th><td class="line-code"><pre><%= line %></pre></td></tr>
<% line_num += 1 %>
<% end %>
</tbody>
</table>
</div>
<div id="syntaxhl_off" style="display:none">
<table class="filecontent syntaxhl">
<tbody>
<tr>
<th style="display:none"></th>
<td class="line-code">
<pre>
<%= content %>
</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>

#34 Updated by rm user almost 5 years ago

Naomasa Takasaki wrote:

please try this code.
this code was tested using IE8,Chrome,Firefox,safari and redmine 1.2.1.

[redmine dir]/app/views/repositories/_link_to_functions.rhtml
[...]

[redmine dir]/app/views/common/_file.rhtml

[...]</td></tr>
<% line_num += 1 >
<
end >
</tbody>
</table>
</div>


[...]</td></tr>
<
line_num += 1 >
<
end %>
</tbody>
</table>
</div>
<div id="syntaxhl_off" style="display:none">
<table class="filecontent syntaxhl">
<tbody>
<tr>
<th style="display:none"></th>
<td class="line-code">
[...]
</td>
</tr>
</tbody>
</table>
</div>
</div>

Thanks it works, but it's not working in code blocks paste into issue or wiki etc.

i.e. with

<pre><code class="ruby">sdsds dsds</code>

#35 Updated by Naomasa Takasaki almost 5 years ago

The code is running only in repository.
you should upgrade javascript syntaxhighlight plugin.

#36 Updated by rm user almost 5 years ago

Naomasa Takasaki wrote:

The code is running only in repository.
you should upgrade javascript syntaxhighlight plugin.

I'm already on the latest 1.4 redmine. What do I need to do? Could you point me exactly?

#37 Updated by Naomasa Takasaki almost 5 years ago

Don't worry.

I am already works in code blocks paste into issue or wiki etc on redmine 1.2.1.

Please go to SyntaxHighlighter official website and get newest Syntaxhighlighter plugin.

http://alexgorbatchev.com/SyntaxHighlighter/

please copy:
[download zip file]/styles/* to [redmine]/public/stylesheets/
[download zip file]/scripts/* to [redmine]/public/javascripts/

register this code near an alike code:
[redminedir]/vendor/plugins/redmine_js_syntax_highlighter/lib/syntaxhighlighter.rb

o << javascript_include_tag("/javascripts/shBrushRuby.js")
o << javascript_include_tag("/javascripts/shBrush****.js")

please restart httpd.

change code syntax:
<pre class="brush: ruby">
puts "Hello World"
</pre>

and please write this code wiki or etc..
(This code does not work in preview mode.)

#38 Updated by rm user almost 5 years ago

Naomasa Takasaki wrote:

Don't worry.

I am already works in code blocks paste into issue or wiki etc on redmine 1.2.1.

Please go to SyntaxHighlighter official website and get newest Syntaxhighlighter plugin.

http://alexgorbatchev.com/SyntaxHighlighter/

please copy:
[download zip file]/styles/* to [redmine]/public/stylesheets/
[download zip file]/scripts/* to [redmine]/public/javascripts/

register this code near an alike code:
[redminedir]/vendor/plugins/redmine_js_syntax_highlighter/lib/syntaxhighlighter.rb

o << javascript_include_tag("/javascripts/shBrushRuby.js")
o << javascript_include_tag("/javascripts/shBrush****.js")

please restart httpd.

change code syntax:
<pre class="brush: ruby">
puts "Hello World"
</pre>

and please write this code wiki or etc..
(This code does not work in preview mode.)

Thanks a lot will try this bit later!

#39 Updated by rm user almost 5 years ago

hi! thanks again for this suggestion, but it's bit not comfort to use custom <pre class> instead of the usual <code> block.

could you make it work using standard <code> block ?

#40 Updated by Naomasa Takasaki almost 5 years ago

code tag should be replaced with script tag.

http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html

but, in redmine ,script tag is not works.

probably,redmine syntaxhighlighter plugin,It does not correspond to the newest version of syntaxhighlighter.

https://github.com/k2s/redmine_js_syntax_highlighter/blob/master/lib/syntaxhighlighter.rb

The comment about a script tag is not found in the code.

#41 Updated by rm user almost 5 years ago

Naomasa Takasaki wrote:

code tag should be replaced with script tag.

http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html

but, in redmine ,script tag is not works.

probably,redmine syntaxhighlighter plugin,It does not correspond to the newest version of syntaxhighlighter.

https://github.com/k2s/redmine_js_syntax_highlighter/blob/master/lib/syntaxhighlighter.rb

The comment about a script tag is not found in the code.

does it load .js files from alexgorbachev's site? would really like standalone-solution so I don't need to load any 3rd party files from websites, especially if redmine installed inside the local area.

sorry, if i'm sounding too much demanding :) your solution with hide/show so far working great for me in repository view (althrough it's still to be considered a dirty hack).

i'm still waiting for redmine maintainers to look at this issue closer and make relevant changes inside redmine's core system.

#42 Updated by rm user almost 5 years ago

even if i will use the proposed syntax highlighter if I try to use diff between revisions lines would be still copied :(

so needs a solution which will fix this in the redmine's core.

#43 Updated by Terence Mill almost 5 years ago

+1

#44 Updated by rm user about 4 years ago

installed latest stable 2.2.4

issue is still happening here

any update?

#45 Updated by Mischa The Evil about 4 years ago

AFAIK line numbering is removed from CodeRay syntax highlighting completely with r10131 (first included in Redmine 2.1.0).

#46 Updated by Etienne Massip about 4 years ago

Mischa The Evil wrote:

AFAIK line numbering is removed from CodeRay syntax highlighting completely with r10131 (first included in Redmine 2.1.0).

Sure but Redmine itself generates line numbers and you still can't copy/paste without pasting them along with the selected source code.

#47 Updated by rm user about 4 years ago

I don't want to sound like a b*tch, but why all these new versions for ?

If basic bugs like this, cant be fixed and need to use workarounds for that .. :/

#48 Updated by Etienne Massip about 4 years ago

rm user wrote:

I don't want to sound like a b*tch, but why all these new versions for ?

What versions are you talking about?

If basic bugs like this, cant be fixed and need to use workarounds for that .. :/

This bug may look basic but is actually a bit tricky, do you have a neat fix for this? I mean, without changing actual default theme behavior which is that lines can be wrapped?

#49 Updated by rm user about 4 years ago

Etienne Massip wrote:

rm user wrote:

I don't want to sound like a b*tch, but why all these new versions for ?

What versions are you talking about?

I mean there are new versions coming 2.0, 2.1, 2.2, now 2.3 in development..

If basic bugs like this, cant be fixed and need to use workarounds for that .. :/

This bug may look basic but is actually a bit tricky, do you have a neat fix for this? I mean, without changing actual default theme behavior which is that lines can be wrapped?

I understand the issue is bit harder, the only fix that worked for me so far in the repo code is http://www.redmine.org/issues/3382#note-33

but you need to click each time before you copy anything.

#50 Updated by rm user about 4 years ago

any comments on the above?

#51 Updated by Etienne Massip about 4 years ago

rm user wrote:

any comments on the above?

Not really; #3382#note-33 proposal is JavaScript and not what I was thinking when I talked about a neat fix, sounds more like overkill to me.

#52 Updated by Christoph Dwertmann about 4 years ago

I created a plugin that turns line numbering back on and adds a toggle to each page to turn it off (for copy & paste):
http://www.redmine.org/plugins/line_numbers

Enjoy!

#53 Updated by Toshi MARUYAMA almost 4 years ago

  • Duplicated by Feature #14469: change source code browser's html layout added

#54 Updated by Sergey B over 3 years ago

+1

#55 Updated by rm user over 3 years ago

+100500 !!!

still not fixed, had to use workaround :/

#56 Updated by Stefan Tatschner over 3 years ago

+2

#57 Updated by Billy T almost 3 years ago

This is not a feature. This is really a bug!
+infinity

Also available in: Atom PDF