sson is a node module for parsing stylesheet markdown comments into semantic JSON
Install with npm install sson --save
.
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.
var sson = require('sson')
var data = fs.readFileSync('foo.css')
sson(data)
/*
Foo
===
Renders paragraphs as bold text.
<p>Hello World</p>
*/
p {
font-weight: bold;
}
{
"sections": [
{
"comment": "<h1 id=\"foo\">Foo</h1>\n<p>Renders paragraphs as bold text.</p>\n<pre class=\"hljs\"><code><span class=\"hljs-tag\"><<span class=\"hljs-title\">p</span>></span>Hello World<span class=\"hljs-tag\"></<span class=\"hljs-title\">p</span>></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>"
}
]
}
Please note that sson
does not compile any preprocessor source files, merely parses the comments. It works well with Sassdown to produce living styleguides.
- Fork it
- Create your feature branch (
git checkout -b feature/my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create new Pull Request
View the change log.