Giter VIP home page Giter VIP logo

csstools's Introduction

CSS Tools for Wolfram Language

View notebooks

CSSTools is a package for importing CSS files into the Wolfram Language. CSSTools supports 11.0 and later versions of Wolfram Language deployments for the desktop, including Wolfram Desktop and Mathematica.

The initial release of CSSTools contains the core CSS Level 2 Revision 1 specification. The tokenizer follows the CSS Syntax Module Level 3 specification and the selectors follow Selectors Level 3. Additional supported modules include:

The Wolfram Desktop front end uses its own stylesheet system and translation from CSS to Wolfram Desktop is not one-to-one. Regardless, the goal is to conform with all included specifications as much as possible. The listed modules indicate which CSS properties can be validated while importing into Wolfram Desktop. Though the properties can be validated and imported, not all imported CSS properties have a corresponding option in the Wolfram Desktop front end.

Installing the CSSTools release

The CSSTools release comes in the form of a .paclet file, which contains the entire package and its documentation. Download the latest release from this latest release link. To install, run the following command in the Wolfram Language:

PacletInstall["/full/path/to/CSSTools.paclet"]

This will permanently install the CSSTools paclet. The Wolfram Language will always use the latest installed version of CSSTools. Installed versions can be enumerated using the command:

PacletFind["CSSTools"]

And all versions can be uninstalled using the command:

PacletUninstall["CSSTools"]

Using CSSTools

To access the documentation, open the notebook interface help viewer and search for CSSTools. The two results will be a guide page enumerating the most commonly used functions in CSSTools, and a detailed tutorial.

To start, load the CSSTools package and try importing some basic CSS rules.

Needs["CSSTools`"]
cssData = ImportString["h1 {font-size:14pt; color:red}", "CSS"]

The result is a Dataset expression that matches a canonical layout of a CSS file with additional interpretations. Use the CSSCascade function to perform the CSS cascade algorithm and translate the imported CSS to Wolfram Desktop options.

CSSCascade[All (*all properties*), Cell (*as cell-level options*), cssData, All (*all rulesets*)]

More details can be found in the included documentation.

Where did this come from?

CSSTools is a paclet maintained by Kevin Daily of Wolfram Research. He began building CSSTools because he thought it would be neat to use the CSS stylesheet language in Wolfram Desktop. He did not realize how hard it would be to translate CSS to Wolfram Desktop options including the multitude of additional CSS modules that must all work together.

CSSTools is implemented completely in the Wolfram Language. It might have been better suited to build off of an existing library, but none were found that exactly matched the translations that were needed to match Wolfram Language code.

...and where's it going?

The hope is for CSSTools to be further developed by community support. Using the tokenizer and its related functions, additional properties should be straightforward to add to the package. Some CSS features that would be nice to see are vendor-specific properties added as recognizable properties. More ambitious additions would be animation rules.

More...

See the following files for more information:

csstools's People

Contributors

kmdaily avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.