Skip to content
This repository has been archived by the owner on Jul 31, 2021. It is now read-only.
/ cssParser.js Public archive

A simple, tiny, light and powerful CSS parser written completely in JavaScript.

License

Notifications You must be signed in to change notification settings

FlexOS-org/cssParser.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cssParser.js

A simple, tiny, light and powerful CSS parser written completely in JavaScript and Node.js developed originally for ThetaIDE.

How to run it:

NOTE: This library requires Node.js. If you didn't install it, download it from the original site https://nodejs.org/en/ or run sudo apt-get install nodejs command if you're on Ubuntu or Debian.

For an example, create an index.js file:

const cssParser = require('./cssParser.js');
const FileSystem= require('fs');
cssParser.parse(FileSystem.readFileSync("example.css").toString());

And create a CSS file called "example.css" in the same directory:

example {
   background-color: blue;
   color: white;
}

Finally, run node index.js and the output will be an object describing each code block, property and value.

Example:

{ '0': 
   { start: 9,
     end: 56,
     string: '{ background-color: blue; color: white; }',
     type: 'Code block',
     selector: '.example',
     'Declaration 0': 
      { string: ' background-color: blue;',
        property: [Object],
        start: 9,
        end: 34,
        value: [Object] },
     'Declaration 1': 
      { string: ' color: white;',
        property: [Object],
        start: 34,
        end: 54,
        value: [Object] } } }

About

A simple, tiny, light and powerful CSS parser written completely in JavaScript.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published