mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 14:26:04 +01:00
Added code highlighting support in wiki, using this syntax:
<pre><code> <-- cut here
<pre><code class="ruby">
Place you code here.
</code></pre>
cut here --> </pre></code>
git-svn-id: http://redmine.rubyforge.org/svn/trunk@710 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -25,6 +25,10 @@ module Encoders
|
||||
#
|
||||
# == Options
|
||||
#
|
||||
# === :escape
|
||||
# Escape html entities
|
||||
# Default: true
|
||||
#
|
||||
# === :tab_width
|
||||
# Convert \t characters to +n+ spaces (a number.)
|
||||
# Default: 8
|
||||
@@ -70,6 +74,7 @@ module Encoders
|
||||
FILE_EXTENSION = 'html'
|
||||
|
||||
DEFAULT_OPTIONS = {
|
||||
:escape => true,
|
||||
:tab_width => 8,
|
||||
|
||||
:level => :xhtml,
|
||||
@@ -145,6 +150,7 @@ module Encoders
|
||||
@HTML_ESCAPE = HTML_ESCAPE.dup
|
||||
@HTML_ESCAPE["\t"] = ' ' * options[:tab_width]
|
||||
|
||||
@escape = options[:escape]
|
||||
@opened = [nil]
|
||||
@css = CSS.new options[:style]
|
||||
|
||||
@@ -222,7 +228,7 @@ module Encoders
|
||||
|
||||
def token text, type
|
||||
if text.is_a? ::String
|
||||
if text =~ /#{HTML_ESCAPE_PATTERN}/o
|
||||
if @escape && (text =~ /#{HTML_ESCAPE_PATTERN}/o)
|
||||
text = text.gsub(/#{HTML_ESCAPE_PATTERN}/o) { |m| @HTML_ESCAPE[m] }
|
||||
end
|
||||
@opened[0] = type
|
||||
|
||||
Reference in New Issue
Block a user