Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

css

A CSS engine for nimony / Nim 3.0 — parse a stylesheet, validate every value, selector and at-rule against its official grammar, lint it in context, then run the cascade over an element tree and get computed values (inheritance, var(), layers, @media, nesting, logical properties, colours, absolute lengths). Standard library only, no dependencies.

📖 Full docs → aoughwl.github.io/docs/css

import css

validateValue("width", "clamp(1rem, 2vw)").error         # "clamp() expects 3 arguments, got 2"
validateMediaQueryList("(min-widht: 600px)").error       # "unknown media feature 'min-widht'"
for d in lintStylesheet(src): echo $d                    # "5: error: colr is not a known CSS property"

let eng = newStyleEngine()
eng.addStylesheet(src)
eng.computedStyle(querySelector(doc, "h1")).get("color") # "rgb(255, 0, 0)"
eng.why(h1, "color")                                     # which rule won, and what it beat

Driven by the MDN data in css/data/*.json. Tests: tests/run.sh. Successor to the Nim-2 thing-king/css.

About

A CSS engine for nimony / Nim 3.0: MDN-typed validation of values, selectors and at-rules, a whole-stylesheet linter, selector matching, the cascade with computed values (var(), layers, @media, nesting, logical properties), @import, colours and a minifier. Pure stdlib.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages