summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-06-01 21:33:24 +0000
committermurphy <murphy@rubychan.de>2010-06-01 21:33:24 +0000
commit6f87649e90c55efac703d9c5b7838fceada89b9e (patch)
treea01491ec327c86c016cb8169be13704b452a80ce
parent5544505fc7b7cace58ff1b4bedb273eeeda4a514 (diff)
downloadcoderay-6f87649e90c55efac703d9c5b7838fceada89b9e.tar.gz
Added :eyecatcher token type (for inline diff highlighting) and improved
some nested styles.
-rw-r--r--Changes.textile2
-rw-r--r--lib/coderay/styles/alpha.rb25
-rwxr-xr-xlib/coderay/token_kinds.rb4
-rwxr-xr-xtest/functional/examples.rb6
4 files changed, 21 insertions, 16 deletions
diff --git a/Changes.textile b/Changes.textile
index c2ab2de..4bdf402 100644
--- a/Changes.textile
+++ b/Changes.textile
@@ -39,7 +39,7 @@ Renamed from @ClassOfKind@; the term "token class" is no longer used in CodeRay.
See "#122":http://redmine.rubychan.de/issues/122.
* *REMOVED* token kinds @:attribute_name_fat@, @:attribute_value_fat@, @:operator_fat@, @:tag_fat@, @:xml_text@, @:open@, and @:close@.
-* *ADDED* token kinds @:filename@ and @:namespace@.
+* *ADDED* token kinds @:filename@, @:namespace@, and @:eyecatcher@.
* *CHANGED*: Don't raise error for unknown token kinds unless in @$CODERAY_DEBUG@ mode.
h3. @Encoders::CommentFilter@
diff --git a/lib/coderay/styles/alpha.rb b/lib/coderay/styles/alpha.rb
index 5e9ebfa..9e5d8c4 100644
--- a/lib/coderay/styles/alpha.rb
+++ b/lib/coderay/styles/alpha.rb
@@ -77,7 +77,7 @@ table.CodeRay td { padding: 2px 4px; vertical-align: top; }
.il { background-color: hsla(0,0%,0%,0.1); color: black }
.il .idl { font-weight: bold; color: #666 }
-.idl { font-weight: bold; color: #666; }
+.idl { font-weight: bold; background-color: hsla(0,0%,0%,0.1); color: #666; }
.im { color:#f00; }
.in { color:#B2B; font-weight:bold }
@@ -99,19 +99,19 @@ table.CodeRay td { padding: 2px 4px; vertical-align: top; }
.ke .ch { color: #80f; }
.vl { color: #088; }
-.rx { background-color:hsla(300,100%,50%,0.1); color:#808 }
-.rx .k { }
+.rx { background-color:hsla(300,100%,50%,0.1); }
+.rx .k { color:#808 }
.rx .dl { color:#404 }
.rx .mod { color:#C2C }
.rx .fu { color:#404; font-weight: bold }
-.s { background-color:hsla(0,100%,50%,0.1); color: #D20; }
-.s .k { }
+.s { background-color:hsla(0,100%,50%,0.1); }
+.s .k { color: #D20; }
.s .ch { color: #b0b; }
.s .dl { color: #710; }
-.sh { background-color:hsla(120,100%,50%,0.1); color:#2B2 }
-.sh .k { }
+.sh { background-color:hsla(120,100%,50%,0.1); }
+.sh .k { color:#2B2 }
.sh .dl { color:#161 }
.sy { color:#A60 }
@@ -124,14 +124,17 @@ table.CodeRay td { padding: 2px 4px; vertical-align: top; }
.v { color:#036 }
.xt { color:#444 }
-.ins { background: #afa; }
-.del { background: #faa; }
+.ins { background: hsla(120,100%,50%,0.2) }
+.del { background: hsla(0,100%,50%,0.2) }
.chg { color: #aaf; background: #007; }
.head { color: #f8f; background: #505 }
.head .filename { color: white; }
-.ins .ins { color: #080; font-weight:bold }
-.del .del { color: #800; font-weight:bold }
+.ins .eye { background-color: hsla(120,100%,50%,0.2) }
+.del .eye { background-color: hsla(0,100%,50%,0.2) }
+
+.ins .ins { color: #080; background:transparent; font-weight:bold }
+.del .del { color: #800; background:transparent; font-weight:bold }
.chg .chg { color: #66f; }
.head .head { color: #f4f; }
TOKENS
diff --git a/lib/coderay/token_kinds.rb b/lib/coderay/token_kinds.rb
index 9904d50..e9e60cf 100755
--- a/lib/coderay/token_kinds.rb
+++ b/lib/coderay/token_kinds.rb
@@ -71,7 +71,9 @@ module CodeRay
:delete => 'del',
:change => 'chg',
:head => 'head',
-
+
+ :eyecatcher => 'eye',
+
:ident => :NO_HIGHLIGHT, # 'id'
#:operator => 'op',
:operator => :NO_HIGHLIGHT, # 'op'
diff --git a/test/functional/examples.rb b/test/functional/examples.rb
index 14f0aea..8452c34 100755
--- a/test/functional/examples.rb
+++ b/test/functional/examples.rb
@@ -8,7 +8,7 @@ class ExamplesTest < Test::Unit::TestCase
div = CodeRay.scan('puts "Hello, world!"', :ruby).div
assert_equal <<-DIV, div
<div class="CodeRay">
- <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.1);color:#D20"><span style="color:#710">&quot;</span><span style="">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
+ <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.1)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
</div>
DIV
@@ -25,7 +25,7 @@ end
<a href="#n3" name="n3">3</a>
</pre></td>
<td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"><span style="color:#00D;font-weight:bold">5</span>.times <span style="color:#080;font-weight:bold">do</span>
- puts <span style="background-color:hsla(0,100%,50%,0.1);color:#D20"><span style="color:#710">'</span><span style="">Hello, world!</span><span style="color:#710">'</span></span>
+ puts <span style="background-color:hsla(0,100%,50%,0.1)"><span style="color:#710">'</span><span style="color:#D20">Hello, world!</span><span style="color:#710">'</span></span>
<span style="color:#080;font-weight:bold">end</span></pre></td>
</tr></table>
DIV
@@ -116,7 +116,7 @@ Token Types (5):
div = ruby_highlighter.encode('puts "Hello, world!"')
assert_equal <<-DIV, div
<div class="CodeRay">
- <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.1);color:#D20"><span style="color:#710">&quot;</span><span style="">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
+ <div class="code"><pre>puts <span style="background-color:hsla(0,100%,50%,0.1)"><span style="color:#710">&quot;</span><span style="color:#D20">Hello, world!</span><span style="color:#710">&quot;</span></span></pre></div>
</div>
DIV
end