rouge 0.2.13 → 0.2.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,6 +43,8 @@ load load_dir.join('rouge/lexers/diff.rb')
43
43
  load load_dir.join('rouge/lexers/tex.rb')
44
44
  load load_dir.join('rouge/lexers/markdown.rb')
45
45
  load load_dir.join('rouge/lexers/yaml.rb')
46
+ load load_dir.join('rouge/lexers/toml.rb')
47
+ load load_dir.join('rouge/lexers/ini.rb')
46
48
 
47
49
  load load_dir.join('rouge/lexers/sql.rb')
48
50
 
@@ -52,6 +54,7 @@ load load_dir.join('rouge/lexers/viml.rb')
52
54
  load load_dir.join('rouge/lexers/nginx.rb')
53
55
  load load_dir.join('rouge/lexers/conf.rb')
54
56
  load load_dir.join('rouge/lexers/sed.rb')
57
+ load load_dir.join('rouge/lexers/puppet.rb')
55
58
 
56
59
  load load_dir.join('rouge/lexers/javascript.rb')
57
60
  load load_dir.join('rouge/lexers/css.rb')
@@ -63,6 +66,7 @@ load load_dir.join('rouge/lexers/haml.rb')
63
66
  load load_dir.join('rouge/lexers/sass.rb')
64
67
  load load_dir.join('rouge/lexers/scss.rb')
65
68
  load load_dir.join('rouge/lexers/coffeescript.rb')
69
+ load load_dir.join('rouge/lexers/literate_coffeescript.rb')
66
70
 
67
71
  load load_dir.join('rouge/lexers/erb.rb')
68
72
  load load_dir.join('rouge/lexers/handlebars.rb')
@@ -77,6 +81,7 @@ load load_dir.join('rouge/lexers/groovy.rb')
77
81
  load load_dir.join('rouge/lexers/io.rb')
78
82
 
79
83
  load load_dir.join('rouge/lexers/haskell.rb')
84
+ load load_dir.join('rouge/lexers/literate_haskell.rb')
80
85
  load load_dir.join('rouge/lexers/scheme.rb')
81
86
  load load_dir.join('rouge/lexers/common_lisp.rb')
82
87
 
@@ -0,0 +1,3 @@
1
+ Import the helpers we plan to use.
2
+
3
+ {extend, last} = require './helpers'
@@ -0,0 +1,7 @@
1
+ In Bird-style you have to leave a blank before the code.
2
+
3
+ > fact :: Integer -> Integer
4
+ > fact 0 = 1
5
+ > fact n = n * fact (n-1)
6
+
7
+ And you have to leave a blank line after the code as well.
@@ -0,0 +1,6 @@
1
+ service { 'ntp':
2
+ name => $service_name,
3
+ ensure => running,
4
+ enable => true,
5
+ subscribe => File['ntp.conf'],
6
+ }
@@ -4,7 +4,7 @@ module Rouge
4
4
  desc "The Clojure programming language (clojure.org)"
5
5
 
6
6
  tag 'clojure'
7
- aliases 'clj'
7
+ aliases 'clj', 'cljs'
8
8
 
9
9
  filenames '*.clj', '*.cljs'
10
10
 
@@ -91,7 +91,7 @@ module Rouge
91
91
  end
92
92
 
93
93
  rule identifier do |m|
94
- token name_token(m[0]) || 'Name.Variable'
94
+ token name_token(m[0]) || 'Name'
95
95
  end
96
96
 
97
97
  # vectors
