Project

General

Profile

Actions

Feature #4267

open

<code> block improvements

Added by Aleksej Lebedev almost 15 years ago. Updated about 12 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Text formatting
Target version:
-
Start date:
2009-11-23
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

I think it would be useful to implement the following features1 for code block

Source code:

&lt;pre&gt;&lt;code class="ruby"&gt;
# The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize
  end

  def salute
    puts "Hello #{@name}!" 
  end
end
&lt;/code&gt;&lt;/pre&gt;

Result:

# The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize
  end

  def salute
    puts "Hello #{@name}!" 
  end
end

:line_numbers2

&lt;code class="ruby" lineNumbers="yes"&gt;.....&lt;/code&gt;
&lt;code class="ruby" lineNumbers="no"&gt;.....&lt;/code&gt;

:line_number_start2

&lt;code class="ruby" start="50"&gt;.....&lt;/code&gt;

:bold_every2

&lt;code class="ruby" every="2"&gt;.....&lt;/code&gt;

:highlight_lines2

&lt;code class="ruby" highlight="1,3,5,7"&gt;.....&lt;/code&gt;

title

&lt;code class="ruby" title="/path/to/file.rb"&gt;.....&lt;/code&gt;


1 This standard features in CodeRay, but unfortunately not supported in Redmine :(

2 CodeRay HTML Encoder options


Files

Redmine_code_lineNumbers_no.png (5.51 KB) Redmine_code_lineNumbers_no.png Aleksej Lebedev, 2009-11-23 13:46
Redmine_code_start_50.png (6.39 KB) Redmine_code_start_50.png Aleksej Lebedev, 2009-11-23 13:46
Redmine_every_2.png (6.11 KB) Redmine_every_2.png Aleksej Lebedev, 2009-11-23 13:46
Redmine_highlight_1_3_5_7.png (6.22 KB) Redmine_highlight_1_3_5_7.png Aleksej Lebedev, 2009-11-23 13:46
Redmine_title.png (5.32 KB) Redmine_title.png Aleksej Lebedev, 2009-11-23 13:46

Related issues

Related to Redmine - Feature #3382: Ability to select only source code without line numbersClosed2009-05-18

Actions
Actions #1

Updated by Mischa The Evil almost 15 years ago

+10 from me on this one. I actually still had to file this issue myself... Thanks for doing it for me :)

These options really would make syntax-highlighting more useable IMHO.

Actions #2

Updated by Kornelius Kalnbach over 14 years ago

It seems to me that :line_number_start and highlight_lines are most useful. We should focus on them, to keep the highlighter plugin API simple, and ensure that other highlighters can adapt.

Actions #3

Updated by William Baum over 14 years ago

For me, the inability to cut and paste code without the line numbers is a deal-breaker. Furthermore, without representing file line numbers, I don't see how they add value. While the CODE blocks are prettier, the plain PRE blocks are better for exchanging code snippets, simply due to the line numbers.

In terms of usefulness and ease of implementation, the CodeRay features I'd like to see supported are:

  1. Suppress the line numbers
    :line_numbers => nil
    
  2. Use the table method:
    :line_numbers => :table
    
  3. Use actual file line numbers:
    :line_number_start
    

I did experiment with changing the line numbering method in lib/redmine/syntax_highlighting.rb.

nil works fine and does suppress the line numbers. :table will require some changes to the style declarations to get working properly, but would fix the clipboard issues. The samples on the CodeRay site that cut and paste well seem to be using the :table method.

Actions #4

Updated by Eric Thomas over 14 years ago

William Baum wrote:

For me, the inability to cut and paste code without the line numbers is a deal-breaker. Furthermore, without representing file line numbers, I don't see how they add value. While the CODE blocks are prettier, the plain PRE blocks are better for exchanging code snippets, simply due to the line numbers.

In terms of usefulness and ease of implementation, the CodeRay features I'd like to see supported are:

  1. Suppress the line numbers
    [...]
  2. Use the table method:
    [...]
  3. Use actual file line numbers:
    [...]

I did experiment with changing the line numbering method in lib/redmine/syntax_highlighting.rb.

nil works fine and does suppress the line numbers. :table will require some changes to the style declarations to get working properly, but would fix the clipboard issues. The samples on the CodeRay site that cut and paste well seem to be using the :table method.

William, if you get a chance please see my patch at #3382. Thanks.

Actions #5

Updated by Ling Li over 13 years ago

+1

I like William Baum's suggestion in note#3 a lot! Would this be put into some planned version?

William Baum wrote:

For me, the inability to cut and paste code without the line numbers is a deal-breaker.

Strongly agree!

Actions #6

Updated by Anthony Gerrard over 13 years ago

Generally +1

For me, the inability to cut and paste code without the line numbers is a deal-breaker.

+10 on this

Actions

Also available in: Atom PDF