gitlab-rouge 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +23 -0
- data/LICENSE +186 -0
- data/bin/rougify +16 -0
- data/gitlab-rouge.gemspec +17 -0
- data/lib/rouge.rb +57 -0
- data/lib/rouge/cli.rb +363 -0
- data/lib/rouge/demos/apache +21 -0
- data/lib/rouge/demos/applescript +2 -0
- data/lib/rouge/demos/c +8 -0
- data/lib/rouge/demos/clojure +5 -0
- data/lib/rouge/demos/coffeescript +5 -0
- data/lib/rouge/demos/common_lisp +1 -0
- data/lib/rouge/demos/conf +4 -0
- data/lib/rouge/demos/cpp +8 -0
- data/lib/rouge/demos/csharp +5 -0
- data/lib/rouge/demos/css +4 -0
- data/lib/rouge/demos/dart +6 -0
- data/lib/rouge/demos/diff +7 -0
- data/lib/rouge/demos/elixir +1 -0
- data/lib/rouge/demos/erb +1 -0
- data/lib/rouge/demos/erlang +7 -0
- data/lib/rouge/demos/factor +5 -0
- data/lib/rouge/demos/gherkin +17 -0
- data/lib/rouge/demos/glsl +14 -0
- data/lib/rouge/demos/go +7 -0
- data/lib/rouge/demos/groovy +9 -0
- data/lib/rouge/demos/haml +5 -0
- data/lib/rouge/demos/handlebars +7 -0
- data/lib/rouge/demos/haskell +6 -0
- data/lib/rouge/demos/html +8 -0
- data/lib/rouge/demos/http +14 -0
- data/lib/rouge/demos/ini +4 -0
- data/lib/rouge/demos/io +11 -0
- data/lib/rouge/demos/java +5 -0
- data/lib/rouge/demos/javascript +1 -0
- data/lib/rouge/demos/json +1 -0
- data/lib/rouge/demos/json-doc +1 -0
- data/lib/rouge/demos/liquid +11 -0
- data/lib/rouge/demos/literate_coffeescript +3 -0
- data/lib/rouge/demos/literate_haskell +7 -0
- data/lib/rouge/demos/llvm +20 -0
- data/lib/rouge/demos/lua +12 -0
- data/lib/rouge/demos/make +6 -0
- data/lib/rouge/demos/markdown +4 -0
- data/lib/rouge/demos/matlab +6 -0
- data/lib/rouge/demos/moonscript +16 -0
- data/lib/rouge/demos/nginx +5 -0
- data/lib/rouge/demos/nim +27 -0
- data/lib/rouge/demos/objective_c +14 -0
- data/lib/rouge/demos/ocaml +12 -0
- data/lib/rouge/demos/perl +5 -0
- data/lib/rouge/demos/php +3 -0
- data/lib/rouge/demos/plaintext +1 -0
- data/lib/rouge/demos/powershell +49 -0
- data/lib/rouge/demos/prolog +9 -0
- data/lib/rouge/demos/properties +7 -0
- data/lib/rouge/demos/puppet +6 -0
- data/lib/rouge/demos/python +6 -0
- data/lib/rouge/demos/qml +9 -0
- data/lib/rouge/demos/r +8 -0
- data/lib/rouge/demos/racket +24 -0
- data/lib/rouge/demos/ruby +9 -0
- data/lib/rouge/demos/rust +12 -0
- data/lib/rouge/demos/sass +3 -0
- data/lib/rouge/demos/scala +3 -0
- data/lib/rouge/demos/scheme +4 -0
- data/lib/rouge/demos/scss +5 -0
- data/lib/rouge/demos/sed +4 -0
- data/lib/rouge/demos/shell +2 -0
- data/lib/rouge/demos/slim +17 -0
- data/lib/rouge/demos/smalltalk +6 -0
- data/lib/rouge/demos/sml +4 -0
- data/lib/rouge/demos/sql +1 -0
- data/lib/rouge/demos/swift +5 -0
- data/lib/rouge/demos/tcl +1 -0
- data/lib/rouge/demos/tex +1 -0
- data/lib/rouge/demos/toml +9 -0
- data/lib/rouge/demos/tulip +14 -0
- data/lib/rouge/demos/vb +4 -0
- data/lib/rouge/demos/viml +5 -0
- data/lib/rouge/demos/xml +2 -0
- data/lib/rouge/demos/yaml +4 -0
- data/lib/rouge/formatter.rb +50 -0
- data/lib/rouge/formatters/html.rb +117 -0
- data/lib/rouge/formatters/null.rb +19 -0
- data/lib/rouge/formatters/terminal256.rb +176 -0
- data/lib/rouge/lexer.rb +443 -0
- data/lib/rouge/lexers/apache.rb +68 -0
- data/lib/rouge/lexers/apache/keywords.yml +453 -0
- data/lib/rouge/lexers/apple_script.rb +367 -0
- data/lib/rouge/lexers/c.rb +212 -0
- data/lib/rouge/lexers/clojure.rb +112 -0
- data/lib/rouge/lexers/coffeescript.rb +174 -0
- data/lib/rouge/lexers/common_lisp.rb +345 -0
- data/lib/rouge/lexers/conf.rb +24 -0
- data/lib/rouge/lexers/cpp.rb +66 -0
- data/lib/rouge/lexers/csharp.rb +88 -0
- data/lib/rouge/lexers/css.rb +271 -0
- data/lib/rouge/lexers/dart.rb +104 -0
- data/lib/rouge/lexers/diff.rb +31 -0
- data/lib/rouge/lexers/elixir.rb +108 -0
- data/lib/rouge/lexers/erb.rb +56 -0
- data/lib/rouge/lexers/erlang.rb +118 -0
- data/lib/rouge/lexers/factor.rb +302 -0
- data/lib/rouge/lexers/gherkin.rb +137 -0
- data/lib/rouge/lexers/gherkin/keywords.rb +14 -0
- data/lib/rouge/lexers/glsl.rb +135 -0
- data/lib/rouge/lexers/go.rb +178 -0
- data/lib/rouge/lexers/groovy.rb +104 -0
- data/lib/rouge/lexers/haml.rb +228 -0
- data/lib/rouge/lexers/handlebars.rb +79 -0
- data/lib/rouge/lexers/haskell.rb +183 -0
- data/lib/rouge/lexers/html.rb +94 -0
- data/lib/rouge/lexers/http.rb +80 -0
- data/lib/rouge/lexers/ini.rb +57 -0
- data/lib/rouge/lexers/io.rb +68 -0
- data/lib/rouge/lexers/java.rb +76 -0
- data/lib/rouge/lexers/javascript.rb +297 -0
- data/lib/rouge/lexers/liquid.rb +287 -0
- data/lib/rouge/lexers/literate_coffeescript.rb +33 -0
- data/lib/rouge/lexers/literate_haskell.rb +36 -0
- data/lib/rouge/lexers/llvm.rb +84 -0
- data/lib/rouge/lexers/lua.rb +122 -0
- data/lib/rouge/lexers/lua/builtins.rb +22 -0
- data/lib/rouge/lexers/make.rb +116 -0
- data/lib/rouge/lexers/markdown.rb +154 -0
- data/lib/rouge/lexers/matlab.rb +74 -0
- data/lib/rouge/lexers/matlab/builtins.rb +11 -0
- data/lib/rouge/lexers/moonscript.rb +110 -0
- data/lib/rouge/lexers/nginx.rb +71 -0
- data/lib/rouge/lexers/nim.rb +152 -0
- data/lib/rouge/lexers/objective_c.rb +197 -0
- data/lib/rouge/lexers/ocaml.rb +111 -0
- data/lib/rouge/lexers/perl.rb +197 -0
- data/lib/rouge/lexers/php.rb +173 -0
- data/lib/rouge/lexers/php/builtins.rb +204 -0
- data/lib/rouge/lexers/plain_text.rb +25 -0
- data/lib/rouge/lexers/powershell.rb +96 -0
- data/lib/rouge/lexers/prolog.rb +64 -0
- data/lib/rouge/lexers/properties.rb +55 -0
- data/lib/rouge/lexers/puppet.rb +128 -0
- data/lib/rouge/lexers/python.rb +228 -0
- data/lib/rouge/lexers/qml.rb +72 -0
- data/lib/rouge/lexers/r.rb +56 -0
- data/lib/rouge/lexers/racket.rb +542 -0
- data/lib/rouge/lexers/ruby.rb +415 -0
- data/lib/rouge/lexers/rust.rb +191 -0
- data/lib/rouge/lexers/sass.rb +74 -0
- data/lib/rouge/lexers/sass/common.rb +180 -0
- data/lib/rouge/lexers/scala.rb +142 -0
- data/lib/rouge/lexers/scheme.rb +112 -0
- data/lib/rouge/lexers/scss.rb +34 -0
- data/lib/rouge/lexers/sed.rb +170 -0
- data/lib/rouge/lexers/shell.rb +152 -0
- data/lib/rouge/lexers/slim.rb +228 -0
- data/lib/rouge/lexers/smalltalk.rb +116 -0
- data/lib/rouge/lexers/sml.rb +347 -0
- data/lib/rouge/lexers/sql.rb +140 -0
- data/lib/rouge/lexers/swift.rb +144 -0
- data/lib/rouge/lexers/tcl.rb +192 -0
- data/lib/rouge/lexers/tex.rb +72 -0
- data/lib/rouge/lexers/toml.rb +71 -0
- data/lib/rouge/lexers/tulip.rb +75 -0
- data/lib/rouge/lexers/vb.rb +164 -0
- data/lib/rouge/lexers/viml.rb +101 -0
- data/lib/rouge/lexers/viml/keywords.rb +12 -0
- data/lib/rouge/lexers/xml.rb +59 -0
- data/lib/rouge/lexers/yaml.rb +364 -0
- data/lib/rouge/plugins/redcarpet.rb +30 -0
- data/lib/rouge/regex_lexer.rb +439 -0
- data/lib/rouge/template_lexer.rb +22 -0
- data/lib/rouge/text_analyzer.rb +48 -0
- data/lib/rouge/theme.rb +195 -0
- data/lib/rouge/themes/base16.rb +130 -0
- data/lib/rouge/themes/colorful.rb +67 -0
- data/lib/rouge/themes/github.rb +71 -0
- data/lib/rouge/themes/molokai.rb +82 -0
- data/lib/rouge/themes/monokai.rb +92 -0
- data/lib/rouge/themes/monokai_sublime.rb +90 -0
- data/lib/rouge/themes/thankful_eyes.rb +71 -0
- data/lib/rouge/token.rb +182 -0
- data/lib/rouge/util.rb +101 -0
- data/lib/rouge/version.rb +7 -0
- metadata +231 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 57aa0f443e2f11f799446cad2c73155a274eba34
|
4
|
+
data.tar.gz: fce722eb099832fc128e1fb409ef26f20bde1b68
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2ff1dce9852605af2231b1a3858f291217c39923a64852bafc1ba042395b393f6387fb9e8239516d356f4d432ffc170d441253ec7e502744c2e6bc4030518e3
|
7
|
+
data.tar.gz: f9f18423829a7918d15f0bdc314eca82acc063795094549eaf2a1d96f6d44f51b78a189378dd40baabb430100ce5ec48db58e5d9a6e91bd3c3a82371ff0a907d
|
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'minitest', '~> 4.0'
|
6
|
+
gem 'wrong'
|
7
|
+
|
8
|
+
gem 'rake'
|
9
|
+
|
10
|
+
# don't try to install redcarpet under jruby
|
11
|
+
gem 'redcarpet', :platforms => :ruby
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'pry'
|
15
|
+
|
16
|
+
# docs
|
17
|
+
gem 'yard'
|
18
|
+
gem 'github-markup'
|
19
|
+
|
20
|
+
# for visual tests
|
21
|
+
gem 'sinatra'
|
22
|
+
gem 'shotgun'
|
23
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
# MIT license. See http://www.opensource.org/licenses/mit-license.php
|
2
|
+
|
3
|
+
Copyright (c) 2012 Jeanine Adkisson.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
23
|
+
# SPECIAL NOTE:
|
24
|
+
Many of the lexers in this project are adaptations of those in Pygments
|
25
|
+
(pygments.org). The license for Pygments is as follows:
|
26
|
+
|
27
|
+
# BEGIN pygments/LICENSE #
|
28
|
+
|
29
|
+
Copyright (c) 2006-2012 by the respective authors (see AUTHORS file).
|
30
|
+
All rights reserved.
|
31
|
+
|
32
|
+
Redistribution and use in source and binary forms, with or without
|
33
|
+
modification, are permitted provided that the following conditions are
|
34
|
+
met:
|
35
|
+
|
36
|
+
* Redistributions of source code must retain the above copyright
|
37
|
+
notice, this list of conditions and the following disclaimer.
|
38
|
+
|
39
|
+
* Redistributions in binary form must reproduce the above copyright
|
40
|
+
notice, this list of conditions and the following disclaimer in the
|
41
|
+
documentation and/or other materials provided with the distribution.
|
42
|
+
|
43
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
44
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
45
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
46
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
47
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
48
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
49
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
50
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
51
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
52
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
53
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
54
|
+
|
55
|
+
# END pygments/LICENSE #
|
56
|
+
|
57
|
+
The contents of the AUTHORS file at the time of porting was:
|
58
|
+
|
59
|
+
# BEGIN pygments/AUTHORS #
|
60
|
+
|
61
|
+
Pygments is written and maintained by Georg Brandl <georg@python.org>.
|
62
|
+
|
63
|
+
Major developers are Tim Hatch <tim@timhatch.com> and Armin Ronacher
|
64
|
+
<armin.ronacher@active-4.com>.
|
65
|
+
|
66
|
+
Other contributors, listed alphabetically, are:
|
67
|
+
|
68
|
+
* Sam Aaron -- Ioke lexer
|
69
|
+
* Kumar Appaiah -- Debian control lexer
|
70
|
+
* Ali Afshar -- image formatter
|
71
|
+
* Andreas Amann -- AppleScript lexer
|
72
|
+
* Jeffrey Arnold -- R/S lexer, BUGS lexers
|
73
|
+
* Jeremy Ashkenas -- CoffeeScript lexer
|
74
|
+
* Stefan Matthias Aust -- Smalltalk lexer
|
75
|
+
* Ben Bangert -- Mako lexers
|
76
|
+
* Max Battcher -- Darcs patch lexer
|
77
|
+
* Paul Baumgart, 280 North, Inc. -- Objective-J lexer
|
78
|
+
* Michael Bayer -- Myghty lexers
|
79
|
+
* John Benediktsson -- Factor lexer
|
80
|
+
* Christopher Bertels -- Fancy lexer
|
81
|
+
* Jarrett Billingsley -- MiniD lexer
|
82
|
+
* Adam Blinkinsop -- Haskell, Redcode lexers
|
83
|
+
* Frits van Bommel -- assembler lexers
|
84
|
+
* Pierre Bourdon -- bugfixes
|
85
|
+
* Hiram Chirino -- Scaml and Jade lexers
|
86
|
+
* Leaf Corcoran -- MoonScript lexer
|
87
|
+
* Christopher Creutzig -- MuPAD lexer
|
88
|
+
* Pete Curry -- bugfixes
|
89
|
+
* Owen Durni -- haXe lexer
|
90
|
+
* Nick Efford -- Python 3 lexer
|
91
|
+
* Sven Efftinge -- Xtend lexer
|
92
|
+
* Artem Egorkine -- terminal256 formatter
|
93
|
+
* James H. Fisher -- PostScript lexer
|
94
|
+
* Carlos Galdino -- Elixir and Elixir Console lexers
|
95
|
+
* Naveen Garg -- Autohotkey lexer
|
96
|
+
* Laurent Gautier -- R/S lexer
|
97
|
+
* Alex Gaynor -- PyPy log lexer
|
98
|
+
* Bertrand Goetzmann -- Groovy lexer
|
99
|
+
* Krzysiek Goj -- Scala lexer
|
100
|
+
* Matt Good -- Genshi, Cheetah lexers
|
101
|
+
* Patrick Gotthardt -- PHP namespaces support
|
102
|
+
* Olivier Guibe -- Asymptote lexer
|
103
|
+
* Martin Harriman -- SNOBOL lexer
|
104
|
+
* Matthew Harrison -- SVG formatter
|
105
|
+
* Steven Hazel -- Tcl lexer
|
106
|
+
* Aslak Hellesøy -- Gherkin lexer
|
107
|
+
* Greg Hendershott -- Racket lexer
|
108
|
+
* Jordi Gutiérrez Hermoso -- Octave lexer
|
109
|
+
* David Hess, Fish Software, Inc. -- Objective-J lexer
|
110
|
+
* Varun Hiremath -- Debian control lexer
|
111
|
+
* Doug Hogan -- Mscgen lexer
|
112
|
+
* Ben Hollis -- Mason lexer
|
113
|
+
* Tim Howard -- BlitzMax lexer
|
114
|
+
* Ivan Inozemtsev -- Fantom lexer
|
115
|
+
* Brian R. Jackson -- Tea lexer
|
116
|
+
* Dennis Kaarsemaker -- sources.list lexer
|
117
|
+
* Igor Kalnitsky -- vhdl lexer
|
118
|
+
* Eric Knibbe -- Lasso lexer
|
119
|
+
* Adam Koprowski -- Opa lexer
|
120
|
+
* Benjamin Kowarsch -- Modula-2 lexer
|
121
|
+
* Alexander Kriegisch -- Kconfig and AspectJ lexers
|
122
|
+
* Marek Kubica -- Scheme lexer
|
123
|
+
* Jochen Kupperschmidt -- Markdown processor
|
124
|
+
* Gerd Kurzbach -- Modelica lexer
|
125
|
+
* Olov Lassus -- Dart lexer
|
126
|
+
* Sylvestre Ledru -- Scilab lexer
|
127
|
+
* Mark Lee -- Vala lexer
|
128
|
+
* Ben Mabey -- Gherkin lexer
|
129
|
+
* Simone Margaritelli -- Hybris lexer
|
130
|
+
* Kirk McDonald -- D lexer
|
131
|
+
* Gordon McGregor -- SystemVerilog lexer
|
132
|
+
* Stephen McKamey -- Duel/JBST lexer
|
133
|
+
* Brian McKenna -- F# lexer
|
134
|
+
* Lukas Meuser -- BBCode formatter, Lua lexer
|
135
|
+
* Paul Miller -- LiveScript lexer
|
136
|
+
* Hong Minhee -- HTTP lexer
|
137
|
+
* Michael Mior -- Awk lexer
|
138
|
+
* Jon Morton -- Rust lexer
|
139
|
+
* Paulo Moura -- Logtalk lexer
|
140
|
+
* Mher Movsisyan -- DTD lexer
|
141
|
+
* Ana Nelson -- Ragel, ANTLR, R console lexers
|
142
|
+
* Nam T. Nguyen -- Monokai style
|
143
|
+
* Jesper Noehr -- HTML formatter "anchorlinenos"
|
144
|
+
* Mike Nolta -- Julia lexer
|
145
|
+
* Jonas Obrist -- BBCode lexer
|
146
|
+
* David Oliva -- Rebol lexer
|
147
|
+
* Jon Parise -- Protocol buffers lexer
|
148
|
+
* Ronny Pfannschmidt -- BBCode lexer
|
149
|
+
* Benjamin Peterson -- Test suite refactoring
|
150
|
+
* Dominik Picheta -- Nimrod lexer
|
151
|
+
* Clément Prévost -- UrbiScript lexer
|
152
|
+
* Kashif Rasul -- CUDA lexer
|
153
|
+
* Justin Reidy -- MXML lexer
|
154
|
+
* Norman Richards -- JSON lexer
|
155
|
+
* Lubomir Rintel -- GoodData MAQL and CL lexers
|
156
|
+
* Andre Roberge -- Tango style
|
157
|
+
* Konrad Rudolph -- LaTeX formatter enhancements
|
158
|
+
* Mario Ruggier -- Evoque lexers
|
159
|
+
* Stou Sandalski -- NumPy, FORTRAN, tcsh and XSLT lexers
|
160
|
+
* Matteo Sasso -- Common Lisp lexer
|
161
|
+
* Joe Schafer -- Ada lexer
|
162
|
+
* Ken Schutte -- Matlab lexers
|
163
|
+
* Tassilo Schweyer -- Io, MOOCode lexers
|
164
|
+
* Joerg Sieker -- ABAP lexer
|
165
|
+
* Robert Simmons -- Standard ML lexer
|
166
|
+
* Kirill Simonov -- YAML lexer
|
167
|
+
* Steve Spigarelli -- XQuery lexer
|
168
|
+
* Jerome St-Louis -- eC lexer
|
169
|
+
* James Strachan -- Kotlin lexer
|
170
|
+
* Tiberius Teng -- default style overhaul
|
171
|
+
* Jeremy Thurgood -- Erlang, Squid config lexers
|
172
|
+
* Erick Tryzelaar -- Felix lexer
|
173
|
+
* Daniele Varrazzo -- PostgreSQL lexers
|
174
|
+
* Abe Voelker -- OpenEdge ABL lexer
|
175
|
+
* Whitney Young -- ObjectiveC lexer
|
176
|
+
* Matthias Vallentin -- Bro lexer
|
177
|
+
* Nathan Weizenbaum -- Haml and Sass lexers
|
178
|
+
* Dietmar Winkler -- Modelica lexer
|
179
|
+
* Nils Winter -- Smalltalk lexer
|
180
|
+
* Davy Wybiral -- Clojure lexer
|
181
|
+
* Diego Zamboni -- CFengine3 lexer
|
182
|
+
* Alex Zimin -- Nemerle lexer
|
183
|
+
|
184
|
+
Many thanks for all contributions!
|
185
|
+
|
186
|
+
# END pygments/AUTHORS #
|
data/bin/rougify
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
ROOT_DIR = Pathname.new(__FILE__).dirname.parent
|
5
|
+
load ROOT_DIR.join('lib/rouge.rb')
|
6
|
+
load ROOT_DIR.join('lib/rouge/cli.rb')
|
7
|
+
|
8
|
+
begin
|
9
|
+
Rouge::CLI.parse(ARGV).run
|
10
|
+
rescue Rouge::CLI::Error => e
|
11
|
+
puts e.message
|
12
|
+
exit e.status
|
13
|
+
rescue Interrupt
|
14
|
+
$stderr.puts "\nrouge: interrupted"
|
15
|
+
exit 2
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require './lib/rouge/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "gitlab-rouge"
|
5
|
+
s.version = Rouge.version
|
6
|
+
s.authors = ["Jeanine Adkisson", "Douwe Maan"]
|
7
|
+
s.email = ["jneen@jneen.net", "douwe@gitlab.com"]
|
8
|
+
s.summary = "A pure-ruby colorizer based on pygments"
|
9
|
+
s.description = <<-desc.strip.gsub(/\s+/, ' ')
|
10
|
+
Rouge aims to a be a simple, easy-to-extend drop-in replacement
|
11
|
+
for pygments.
|
12
|
+
desc
|
13
|
+
s.homepage = "https://gitlab.com/gitlab-org/gitlab-rouge"
|
14
|
+
s.files = Dir['Gemfile', 'LICENSE', 'gitlab-rouge.gemspec', 'lib/**/*.rb', 'lib/**/*.yml', 'bin/rougify', 'lib/rouge/demos/*']
|
15
|
+
s.executables = %w(rougify)
|
16
|
+
s.license = 'MIT (see LICENSE file)'
|
17
|
+
end
|
data/lib/rouge.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
# stdlib
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
# The containing module for Rouge
|
7
|
+
module Rouge
|
8
|
+
class << self
|
9
|
+
# Highlight some text with a given lexer and formatter.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Rouge.highlight('@foo = 1', 'ruby', 'html')
|
13
|
+
# Rouge.highlight('var foo = 1;', 'js', 'terminal256')
|
14
|
+
#
|
15
|
+
# # streaming - chunks become available as they are lexed
|
16
|
+
# Rouge.highlight(large_string, 'ruby', 'html') do |chunk|
|
17
|
+
# $stdout.print chunk
|
18
|
+
# end
|
19
|
+
def highlight(text, lexer, formatter, &b)
|
20
|
+
lexer = Lexer.find(lexer) unless lexer.respond_to? :lex
|
21
|
+
raise "unknown lexer #{lexer}" unless lexer
|
22
|
+
|
23
|
+
formatter = Formatter.find(formatter) unless formatter.respond_to? :format
|
24
|
+
raise "unknown formatter #{formatter}" unless formatter
|
25
|
+
|
26
|
+
formatter.format(lexer.lex(text), &b)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
load_dir = Pathname.new(__FILE__).dirname
|
32
|
+
load load_dir.join('rouge/version.rb')
|
33
|
+
|
34
|
+
load load_dir.join('rouge/util.rb')
|
35
|
+
|
36
|
+
load load_dir.join('rouge/text_analyzer.rb')
|
37
|
+
load load_dir.join('rouge/token.rb')
|
38
|
+
|
39
|
+
load load_dir.join('rouge/lexer.rb')
|
40
|
+
load load_dir.join('rouge/regex_lexer.rb')
|
41
|
+
load load_dir.join('rouge/template_lexer.rb')
|
42
|
+
|
43
|
+
Dir.glob(load_dir.join('rouge/lexers/*.rb')).each { |f| load f }
|
44
|
+
|
45
|
+
load load_dir.join('rouge/formatter.rb')
|
46
|
+
load load_dir.join('rouge/formatters/html.rb')
|
47
|
+
load load_dir.join('rouge/formatters/terminal256.rb')
|
48
|
+
load load_dir.join('rouge/formatters/null.rb')
|
49
|
+
|
50
|
+
load load_dir.join('rouge/theme.rb')
|
51
|
+
load load_dir.join('rouge/themes/thankful_eyes.rb')
|
52
|
+
load load_dir.join('rouge/themes/colorful.rb')
|
53
|
+
load load_dir.join('rouge/themes/base16.rb')
|
54
|
+
load load_dir.join('rouge/themes/github.rb')
|
55
|
+
load load_dir.join('rouge/themes/monokai.rb')
|
56
|
+
load load_dir.join('rouge/themes/molokai.rb')
|
57
|
+
load load_dir.join('rouge/themes/monokai_sublime.rb')
|
data/lib/rouge/cli.rb
ADDED
@@ -0,0 +1,363 @@
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
2
|
+
|
3
|
+
# not required by the main lib.
|
4
|
+
# to use this module, require 'rouge/cli'.
|
5
|
+
|
6
|
+
module Rouge
|
7
|
+
class FileReader
|
8
|
+
attr_reader :input
|
9
|
+
def initialize(input)
|
10
|
+
@input = input
|
11
|
+
end
|
12
|
+
|
13
|
+
def file
|
14
|
+
case input
|
15
|
+
when '-'
|
16
|
+
$stdin
|
17
|
+
when String
|
18
|
+
File.new(input)
|
19
|
+
when ->(i){ i.respond_to? :read }
|
20
|
+
input
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def read
|
25
|
+
@read ||= begin
|
26
|
+
file.read
|
27
|
+
rescue => e
|
28
|
+
$stderr.puts "unable to open #{input}: #{e.message}"
|
29
|
+
exit 1
|
30
|
+
ensure
|
31
|
+
file.close
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class CLI
|
37
|
+
def self.doc
|
38
|
+
return enum_for(:doc) unless block_given?
|
39
|
+
|
40
|
+
yield %|usage: rougify [command] [args...]|
|
41
|
+
yield %||
|
42
|
+
yield %|where <command> is one of:|
|
43
|
+
yield %| highlight #{Highlight.desc}|
|
44
|
+
yield %| help #{Help.desc}|
|
45
|
+
yield %| style #{Style.desc}|
|
46
|
+
yield %| list #{List.desc}|
|
47
|
+
yield %| version #{Version.desc}|
|
48
|
+
yield %||
|
49
|
+
yield %|See `rougify help <command>` for more info.|
|
50
|
+
end
|
51
|
+
|
52
|
+
class Error < StandardError
|
53
|
+
attr_reader :message, :status
|
54
|
+
def initialize(message, status=1)
|
55
|
+
@message = message
|
56
|
+
@status = status
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.parse(argv=ARGV)
|
61
|
+
argv = normalize_syntax(argv)
|
62
|
+
|
63
|
+
mode = argv.shift
|
64
|
+
|
65
|
+
klass = class_from_arg(mode)
|
66
|
+
return klass.parse(argv) if klass
|
67
|
+
|
68
|
+
case mode
|
69
|
+
when '-h', '--help', 'help', '-help'
|
70
|
+
Help.parse(argv)
|
71
|
+
else
|
72
|
+
argv.unshift(mode) if mode
|
73
|
+
Highlight.parse(argv)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def initialize(options={})
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.error!(msg, status=1)
|
81
|
+
raise Error.new(msg, status)
|
82
|
+
end
|
83
|
+
|
84
|
+
def error!(*a)
|
85
|
+
self.class.error!(*a)
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.class_from_arg(arg)
|
89
|
+
case arg
|
90
|
+
when 'version', '--version', '-v'
|
91
|
+
Version
|
92
|
+
when 'help'
|
93
|
+
Help
|
94
|
+
when 'highlight', 'hi'
|
95
|
+
Highlight
|
96
|
+
when 'style'
|
97
|
+
Style
|
98
|
+
when 'list'
|
99
|
+
List
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class Version < CLI
|
104
|
+
def self.desc
|
105
|
+
"print the rouge version number"
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.parse(*); new; end
|
109
|
+
|
110
|
+
def run
|
111
|
+
puts Rouge.version
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class Help < CLI
|
116
|
+
def self.desc
|
117
|
+
"print help info"
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.doc
|
121
|
+
return enum_for(:doc) unless block_given?
|
122
|
+
|
123
|
+
yield %|usage: rougify help <command>|
|
124
|
+
yield %||
|
125
|
+
yield %|print help info for <command>.|
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.parse(argv)
|
129
|
+
opts = { :mode => CLI }
|
130
|
+
until argv.empty?
|
131
|
+
arg = argv.shift
|
132
|
+
klass = class_from_arg(arg)
|
133
|
+
if klass
|
134
|
+
opts[:mode] = klass
|
135
|
+
next
|
136
|
+
end
|
137
|
+
end
|
138
|
+
new(opts)
|
139
|
+
end
|
140
|
+
|
141
|
+
def initialize(opts={})
|
142
|
+
@mode = opts[:mode]
|
143
|
+
end
|
144
|
+
|
145
|
+
def run
|
146
|
+
@mode.doc.each(&method(:puts))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
class Highlight < CLI
|
151
|
+
def self.desc
|
152
|
+
"highlight code"
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.doc
|
156
|
+
return enum_for(:doc) unless block_given?
|
157
|
+
|
158
|
+
yield %[usage: rougify highlight <filename> [options...]]
|
159
|
+
yield %[ rougify highlight [options...]]
|
160
|
+
yield %[]
|
161
|
+
yield %[--input-file|-i <filename> specify a file to read, or - to use stdin]
|
162
|
+
yield %[]
|
163
|
+
yield %[--lexer|-l <lexer> specify the lexer to use.]
|
164
|
+
yield %[ If not provided, rougify will try to guess]
|
165
|
+
yield %[ based on --mimetype, the filename, and the]
|
166
|
+
yield %[ file contents.]
|
167
|
+
yield %[]
|
168
|
+
yield %[--formatter|-f <opts> specify the output formatter to use.]
|
169
|
+
yield %[ If not provided, rougify will default to]
|
170
|
+
yield %[ terminal256.]
|
171
|
+
yield %[]
|
172
|
+
yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing]
|
173
|
+
yield %[]
|
174
|
+
yield %[--lexer-opts|-L <opts> specify lexer options in CGI format]
|
175
|
+
yield %[ (opt1=val1&opt2=val2)]
|
176
|
+
yield %[]
|
177
|
+
yield %[--formatter-opts|-F <opts> specify formatter options in CGI format]
|
178
|
+
yield %[ (opt1=val1&opt2=val2)]
|
179
|
+
end
|
180
|
+
|
181
|
+
def self.parse(argv)
|
182
|
+
opts = {
|
183
|
+
:formatter => 'terminal256',
|
184
|
+
:input_file => '-',
|
185
|
+
:lexer_opts => {},
|
186
|
+
:formatter_opts => {},
|
187
|
+
}
|
188
|
+
|
189
|
+
until argv.empty?
|
190
|
+
arg = argv.shift
|
191
|
+
case arg
|
192
|
+
when '--input-file', '-i'
|
193
|
+
opts[:input_file] = argv.shift
|
194
|
+
when '--mimetype', '-m'
|
195
|
+
opts[:mimetype] = argv.shift
|
196
|
+
when '--lexer', '-l'
|
197
|
+
opts[:lexer] = argv.shift
|
198
|
+
when '--formatter', '-f'
|
199
|
+
opts[:formatter] = argv.shift
|
200
|
+
when '--lexer-opts', '-L'
|
201
|
+
opts[:lexer_opts] = parse_cgi(argv.shift)
|
202
|
+
when '--formatter-opts', '-F'
|
203
|
+
opts[:formatter_opts] = parse_cgi(argv.shift)
|
204
|
+
when /^--/
|
205
|
+
error! "unknown option #{arg.inspect}"
|
206
|
+
else
|
207
|
+
opts[:input_file] = arg
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
new(opts)
|
212
|
+
end
|
213
|
+
|
214
|
+
def input_stream
|
215
|
+
@input_stream ||= FileReader.new(@input_file)
|
216
|
+
end
|
217
|
+
|
218
|
+
def input
|
219
|
+
@input ||= input_stream.read
|
220
|
+
end
|
221
|
+
|
222
|
+
def lexer_class
|
223
|
+
@lexer_class ||= Lexer.guess(
|
224
|
+
:filename => @input_file,
|
225
|
+
:mimetype => @mimetype,
|
226
|
+
:source => input_stream,
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
230
|
+
def lexer
|
231
|
+
@lexer ||= lexer_class.new(@lexer_opts)
|
232
|
+
end
|
233
|
+
|
234
|
+
attr_reader :input_file, :lexer_name, :mimetype, :formatter
|
235
|
+
|
236
|
+
def initialize(opts={})
|
237
|
+
@input_file = opts[:input_file]
|
238
|
+
|
239
|
+
if opts[:lexer]
|
240
|
+
@lexer_class = Lexer.find(opts[:lexer]) \
|
241
|
+
or error! "unkown lexer #{opts[:lexer].inspect}"
|
242
|
+
else
|
243
|
+
@lexer_name = opts[:lexer]
|
244
|
+
@mimetype = opts[:mimetype]
|
245
|
+
end
|
246
|
+
|
247
|
+
@lexer_opts = opts[:lexer_opts]
|
248
|
+
|
249
|
+
formatter_class = Formatter.find(opts[:formatter]) \
|
250
|
+
or error! "unknown formatter #{opts[:formatter]}"
|
251
|
+
|
252
|
+
@formatter = formatter_class.new(opts[:formatter_opts])
|
253
|
+
end
|
254
|
+
|
255
|
+
def run
|
256
|
+
formatter.format(lexer.lex(input), &method(:print))
|
257
|
+
end
|
258
|
+
|
259
|
+
private
|
260
|
+
def self.parse_cgi(str)
|
261
|
+
pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] }
|
262
|
+
Hash[pairs]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
class Style < CLI
|
267
|
+
def self.desc
|
268
|
+
"print CSS styles"
|
269
|
+
end
|
270
|
+
|
271
|
+
def self.doc
|
272
|
+
return enum_for(:doc) unless block_given?
|
273
|
+
|
274
|
+
yield %|usage: rougify style [<theme-name>] [<options>]|
|
275
|
+
yield %||
|
276
|
+
yield %|Print CSS styles for the given theme. Extra options are|
|
277
|
+
yield %|passed to the theme. Theme defaults to thankful_eyes.|
|
278
|
+
yield %||
|
279
|
+
yield %|options:|
|
280
|
+
yield %| --scope (default: .highlight) a css selector to scope by|
|
281
|
+
yield %||
|
282
|
+
yield %|available themes:|
|
283
|
+
yield %| #{Theme.registry.keys.sort.join(', ')}|
|
284
|
+
end
|
285
|
+
|
286
|
+
def self.parse(argv)
|
287
|
+
opts = { :theme_name => 'thankful_eyes' }
|
288
|
+
|
289
|
+
until argv.empty?
|
290
|
+
arg = argv.shift
|
291
|
+
case arg
|
292
|
+
when /--(\w+)/
|
293
|
+
opts[$1.tr('-', '_').to_sym] = argv.shift
|
294
|
+
else
|
295
|
+
opts[:theme_name] = arg
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
new(opts)
|
300
|
+
end
|
301
|
+
|
302
|
+
def initialize(opts)
|
303
|
+
theme_name = opts.delete(:theme_name)
|
304
|
+
theme_class = Theme.find(theme_name) \
|
305
|
+
or error! "unknown theme: #{theme_name}"
|
306
|
+
|
307
|
+
@theme = theme_class.new(opts)
|
308
|
+
end
|
309
|
+
|
310
|
+
def run
|
311
|
+
@theme.render(&method(:puts))
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
class List < CLI
|
316
|
+
def self.desc
|
317
|
+
"list available lexers"
|
318
|
+
end
|
319
|
+
|
320
|
+
def self.doc
|
321
|
+
return enum_for(:doc) unless block_given?
|
322
|
+
|
323
|
+
yield %|usage: rouge list|
|
324
|
+
yield %||
|
325
|
+
yield %|print a list of all available lexers with their descriptions.|
|
326
|
+
end
|
327
|
+
|
328
|
+
def self.parse(argv)
|
329
|
+
new
|
330
|
+
end
|
331
|
+
|
332
|
+
def run
|
333
|
+
puts "== Available Lexers =="
|
334
|
+
|
335
|
+
Lexer.all.sort_by(&:tag).each do |lexer|
|
336
|
+
desc = "#{lexer.desc}"
|
337
|
+
if lexer.aliases.any?
|
338
|
+
desc << " [aliases: #{lexer.aliases.join(',')}]"
|
339
|
+
end
|
340
|
+
puts "%s: %s" % [lexer.tag, desc]
|
341
|
+
puts
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
private
|
347
|
+
def self.normalize_syntax(argv)
|
348
|
+
out = []
|
349
|
+
argv.each do |arg|
|
350
|
+
case arg
|
351
|
+
when /^(--\w+)=(.*)$/
|
352
|
+
out << $1 << $2
|
353
|
+
when /^(-\w)(.+)$/
|
354
|
+
out << $1 << $2
|
355
|
+
else
|
356
|
+
out << arg
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
out
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|