Class: Rouge::TextAnalyzer
- Inherits:
-
String
- Object
- String
- Rouge::TextAnalyzer
- Defined in:
- lib/rouge/text_analyzer.rb
Instance Method Summary collapse
- #doctype ⇒ Object
- #doctype?(type) ⇒ Boolean
- #lexes_cleanly?(lexer) ⇒ Boolean
- #shebang ⇒ Object
- #shebang?(match) ⇒ Boolean
Instance Method Details
#doctype ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rouge/text_analyzer.rb', line 15 def doctype return @doctype if instance_variable_defined? :@doctype self =~ %r(\A\s* (?:<\?.*?\?>\s*)? # possible <?xml...?> tag <!DOCTYPE\s+(.+?)> )xm @doctype = $1 end |
#doctype?(type) ⇒ Boolean
25 26 27 |
# File 'lib/rouge/text_analyzer.rb', line 25 def doctype?(type) type === doctype end |
#lexes_cleanly?(lexer) ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/rouge/text_analyzer.rb', line 29 def lexes_cleanly?(lexer) lexer.lex(self) do |(tok, _)| return false if tok.name == 'Error' end true end |
#shebang ⇒ Object
3 4 5 6 7 8 |
# File 'lib/rouge/text_analyzer.rb', line 3 def shebang return @shebang if instance_variable_defined? :@shebang self =~ /\A\s*#!(.*)$/ @shebang = $1 end |
#shebang?(match) ⇒ Boolean
10 11 12 13 |
# File 'lib/rouge/text_analyzer.rb', line 10 def shebang?(match) match = /\b#{match}(\s|$)/ match === shebang end |