rouge 1.7.7 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge.rb +1 -0
  3. data/lib/rouge/cli.rb +1 -1
  4. data/lib/rouge/demos/liquid +11 -0
  5. data/lib/rouge/lexer.rb +8 -0
  6. data/lib/rouge/lexers/apache.rb +1 -0
  7. data/lib/rouge/lexers/apple_script.rb +1 -0
  8. data/lib/rouge/lexers/c.rb +1 -0
  9. data/lib/rouge/lexers/clojure.rb +1 -0
  10. data/lib/rouge/lexers/coffeescript.rb +1 -0
  11. data/lib/rouge/lexers/common_lisp.rb +1 -0
  12. data/lib/rouge/lexers/conf.rb +1 -0
  13. data/lib/rouge/lexers/cpp.rb +1 -0
  14. data/lib/rouge/lexers/csharp.rb +1 -0
  15. data/lib/rouge/lexers/css.rb +1 -0
  16. data/lib/rouge/lexers/dart.rb +1 -0
  17. data/lib/rouge/lexers/diff.rb +1 -0
  18. data/lib/rouge/lexers/elixir.rb +1 -0
  19. data/lib/rouge/lexers/erb.rb +1 -0
  20. data/lib/rouge/lexers/erlang.rb +1 -0
  21. data/lib/rouge/lexers/factor.rb +1 -0
  22. data/lib/rouge/lexers/gherkin.rb +1 -1
  23. data/lib/rouge/lexers/go.rb +1 -0
  24. data/lib/rouge/lexers/groovy.rb +1 -0
  25. data/lib/rouge/lexers/haml.rb +1 -0
  26. data/lib/rouge/lexers/handlebars.rb +1 -0
  27. data/lib/rouge/lexers/haskell.rb +1 -0
  28. data/lib/rouge/lexers/html.rb +1 -0
  29. data/lib/rouge/lexers/http.rb +1 -0
  30. data/lib/rouge/lexers/ini.rb +1 -0
  31. data/lib/rouge/lexers/io.rb +1 -0
  32. data/lib/rouge/lexers/java.rb +1 -0
  33. data/lib/rouge/lexers/javascript.rb +1 -0
  34. data/lib/rouge/lexers/liquid.rb +282 -0
  35. data/lib/rouge/lexers/literate_coffeescript.rb +1 -0
  36. data/lib/rouge/lexers/literate_haskell.rb +2 -2
  37. data/lib/rouge/lexers/llvm.rb +1 -0
  38. data/lib/rouge/lexers/lua.rb +1 -0
  39. data/lib/rouge/lexers/make.rb +1 -0
  40. data/lib/rouge/lexers/markdown.rb +1 -0
  41. data/lib/rouge/lexers/matlab.rb +1 -0
  42. data/lib/rouge/lexers/moonscript.rb +1 -0
  43. data/lib/rouge/lexers/nginx.rb +1 -0
  44. data/lib/rouge/lexers/nim.rb +5 -4
  45. data/lib/rouge/lexers/objective_c.rb +1 -1
  46. data/lib/rouge/lexers/ocaml.rb +1 -1
  47. data/lib/rouge/lexers/perl.rb +1 -0
  48. data/lib/rouge/lexers/php.rb +1 -0
  49. data/lib/rouge/lexers/plain_text.rb +1 -0
  50. data/lib/rouge/lexers/prolog.rb +1 -0
  51. data/lib/rouge/lexers/properties.rb +1 -0
  52. data/lib/rouge/lexers/puppet.rb +1 -0
  53. data/lib/rouge/lexers/python.rb +1 -0
  54. data/lib/rouge/lexers/qml.rb +1 -1
  55. data/lib/rouge/lexers/r.rb +2 -2
  56. data/lib/rouge/lexers/racket.rb +1 -0
  57. data/lib/rouge/lexers/ruby.rb +3 -2
  58. data/lib/rouge/lexers/rust.rb +1 -0
  59. data/lib/rouge/lexers/sass.rb +1 -0
  60. data/lib/rouge/lexers/scala.rb +1 -0
  61. data/lib/rouge/lexers/scheme.rb +1 -0
  62. data/lib/rouge/lexers/scss.rb +1 -0
  63. data/lib/rouge/lexers/sed.rb +1 -0
  64. data/lib/rouge/lexers/shell.rb +1 -0
  65. data/lib/rouge/lexers/slim.rb +3 -2
  66. data/lib/rouge/lexers/smalltalk.rb +1 -0
  67. data/lib/rouge/lexers/sml.rb +1 -1
  68. data/lib/rouge/lexers/sql.rb +1 -0
  69. data/lib/rouge/lexers/swift.rb +24 -7
  70. data/lib/rouge/lexers/tcl.rb +1 -0
  71. data/lib/rouge/lexers/tex.rb +1 -0
  72. data/lib/rouge/lexers/toml.rb +1 -0
  73. data/lib/rouge/lexers/vb.rb +1 -1
  74. data/lib/rouge/lexers/viml.rb +1 -0
  75. data/lib/rouge/lexers/xml.rb +1 -0
  76. data/lib/rouge/lexers/yaml.rb +1 -0
  77. data/lib/rouge/themes/molokai.rb +82 -0
  78. data/lib/rouge/themes/monokai.rb +4 -2
  79. data/lib/rouge/version.rb +1 -1
  80. metadata +5 -2
