rouge 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ %%% Geometry module.
2
+ -module(geometry).
3
+ -export([area/1]).
4
+
5
+ %% Compute rectangle and circle area.
6
+ area({rectangle, Width, Ht}) -> Width * Ht;
7
+ area({circle, R}) -> 3.14159 * R * R.
@@ -0,0 +1,14 @@
1
+ POST /demo/submit/ HTTP/1.1
2
+ Host: rouge.jayferd.us
3
+ Cache-Control: max-age=0
4
+ Origin: http://rouge.jayferd.us
5
+ User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2)
6
+ AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
7
+ Content-Type: application/json
8
+ Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
9
+ Referer: http://pygments.org/
10
+ Accept-Encoding: gzip,deflate,sdch
11
+ Accept-Language: en-US,en;q=0.8
12
+ Accept-Charset: windows-949,utf-8;q=0.7,*;q=0.3
13
+
14
+ {"name":"test","lang":"text","boring":true}
@@ -0,0 +1,124 @@
1
+ module Rouge
2
+ module Lexers
3
+ class Erlang < RegexLexer
4
+ desc "The Erlang programming language (erlang.org)"
5
+ tag 'erlang'
6
+ aliases 'erl'
7
+ filenames '*.erl', '*.hrl'
8
+
9
+ mimetypes 'text/x-erlang', 'application/x-erlang'
10
+
11
+ def self.analyze_text(text)
12
+ return 0.3 if text =~ /^-module[(]\w+[)][.]/
13
+ end
14
+
15
+ keywords = %w(
16
+ after begin case catch cond end fun if
17
+ let of query receive try when
18
+ )
19
+
20
+ builtins = %w(
21
+ abs append_element apply atom_to_list binary_to_list
22
+ bitstring_to_list binary_to_term bit_size bump_reductions
23
+ byte_size cancel_timer check_process_code delete_module
24
+ demonitor disconnect_node display element erase exit
25
+ float float_to_list fun_info fun_to_list
26
+ function_exported garbage_collect get get_keys
27
+ group_leader hash hd integer_to_list iolist_to_binary
28
+ iolist_size is_atom is_binary is_bitstring is_boolean
29
+ is_builtin is_float is_function is_integer is_list
30
+ is_number is_pid is_port is_process_alive is_record
31
+ is_reference is_tuple length link list_to_atom
32
+ list_to_binary list_to_bitstring list_to_existing_atom
33
+ list_to_float list_to_integer list_to_pid list_to_tuple
34
+ load_module localtime_to_universaltime make_tuple md5
35
+ md5_final md5_update memory module_loaded monitor
36
+ monitor_node node nodes open_port phash phash2
37
+ pid_to_list port_close port_command port_connect
38
+ port_control port_call port_info port_to_list
39
+ process_display process_flag process_info purge_module
40
+ put read_timer ref_to_list register resume_process
41
+ round send send_after send_nosuspend set_cookie
42
+ setelement size spawn spawn_link spawn_monitor
43
+ spawn_opt split_binary start_timer statistics
44
+ suspend_process system_flag system_info system_monitor
45
+ system_profile term_to_binary tl trace trace_delivered
46
+ trace_info trace_pattern trunc tuple_size tuple_to_list
47
+ universaltime_to_localtime unlink unregister whereis
48
+ )
49
+
50
+ operators = %r{(\+\+?|--?|\*|/|<|>|/=|=:=|=/=|=<|>=|==?|<-|!|\?)}
51
+ word_operators = %w(
52
+ and andalso band bnot bor bsl bsr bxor
53
+ div not or orelse rem xor
54
+ )
55
+
56
+ atom_re = %r{(?:[a-z][a-zA-Z0-9_]*|'[^\n']*[^\\]')}
57
+
58
+ variable_re = %r{(?:[A-Z_][a-zA-Z0-9_]*)}
59
+
60
+ escape_re = %r{(?:\\(?:[bdefnrstv\'"\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))}
61
+
62
+ macro_re = %r{(?:#{variable_re}|#{atom_re})}
63
+
64
+ base_re = %r{(?:[2-9]|[12][0-9]|3[0-6])}
65
+
66
+ state :root do
67
+ rule(/\s+/, "Text")
68
+ rule(/%.*\n/, "Comment")
69
+ rule(%r{(#{keywords.join('|')})\b}, "Keyword")
70
+ rule(%r{(#{builtins.join('|')})\b}, "Name.Builtin")
71
+ rule(%r{(#{word_operators.join('|')})\b}, "Operator.Word")
72
+ rule(/^-/, "Punctuation", :directive)
73
+ rule(operators, "Operator")
74
+ rule(/"/, "Literal.String", :string)
75
+ rule(/<</, "Name.Label")
76
+ rule(/>>/, "Name.Label")
77
+ rule %r{(#{atom_re})(:)} do
78
+ group "Name.Namespace"
79
+ group "Punctuation"
80
+ end
81
+ rule %r{(?:^|(?<=:))(#{atom_re})(\s*)(\()} do
82
+ group "Name.Function"
83
+ group "Text"
84
+ group "Punctuation"
85
+ end
86
+ rule(%r{[+-]?#{base_re}#[0-9a-zA-Z]+}, "Literal.Number.Integer")
87
+ rule(/[+-]?\d+/, "Literal.Number.Integer")
88
+ rule(/[+-]?\d+.\d+/, "Literal.Number.Float")
89
+ rule(%r{[\]\[:_@\".{}()|;,]}, "Punctuation")
90
+ rule(variable_re, "Name.Variable")
91
+ rule(atom_re, "Name")
92
+ rule(%r{\?#{macro_re}}, "Name.Constant")
93
+ rule(%r{\$(?:#{escape_re}|\\[ %]|[^\\])}, "Literal.String.Char")
94
+ rule(%r{##{atom_re}(:?\.#{atom_re})?}, "Name.Label")
95
+ end
96
+
97
+ state :string do
98
+ rule(escape_re, "Literal.String.Escape")
99
+ rule(/"/, "Literal.String", :pop!)
100
+ rule(%r{~[0-9.*]*[~#+bBcdefginpPswWxX]}, "Literal.String.Interpol")
101
+ rule(%r{[^"\\~]+}, "Literal.String")
102
+ rule(/~/, "Literal.String")
103
+ end
104
+
105
+ state :directive do
106
+ rule %r{(define)(\s*)(\()(#{macro_re})} do
107
+ group "Name.Entity"
108
+ group "Text"
109
+ group "Punctuation"
110
+ group "Name.Constant"
111
+ pop!
112
+ end
113
+ rule %r{(record)(\s*)(\()(#{macro_re})} do
114
+ group "Name.Entity"
115
+ group "Text"
116
+ group "Punctuation"
117
+ group "Name.Label"
118
+ pop!
119
+ end
120
+ rule(atom_re, "Name.Entity", :pop!)
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,68 @@
1
+ module Rouge
2
+ module Lexers
3
+ class HTTP < RegexLexer
4
+ tag 'http'
5
+ desc 'http requests and responses'
6
+
7
+ def self.methods
8
+ @methods ||= %w(GET POST PUT DELETE HEAD OPTIONS TRACE)
9
+ end
10
+
11
+ start { @content_type = 'text/plain' }
12
+
13
+ state :root do
14
+ # request
15
+ rule %r(
16
+ (#{HTTP.methods.join('|')})([ ]+) # method
17
+ ([^ ]+)([ ]+) # path
18
+ (HTTPS?)(/)(1[.][01])(\r?\n|$) # http version
19
+ )ox do
20
+ group 'Name.Function'; group 'Text'
21
+ group 'Name.Namespace'; group 'Text'
22
+ group 'Keyword'; group 'Operator'
23
+ group 'Literal.Number'; group 'Text'
24
+ push :headers
25
+ end
26
+
27
+ # response
28
+ rule %r(
29
+ (HTTPS?)(/)(1[.][01])([ ]+) # http version
30
+ (\d{3})([ ]+) # status
31
+ ([^\r\n]+)(\r?\n|$) # status message
32
+ )x do
33
+ group 'Keyword'; group 'Operator'
34
+ group 'Literal.Number'; group 'Text'
35
+ group 'Literal.Number'; group 'Text'
36
+ group 'Name.Exception'; group 'Text'
37
+ push :headers
38
+ end
39
+ end
40
+
41
+ state :headers do
42
+ rule /([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)/ do |m|
43
+ key = m[1]
44
+ value = m[5]
45
+ if key.strip.downcase == 'content-type'
46
+ @content_type = value.split(';')[0].downcase
47
+ end
48
+
49
+ group 'Name.Attribute'; group 'Text'
50
+ group 'Punctuation'; group 'Text'
51
+ group 'Literal.String'; group 'Text'
52
+ end
53
+
54
+ rule /([^\r\n]+)(\r?\n|$)/ do
55
+ group 'Literal.String'; group 'Text'
56
+ end
57
+
58
+ rule /\r?\n/, 'Text', :content
59
+ end
60
+
61
+ state :content do
62
+ rule /.+/ do |m|
63
+ delegate Lexer.guess_by_mimetype(@content_type)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -182,6 +182,7 @@ module Rouge
182
182
  group 'Text.Whitespace'
183
183
  group 'Punctuation'
184
184
  end
185
+ rule /true|false/, 'Keyword.Constant'
185
186
  rule /{/, 'Punctuation', :object_key
186
187
  rule /\[/, 'Punctuation', :array
187
188
  rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, 'Literal.Number.Float'
data/lib/rouge/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Rouge
2
2
  def self.version
3
- "0.3.7"
3
+ "0.3.8"
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.7
4
+ version: 0.3.8
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-06-07 00:00:00.000000000 Z
12
+ date: 2013-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime
@@ -76,6 +76,7 @@ files:
76
76
  - lib/rouge/lexers/toml.rb
77
77
  - lib/rouge/lexers/puppet.rb
78
78
  - lib/rouge/lexers/ruby.rb
79
+ - lib/rouge/lexers/http.rb
79
80
  - lib/rouge/lexers/xml.rb
80
81
  - lib/rouge/lexers/handlebars.rb
81
82
  - lib/rouge/lexers/php.rb
@@ -87,6 +88,7 @@ files:
87
88
  - lib/rouge/lexers/scss.rb
88
89
  - lib/rouge/lexers/javascript.rb
89
90
  - lib/rouge/lexers/shell.rb
91
+ - lib/rouge/lexers/erlang.rb
90
92
  - lib/rouge/lexers/yaml.rb
91
93
  - lib/rouge/lexers/make.rb
92
94
  - lib/rouge/lexers/lua.rb
@@ -111,6 +113,7 @@ files:
111
113
  - lib/rouge/lexers/conf.rb
112
114
  - lib/rouge.rb
113
115
  - bin/rougify
116
+ - lib/rouge/demos/erlang
114
117
  - lib/rouge/demos/sass
115
118
  - lib/rouge/demos/ruby
116
119
  - lib/rouge/demos/factor
@@ -149,6 +152,7 @@ files:
149
152
  - lib/rouge/demos/nginx
150
153
  - lib/rouge/demos/toml
151
154
  - lib/rouge/demos/gherkin
155
+ - lib/rouge/demos/http
152
156
  - lib/rouge/demos/rust
153
157
  - lib/rouge/demos/json
154
158
  - lib/rouge/demos/markdown