rouge 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 105d563933ea57ff19cca03ab1fd98fc3b01ea3a
4
- data.tar.gz: 72e6098b1419ff753ddb8bf748d6822d5fc5c1a5
3
+ metadata.gz: ddf4afdd370e299029a9ec6d47a7742cb94208a1
4
+ data.tar.gz: a5cb0844af8b6be69ec296679c9ae5d28ed59034
5
5
  SHA512:
6
- metadata.gz: 6346ab18ab19b7758e3f37eec75ddeac72a11edacd4416783dbfaccb33e3aadda9841373db11436a9fe4fbdd457a8bb2f4575f79b2c546e596b9d9cc829612e3
7
- data.tar.gz: 9df1ed34e20dfbb2733ebef31d80792547913afdff931c556e73ff731875968233f12e1c62e91cfbaa84d4653b684aeec5e9a4778ff16fb3c5279585b974a846
6
+ metadata.gz: 7fa77ad742055077ee715ec202ad8fd4d8929dbd8397d1c9d16b0ea0e8a84d6b118b13dbb255dfb643ab89c88d348f22d80d157b836d350555b2f4afe1989ba6
7
+ data.tar.gz: a5c77e2ab64220fcf42c8afc71185f5f03c8dee74dd6dc27fb54e5a88002806d3b63aeadb9db121507e0a8b539c1e36d4235ee4c82d9f4c0f4ae8262bc92233c
@@ -0,0 +1,4 @@
1
+ import Html exposing (text)
2
+
3
+ main =
4
+ text "Hello, World!"
@@ -0,0 +1,5 @@
1
+ <?hh // strict
2
+
3
+ async function foo(): Awaitable<string> {
4
+ return await (() ==> 'Hello, world')();
5
+ }
@@ -83,6 +83,19 @@ module Rouge
83
83
 
84
84
  next Matlab if matches?(/^\s*?%/)
85
85
  end
