Code Monkey home page Code Monkey logo

cassidy's Introduction

Cassidy

The beginnings of a CSS library for Python.

At present it implements a decent part of the CSS Selectors spec and the draft CSS3-Syntax spec.

Here's an example of the selectors implementation:

>>> import html5lib
>>> from cassidy.selectors import selector
>>> doc = html5lib.parse("<div><p id='foo'>hello</p><p class='bar'>world</p></div>")
>>> for element in selector("p").find(doc):
...     print element.toxml()
... 
<p id="foo">hello</p>
<p class="bar">world</p>

>>> for element in selector("div .bar").find(doc):
...     print element.toxml()
... 
<p class="bar">world</p>

The css3syntax directory is a work-in-progress implementation of CSS3-Syntax draft spec. css3_selectors_test.py is a test-driven implementation of selectors using css3syntax for tokenization and parsing rather than PLY as cassidy.selectors does. The same actual selector implementation is used, though. This version will likely replace the PLY-based version eventually.

Besides improving all the above, the plan next is to implement the property model and then value calculation and inheritance.

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.