Module: Crass

Defined in:
lib/crass.rb,
lib/crass/parser.rb,
lib/crass/scanner.rb,
lib/crass/version.rb,
lib/crass/tokenizer.rb,
lib/crass/token-scanner.rb

Overview

A CSS parser based on the CSS Syntax Module Level 3 spec.

Defined Under Namespace

Classes: Parser, Scanner, TokenScanner, Tokenizer

Constant Summary collapse

VERSION =
'1.0.7'

Class Method Summary collapse

Class Method Details

.parse(input, options = {}) ⇒ Object

Parses input as a CSS stylesheet and returns a parse tree.

Options:

  • :maximum_depth - Maximum nesting depth for simple blocks and functions. Constructs nested more deeply than this are discarded to prevent stack exhaustion. Defaults to Crass::Parser::DEFAULT_MAXIMUM_DEPTH.

  • :preserve_comments - If true, comments will be preserved as :comment tokens.

  • :preserve_hacks - If true, certain non-standard browser hacks such as the IE "*" hack will be preserved even though they violate CSS 3 syntax rules.



22
23
24
# File 'lib/crass.rb', line 22

def self.parse(input, options = {})
  Parser.parse_stylesheet(input, options)
end

.parse_properties(input, options = {}) ⇒ Object

Parses input as a string of CSS properties (such as the contents of an HTML element's style attribute) and returns a parse tree.

See parse for options.



30
31
32
# File 'lib/crass.rb', line 30

def self.parse_properties(input, options = {})
  Parser.parse_properties(input, options)
end