86
+
87
+ disambiguate '*.php' do
88
+ # PHP always takes precedence over Hack
89
+ PHP
90
+ end
91
+
92
+ disambiguate '*.hh' do
93
+ next Cpp if matches?(/^\s*#include/)
94
+ next Hack if matches?(/^<\?hh/)
95
+ next Hack if matches?(/(\(|, ?)\$\$/)
96
+
97
+ Cpp
98
+ end
86
99
  end
87
100
  end
88
101
  end
@@ -85,7 +85,7 @@ module Rouge
85
85
 
86
86
  state :whitespace do
87
87
  rule /\n+/m, Text, :bol
88
- rule %r(//(\\.|.)*?\n), Comment::Single, :bol
88
+ rule %r(//(\\.|.)*?$), Comment::Single, :bol
89
89
  mixin :inline_whitespace
90
90
  end
91
91
 
@@ -0,0 +1,89 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Elm < RegexLexer
6
+ title "Elm"
7
+ desc "The Elm programming language (http://elm-lang.org/)"
8
+
9
+ tag 'elm'
10
+ filenames '*.elm'
11
+ mimetypes 'text/x-elm'
12
+
13
+ # Keywords are logically grouped by lines
14
+ keywords = %w(
15
+ module exposing port
16
+ import as
17
+ type alias
18
+ if then else
19
+ case of
20
+ let in
21
+ )
22
+
23
+ state :root do
24
+ # Whitespaces
25
+ rule /\s+/m, Text
26
+ # Single line comments
27
+ rule /--.*/, Comment::Single
28
+ # Multiline comments
29
+ rule /{-/, Comment::Multiline, :multiline_comment
30
+
31
+ # Keywords
32
+ rule /\b(#{keywords.join('|')})\b/, Keyword
33
+
34
+ # Variable or a function
35
+ rule /[a-z][\w]*/, Name
36
+ # Underscore is a name for a variable, when it won't be used later
37
+ rule /_/, Name
38
+ # Type
39
+ rule /[A-Z][\w]*/, Keyword::Type
40
+
41
+ # Two symbol operators: -> :: // .. && || ++ |> <| << >> == /= <= >=
42
+ rule /(->|::|\/\/|\.\.|&&|\|\||\+\+|\|>|<\||>>|<<|==|\/=|<=|>=)/, Operator
43
+ # One symbol operators: + - / * % = < > ^ | !
44
+ rule /[+-\/*%=<>^\|!]/, Operator
45
+ # Lambda operator
46
+ rule /\\/, Operator
47
+ # Not standard Elm operators, but these symbols can be used for custom inflix operators. We need to highlight them as operators as well.
48
+ rule /[@\#$&~?]/, Operator
49
+
50
+ # Single, double quotes, and triple double quotes
51
+ rule /"""/, Str, :multiline_string
52
+ rule /'(\\.|.)'/, Str::Char
53
+ rule /"/, Str, :double_quote
54
+
55
+ # Numbers
56
+ rule /0x[\da-f]+/i, Num::Hex
57
+ rule /\d+e[+-]?\d+/i, Num::Float
58
+ rule /\d+\.\d+(e[+-]?\d+)?/i, Num::Float
59
+ rule /\d+/, Num::Integer
60
+
61
+ # Punctuation: [ ] ( ) , ; ` { } :
62
+ rule /[\[\](),;`{}:]/, Punctuation
63
+ end
64
+
65
+ # Multiline and nested commenting
66
+ state :multiline_comment do
67
+ rule /-}/, Comment::Multiline, :pop!
68
+ rule /{-/, Comment::Multiline, :multiline_comment
69
+ rule /[^-{}]+/, Comment::Multiline
70
+ rule /[-{}]/, Comment::Multiline
71
+ end
72
+
73
+ # Double quotes
74
+ state :double_quote do
75
+ rule /[^\\"]+/, Str::Double
76
+ rule /\\"/, Str::Escape
77
+ rule /"/, Str::Double, :pop!
78
+ end
79
+
80
+ # Multiple line string with tripple double quotes, e.g. """ multi """
81
+ state :multiline_string do
82
+ rule /\s*"""/, Str, :pop!
83
+ rule /.*/, Str
84
+ rule /\s*/, Str
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -41,7 +41,7 @@ module Rouge
41
41
  end
42
42
 
43
43
  operator = %r([\[\];,{}_()!$%&*+./:<=>?@^|~#-]+)
44
- id = /[a-z][\w']*/i
44
+ id = /([a-z][\w']*)|(``[^`\n\r\t]+``)/i
45
45
  upper_id = /[A-Z][\w']*/
46
46
 
47
47
  state :root do
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ load_lexer 'php.rb'
6
+
7
+ class Hack < PHP
8
+ title 'Hack'
9
+ desc 'The Hack programming language (hacklang.org)'
10
+ tag 'hack'
11
+ aliases 'hack', 'hh'
12
+ filenames '*.php', '*.hh'
13
+
14
+ def self.detect?(text)
15
+ return true if /<\?hh/ =~ text
16
+ return true if text.shebang?('hhvm')
17
+ return true if /async function [a-zA-Z]/ =~ text
18
+ return true if /\): Awaitable</ =~ text
19
+
20
+ return false
21
+ end
22
+
23
+ def self.keywords
24
+ @hh_keywords ||= super.merge Set.new %w(
25
+ type newtype enum
26
+ as super
27
+ async await Awaitable
28
+ vec dict keyset
29
+ void int string bool float double
30
+ arraykey num Stringish
31
+ )
32
+ end
33
+
34
+ prepend :template do
35
+ rule /<\?hh(\s*\/\/\s*(strict|decl|partial))?$/, Comment::Preproc, :php
36
+ end
37
+
38
+ prepend :php do
39
+ rule %r((/\*\s*)(HH_(?:IGNORE_ERROR|FIXME)\[\d+\])([^*]*)(\*/)) do
40
+ groups Comment::Preproc, Comment::Preproc, Comment::Multiline, Comment::Preproc
41
+ end
42
+
43
+ rule %r(// UNSAFE(?:_EXPR|_BLOCK)?), Comment::Preproc
44
+ rule %r(/\*\s*UNSAFE_EXPR\s*\*/), Comment::Preproc
45
+ end
46
+ end
47
+ end
48
+ end
@@ -55,7 +55,6 @@ module Rouge
55
55
 
56
56
  rule /\bimport\b/, Keyword::Reserved, :import
57
57
  rule /\bmodule\b/, Keyword::Reserved, :module
58
- rule /\berror\b/, Name::Exception
59
58
  rule /\b(?:#{reserved.join('|')})\b/, Keyword::Reserved
60
59
  # not sure why, but ^ doesn't work here
61
60
  # rule /^[_a-z][\w']*/, Name::Function
@@ -31,7 +31,7 @@ module Rouge
31
31
  rule %r'^\s*\[.*?\]', Name::Attribute
32
32
  rule %r'[^\S\n]+', Text
33
33
  rule %r'\\\n', Text # line continuation
34
- rule %r'//.*?\n', Comment::Single
34
+ rule %r'//.*?$', Comment::Single
35
35
  rule %r'/[*].*?[*]/'m, Comment::Multiline
36
36
  rule %r'\n', Text
37
37
  rule %r'::|!!|\?[:.]', Operator
@@ -77,6 +77,8 @@ module Rouge
77
77
 
78
78
  def self.detect?(text)
79
79
  return true if text.shebang?('php')
80
+ return false if /^<\?hh/ =~ text
81
+ return true if /^<\?php/ =~ text
80
82
  end
81
83
 
82
84
  state :root do
@@ -97,8 +99,8 @@ module Rouge
97
99
  # heredocs
98
100
  rule /<<<('?)(#{id})\1\n.*?\n\2;?\n/im, Str::Heredoc
99
101
  rule /\s+/, Text
100
- rule /#.*?\n/, Comment::Single
101
- rule %r(//.*?\n), Comment::Single
102
+ rule /#.*?$/, Comment::Single
103
+ rule %r(//.*?$), Comment::Single
102
104
  # empty comment, otherwise seen as the start of a docstring
103
105
  rule %r(/\*\*/), Comment::Multiline
104
106
  rule %r(/\*\*.*?\*/)m, Str::Doc
@@ -9,7 +9,7 @@ module Rouge
9
9
  desc 'powershell'
10
10
  tag 'powershell'
11
11
  aliases 'posh'
12
- filenames '*.ps1', '*.psm1', '*.psd1'
12
+ filenames '*.ps1', '*.psm1', '*.psd1', '*.psrc', '*.pssc'
13
13
  mimetypes 'text/x-powershell'
14
14
 
15
15
  ATTRIBUTES = %w(
@@ -19,6 +19,7 @@ module Rouge
19
19
  assert break continue del elif else except exec
20
20
  finally for global if lambda pass print raise
21
21
  return try while yield as with from import yield
22
+ async await
22
23
  )
23
24
  end
24
25
 
@@ -9,7 +9,7 @@ module Rouge
9
9
  aliases 'rb'
10
10
  filenames '*.rb', '*.ruby', '*.rbw', '*.rake', '*.gemspec', '*.podspec',
11
11
  'Rakefile', 'Guardfile', 'Gemfile', 'Capfile', 'Podfile',
12
- 'Vagrantfile', '*.ru', '*.prawn', 'Berksfile'
12
+ 'Vagrantfile', '*.ru', '*.prawn', 'Berksfile', '*.arb'
13
13
 
14
14
  mimetypes 'text/x-ruby', 'application/x-ruby'
15
15
 
@@ -18,8 +18,8 @@ module Rouge
18
18
  @keywords ||= %w(
19
19
  as assert break const copy do drop else enum extern fail false
20
20
  fn for if impl let log loop match mod move mut priv pub pure
21
- ref return self static struct true trait type unsafe use while
22
- box
21
+ ref return self static struct true trait type unsafe use where
22
+ while box
23
23
  )
24
24
  end
25
25
 
@@ -23,7 +23,7 @@ module Rouge
23
23
 
24
24
  state :content do
25
25
  # block comments
26
- rule %r(//.*?\n) do
26
+ rule %r(//.*?$) do
27
27
  token Comment::Single
28
28
  pop!; starts_block :single_comment
29
29
  end
@@ -42,13 +42,13 @@ module Rouge
42
42
 
43
43
  rule /:/, Name::Attribute, :old_style_attr
44
44
 
45
- rule(/(?=.+?:([^a-z]|$))/) { push :attribute }
45
+ rule(/(?=[^\[\n]+?:([^a-z]|$))/) { push :attribute }
46
46
 
47
47
  rule(//) { push :selector }
48
48
  end
49
49
 
50
50
  state :single_comment do
51
- rule /.*?\n/, Comment::Single, :pop!
51
+ rule /.*?$/, Comment::Single, :pop!
52
52
  end
53
53
 
54
54
  state :multi_comment do
@@ -13,14 +13,14 @@ module Rouge
13
13
 
14
14
  state :root do
15
15
  rule /\s+/, Text
16
- rule %r(//.*?\n), Comment::Single
16
+ rule %r(//.*?$), Comment::Single
17
17
  rule %r(/[*].*?[*]/)m, Comment::Multiline
18
18
  rule /@import\b/, Keyword, :value
19
19
 
20
20
  mixin :content_common
21
21
 
22
22
  rule(/(?=[^;{}][;}])/) { push :attribute }
23
- rule(/(?=[^;{}:]+:[^a-z])/) { push :attribute }
23
+ rule(/(?=[^;{}:\[]+:[^a-z])/) { push :attribute }
24
24
 
25
25
  rule(//) { push :selector }
26
26
  end
@@ -24,13 +24,22 @@ module Rouge
24
24
 
25
25
  BUILTINS = %w(
26
26
  alias bg bind break builtin caller cd command compgen
27
- complete declare dirs disown echo enable eval exec exit
28
- export false fc fg getopts hash help history jobs kill let
29
- local logout popd printf pushd pwd read readonly set shift
30
- shopt source suspend test time times trap true type typeset
31
- ulimit umask unalias unset wait
32
-
33
- ls tar cat grep sudo
27
+ complete declare dirs disown enable eval exec exit
28
+ export false fc fg getopts hash help history jobs let
29
+ local logout mapfile popd pushd pwd read readonly set
30
+ shift shopt source suspend test time times trap true type
31
+ typeset ulimit umask unalias unset wait
32
+
33
+ cat tac nl od base32 base64 fmt pr fold head tail split csplit
34
+ wc sum cksum b2sum md5sum sha1sum sha224sum sha256sum sha384sum
35
+ sha512sum sort shuf uniq comm ptx tsort cut paste join tr expand
36
+ unexpand ls dir vdir dircolors cp dd install mv rm shred link ln
37
+ mkdir mkfifo mknod readlink rmdir unlink chown chgrp chmod touch
38
+ df du stat sync truncate echo printf yes expr tee basename dirname
39
+ pathchk mktemp realpath pwd stty printenv tty id logname whoami
40
+ groups users who date arch nproc uname hostname hostid uptime chcon
41
+ runcon chroot env nice nohup stdbuf timeout kill sleep factor numfmt
42
+ seq tar grep sudo awk sed gzip gunzip
34
43
  ).join('|')
35
44
 
36
45
  state :basic do
@@ -66,7 +66,7 @@ module Rouge
66
66
  mixin :whitespace
67
67
  rule /\$(([1-9]\d*)?\d)/, Name::Variable
68
68
 
69
- rule %r{[()\[\]{}:;,?]}, Punctuation
69
+ rule %r{[()\[\]{}:;,?\\]}, Punctuation
70
70
  rule %r([-/=+*%<>!&|^.~]+), Operator
71
71
  rule /@?"/, Str, :dq
72
72
  rule /'(\\.|.)'/, Str::Char
@@ -107,8 +107,13 @@ module Rouge
107
107
  groups Keyword, Text, Name::Variable
108
108
  end
109
109
 
110
- rule /(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[(])/ do |m|
111
- if m[0] =~ /^[[:upper:]]/
110
+ rule /(let|var)\b(\s*)([(])/ do
111
+ groups Keyword, Text, Punctuation
112
+ push :tuple
113
+ end
114
+
115
+ rule /(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[({])/ do |m|
116
+ if m[1] == '(' && m[0] =~ /^[[:upper:]]/
112
117
  token Keyword::Type
113
118
  else
114
119
  token Name::Function
@@ -135,6 +140,21 @@ module Rouge
135
140
  token Name
136
141
  end
137
142
  end
143
+
144
+ rule /(`)(#{id})(`)/ do
145
+ groups Punctuation, Name::Variable, Punctuation
146
+ end
147
+ end
148
+
149
+ state :tuple do
150
+ rule /(#{id})/, Name::Variable
151
+ rule /(`)(#{id})(`)/ do
152
+ groups Punctuation, Name::Variable, Punctuation
153
+ end
154
+ rule /,/, Punctuation
155
+ rule /[(]/, Punctuation, :push
156
+ rule /[)]/, Punctuation, :pop!
157
+ mixin :inline_whitespace
138
158
  end
139
159
 
140
160
  state :dq do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rouge
4
4
  def self.version
5
- "3.0.0"
5
+ "3.1.0"
6
6
  end
7
7
  end
@@ -16,4 +16,8 @@ Gem::Specification.new do |s|
16
16
  s.executables = %w(rougify)
17
17
  s.licenses = ['MIT', 'BSD-2-Clause']
18
18
  s.required_ruby_version = '>= 2.0'
19
+ s.metadata = {
20
+ 'source_code_uri' => 'https://github.com/jneen/rouge',
21
+ 'changelog_uri' => 'https://github.com/jneen/rouge/blob/master/CHANGELOG.md'
22
+ }
19
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-12-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
14
14
  email:
@@ -52,6 +52,7 @@ files:
52
52
  - lib/rouge/demos/dot
53
53
  - lib/rouge/demos/eiffel
54
54
  - lib/rouge/demos/elixir
55
+ - lib/rouge/demos/elm
55
56
  - lib/rouge/demos/erb
56
57
  - lib/rouge/demos/erlang
57
58
  - lib/rouge/demos/factor
@@ -63,6 +64,7 @@ files:
63
64
  - lib/rouge/demos/gradle
64
65
  - lib/rouge/demos/graphql
65
66
  - lib/rouge/demos/groovy
67
+ - lib/rouge/demos/hack
66
68
  - lib/rouge/demos/haml
67
69
  - lib/rouge/demos/handlebars
68
70
  - lib/rouge/demos/haskell
@@ -201,6 +203,7 @@ files:
201
203
  - lib/rouge/lexers/dot.rb
202
204
  - lib/rouge/lexers/eiffel.rb
203
205
  - lib/rouge/lexers/elixir.rb
206
+ - lib/rouge/lexers/elm.rb
204
207
  - lib/rouge/lexers/erb.rb
205
208
  - lib/rouge/lexers/erlang.rb
206
209
  - lib/rouge/lexers/factor.rb
@@ -213,6 +216,7 @@ files:
213
216
  - lib/rouge/lexers/gradle.rb
214
217
  - lib/rouge/lexers/graphql.rb
215
218
  - lib/rouge/lexers/groovy.rb
219
+ - lib/rouge/lexers/hack.rb
216
220
  - lib/rouge/lexers/haml.rb
217
221
  - lib/rouge/lexers/handlebars.rb
218
222
  - lib/rouge/lexers/haskell.rb
@@ -333,7 +337,9 @@ homepage: http://rouge.jneen.net/
333
337
  licenses:
334
338
  - MIT
335
339
  - BSD-2-Clause
336
- metadata: {}
340
+ metadata:
341
+ source_code_uri: https://github.com/jneen/rouge
342
+ changelog_uri: https://github.com/jneen/rouge/blob/master/CHANGELOG.md
337
343
  post_install_message:
338
344
  rdoc_options: []
339
345
  require_paths: