{"id":18431648,"url":"https://github.com/astrada/ocaml-css-parser","last_synced_at":"2025-04-07T18:33:02.584Z","repository":{"id":47401309,"uuid":"159971961","full_name":"astrada/ocaml-css-parser","owner":"astrada","description":"A CSS parser written in OCaml","archived":false,"fork":false,"pushed_at":"2021-09-01T18:43:59.000Z","size":126,"stargazers_count":32,"open_issues_count":1,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2023-03-12T16:15:25.885Z","etag":null,"topics":["css","ocaml","parser"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astrada.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-01T17:55:02.000Z","updated_at":"2023-03-12T16:15:25.885Z","dependencies_parsed_at":"2022-08-17T15:26:26.294Z","dependency_job_id":null,"html_url":"https://github.com/astrada/ocaml-css-parser","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrada%2Focaml-css-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrada%2Focaml-css-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrada%2Focaml-css-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrada%2Focaml-css-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astrada","download_url":"https://codeload.github.com/astrada/ocaml-css-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223288803,"owners_count":17120478,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","ocaml","parser"],"created_at":"2024-11-06T05:25:48.562Z","updated_at":"2024-11-06T05:25:49.242Z","avatar_url":"https://github.com/astrada.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"ocaml-css-parser\n================\n\nA CSS parser written in OCaml.\n\nParses a CSS string and produces an AST.\n\n### Build\n\n```bash\nnpm install -g esy\nesy\n# to build and run tests\nesy dune runtest\n```\n\n### Example\n\n```ocaml\nlet css =\n{|\n  {\n    color: red !important;\n    width: 100%;\n  }\n|} in\n  let ast = Css.Parser.parse_stylesheet css in\n  (* ast is a value of type Css.Stylesheet.t defined in lib/types.mli *)\n  (* that looks like that:\n    ([Rule.Style_rule\n        {Style_rule.prelude = ([], Location.none);\n         block =\n           ([Declaration_list.Declaration\n               {Declaration.name = (\"color\", Location.none);\n                  value = ([(Component_value.Ident \"blue\", Location.none)], Location.none);\n                  important = (true, Location.none);\n                  loc = Location.none;\n                 };\n               {Declaration.name = (\"width\", Location.none);\n                  value = ([(Component_value.Percentage \"100\", Location.none)], Location.none);\n                  important = (false, Location.none);\n                  loc = Location.none;\n                };\n            ], Location.none);\n         loc = Location.none;\n        };\n     ], Location.none)\n  *)\n```\n\n### Remarks\n\nWhitespaces and comments are discarded by the lexer, so they are not available\nto the parser. An exception is made for significant whitespaces in rule\npreludes, to disambiguate between selectors like `p :first-child` and\n`p:first-child`. These whitespaces are replaced with `*` to keep CSS semantics\nintact. So, e.g., `p :first-child` is parsed as `p *:first-child`, `p .class`\nas `p *.class`, and `p #id` as `p *#id`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrada%2Focaml-css-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastrada%2Focaml-css-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrada%2Focaml-css-parser/lists"}