Feature #4267
open<code> block improvements
0%
Description
I think it would be useful to implement the following features1 for code
block
Source code:
<pre><code class="ruby">
# The Greeter class
class Greeter
def initialize(name)
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
</code></pre>
Result:
# The Greeter class
class Greeter
def initialize(name)
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
:line_numbers2¶
<code class="ruby" lineNumbers="yes">.....</code>
<code class="ruby" lineNumbers="no">.....</code>
:line_number_start2¶
<code class="ruby" start="50">.....</code>
:bold_every2¶
<code class="ruby" every="2">.....</code>
:highlight_lines2¶
<code class="ruby" highlight="1,3,5,7">.....</code>
title¶
<code class="ruby" title="/path/to/file.rb">.....</code>
1 This standard features in CodeRay, but unfortunately not supported in Redmine :(
2 CodeRay HTML Encoder options
Files
Related issues
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.
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.
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:
- Suppress the line numbers
:line_numbers => nil
- Use the table method:
:line_numbers => :table
- 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.
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:
- Suppress the line numbers
[...]- Use the table method:
[...]- 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.
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!
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