class Rouge::TextAnalyzer
def doctype
def doctype return @doctype if instance_variable_defined? :@doctype self =~ %r(\A\s* (?:<\?.*?\?>\s*)? # possible <?xml...?> tag <!DOCTYPE\s+(.+?)> )xm @doctype = $1 end
def doctype?(type=//)
def doctype?(type=//) type === doctype end
def lexes_cleanly?(lexer)
Return true if the result of lexing with the given lexer contains no
def lexes_cleanly?(lexer) lexer.lex(self) do |(tok, _)| return false if tok.name == 'Error' end true end
def shebang
def shebang return @shebang if instance_variable_defined? :@shebang self =~ /\A\s*#!(.*)$/ @shebang = $1 end
def shebang?(match)
This normalizes things so that `text.shebang?('bash')` will detect
Check if the given shebang is present.
def shebang?(match) match = /\b#{match}(\s|$)/ match === shebang end