Skip to content

Commit 279348d

Browse files
committed
:map token kind
Use :map instead of :table. It's more generic, and won't be confused with the :table rendering style.
1 parent 308fd38 commit 279348d

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

lib/coderay/scanners/lua.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def scan_tokens(encoder, options)
9898
@encoder.text_token(match, kind)
9999

100100
elsif match = scan(/\{/) # Opening table brace {
101-
@encoder.begin_group(:table)
101+
@encoder.begin_group(:map)
102102
@encoder.text_token(match, @brace_depth >= 1 ? :inline_delimiter : :delimiter)
103103
@brace_depth += 1
104-
@state = :table
104+
@state = :map
105105

106106
elsif match = scan(/\}/) # Closing table brace }
107107
if @brace_depth == 1
@@ -112,9 +112,9 @@ def scan_tokens(encoder, options)
112112
else
113113
@brace_depth -= 1
114114
@encoder.text_token(match, :inline_delimiter)
115-
@state = :table
115+
@state = :map
116116
end
117-
@encoder.end_group(:table)
117+
@encoder.end_group(:map)
118118

119119
elsif match = scan(/["']/) # String delimiters " and '
120120
@encoder.begin_group(:string)
@@ -142,8 +142,8 @@ def scan_tokens(encoder, options)
142142

143143
# It may be that we’re scanning a full-blown subexpression of a table
144144
# (tables can contain full expressions in parts).
145-
# If this is the case, return to :table scanning state.
146-
@state = :table if @state == :initial && @brace_depth >= 1
145+
# If this is the case, return to :map scanning state.
146+
@state = :map if @state == :initial && @brace_depth >= 1
147147

148148
when :function_expected
149149
if match = scan(/\(.*?\)/m) # x = function() # "Anonymous" function without explicit name
@@ -237,7 +237,7 @@ def scan_tokens(encoder, options)
237237
@encoder.text_token(getch, :error)
238238
end
239239

240-
when :table
240+
when :map
241241
if match = scan(/[,;]/)
242242
@encoder.text_token(match, :operator)
243243
elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]* (?=\s*=)/x)

lib/coderay/styles/alpha.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module CodeRay
22
module Styles
3-
3+
44
# A colorful theme using CSS 3 colors (with alpha channel).
55
class Alpha < Style
66

@@ -116,9 +116,9 @@ class Alpha < Style
116116
.symbol .content { color:#A60 }
117117
.symbol .delimiter { color:#630 }
118118
.symbol { color:#A60 }
119-
.table .content { color:#808 }
120-
.table .delimiter { color:#40A}
121-
.table { background-color:hsla(200,100%,50%,0.06); }
119+
.map .content { color:#808 }
120+
.map .delimiter { color:#40A}
121+
.map { background-color:hsla(200,100%,50%,0.06); }
122122
.tag { color:#070 }
123123
.type { color:#339; font-weight:bold }
124124
.value { color: #088; }

lib/coderay/token_kinds.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module CodeRay
2-
2+
33
# A Hash of all known token kinds and their associated CSS classes.
44
TokenKinds = Hash.new do |h, k|
55
warn 'Undefined Token kind: %p' % [k] if $CODERAY_DEBUG
66
false
77
end
8-
8+
99
# speedup
1010
TokenKinds.compare_by_identity if TokenKinds.respond_to? :compare_by_identity
11-
11+
1212
TokenKinds.update( # :nodoc:
1313
:annotation => 'annotation',
1414
:attribute_name => 'attribute-name',
@@ -50,6 +50,7 @@ module CodeRay
5050
:keyword => 'keyword',
5151
:label => 'label',
5252
:local_variable => 'local-variable',
53+
:map => 'map',
5354
:modifier => 'modifier',
5455
:namespace => 'namespace',
5556
:octal => 'octal',
@@ -63,29 +64,28 @@ module CodeRay
6364
:shell => 'shell',
6465
:string => 'string',
6566
:symbol => 'symbol',
66-
:table => 'table',
6767
:tag => 'tag',
6868
:type => 'type',
6969
:value => 'value',
7070
:variable => 'variable',
71-
71+
7272
:change => 'change',
7373
:delete => 'delete',
7474
:head => 'head',
7575
:insert => 'insert',
76-
76+
7777
:eyecatcher => 'eyecatcher',
78-
78+
7979
:ident => false,
8080
:operator => false,
81-
81+
8282
:space => false,
8383
:plain => false
8484
)
85-
85+
8686
TokenKinds[:method] = TokenKinds[:function]
8787
TokenKinds[:escape] = TokenKinds[:delimiter]
8888
TokenKinds[:docstring] = TokenKinds[:comment]
89-
89+
9090
TokenKinds.freeze
9191
end

0 commit comments

Comments
 (0)