servo/rust-cssparser
소개
CSS Syntax Level 3의 Rust 구현입니다.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- +1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalrust-cssparser
Rust implementation of CSS Syntax Module Level 3
The Servo Code of Conduct and AI Usage Policy apply to this repository.
Overview
Parsing CSS involves a series of steps:
When parsing from bytes, (e.g. reading a file or fetching an URL from the network,) detect the character encoding (based on a
Content-TypeHTTP header, an@charsetrule, a BOM, etc.) and decode to Unicode text.rust-cssparser does not do this yet and just assumes UTF-8.
This step is skipped when parsing from Unicode, e.g. in an HTML
<style>element.Tokenization, a.k.a. lexing. The input, a stream of Unicode text, is transformed into a stream of tokens. Tokenization never fails, although the output may contain error tokens.
This flat stream of tokens is then transformed into a tree of component values, which are either preserved tokens, or blocks/functions (
{ … },[ … ],( … ),foo( … )) that contain more component values.rust-cssparser does this at the same time as tokenization: raw tokens are never materialized, you only get component values.
Component values can then be parsed into generic rules or declarations. The header and body of rules as well as the value of declarations are still just lists of component values at this point. See the
Tokenenum for the data structure.The last step of a full CSS parser is parsing the remaining component values into Selectors, specific CSS properties, etc.
By design, rust-cssparser does not do this last step which depends a lot on what you want to do: which properties you want to support, what you want to do with selectors, etc.
It does however provide some helper functions to parse CSS colors and An+B (the argument to
:nth-child()and related selectors.See Servo’s
stylecrate for an example of a parser based on rust-cssparser.
관련 프로젝트 살펴보기
불러오는 중…