0.6.2 • Published 8 years ago

css-annotation v0.6.2

Weekly downloads
369
License
MIT
Repository
github
Last release
8 years ago

css-annotation Build Status

Annotation parser for CSS

Installation

$ npm install css-annotation

Example

input.css:

/*
 * @foo foofoo
 * @bar bar bar bar
 */

@media screen (min-width: 600px) {
  /*
   * @hoge
   */
  .class {
    /*
     * @baz baz1, baz2, baz3
     */
     font-size: 12px;
  }
}
var fs = require('fs')
var annotation = require('./')

var css = fs.readFileSync('input.css', 'utf-8').trim()

annotation.parse(css)
/*
[
  {
    foo: 'foofoo',
    bar: 'bar bar bar'
  },
  {
    atrule: 'media',
    hoge: true,
    params: 'screen (min-width: 600px)'
  },
  {
    baz: ['baz1', 'baz2', 'baz3']
    rule: '.class'
  }
]
*/

API

annotation.parse(css)

Parse annotation comment in css and return array of its results.

annotation.read(commentText)

commentText is PostCSS's comment.text.

Return its parse results.

License

The MIT License (MIT)

Copyright (c) 2014 Masaaki Morishita