rouge 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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'
@@ -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'
@@ -1,4 +1,14 @@
1
1
  module Rouge
2
+ class Yielder
3
+ def initialize(&pr)
4
+ @proc = pr
5
+ end
6
+
7
+ def <<(*a)
8
+ @proc && @proc.call(*a)
9
+ end
10
+ end
11
+
2
12
  class InheritableHash < Hash
3
13
  def initialize(parent=nil)
4
14
  @parent = parent
@@ -1,5 +1,5 @@
1
1
  module Rouge
2
2
  def self.version
3
- "0.2.0"
3
+ "0.2.1"
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.2.0
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-10 00:00:00.000000000 Z
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