@@ -4,6 +4,7 @@ module Rouge
4
4
  module Lexers
5
5
  class LiterateCoffeescript < RegexLexer
6
6
  tag 'literate_coffeescript'
7
+ title "Literate CoffeeScript"
7
8
  desc 'Literate coffeescript'
8
9
  aliases 'litcoffee'
9
10
  filenames '*.litcoffee'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class LiterateHaskell < RegexLexer
6
+ title "Literate Haskell"
6
7
  desc 'Literate haskell'
7
8
  tag 'literate_haskell'
8
9
  aliases 'lithaskell', 'lhaskell', 'lhs'
@@ -16,7 +17,6 @@ module Rouge
16
17
  start { haskell.reset! }
17
18
 
18
19
  # TODO: support TeX versions as well.
19
- # TODO: enforce a blank line before and after code
20
20
  state :root do
21
21
  rule /\s*?\n(?=>)/, Text, :code
22
22
  rule /.*?\n/, Text
@@ -24,7 +24,7 @@ module Rouge
24
24
  end
25
25
 
26
26
  state :code do
27
- rule /(>)( .*?\n)/ do |m|
27
+ rule /(>)( .*?(\n|\z))/ do |m|
28
28
  token Name::Label, m[1]
29
29
  delegate haskell, m[2]
30
30
  end
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class LLVM < RegexLexer
6
+ title "LLVM"
6
7
  desc 'The LLVM Compiler Infrastructure (http://llvm.org/)'
7
8
  tag 'llvm'
8
9
 
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Lua < RegexLexer
6
+ title "Lua"
6
7
  desc "Lua (http://www.lua.org)"
7
8
  tag 'lua'
8
9
  filenames '*.lua', '*.wlua'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Make < RegexLexer
6
+ title "Make"
6
7
  desc "Makefile syntax"
7
8
  tag 'make'
8
9
  aliases 'makefile', 'mf', 'gnumake', 'bsdmake'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Markdown < RegexLexer
6
+ title "Markdown"
6
7
  desc "Markdown, a light-weight markup language for authors"
7
8
 
8
9
  tag 'markdown'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Matlab < RegexLexer
6
+ title "MATLAB"
6
7
  desc "Matlab"
7
8
  tag 'matlab'
8
9
  aliases 'm'
@@ -5,6 +5,7 @@ module Rouge
5
5
  load_const :Lua, 'lua.rb'
6
6
 
7
7
  class Moonscript < RegexLexer
8
+ title "MoonScript"
8
9
  desc "Moonscript (http://www.moonscript.org)"
9
10
  tag 'moonscript'
10
11
  aliases 'moon'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Nginx < RegexLexer
6
+ title "nginx"
6
7
  desc 'configuration files for the nginx web server (nginx.org)'
7
8
  tag 'nginx'
8
9
  mimetypes 'text/x-nginx-conf'
