Skip to content

Latest commit

 

History

History
64 lines (41 loc) · 1.78 KB

Exports.md

File metadata and controls

64 lines (41 loc) · 1.78 KB

Exported Methods

This module exports the following methods:

parse(css, options)

Returns: Root<Node>

Parses a given String and returns an AST with a Root node. If the input is an invalid CSS value, a CSSSyntaxError is thrown.

Parameters

css

Type: String
Required

options

Type: Object

Properties
ignoreUnknownWords

Type: Boolean
Default: false

If true, will allow all unknown parts of the value to be parsed and added to the AST. Similar functionality in the previous version went by the loose option name. If false, unknown values will throw CssSyntaxError.

interpolation

Type: Boolean|Object
Default: false

Set this option to enable parsing of interpolated values for languages such as SCSS. For example: interpolation: { prefix: '@' } will allow parsing of the interpolated value @{batman} which uses @ as the "prefix". For SCSS one might use interpolation: { prefix: '#' }.

variables

Type: Object
Default: { prefixes: ['--'] }

Set this option to modify how variables are identified in a value. By default, this option is set to recognize CSS variables. For languages such as LESS and SCSS which have their own variable prefixes, additional prefixes can be added to the prefixes array.

stringify(node, builder)

A Function with a signature matching (bit) => {} used to concatenate or manipulate each portion (or bit) of the Node's own AST. The nodeToString method makes use of this, as a simple example.

Parameters

node

Type: Node
Required

The Node to stringify.

builder

Type: Function Required

nodeToString(node)

Transforms a Node into its String representation.

Parameters

node

Type: Node
Required