Skip to content

Add General CSS Tokenizer and Parser in cssom/parsers #303

@yorkie

Description

@yorkie

Background

To support advanced CSS features and improve maintainability, a general-purpose CSS Tokenizer and Parser should be introduced under cssom/parsers.

Requirements

  • Tokenizer: Implement a tokenizer for CSS that can tokenize input for both stylesheets and inline style declarations.
  • Parser: Implement a general parser that can:
    • Parse an entire CSS stylesheet.
    • Parse a single style declaration (e.g., from a style attribute).

Stylesheet Parsing

  • The parser should support the following rule types:
    • StyleRule (standard style rules)
    • KeyframeRule (for @keyframes)
    • FontFaceRule (for @font-face)
    • MediaRule (for @media)
    • ImportRule (for @import)

Single Style Declaration Parsing

  • Should parse style declarations into a map/object of key/value pairs for use with inline styles or style attributes.
  • Only key/value extraction is required for declarations.

Acceptance Criteria

  • Tokenizer covers all valid CSS tokens used in the above rule types and declarations.
  • Parser correctly parses complete stylesheets with the listed rule types.
  • Parser can parse a single style declaration into key/value pairs.
  • Unit tests for both tokenizer and parser (stylesheet + declaration cases).

References


This feature will lay the groundwork for more robust CSS support throughout the engine.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions