rouge 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,32 +12,102 @@ module Rouge
12
12
 
13
13
  def self.attributes
14
14
  @attributes ||= Set.new %w(
15
- azimuth background background-attachment background-color
16
- background-image background-position background-repeat
17
- border border-bottom border-bottom-color border-bottom-style
18
- border-bottom-width border-collapse border-color border-left
19
- border-left-color border-left-style border-left-width
20
- border-right border-right-color border-right-style
21
- border-right-width border-spacing border-style border-top
22
- border-top-color border-top-style border-top-width
23
- border-width bottom caption-side clear clip color content
24
- counter-increment counter-reset cue cue-after cue-before cursor
25
- direction display elevation empty-cells float font font-family
26
- font-size font-size-adjust font-stretch font-style font-variant
27
- font-weight height left letter-spacing line-height list-style
28
- list-style-image list-style-position list-style-type margin
29
- margin-bottom margin-left margin-right margin-top marker-offset
30
- marks max-height max-width min-height min-width opacity orphans
31
- outline outline-color outline-style outline-width overflow-x
32
- overflow-y padding padding-bottom padding-left padding-right
33
- padding-top page page-break-after page-break-before
34
- page-break-inside pause pause-after pause-before pitch
35
- pitch-range play-during position quotes richness right size
36
- speak speak-header speak-numeral speak-punctuation speech-rate
37
- src stress table-layout text-align text-decoration text-indent
38
- text-shadow text-transform top unicode-bidi vertical-align
39
- visibility voice-family volume white-space widows width
40
- word-spacing z-index
15
+ align-content align-items align-self alignment-adjust
16
+ alignment-baseline all anchor-point animation
17
+ animation-delay animation-direction animation-duration
18
+ animation-fill-mode animation-iteration-count animation-name
19
+ animation-play-state animation-timing-function appearance
20
+ azimuth backface-visibility background background-attachment
21
+ background-clip background-color background-image
22
+ background-origin background-position background-repeat
23
+ background-size baseline-shift binding bleed bookmark-label
24
+ bookmark-level bookmark-state bookmark-target border
25
+ border-bottom border-bottom-color border-bottom-left-radius
26
+ border-bottom-right-radius border-bottom-style
27
+ border-bottom-width border-collapse border-color
28
+ border-image border-image-outset border-image-repeat
29
+ border-image-slice border-image-source border-image-width
30
+ border-left border-left-color border-left-style
31
+ border-left-width border-radius border-right
32
+ border-right-color border-right-style border-right-width
33
+ border-spacing border-style border-top border-top-color
34
+ border-top-left-radius border-top-right-radius
35
+ border-top-style border-top-width border-width bottom
36
+ box-align box-decoration-break box-direction box-flex
37
+ box-flex-group box-lines box-ordinal-group box-orient
38
+ box-pack box-shadow box-sizing break-after break-before
39
+ break-inside caption-side clear clip clip-path
40
+ clip-rule color color-profile columns column-count
41
+ column-fill column-gap column-rule column-rule-color
42
+ column-rule-style column-rule-width column-span
43
+ column-width content counter-increment counter-reset
44
+ crop cue cue-after cue-before cursor direction display
45
+ dominant-baseline drop-initial-after-adjust
46
+ drop-initial-after-align drop-initial-before-adjust
47
+ drop-initial-before-align drop-initial-size
48
+ drop-initial-value elevation empty-cells filter fit
49
+ fit-position flex flex-basis flex-direction flex-flow
50
+ flex-grow flex-shrink flex-wrap float float-offset
51
+ font font-family font-feature-settings
52
+ font-kerning font-language-override font-size
53
+ font-size-adjust font-stretch font-style font-synthesis
54
+ font-variant font-variant-alternates font-variant-caps
55
+ font-variant-east-asian font-variant-ligatures
56
+ font-variant-numeric font-variant-position font-weight
57
+ grid-cell grid-column grid-column-align grid-column-sizing
58
+ grid-column-span grid-columns grid-flow grid-row
59
+ grid-row-align grid-row-sizing grid-row-span
60
+ grid-rows grid-template hanging-punctuation height
61
+ hyphenate-after hyphenate-before hyphenate-character
62
+ hyphenate-lines hyphenate-resource hyphens icon
63
+ image-orientation image-rendering image-resolution
64
+ ime-mode inline-box-align justify-content
65
+ left letter-spacing line-break line-height
66
+ line-stacking line-stacking-ruby line-stacking-shift
67
+ line-stacking-strategy list-style list-style-image
68
+ list-style-position list-style-type margin
69
+ margin-bottom margin-left margin-right margin-top
70
+ mark marker-offset marks mark-after mark-before
71
+ marquee-direction marquee-loop marquee-play-count
72
+ marquee-speed marquee-style mask max-height max-width
73
+ min-height min-width move-to nav-down
74
+ nav-index nav-left nav-right nav-up object-fit
75
+ object-position opacity order orphans outline
76
+ outline-color outline-offset outline-style
77
+ outline-width overflow overflow-style overflow-wrap
78
+ overflow-x overflow-y padding padding-bottom
79
+ padding-left padding-right padding-top
80
+ page page-break-after page-break-before
81
+ page-break-inside page-policy pause pause-after
82
+ pause-before perspective perspective-origin
83
+ phonemes pitch pitch-range play-during pointer-events
84
+ position presentation-level punctuation-trim quotes
85
+ rendering-intent resize rest rest-after rest-before
86
+ richness right rotation rotation-point ruby-align
87
+ ruby-overhang ruby-position ruby-span size speak
88
+ speak-as speak-header speak-numeral speak-punctuation
89
+ speech-rate src stress string-set
90
+ tab-size table-layout target target-name
91
+ target-new target-position text-align
92
+ text-align-last text-combine-horizontal
93
+ text-decoration text-decoration-color
94
+ text-decoration-line text-decoration-skip
95
+ text-decoration-style text-emphasis
96
+ text-emphasis-color text-emphasis-position
97
+ text-emphasis-style text-height text-indent
98
+ text-justify text-orientation text-outline
99
+ text-overflow text-rendering text-shadow
100
+ text-space-collapse text-transform
101
+ text-underline-position text-wrap top
102
+ transform transform-origin transform-style
103
+ transition transition-delay transition-duration
104
+ transition-property transition-timing-function
105
+ unicode-bidi vertical-align
106
+ visibility voice-balance voice-duration
107
+ voice-family voice-pitch voice-pitch-range
108
+ voice-range voice-rate voice-stress voice-volume
109
+ volume white-space widows width word-break
110
+ word-spacing word-wrap writing-mode z-index
41
111
  )
