Skip to content

Instantly share code, notes, and snippets.

@jakerb
Last active October 12, 2015 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakerb/b8856a592cfa73f6e595 to your computer and use it in GitHub Desktop.
Save jakerb/b8856a592cfa73f6e595 to your computer and use it in GitHub Desktop.
Human Readable Stylesheets

#Human Readable Stylesheets

HRSS is a jQuery class to compile CSS from sentence-like stylesheets, this was an experiment on creating website styling based on human readable and written syntax.

#Using HRSS

You can get started writing HRSS by using the following keywords: has a, and, of and have a. You can declare the styling of a selector by starting a new line \n. An example of using HRSS is given below.

body has a border-radius of 3px, padding of 2px and a margin of 0px
.parent + .child have a margin of 0px and a border of 0px

This will output:

body { border-radius: 3px; padding: 2px; margin: 0px ; } .parent + .child { margin: 0px; border: 0px; }
/*
* @title HRSS (Human Readable StyleSheets
* @author Jake Bown <jakebown@gmail.com>
*/
var hrss={compile:function(e){e=e.replace(/have a/g,"{"),e=e.replace(/has a/g,"{"),e=e.replace(/\sand a/g,";"),e=e.replace(/\sof/g,":"),e=e.replace(/,/g,";"),e=e.replace(/\n/g,"; }"),e+="; }",console.log(e)}};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment