rouge 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/lib/rouge.rb +3 -0
- data/lib/rouge/cli.rb +18 -2
- data/lib/rouge/formatter.rb +7 -0
- data/lib/rouge/formatters/html.rb +4 -0
- data/lib/rouge/formatters/terminal256.rb +8 -2
- data/lib/rouge/lexer.rb +34 -4
- data/lib/rouge/lexers/c.rb +3 -0
- data/lib/rouge/lexers/common_lisp.rb +1 -0
- data/lib/rouge/lexers/cpp.rb +2 -0
- data/lib/rouge/lexers/css.rb +2 -0
- data/lib/rouge/lexers/diff.rb +2 -0
- data/lib/rouge/lexers/erb.rb +2 -0
- data/lib/rouge/lexers/factor.rb +1 -0
- data/lib/rouge/lexers/haml.rb +9 -4
- data/lib/rouge/lexers/haskell.rb +2 -0
- data/lib/rouge/lexers/html.rb +1 -0
- data/lib/rouge/lexers/java.rb +2 -0
- data/lib/rouge/lexers/javascript.rb +4 -1
- data/lib/rouge/lexers/make.rb +1 -0
- data/lib/rouge/lexers/markdown.rb +2 -0
- data/lib/rouge/lexers/perl.rb +2 -0
- data/lib/rouge/lexers/php.rb +6 -2
- data/lib/rouge/lexers/python.rb +1 -0
- data/lib/rouge/lexers/ruby.rb +2 -1
- data/lib/rouge/lexers/scheme.rb +2 -0
- data/lib/rouge/lexers/shell.rb +2 -0
- data/lib/rouge/lexers/sql.rb +137 -0
- data/lib/rouge/lexers/tcl.rb +1 -0
- data/lib/rouge/lexers/tex.rb +1 -0
- data/lib/rouge/lexers/text.rb +2 -0
- data/lib/rouge/lexers/viml.rb +98 -0
- data/lib/rouge/lexers/viml/keywords.rb +11 -0
- data/lib/rouge/lexers/xml.rb +1 -0
- data/lib/rouge/lexers/yaml.rb +4 -3
- data/lib/rouge/regex_lexer.rb +142 -43
- data/lib/rouge/template_lexer.rb +6 -0
- data/lib/rouge/text_analyzer.rb +9 -0
- data/lib/rouge/util.rb +10 -0
- data/lib/rouge/version.rb +1 -1
- metadata +5 -2
data/lib/rouge/template_lexer.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
module Rouge
|
2
|
+
# @abstract
|
3
|
+
# A TemplateLexer is one that accepts a :parent option, to specify
|
4
|
+
# which language is being templated. The lexer class can specify its
|
5
|
+
# own default for the parent lexer, which is otherwise defaulted to
|
6
|
+
# HTML.
|
2
7
|
class TemplateLexer < RegexLexer
|
8
|
+
# the parent lexer - the one being templated.
|
3
9
|
def parent
|
4
10
|
return @parent if instance_variable_defined? :@parent
|
5
11
|
@parent = option(:parent) || 'html'
|
data/lib/rouge/text_analyzer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Rouge
|
2
2
|
class TextAnalyzer < String
|
3
|
+
# Find a shebang. Returns nil if no shebang is present.
|
3
4
|
def shebang
|
4
5
|
return @shebang if instance_variable_defined? :@shebang
|
5
6
|
|
@@ -7,11 +8,16 @@ module Rouge
|
|
7
8
|
@shebang = $1
|
8
9
|
end
|
9
10
|
|
11
|
+
# Check if the given shebang is present.
|
12
|
+
#
|
13
|
+
# This normalizes things so that `text.shebang?('bash')` will detect
|
14
|
+
# `#!/bash`, '#!/bin/bash', '#!/usr/bin/env bash', and '#!/bin/bash -x'
|
10
15
|
def shebang?(match)
|
11
16
|
match = /\b#{match}(\s|$)/
|
12
17
|
match === shebang
|
13
18
|
end
|
14
19
|
|
20
|
+
# Return the contents of the doctype tag if present, nil otherwise.
|
15
21
|
def doctype
|
16
22
|
return @doctype if instance_variable_defined? :@doctype
|
17
23
|
|
@@ -22,10 +28,13 @@ module Rouge
|
|
22
28
|
@doctype = $1
|
23
29
|
end
|
24
30
|
|
31
|
+
# Check if the doctype matches a given regexp or string
|
25
32
|
def doctype?(type=//)
|
26
33
|
type === doctype
|
27
34
|
end
|
28
35
|
|
36
|
+
# Return true if the result of lexing with the given lexer contains no
|
37
|
+
# error tokens.
|
29
38
|
def lexes_cleanly?(lexer)
|
30
39
|
lexer.lex(self) do |(tok, _)|
|
31
40
|
return false if tok.name == 'Error'
|
data/lib/rouge/util.rb
CHANGED
data/lib/rouge/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.1
|
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: 2012-10-
|
12
|
+
date: 2012-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- Gemfile
|
39
39
|
- lib/rouge/util.rb
|
40
40
|
- lib/rouge/lexers/python.rb
|
41
|
+
- lib/rouge/lexers/sql.rb
|
41
42
|
- lib/rouge/lexers/common_lisp.rb
|
42
43
|
- lib/rouge/lexers/erb.rb
|
43
44
|
- lib/rouge/lexers/scheme.rb
|
@@ -49,6 +50,7 @@ files:
|
|
49
50
|
- lib/rouge/lexers/perl.rb
|
50
51
|
- lib/rouge/lexers/javascript.rb
|
51
52
|
- lib/rouge/lexers/diff.rb
|
53
|
+
- lib/rouge/lexers/viml.rb
|
52
54
|
- lib/rouge/lexers/php/builtins.rb
|
53
55
|
- lib/rouge/lexers/haskell.rb
|
54
56
|
- lib/rouge/lexers/c.rb
|
@@ -63,6 +65,7 @@ files:
|
|
63
65
|
- lib/rouge/lexers/css.rb
|
64
66
|
- lib/rouge/lexers/cpp.rb
|
65
67
|
- lib/rouge/lexers/factor.rb
|
68
|
+
- lib/rouge/lexers/viml/keywords.rb
|
66
69
|
- lib/rouge/plugins/redcarpet.rb
|
67
70
|
- lib/rouge/themes/thankful_eyes.rb
|
68
71
|
- lib/rouge/themes/colorful.rb
|