@@ -4,6 +4,7 @@ module Rouge
4
4
  module Lexers
5
5
  class Nim < RegexLexer
6
6
  # This is pretty much a 1-1 port of the pygments NimrodLexer class
7
+ title "Nim"
7
8
  desc "The Nim programming language (http://nim-lang.org/)"
8
9
 
9
10
  tag 'nim'
@@ -13,8 +14,8 @@ module Rouge
13
14
  KEYWORDS = %w(
14
15
  addr as asm atomic bind block break case cast const continue
15
16
  converter defer discard distinct do elif else end enum except export
16
- func finally for from generic if import include interface iterator let
17
- macro method mixin nil object of out proc ptr raise ref return static
17
+ func finally for from generic if import include interface iterator let
18
+ macro method mixin nil object of out proc ptr raise ref return static
18
19
  template try tuple type using var when while with without yield
19
20
  )
20
21
 
@@ -29,7 +30,7 @@ module Rouge
29
30
  TYPES = %w(
30
31
  int int8 int16 int32 int64 float float32 float64 bool char range array
31
32
  seq set string
32
- )
33
+ )
33
34
 
34
35
  NAMESPACE = %w(
35
36
  from import include
@@ -133,7 +134,7 @@ module Rouge
133
134
  # since we can't pass array of states like w/ Pygments.
134
135
  rule(/[0-9][0-9_]*(?=([eE.]|'?[fF](32|64)))/) do |number|
135
136
  push :floatsuffix
136
- push :floatnumber
137
+ push :floatnumber
137
138
  token Num::Float
138
139
  end
139
140
  rule(/0[xX][a-fA-F0-9][a-fA-F0-9_]*/, Num::Hex, :intsuffix)
@@ -6,6 +6,7 @@ module Rouge
6
6
 
7
7
  class ObjectiveC < C
8
8
  tag 'objective_c'
9
+ title "Objective-C"
9
10
  desc 'an extension of C commonly used to write Apple software'
10
11
  aliases 'objc'
11
12
  filenames '*.m', '*.h'
@@ -187,4 +188,3 @@ module Rouge
187
188
  end
188
189
  end
189
190
  end
190
-
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class OCaml < RegexLexer
6
+ title "OCaml"
6
7
  desc 'Objective CAML (ocaml.org)'
7
8
  tag 'ocaml'
8
9
  filenames '*.ml', '*.mli', '*.mll', '*.mly'
@@ -108,4 +109,3 @@ module Rouge
108
109
  end
109
110
  end
110
111
  end
111
-
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Perl < RegexLexer
6
+ title "Perl"
6
7
  desc "The Perl scripting language (perl.org)"
7
8
 
8
9
  tag 'perl'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class PHP < TemplateLexer
6
+ title "PHP"
6
7
  desc "The PHP scripting language (php.net)"
7
8
  tag 'php'
8
9
  aliases 'php', 'php3', 'php4', 'php5'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class PlainText < Lexer
6
+ title "Plain Text"
6
7
  desc "A boring lexer that doesn't highlight anything"
7
8
 
8
9
  tag 'plaintext'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Prolog < RegexLexer
6
+ title "Prolog"
6
7
  desc "The Prolog programming language (http://en.wikipedia.org/wiki/Prolog)"
7
8
  tag 'prolog'
8
9
  aliases 'prolog'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Properties < RegexLexer
6
+ title ".properties"
6
7
  desc '.properties config files for Java'
7
8
  tag 'properties'
8
9
 
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Puppet < RegexLexer
6
+ title "Puppet"
6
7
  desc 'The Puppet configuration management language (puppetlabs.org)'
7
8
  tag 'puppet'
8
9
  aliases 'pp'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Python < RegexLexer
6
+ title "Python"
6
7
  desc "The Python programming language (python.org)"
7
8
  tag 'python'
8
9
  aliases 'py'
@@ -4,6 +4,7 @@ module Rouge
4
4
  module Lexers
5
5
  load_const :Javascript, 'javascript.rb'
6
6
  class Qml < Javascript
7
+ title "QML"
7
8
  desc 'QML, a UI markup language'
8
9
  tag 'qml'
9
10
  aliases 'qml'
@@ -69,4 +70,3 @@ module Rouge
69
70
  end
70
71
  end
71
72
  end
72
-
@@ -3,10 +3,11 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class R < RegexLexer
6
+ title "R"
6
7
  desc 'The R statistics language (r-project.org)'
7
8
  tag 'r'
8
9
  aliases 'r', 'R', 's', 'S'
9
- filenames '*.R', '*.S', '.Rhistory', '.Rprofile'
10
+ filenames '*.R', '.Rhistory', '.Rprofile'
10
11
  mimetypes 'text/x-r-source', 'text/x-r', 'text/x-R'
11
12
 
12
13
  mimetypes 'text/x-r', 'application/x-r'
@@ -19,7 +20,6 @@ module Rouge
19
20
 
20
21
  def self.analyze_text(text)
21
22
  return 1 if text.shebang? 'Rscript'
22
- return 0.1 if text.include? '->'
23
23
  end
24
24
 
25
25
  state :root do
@@ -2,6 +2,7 @@
2
2
  module Rouge
3
3
  module Lexers
4
4
  class Racket < RegexLexer
5
+ title "Racket"
5
6
  desc "Racket is a Lisp descended from Scheme (racket-lang.org)"
6
7
 
7
8
  tag 'racket'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Ruby < RegexLexer
6
+ title "Ruby"
6
7
  desc "The Ruby programming language (ruby-lang.org)"
7
8
  tag 'ruby'
8
9
  aliases 'rb'
@@ -108,8 +109,8 @@ module Rouge
108
109
 
109
110
  keywords_pseudo = %w(
110
111
  initialize new loop include extend raise attr_reader attr_writer
111
- attr_accessor attr catch throw private module_function public
112
- protected true false nil __FILE__ __LINE__
112
+ attr_accessor alias_method attr catch throw private module_function
113
+ public protected true false nil __FILE__ __LINE__
113
114
  )
114
115
 
115
116
  builtins_g = %w(
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Rust < RegexLexer
6
+ title "Rust"
6
7
  desc 'The Rust programming language (rust-lang.org)'
7
8
  tag 'rust'
8
9
  aliases 'rs'
@@ -7,6 +7,7 @@ module Rouge
7
7
  class Sass < SassCommon
8
8
  include Indentation
9
9
 
10
+ title "Sass"
10
11
  desc 'The Sass stylesheet language language (sass-lang.com)'
11
12
 
12
13
  tag 'sass'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Scala < RegexLexer
6
+ title "Scala"
6
7
  desc "The Scala programming language (scala-lang.org)"
7
8
  tag 'scala'
8
9
  aliases 'scala'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Scheme < RegexLexer
6
+ title "Scheme"
6
7
  desc "The Scheme variant of Lisp"
7
8
 
8
9
  tag 'scheme'
@@ -5,6 +5,7 @@ module Rouge
5
5
  load_const :SassCommon, 'sass/common.rb'
6
6
 
7
7
  class Scss < SassCommon
8
+ title "SCSS"
8
9
  desc "SCSS stylesheets (sass-lang.com)"
9
10
  tag 'scss'
10
11
  filenames '*.scss'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Sed < RegexLexer
6
+ title "sed"
6
7
  desc 'sed, the ultimate stream editor'
7
8
 
8
9
  tag 'sed'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Shell < RegexLexer
6
+ title "shell"
6
7
  desc "Various shell languages, including sh and bash"
7
8
 
8
9
  tag 'shell'
@@ -7,6 +7,7 @@ module Rouge
7
7
  class Slim < RegexLexer
8
8
  include Indentation
9
9
 
10
+ title "Slim"
10
11
  desc 'The Slim template language'
11
12
 
12
13
  tag 'slim'
@@ -151,8 +152,8 @@ module Rouge
151
152
  end
152
153
 
153
154
  state :css do
154
- rule(/\.\w+/) { token Name::Class; goto :tag }
155
- rule(/#\w+/) { token Name::Function; goto :tag }
155
+ rule(/\.[\w-]*/) { token Name::Class; goto :tag }
156
+ rule(/#[a-zA-Z][\w:-]*/) { token Name::Function; goto :tag }
156
157
  end
157
158
 
158
159
  state :html_attr do
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class Smalltalk < RegexLexer
6
+ title "Smalltalk"
6
7
  desc 'The Smalltalk programming language'
7
8
 
8
9
  tag 'smalltalk'
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class SML < RegexLexer
6
+ title "SML"
6
7
  desc 'Standard ML'
7
8
  tag 'sml'
8
9
  aliases 'ml'
@@ -344,4 +345,3 @@ module Rouge
344
345
  end
345
346
  end
346
347
  end
347
-
@@ -3,6 +3,7 @@
3
3
  module Rouge
4
4
  module Lexers
5
5
  class SQL < RegexLexer
6
+ title "SQL"
6
7
  desc "Structured Query Language, for relational databases"
7
8
  tag 'sql'
8
9
  filenames '*.sql'
@@ -6,12 +6,13 @@ module Rouge
6
6
  tag 'swift'
7
7
  filenames '*.swift'
8
8
 
9
+ title "Swift"
9
10
  desc 'Multi paradigm, compiled programming language developed by Apple for iOS and OS X development. (developer.apple.com/swift)'
10
11
 
11
12
  id_head = /_|(?!\p{Mc})\p{Alpha}|[^\u0000-\uFFFF]/
12
13
  id_rest = /[\p{Alnum}_]|[^\u0000-\uFFFF]/
13
14
  id = /#{id_head}#{id_rest}*/
14
-
15
+
15
16
  keywords = Set.new %w(
16
17
  break case continue default do else fallthrough if in for return switch where while
17
18
 
@@ -25,19 +26,35 @@ module Rouge
25
26
  )
26
27
 
27
28
  attributes = Set.new %w(
28
- autoclosure IBAction IBDesignable IBInspectable IBOutlet noreturn NSCopying NSManaged objc UIApplicationMain NSApplicationMain
29
+ autoclosure IBAction IBDesignable IBInspectable IBOutlet noreturn NSCopying NSManaged objc UIApplicationMain NSApplicationMain objc_block
29
30
  )
30
31
 
31
32
  constants = Set.new %w(
32
33
  true false nil
33
34
  )
34
35
 
35
- state :whitespace do
36
+ start { push :bol }
37
+
38
+ # beginning of line
39
+ state :bol do
40
+ rule /#.*/, Comment::Preproc
41
+
42
+ mixin :inline_whitespace
43
+
44
+ rule(//) { pop! }
45
+ end
46
+
47
+ state :inline_whitespace do
36
48
  rule /\s+/m, Text
37
- rule %r(\/\/.*?\n), Comment::Single
38
49
  rule %r((?<re>\/\*(?:(?>[^\/\*\*\/]+)|\g<re>)*\*\/))m, Comment::Multiline
39
50
  end
40
51
 
52
+ state :whitespace do
53
+ rule /\n+/m, Text, :bol
54
+ rule %r(\/\/.*?$), Comment::Single, :bol
55
+ mixin :inline_whitespace
56
+ end
57
+
41
58
  state :root do
42
59
  mixin :whitespace
43
60
  rule /\$(([1-9]\d*)?\d)/, Name::Variable
@@ -52,7 +69,7 @@ module Rouge
52
69
  rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
53
70
  rule /0b[01]+(?:_[01]+)*/, Num::Bin
54
71
  rule %r{[\d]+(?:_\d+)*}, Num::Integer
55
-
72
+
56
73
  rule /@availability[(][^)]+[)]/, Keyword::Declaration
57
74
 
58
75
  rule /(@objc[(])([^)]+)([)])/ do
@@ -82,11 +99,11 @@ module Rouge
82
99
  groups Keyword::Declaration, Error, Keyword::Declaration
83
100
  end
84
101
  end
85
-
102
+
86
103
  rule /(let|var)\b(\s*)(#{id})/ do
87
104
  groups Keyword, Text, Name::Variable
88
105
  end
89
-
106
+
90
107
  rule /(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[(])/ do |m|
91
108
  if m[0] =~ /^[[:upper:]]/
92
109
  token Keyword::Type