Code Monkey home page Code Monkey logo

css-parser's Introduction

Standards-Based CSS Parser

This project implements a standards-based CSS Parser. I'm writing the CSS Syntax spec http://dev.w3.org/csswg/css3-syntax, and need an implementation of it for testing purposes.

This parser is not designed to be fast. Its structure and coding style are instead meant to be very close to the spec, so that it's easy to verify that the code matches the spec (and vice versa) and to make it easy, when the spec changes, to make the same change in the parser.

However, it may still be useful to someone in production, as it is intended to fully and completely match browser behavior (at least, as much as the final spec does).

Using the Library

The functionality is spread across two files for organizational purposes. The tokenizer.js file comes first - call the tokenize() function with a string containing CSS, and it will return an array of CSS tokens. parser.js comes next - call parse() with an array of CSS tokens, and it will return a stylesheet object implementing a very simple tree of rules.

Node Integration

Simon Sapin added some CommonJS export statements to the bottom of tokenizer.js and parser.js exporting the tokenize and parse functions, so as far as I know it will Just Work(tm). I have no idea how to fix it if anything goes wrong, though.

css-parser's People

Contributors

bkardell avatar espadrine avatar raynos avatar simonsapin avatar tabatkins avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.