42
112
  end
43
113
 
@@ -0,0 +1,148 @@
1
+ # module Rouge
2
+ # module Lexers
3
+ # class D < RegexLexer
4
+ # desc 'The D Programming language (http://dlang.org)'
5
+ # tag 'd'
6
+ # aliases 'dlang'
7
+ # filenames '*.d'
8
+ #
9
+ # def self.keywords
10
+ # @keywords ||= %w(
11
+ # abstract alias align asm assert auto body bool break byte
12
+ # case cast catch cdouble cent cfloat char class const continue
13
+ # creal dchar debug default delegate delete deprecated do double
14
+ # else enum export extern false final finally float for foreach
15
+ # foreach_reverse function goto idouble if ifloat immutable
16
+ # import in inout int interface invariant ireal is lazy long
17
+ # macro mixin module new nothrow null out override package pragma
18
+ # private protected public pure real ref return scope shared
19
+ # short static struct super switch synchronized template this
20
+ # throw true try typedef typeid typeof ubyte ucent uint ulong
21
+ # union unittest ushort version void volatile wchar while with
22
+ # __FILE__ __MODULE__ __LINE__ __FUNCTION__ __PRETTY_FUNCTION__
23
+ # __gshared __traits __vector __parameters
24
+ # )
25
+ # end
26
+ #
27
+ # def self.builtins
28
+ # @builtins ||= %w(
29
+ # string wstring dstring size_t ptrdiff_t
30
+ # __DATE__ __TIME__ __TIMESTAMP__ __VENDOR__ __VERSION__
31
+ # )
32
+ # end
33
+ #
34
+ # id = /[[:alpha:]_]\w*/
35
+ # symmetric = {
36
+ # '[' => ']',
37
+ # '<' => '>',
38
+ # '(' => ')',
39
+ # '{' => '}'
40
+ # }
41
+ #
42
+ # escapes = [
43
+ # /\\['"?\\abfnrtv]/,
44
+ # /\\[0-7]{1,3}/,
45
+ # /\\x[0-9a-fA-F]{2}/,
46
+ # /\\u[0-9a-fA-F]{4}/,
47
+ # /\\U[0-9a-fA-F]{8}/,
48
+ # /\\&\w+;/,
49
+ # ]
50
+ #
51
+ # symmetric_open = Regexp.new "[#{Regexp.escape(symmetric.keys.join)}]"
52
+ #
53
+ # state :basic do
54
+ # rule /\s+/m, 'Text'
55
+ # rule %r(//.*$), 'Comment.Single'
56
+ # rule %r(/[*].*?[*]/), 'Comment.Multiline'
57
+ # rule %r(/[+]), 'Comment.Multiline', :nested_comment
58
+ # end
59
+ #
60
+ # state :final_quote do
61
+ # rule /"/, 'Literal.String', :pop!
62
+ # rule /./, 'Error', :pop!
63
+ # end
64
+ #
65
+ # state :nested_comment do
66
+ # rule %r([+]/), :pop!
67
+ # rule %r(/[+]), :nested_comment
68
+ # rule %r([/+]|[^/+]+), 'Comment.Multiline'
69
+ # end
70
+ #
71
+ # state :root do
72
+ # rule /r".*?"/, 'Literal.String'
73
+ # rule /`.*?`/, 'Literal.String'
74
+ # rule /q"(#{id})\n.*?\n\1"/, 'Literal.String.Heredoc'
75
+ # rule /q"(#{symmetric_open})/ do |m|
76
+ # token 'Literal.String'
77
+ # open = Regexp.escape(m[1])
78
+ # close = Regexp.escape(symmetric[m[1]])
79
+ # push :final_quote
80
+ # push do
81
+ # mixin :escapes
82
+ # rule /\\[#{open}#{close}]/, 'Literal.String.Escape'
83
+ # rule(/#{open}/) { token 'Literal.String'; push }
84
+ # rule(/#{close}/) { token 'Literal.String'; pop! }
85
+ # rule /[^\\#{open}#{close}]+/, 'Literal.String'
86
+ # end
87
+ # end
88
+ # rule /q"(\S).*?\1"/, 'Literal.String'
89
+ # # Token strings are going to be lexed like D, because
90
+ # # they're frigging impossible otherwise. I'll highlight
91
+ # # the q as a string, though.
92
+ # rule /q(?=[{])/, 'Literal.String'
93
+ # rule /x"/, 'Literal.String.Other', :hex_string
94
+ # rule /"/, 'Literal.String', :dq
95
+ # rule /'/ do
96
+ # token 'Literal.String.Char'
97
+ # push :char_end; push :char
98
+ # end
99
+ #
100
+ # # numbers
101
+ # rule /0b[01_]+/, 'Literal.Number.Binary'
102
+ # rule /0x[0-9a-f_]+/i,
103
+ # rule /\d+[ul]+/i, 'Literal.Number.Integer'
104
+ #
105
+ # rule /#{keywords.join('|')}/, 'Keyword'
106
+ # end
107
+ #
108
+ # state :escapes do
109
+ # escapes.each do |re|
110
+ # rule re, 'Literal.String.Escape'
111
+ # end
112
+ # end
113
+ #
114
+ # state :char do
115
+ # escapes.each do |re|
116
+ # rule re, 'Literal.String.Char', :pop!
117
+ # end
118
+ #
119
+ # rule /./, 'Literal.String.Char', :pop!
120
+ # end
121
+ #
122
+ # state :hex_string do
123
+ # rule /[0-9a-f]+/i, 'Literal.Number.Hex'
124
+ # rule /\s+/m, 'Literal.String.Other'
125
+ # rule /"/, 'Literal.String.Other', :pop!
126
+ # end
127
+ #
128
+ # state :char_end do
129
+ # rule /'[cwd]+/, 'Literal.String.Char', :pop!
130
+ # rule /./, 'Error', :pop!
131
+ # end
132
+ #
133
+ # state :dq do
134
+ # mixin :escapes
135
+ # rule /[^\\"]+/, 'Literal.String.Double'
136
+ # rule /"/ do
137
+ # token 'Literal.String.Double'
138
+ # pop!; push :post_string
139
+ # end
140
+ # end
141
+ #
142
+ # state :post_string do
143
+ # rule /[cwd]+/, 'Literal.String'
144
+ # rule(//) { pop! }
145
+ # end
146
+ # end
147
+ # end
148
+ # end
@@ -29,13 +29,15 @@ module Rouge
29
29
  ).join('|')
30
30
 
31
31
  state :basic do
32
- rule /#.*\n/, 'Comment'
32
+ rule /#.*$/, 'Comment'
33
33
 
34
34
  rule /\b(#{KEYWORDS})\s*\b/, 'Keyword'
35
35
  rule /\bcase\b/, 'Keyword', :case
36
36
 
37
37
  rule /\b(#{BUILTINS})\s*\b(?!\.)/, 'Name.Builtin'
38
38
 
39
+ rule /^\S*[\$%>#] +/, 'Generic.Prompt'
40
+
39
41
  rule /(\b\w+)(=)/ do |m|
40
42
  group 'Name.Variable'
41
43
  group 'Operator'
@@ -63,7 +63,8 @@ module Rouge
63
63
  def mapping_contains?(mapping, word)
64
64
  shortest, longest = find_likely_mapping(mapping, word)
65
65
 
66
- word.start_with?(shortest) and longest.start_with?(word)
66
+ shortest and word.start_with?(shortest) and
67
+ longest and longest.start_with?(word)
67
68
  end
68
69
 
69
70
  # binary search through the mappings to find the one that's likely
@@ -0,0 +1,12 @@
1
+ module Rouge
2
+ module Lexers
3
+ class WDiff < RegexLexer
4
+ tag 'wdiff'
5
+ desc 'word-level diffs'
6
+
7
+ state :root do
8
+ rule /.+?(?={[+-])/, 'Text'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  module Rouge
2
2
  def self.version
3
- "0.3.2"
3
+ "0.3.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-11 00:00:00.000000000 Z
12
+ date: 2013-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime
@@ -85,6 +85,7 @@ files:
85
85
  - lib/rouge/lexers/ini.rb
86
86
  - lib/rouge/lexers/scss.rb
87
87
  - lib/rouge/lexers/javascript.rb
88
+ - lib/rouge/lexers/wdiff.rb
88
89
  - lib/rouge/lexers/shell.rb
89
90
  - lib/rouge/lexers/yaml.rb
90
91
  - lib/rouge/lexers/make.rb
@@ -105,6 +106,7 @@ files:
105
106
  - lib/rouge/lexers/sql.rb
106
107
  - lib/rouge/lexers/haskell.rb
107
108
  - lib/rouge/lexers/markdown.rb
109
+ - lib/rouge/lexers/d.rb
108
110
  - lib/rouge/lexers/prolog.rb
109
111
  - lib/rouge/lexers/conf.rb
110
112
  - lib/rouge.rb