diff --git a/Gemfile b/Gemfile index bce2fe47..d7873c47 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source :rubygems gem "rails", "2.3.14" -gem "coderay", "~> 0.9.7" +gem "coderay", "~> 1.0.0" gem "i18n", "~> 0.4.2" gem "rubytree", "~> 0.5.2", :require => 'tree' gem "rdoc", ">= 2.4.2" diff --git a/app/views/help/wiki_syntax_detailed.html.erb b/app/views/help/wiki_syntax_detailed.html.erb index 26603f5f..50f7e00c 100644 --- a/app/views/help/wiki_syntax_detailed.html.erb +++ b/app/views/help/wiki_syntax_detailed.html.erb @@ -13,20 +13,22 @@ } a.new { color: #b73535; } - .CodeRay .c { color:#666; } + .syntaxhl .line-numbers { padding: 2px 4px 2px 4px; background-color: #eee; margin:0 } + .syntaxhl .comment { color:#666; } - .CodeRay .cl { color:#B06; font-weight:bold } - .CodeRay .dl { color:black } - .CodeRay .fu { color:#06B; font-weight:bold } + .syntaxhl .class { color:#B06; font-weight:bold } + .syntaxhl .delimiter { color:black } + .syntaxhl .function { color:#06B; font-weight:bold } - .CodeRay .il { background: #eee } - .CodeRay .il .idl { font-weight: bold; color: #888 } + .syntaxhl .inline { background: #eee } + .syntaxhl .inline .inline-delimiter { font-weight: bold; color: #888 } - .CodeRay .iv { color:#33B } - .CodeRay .r { color:#080; font-weight:bold } + .syntaxhl .instance-variable { color:#33B } + .syntaxhl .reserved { color:#080; font-weight:bold } + + .syntaxhl .string { background-color:#fff0f0; color: #D20; } + .syntaxhl .string .delimiter { color:#710 } - .CodeRay .s { background-color:#fff0f0 } - .CodeRay .s .dl { color:#710 } <% end %> <% html_title "Wiki Formatting" %> @@ -236,7 +238,7 @@ To go live, all you need to add is a database and a web server.
Code highlightment relies on CodeRay, a fast syntax highlighting library written completely in Ruby. It currently supports c, cpp, css, delphi, groovy, html, java, javascript, json, php, python, rhtml, ruby, scheme, sql, xml and yaml languages.
+The default code highlighting relies on CodeRay, a fast syntax highlighting library written completely in Ruby. It currently supports c, cpp, css, delphi, groovy, html, java, javascript, json, php, python, rhtml, ruby, scheme, sql, xml and yaml languages.
You can highlight code in your wiki page using this syntax:
@@ -248,15 +250,14 @@ To go live, all you need to add is a database and a web server.Example:
-1 # The Greeter class - 2 class Greeter - 3 def initialize(name) - 4 @name = name.capitalize - 5 end - 6 - 7 def salute - 8 puts "Hello #{@name}!" - 9 end -10 end -
+diff --git a/lib/redmine/syntax_highlighting.rb b/lib/redmine/syntax_highlighting.rb index fabec71b..358cc426 100644 --- a/lib/redmine/syntax_highlighting.rb +++ b/lib/redmine/syntax_highlighting.rb @@ -43,7 +43,7 @@ module Redmine # Highlights +text+ using +language+ syntax # Should not return outer pre tag def highlight_by_language(text, language) - ::CodeRay.scan(text, language).html(:line_numbers => :inline, :wrap => :span) + ::CodeRay.scan(text, language).html(:line_numbers => :inline, :line_number_anchors => false, :wrap => :span) end end end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 19528ae4..9a4df9d1 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -2354,6 +2354,17 @@ Additional wiki styles padding: 4px 4px 4px 48px; min-height: 33px; } + +/* Reset .wiki p.important for syntax highlighting rules */ +.syntaxhl .CodeRay .important { + background: none; + border: none; + display: inline; + margin: 0; + padding: 0; + min-height: 0; +} + .wiki p.smallsee-also, .wiki p.smallcaution, .wiki p.smallimportant, .wiki p.smallinfo, .wiki p.smalltip, .wiki p.smallnote, .wiki span.smallsee-also, .wiki span.smallcaution, .wiki span.smallimportant, .wiki span.smallinfo, .wiki span.smalltip, .wiki span.smallnote { display: block; diff --git a/public/stylesheets/scm.css b/public/stylesheets/scm.css index b974e2b3..2b1fed44 100644 --- a/public/stylesheets/scm.css +++ b/public/stylesheets/scm.css @@ -91,105 +91,91 @@ div.action_A { background: #bfb } /************* CodeRay styles *************/ .syntaxhl div {display: inline;} -.syntaxhl .no { padding: 2px 4px 2px 4px; background-color: #eee; margin:0 } +.syntaxhl .line-numbers { padding: 2px 4px 2px 4px; background-color: #eee; margin: 0 7px 0 0; } .syntaxhl .code pre { overflow: auto } .syntaxhl .debug { color:white ! important; background:blue ! important; } -.syntaxhl .af { color:#00C } -.syntaxhl .an { color:#007 } -.syntaxhl .at { color:#f08 } -.syntaxhl .av { color:#700 } -.syntaxhl .aw { color:#C00 } -.syntaxhl .bi { color:#509; font-weight:bold } -.syntaxhl .c { color:#888; } +.syntaxhl .annotation { color:#007 } +.syntaxhl .attribute-name { color:#b48 } +.syntaxhl .attribute-value { color:#700 } +.syntaxhl .binary { color:#509 } +.syntaxhl .char .content { color:#D20 } +.syntaxhl .char .delimiter { color:#710 } +.syntaxhl .char { color:#D20 } +.syntaxhl .class { color:#B06; font-weight:bold } +.syntaxhl .class-variable { color:#369 } +.syntaxhl .color { color:#0A0 } +.syntaxhl .comment { color:#777 } +.syntaxhl .comment .char { color:#444 } +.syntaxhl .comment .delimiter { color:#444 } +.syntaxhl .complex { color:#A08 } +.syntaxhl .constant { color:#036; font-weight:bold } +.syntaxhl .decorator { color:#B0B } +.syntaxhl .definition { color:#099; font-weight:bold } +.syntaxhl .delimiter { color:black } +.syntaxhl .directive { color:#088; font-weight:bold } +.syntaxhl .doc { color:#970 } +.syntaxhl .doc-string { color:#D42; font-weight:bold } +.syntaxhl .doctype { color:#34b } +.syntaxhl .entity { color:#800; font-weight:bold } +.syntaxhl .error { color:#F00; background-color:#FAA } +.syntaxhl .escape { color:#666 } +.syntaxhl .exception { color:#C00; font-weight:bold } +.syntaxhl .float { color:#60E } +.syntaxhl .function { color:#06B; font-weight:bold } +.syntaxhl .global-variable { color:#d70 } +.syntaxhl .hex { color:#02b } +.syntaxhl .imaginary { color:#f00 } +.syntaxhl .include { color:#B44; font-weight:bold } +.syntaxhl .inline { background-color: hsla(0,0%,0%,0.07); color: black } +.syntaxhl .inline-delimiter { font-weight: bold; color: #666 } +.syntaxhl .instance-variable { color:#33B } +.syntaxhl .integer { color:#00D } +.syntaxhl .key .char { color: #60f } +.syntaxhl .key .delimiter { color: #404 } +.syntaxhl .key { color: #606 } +.syntaxhl .keyword { color:#080; font-weight:bold } +.syntaxhl .label { color:#970; font-weight:bold } +.syntaxhl .local-variable { color:#963 } +.syntaxhl .namespace { color:#707; font-weight:bold } +.syntaxhl .octal { color:#40E } +.syntaxhl .operator { } +.syntaxhl .predefined { color:#369; font-weight:bold } +.syntaxhl .predefined-constant { color:#069 } +.syntaxhl .predefined-type { color:#0a5; font-weight:bold } +.syntaxhl .preprocessor { color:#579 } +.syntaxhl .pseudo-class { color:#00C; font-weight:bold } +.syntaxhl .regexp .content { color:#808 } +.syntaxhl .regexp .delimiter { color:#404 } +.syntaxhl .regexp .modifier { color:#C2C } +.syntaxhl .regexp { background-color:hsla(300,100%,50%,0.06); } +.syntaxhl .reserved { color:#080; font-weight:bold } +.syntaxhl .shell .content { color:#2B2 } +.syntaxhl .shell .delimiter { color:#161 } +.syntaxhl .shell { background-color:hsla(120,100%,50%,0.06); } +.syntaxhl .string .char { color: #b0b } +.syntaxhl .string .content { color: #D20 } +.syntaxhl .string .delimiter { color: #710 } +.syntaxhl .string .modifier { color: #E40 } +.syntaxhl .string { background-color:hsla(0,100%,50%,0.05); } +.syntaxhl .symbol .content { color:#A60 } +.syntaxhl .symbol .delimiter { color:#630 } +.syntaxhl .symbol { color:#A60 } +.syntaxhl .tag { color:#070 } +.syntaxhl .type { color:#339; font-weight:bold } +.syntaxhl .value { color: #088; } +.syntaxhl .variable { color:#037 } -.syntaxhl .ch { color:#04D } -.syntaxhl .ch .k { color:#04D } -.syntaxhl .ch .dl { color:#039 } - -.syntaxhl .cl { color:#B06; font-weight:bold } -.syntaxhl .cm { color:#A08; font-weight:bold } -.syntaxhl .co { color:#036; font-weight:bold } -.syntaxhl .cr { color:#0A0 } -.syntaxhl .cv { color:#369 } -.syntaxhl .de { color:#B0B; } -.syntaxhl .df { color:#099; font-weight:bold } -.syntaxhl .di { color:#088; font-weight:bold } -.syntaxhl .dl { color:black } -.syntaxhl .do { color:#970 } -.syntaxhl .dt { color:#34b } -.syntaxhl .ds { color:#D42; font-weight:bold } -.syntaxhl .e { color:#666; font-weight:bold } -.syntaxhl .en { color:#800; font-weight:bold } -.syntaxhl .er { color:#F00; background-color:#FAA } -.syntaxhl .ex { color:#C00; font-weight:bold } -.syntaxhl .fl { color:#60E; font-weight:bold } -.syntaxhl .fu { color:#06B; font-weight:bold } -.syntaxhl .gv { color:#d70; font-weight:bold } -.syntaxhl .hx { color:#058; font-weight:bold } -.syntaxhl .i { color:#00D; font-weight:bold } -.syntaxhl .ic { color:#B44; font-weight:bold } - -.syntaxhl .il { background: #ddd; color: black } -.syntaxhl .il .il { background: #ccc } -.syntaxhl .il .il .il { background: #bbb } -.syntaxhl .il .idl { background: #ddd; font-weight: bold; color: #666 } -.syntaxhl .idl { background-color: #bbb; font-weight: bold; color: #666; } - -.syntaxhl .im { color:#f00; } -.syntaxhl .in { color:#B2B; font-weight:bold } -.syntaxhl .iv { color:#33B } -.syntaxhl .la { color:#970; font-weight:bold } -.syntaxhl .lv { color:#963 } -.syntaxhl .oc { color:#40E; font-weight:bold } -.syntaxhl .of { color:#000; font-weight:bold } -.syntaxhl .op { } -.syntaxhl .pc { color:#038; font-weight:bold } -.syntaxhl .pd { color:#369; font-weight:bold } -.syntaxhl .pp { color:#579; } -.syntaxhl .ps { color:#00C; font-weight:bold } -.syntaxhl .pt { color:#074; font-weight:bold } -.syntaxhl .r, .kw { color:#080; font-weight:bold } - -.syntaxhl .ke { color: #808; } -.syntaxhl .ke .dl { color: #606; } -.syntaxhl .ke .ch { color: #80f; } -.syntaxhl .vl { color: #088; } - -.syntaxhl .rx { background-color:#fff0ff } -.syntaxhl .rx .k { color:#808 } -.syntaxhl .rx .dl { color:#404 } -.syntaxhl .rx .mod { color:#C2C } -.syntaxhl .rx .fu { color:#404; font-weight: bold } - -.syntaxhl .s { background-color:#fff0f0; color: #D20; } -.syntaxhl .s .s { background-color:#ffe0e0 } -.syntaxhl .s .s .s { background-color:#ffd0d0 } -.syntaxhl .s .k { } -.syntaxhl .s .ch { color: #b0b; } -.syntaxhl .s .dl { color: #710; } - -.syntaxhl .sh { background-color:#f0fff0; color:#2B2 } -.syntaxhl .sh .k { } -.syntaxhl .sh .dl { color:#161 } - -.syntaxhl .sy { color:#A60 } -.syntaxhl .sy .k { color:#A60 } -.syntaxhl .sy .dl { color:#630 } - -.syntaxhl .ta { color:#070 } -.syntaxhl .tf { color:#070; font-weight:bold } -.syntaxhl .ts { color:#D70; font-weight:bold } -.syntaxhl .ty { color:#339; font-weight:bold } -.syntaxhl .v { color:#036 } -.syntaxhl .xt { color:#444 } - -.syntaxhl .ins { background: #cfc; } -.syntaxhl .del { background: #fcc; } -.syntaxhl .chg { color: #aaf; background: #007; } +.syntaxhl .insert { background: hsla(120,100%,50%,0.12) } +.syntaxhl .delete { background: hsla(0,100%,50%,0.12) } +.syntaxhl .change { color: #bbf; background: #007; } .syntaxhl .head { color: #f8f; background: #505 } +.syntaxhl .head .filename { color: white; } -.syntaxhl .ins .ins { color: #080; font-weight:bold } -.syntaxhl .del .del { color: #800; font-weight:bold } -.syntaxhl .chg .chg { color: #66f; } -.syntaxhl .head .head { color: #f4f; } +.syntaxhl .delete .eyecatcher { background-color: hsla(0,100%,50%,0.2); border: 1px solid hsla(0,100%,45%,0.5); margin: -1px; border-bottom: none; border-top-left-radius: 5px; border-top-right-radius: 5px; } +.syntaxhl .insert .eyecatcher { background-color: hsla(120,100%,50%,0.2); border: 1px solid hsla(120,100%,25%,0.5); margin: -1px; border-top: none; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; } + +.syntaxhl .insert .insert { color: #0c0; background:transparent; font-weight:bold } +.syntaxhl .delete .delete { color: #c00; background:transparent; font-weight:bold } +.syntaxhl .change .change { color: #88f } +.syntaxhl .head .head { color: #f4f } diff --git a/test/fixtures/diffs/subversion.diff b/test/fixtures/diffs/subversion.diff index 9b6c9d08..67def6bf 100644 --- a/test/fixtures/diffs/subversion.diff +++ b/test/fixtures/diffs/subversion.diff @@ -22,7 +22,7 @@ Index: app/views/common/_diff.rhtml +<% diff.each do |table_file| -%>1 # The Greeter class + 2 class Greeter + 3 def initialize(name) + 4 @name = name.capitalize + 5 end + 6 + 7 def salute + 8 puts "Hello #{@name}!" + 9 end +10 end
<% if diff_type == 'sbs' -%> -+
@@ -62,3 +63,5 @@ diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 9f85b101..0d368db5 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -475,7 +475,7 @@ EXPECTED RAW expected = <<-EXPECTED -
1 # Some ruby code here +
EXPECTED1# Some ruby code here