@@ -0,0 +1,55 @@
1
+ module Rouge
2
+ module Lexers
3
+ class INI < RegexLexer
4
+ desc 'the INI configuration format'
5
+ tag 'ini'
6
+
7
+ # TODO add more here
8
+ filenames '*.ini', '*.INI', '*.gitconfig'
9
+ mimetypes 'text/x-ini'
10
+
11
+ def self.analyze_text(text)
12
+ return 0.1 if text =~ /\A\[[\w.]+\]\s*\w+=\w+/
13
+ end
14
+
15
+ identifier = /[\w.]+/
16
+
17
+ state :basic do
18
+ rule /[;#].*?\n/, 'Comment'
19
+ rule /\s+/, 'Text'
20
+ rule /\\\n/, 'Literal.String.Escape'
21
+ end
22
+
23
+ state :root do
24
+ mixin :basic
25
+
26
+ rule /(#{identifier})(\s*)(=)/ do
27
+ group 'Name.Property'; group 'Text'
28
+ group 'Punctuation'
29
+ push :value
30
+ end
31
+
32
+ rule /\[.*?\]/, 'Name.Namespace'
33
+ end
34
+
35
+ state :value do
36
+ rule /\n/, 'Text', :pop!
37
+ mixin :basic
38
+ rule /"/, 'Literal.String', :dq
39
+ rule /'.*?'/, 'Literal.String'
40
+ mixin :esc_str
41
+ rule /[^\\\n]+/, 'Literal.String'
42
+ end
43
+
44
+ state :dq do
45
+ rule /"/, 'Literal.String', :pop!
46
+ mixin :esc_str
47
+ rule /[^\\"]+/m, 'Literal.String'
48
+ end
49
+
50
+ state :esc_str do
51
+ rule /\\./m, 'Literal.String.Escape'
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,29 @@
1
+ module Rouge
2
+ module Lexers
3
+ class LiterateCoffeescript < RegexLexer
4
+ tag 'literate_coffeescript'
5
+ aliases 'litcoffee'
6
+ filenames '*.litcoffee'
7
+
8
+ def markdown
9
+ @markdown ||= Markdown.new(options)
10
+ end
11
+
12
+ def coffee
13
+ @coffee ||= Coffeescript.new(options)
14
+ end
15
+
16
+ start { markdown.reset!; coffee.reset! }
17
+
18
+ state :root do
19
+ rule /^( .*?\n)+/m do
20
+ delegate coffee
21
+ end
22
+
23
+ rule /^([ ]{0,3}(\S.*?|)\n)*/m do
24
+ delegate markdown
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ module Rouge
2
+ module Lexers
3
+ class LiterateHaskell < RegexLexer
4
+ desc 'Literate haskell'
5
+ tag 'literate_haskell'
6
+ aliases 'lithaskell', 'lhaskell', 'lhs'
7
+ filenames '*.lhs'
8
+ mimetypes 'text/x-literate-haskell'
9
+
10
+ def haskell
11
+ @haskell ||= Haskell.new(options)
12
+ end
13
+
14
+ start { haskell.reset! }
15
+
16
+ # TODO: support TeX versions as well.
17
+ # TODO: enforce a blank line before and after code
18
+ state :root do
19
+ rule /\s*?\n(?=>)/, 'Text', :code
20
+ rule /.*?\n/, 'Text'
21
+ rule /.+\z/, 'Text'
22
+ end
23
+
24
+ state :code do
25
+ rule /(>)( .*?\n)/ do |m|
26
+ token 'Name.Label', m[1]
27
+ delegate haskell, m[2]
28
+ end
29
+
30
+ rule /\s*\n(?=\s*[^>])/, 'Text', :pop!
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,126 @@
1
+ module Rouge
2
+ module Lexers
3
+ class Puppet < RegexLexer
4
+ desc 'The Puppet configuration management language (puppetlabs.org)'
5
+ tag 'puppet'
6
+ aliases 'pp'
7
+ filenames '*.pp'
8
+
9
+ def self.analyze_text(text)
10
+ return 1 if text.shebang? 'puppet-apply'
11
+ return 1 if text.shebang? 'puppet'
12
+ end
13
+
14
+ def self.keywords
15
+ @keywords ||= Set.new %w(
16
+ and case class default define else elsif if in import inherits
17
+ node unless
18
+ )
19
+ end
20
+
21
+ def self.constants
22
+ @constants ||= Set.new %w(
23
+ false true undef
24
+ )
25
+ end
26
+
27
+ def self.metaparameters
28
+ @metaparameters ||= Set.new %w(
29
+ before require notify subscribe
30
+ )
31
+ end
32
+
33
+ id = /[a-z]\w*/
34
+ cap_id = /[A-Z]\w*/
35
+ qualname = /(::)?(#{id}::)*\w+/
36
+
37
+ state :whitespace do
38
+ rule /\s+/m, 'Text'
39
+ rule /#.*?\n/, 'Comment'
40
+ end
41
+
42
+ state :root do
43
+ mixin :whitespace
44
+
45
+ rule /[$]#{qualname}/, 'Name.Variable'
46
+ rule /(#{id})(?=\s*[=+]>)/m do |m|
47
+ if self.class.metaparameters.include? m[0]
48
+ token 'Keyword.Pseudo'
49
+ else
50
+ token 'Name.Property'
51
+ end
52
+ end
53
+
54
+ rule /(#{qualname})(?=\s*[(])/m, 'Name.Function'
55
+ rule cap_id, 'Name.Class'
56
+
57
+ rule /[+=|~-]>|<[|~-]/, 'Punctuation'
58
+ rule /[:{();\[\]]/, 'Punctuation'
59
+
60
+ # HACK for case statements and selectors
61
+ rule /}/, 'Punctuation', :regex_allowed
62
+ rule /,/, 'Punctuation', :regex_allowed
63
+
64
+ rule /(in|and|or)\b/, 'Operator.Word'
65
+ rule /[=!<>]=/, 'Operator'
66
+ rule /[=!]~/, 'Operator', :regex_allowed
67
+ rule %r([<>!+*/-]), 'Operator'
68
+
69
+ rule /(class|include)(\s*)(#{qualname})/ do
70
+ group 'Keyword'; group 'Text'
71
+ group 'Name.Class'
72
+ end
73
+
74
+ rule /node\b/, 'Keyword', :regex_allowed
75
+
76
+ rule /'(\\[\\']|[^'])*'/m, 'Literal.String.Single'
77
+ rule /"/, 'Literal.String.Double', :dquotes
78
+
79
+ rule /\d+([.]\d+)?(e[+-]\d+)?/, 'Literal.Number'
80
+
81
+ # a valid regex. TODO: regexes are only allowed
82
+ # in certain places in puppet.
83
+ rule qualname do |m|
84
+ if self.class.keywords.include? m[0]
85
+ token 'Keyword'
86
+ elsif self.class.constants.include? m[0]
87
+ token 'Keyword.Constant'
88
+ else
89
+ token 'Name'
90
+ end
91
+ end
92
+ end
93
+
94
+ state :regex_allowed do
95
+ mixin :whitespace
96
+ rule %r(/), 'Literal.String.Regex', :regex
97
+
98
+ rule(//) { pop! }
99
+ end
100
+
101
+ state :regex do
102
+ rule %r(/), 'Literal.String.Regex', :pop!
103
+ rule /\\./, 'Literal.String.Escape'
104
+ rule /[(){}]/, 'Literal.String.Interpol'
105
+ rule /\[/, 'Literal.String.Interpol', :regex_class
106
+ rule /./, 'Literal.String.Regex'
107
+ end
108
+
109
+ state :regex_class do
110
+ rule /\]/, 'Literal.String.Interpol', :pop!
111
+ rule /(?<!\[)-(?=\])/, 'Literal.String.Regex'
112
+ rule /-/, 'Literal.String.Interpol'
113
+ rule /\\./, 'Literal.String.Escape'
114
+ rule /[^\\\]-]+/, 'Literal.String.Regex'
115
+ end
116
+
117
+ state :dquotes do
118
+ rule /"/, 'Literal.String.Double', :pop!
119
+ rule /[^$\\"]+/m, 'Literal.String.Double'
120
+ rule /\\./m, 'Literal.String.Escape'
121
+ rule /[$]#{qualname}/, 'Name.Variable'
122
+ rule /[$][{]#{qualname}[}]/, 'Name.Variable'
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,69 @@
1
+ module Rouge
2
+ module Lexers
3
+ class TOML < RegexLexer
4
+ desc 'the TOML configuration format'
5
+ tag 'toml'
6
+
7
+ filenames '*.toml'
8
+ mimetypes 'text/x-toml'
9
+
10
+ def self.analyze_text(text)
11
+ return 0.1 if text =~ /\A\[[\w.]+\]\s*\w+\s*=\s*("\w+")+/
12
+ end
13
+
14
+ identifier = /[\w.\S]+/
15
+
16
+ state :basic do
17
+ rule /\s+/, 'Text'
18
+ rule /#.*?$/, 'Comment'
19
+ rule /(true|false)/, 'Keyword.Constant'
20
+ rule /(?<!=)\s*\[[\w\d\S]+\]/, 'Name.Namespace'
21
+
22
+ rule /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, 'Literal.Date'
23
+
24
+ rule /(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?/, 'Literal.Number.Float'
25
+ rule /\d+[eE][+-]?[0-9]+j?/, 'Literal.Number.Float'
26
+ rule /\-?\d+/, 'Literal.Number.Integer'
27
+ end
28
+
29
+ state :root do
30
+ mixin :basic
31
+
32
+ rule /(#{identifier})(\s*)(=)/ do
33
+ group 'Name.Property'; group 'Text'
34
+ group 'Punctuation'
35
+ push :value
36
+ end
37
+
38
+ end
39
+
40
+ state :value do
41
+ rule /\n/, 'Text', :pop!
42
+ mixin :content
43
+ end
44
+
45
+ state :content do
46
+ mixin :basic
47
+ rule /"/, 'Literal.String', :dq
48
+ mixin :esc_str
49
+ rule /\,/, 'Punctuation'
50
+ rule /\[/, 'Punctuation', :array
51
+ end
52
+
53
+ state :dq do
54
+ rule /"/, 'Literal.String', :pop!
55
+ mixin :esc_str
56
+ rule /[^\\"]+/, 'Literal.String'
57
+ end
58
+
59
+ state :esc_str do
60
+ rule /\\[0t\tn\n "\\ r]/, 'Literal.String.Escape'
61
+ end
62
+
63
+ state :array do
64
+ mixin :content
65
+ rule /\]/, 'Punctuation', :pop!
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,5 +1,5 @@
1
1
  module Rouge
2
2
  def self.version
3
- "0.2.13"
3
+ "0.2.14"
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.2.13
4
+ version: 0.2.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-12 00:00:00.000000000 Z
12
+ date: 2013-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ type: :runtime
15
16
  name: thor
17
+ prerelease: false
16
18
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
19
  requirements:
19
20
  - - ! '>='
20
21
  - !ruby/object:Gem::Version
21
22
  version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
23
  none: false
24
+ version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ! '>='
28
27
  - !ruby/object:Gem::Version
29
28
  version: '0'
29
+ none: false
30
30
  description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
31
31
  email:
32
32
  - jjmadkisson@gmail.com
@@ -65,10 +65,13 @@ files:
65
65
  - lib/rouge/lexers/groovy.rb
66
66
  - lib/rouge/lexers/sed.rb
67
67
  - lib/rouge/lexers/coffeescript.rb
68
+ - lib/rouge/lexers/literate_coffeescript.rb
68
69
  - lib/rouge/lexers/text.rb
69
70
  - lib/rouge/lexers/diff.rb
70
71
  - lib/rouge/lexers/viml/keywords.rb
71
72
  - lib/rouge/lexers/css.rb
73
+ - lib/rouge/lexers/toml.rb
74
+ - lib/rouge/lexers/puppet.rb
72
75
  - lib/rouge/lexers/ruby.rb
73
76
  - lib/rouge/lexers/xml.rb
74
77
  - lib/rouge/lexers/handlebars.rb
@@ -76,6 +79,7 @@ files:
76
79
  - lib/rouge/lexers/tcl.rb
77
80
  - lib/rouge/lexers/tex.rb
78
81
  - lib/rouge/lexers/rust.rb
82
+ - lib/rouge/lexers/ini.rb
79
83
  - lib/rouge/lexers/scss.rb
80
84
  - lib/rouge/lexers/javascript.rb
81
85
  - lib/rouge/lexers/shell.rb
@@ -87,6 +91,7 @@ files:
87
91
  - lib/rouge/lexers/scheme.rb
88
92
  - lib/rouge/lexers/haml.rb
89
93
  - lib/rouge/lexers/erb.rb
94
+ - lib/rouge/lexers/literate_haskell.rb
90
95
  - lib/rouge/lexers/c.rb
91
96
  - lib/rouge/lexers/io.rb
92
97
  - lib/rouge/lexers/python.rb
@@ -115,9 +120,11 @@ files:
115
120
  - lib/rouge/demos/css
116
121
  - lib/rouge/demos/conf
117
122
  - lib/rouge/demos/haml
123
+ - lib/rouge/demos/literate_haskell
118
124
  - lib/rouge/demos/io
119
125
  - lib/rouge/demos/c
120
126
  - lib/rouge/demos/scss
127
+ - lib/rouge/demos/literate_coffeescript
121
128
  - lib/rouge/demos/python
122
129
  - lib/rouge/demos/make
123
130
  - lib/rouge/demos/clojure
@@ -136,6 +143,7 @@ files:
136
143
  - lib/rouge/demos/cpp
137
144
  - lib/rouge/demos/coffeescript
138
145
  - lib/rouge/demos/sql
146
+ - lib/rouge/demos/puppet
139
147
  - lib/rouge/demos/scheme
140
148
  - lib/rouge/demos/diff
141
149
  homepage: http://github.com/jayferd/rouge
@@ -145,17 +153,17 @@ rdoc_options: []
145
153
  require_paths:
146
154
  - lib
147
155
  required_ruby_version: !ruby/object:Gem::Requirement
148
- none: false
149
156
  requirements:
150
157
  - - ! '>='
151
158
  - !ruby/object:Gem::Version
152
159
  version: '0'
153
- required_rubygems_version: !ruby/object:Gem::Requirement
154
160
  none: false
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
162
  requirements:
156
163
  - - ! '>='
157
164
  - !ruby/object:Gem::Version
158
165
  version: '0'
166
+ none: false
159
167
  requirements: []
160
168
  rubyforge_project: rouge
161
169
  rubygems_version: 1.8.23