Skip to content

SSON parses semantic stylesheet markdown comments into JSON

License

Notifications You must be signed in to change notification settings

winstromming/sson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

SSON parses semantic stylesheet markdown comments into JSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published