Skip to content

Implement LightningCSS.parse to expose the AST - #12

Merged
marcoroth merged 4 commits into
mainfrom
expose-ast
Oct 13, 2026
Merged

marcoroth merged 4 commits into
mainfrom
expose-ast

Conversation

@marcoroth

@marcoroth marcoroth commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

This pull request adds LightningCSS.parse, which returns the AST Lightning CSS parsed a stylesheet to, along with LightningCSS::Node and LightningCSS::Visitor to walk it.

The API follows what oxc-ruby does for JavaScript.

parsed = LightningCSS.parse(".card .title:hover { color: #f00 }")

parsed.stylesheet   #=> the AST exactly as Lightning CSS serializes it
parsed.warnings     #=> []

root = parsed.root

root.type                    
#=> "stylesheet"

root.every("declaration")    
#=> every declaration in the stylesheet

root.rules.first.value.selectors.first.map(&:type)
#=> ["class", "combinator", "class", "pseudo-class"]

Resolves #11

@marcoroth
marcoroth enabled auto-merge (squash) October 13, 2026 03:22
@marcoroth
marcoroth merged commit ad2eaba into main Oct 13, 2026
11 checks passed
@marcoroth
marcoroth deleted the expose-ast branch October 13, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose AST

1 participant