sson
v1.0.1
Published
Parses stylesheet markdown comments into semantic JSON
Downloads
2
Maintainers
Readme
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\"><<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>"
}
]
}
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
- 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
History
View the change log.