1.0.1 • Published 9 years ago

sson v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

sson

sson is a node module for parsing stylesheet markdown comments into semantic JSON

Install

Install with npm install sson --save.

Getting started

Call sson with a content buffer from CSS, SCSS, LESS (or similar file formats) and it will return a JSON object containing sections, one for each block comment in the source file.

Comments will be parsed as Markdown and any recognised code blocks will be rendered as HTML/CSS source-result pairs, with added syntax highlighting.

Example usage

var sson = require('sson')
var data = fs.readFileSync('foo.css')

sson(data)

Example source

/*

Foo
===

Renders paragraphs as bold text.

    <p>Hello World</p>

*/

p {
  font-weight: bold;
}

Example output

{
  "sections": [
    {
      "comment": "<h1 id=\"foo\">Foo</h1>\n<p>Renders paragraphs as bold text.</p>\n<pre class=\"hljs\"><code><span class=\"hljs-tag\">&lt;<span class=\"hljs-title\">p</span>&gt;</span>Hello World<span class=\"hljs-tag\">&lt;/<span class=\"hljs-title\">p</span>&gt;</span></code></pre>",
      "result": "\n<p>Hello World</p>\n",
      "style": "<pre class=\"hljs\"><code><span class=\"hljs-tag\">p</span> {\n  <span class=\"hljs-attribute\">font-weight</span><span class=\"hljs-value\">: bold;</span>\n}</code></pre>"
    }
  ]
}

Notes

Please note that sson does not compile any preprocessor source files, merely parses the comments. It works well with Sassdown to produce living styleguides.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create new Pull Request

History

View the change log.