CSSerpent (csserpent v0.5.1) View Source

CSSerpent, the CSS parser.

Link to this section Summary

Functions

Parses CSS text from a string.

Converts parsed CSS to raw CSS.

Link to this section Functions

Link to this function

parse(body, source \\ nil)

View Source

Specs

parse(String.t(), any()) :: [CSSerpent.Rule.t()]

Parses CSS text from a string.

Example

iex> CSSerpent.parse("p { color: green }")
[
  %CSSerpent.Rule{
    identifier: nil,
    props: [%{property: "color", value: "green"}],
    raw: "p { color: green }",
    rules: nil,
    selector: "p",
    source: nil,
    value: nil
  }
]

Specs

Converts parsed CSS to raw CSS.

Example

iex> CSSerpent.raw_css(%CSSerpent.Rule{props: [%{property: "color", value: "green"}], selector: "p"})
"p{color:green}"

iex> CSSerpent.raw_css([%CSSerpent.Rule{props: [%{property: "color", value: "blue"}], selector: "p"}])
"p{color:blue}"