Module: HtmlConditionalComment

Defined in:
lib/html-conditional-comment.rb,
lib/html-conditional-comment/lexer.rb,
lib/html-conditional-comment/nodes.rb,
lib/html-conditional-comment/parser.rb,
lib/html-conditional-comment/version.rb,
lib/html-conditional-comment/visitor.rb,
lib/html-conditional-comment/version_vector.rb

Defined Under Namespace

Modules: Nodes, Visitors Classes: Lexer, ParseError, Parser, TokenError, VersionVector, VisitError

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.lex(html) ⇒ Object

Tokenize the HTML into an array of tokens



13
14
15
# File 'lib/html-conditional-comment.rb', line 13

def lex(html)
  Lexer.new(html).tokenize()
end

.parse(html) ⇒ Object

Parse into tree of nodes the HTML



20
21
22
# File 'lib/html-conditional-comment.rb', line 20

def parse(html)
  Parser.new(self.lex(html)).parse()
end

.to_string(html, features, version) ⇒ Object

Evaluate conditional comments in HTML using the supplied browser information and return a string

  • features - String or Array of features of browser

  • version - String, Integer, or Float representing version of the browser



31
32
33
# File 'lib/html-conditional-comment.rb', line 31

def to_string(html, features, version)
  self.parse(html).accept(Visitors::ToString.new(features, version))
end