package css-parser
A CSS parser written in OCaml
Install
Dune Dependency
Authors
Maintainers
Sources
v0.2.4.tar.gz
sha256=9c91064fd75dda05dad29b1e05c856ba3b9bac23ca4816e2a2da6bd46645e77e
md5=d437ecdab0138292b4a7081d404f833a
Description
Parses a CSS Level 3 string and produces an AST.
Published: 24 May 2020
README
ocaml-css-parser
A CSS parser written in OCaml.
Parses a CSS string and produces an AST.
Build
npm install -g esy
esy
# to build and run tests
esy dune runtest
Example
let css =
{|
{
color: red !important;
width: 100%;
}
|} in
let ast = Css.Parser.parse_stylesheet css in
(* ast is a value of type Css.Stylesheet.t defined in lib/types.mli *)
(* that looks like that:
([Rule.Style_rule
{Style_rule.prelude = ([], Location.none);
block =
([Declaration_list.Declaration
{Declaration.name = ("color", Location.none);
value = ([(Component_value.Ident "blue", Location.none)], Location.none);
important = (true, Location.none);
loc = Location.none;
};
{Declaration.name = ("width", Location.none);
value = ([(Component_value.Percentage "100", Location.none)], Location.none);
important = (false, Location.none);
loc = Location.none;
};
], Location.none);
loc = Location.none;
};
], Location.none)
*)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page