1 | Styledown
|
2 | =========
|
3 |
|
4 | A markdown dialect to help you write CSS styleguides efficiently.
|
5 |
|
6 | [![Status](https://travis-ci.org/rstacruz/styledown.png?branch=master)](https://travis-ci.org/rstacruz/styledown)
|
7 |
|
8 | Installation
|
9 | ------------
|
10 |
|
11 | ``` bash
|
12 | $ npm install -g styledown
|
13 | $ styledown --help
|
14 | ```
|
15 |
|
16 | [![npm version](https://badge.fury.io/js/styledown.svg)](https://npmjs.org/package/styledown "View this project on npm")
|
17 |
|
18 | Usage
|
19 | -----
|
20 |
|
21 | Styledown supports 2 modes of operation: Markdown mode (default) and Inline mode
|
22 | (`-i | --inline`).
|
23 |
|
24 | __Markdown mode:__ Use Styledown to generate an `.html` styleguide from one or
|
25 | more `.md` files.
|
26 |
|
27 | ```
|
28 | $ mdextract styles.md > styleguide.html
|
29 | ```
|
30 |
|
31 | __Inline mode:__ Generate an `.html` styleguide from one or more CSS files with
|
32 | inline comments. (You can use less/styl/sass here, too.)
|
33 |
|
34 | ```
|
35 | $ mdextract -i *.css > styleguide.html
|
36 | ```
|
37 |
|
38 | Markdown format
|
39 | ---------------
|
40 |
|
41 | All Markdown documents are also Styledown documents. That is, all of Markdown
|
42 | will work. Styledown implements a few extensions that helps you create
|
43 | styleguides.
|
44 |
|
45 | __Example blocks:__ Write your CSS documentation with an `h3`, and a code block
|
46 | that begins with `@example`.
|
47 |
|
48 | ``` markdown
|
49 | ### Button
|
50 |
|
51 | Create your buttons with a `.button` class.
|
52 |
|
53 | @example
|
54 | <a class="button">Button</a>
|
55 | <a class="button primary">Button</a>
|
56 | ```
|
57 |
|
58 | __Jade examples:__ Jade is also supported. It's auto-detected for you when you
|
59 | want Jade or HTML. This allows you to write simpler example code.
|
60 |
|
61 | ``` markdown
|
62 | ### Tables
|
63 |
|
64 | Tables have a class `.table`.
|
65 |
|
66 | @example
|
67 | table.table
|
68 | tr
|
69 | td Item 1
|
70 | td Item 2
|
71 | td Item 3
|
72 | ```
|
73 |
|
74 | Example
|
75 | -------
|
76 |
|
77 | Example blocks are transformed into `div.sg-example` blocks, containing a
|
78 | `.sg-canvas` (the actual HTML example) and `.sg-code` (with the HTML source).
|
79 |
|
80 | #### Input
|
81 |
|
82 | ``` markdown
|
83 | Consider this example:
|
84 |
|
85 | @example
|
86 | <a class="button">Button</a>
|
87 | <a class="button primary">Button</a>
|
88 | ```
|
89 |
|
90 | #### Output
|
91 |
|
92 | ``` html
|
93 | <p>Consider this example:</p>
|
94 |
|
95 | <div class="sg-example">
|
96 | <!-- Actual HTML code is rendered here in `.sg-canvas` -->
|
97 | <div class="sg-canvas">
|
98 | <a class="button">Button</a>
|
99 | <a class="button primary">Button</a>
|
100 | </div>
|
101 |
|
102 | <!-- Syntax-highlighted source code here in `.sg-code` -->
|
103 | <pre class="sg-code">
|
104 | <a class="button">...
|
105 | </pre>
|
106 | </div>
|
107 | ```
|
108 |
|
109 | Syntax highlighting
|
110 | -------------------
|
111 |
|
112 | Syntax highlighting comes for free, without any client-side code. Simply
|
113 | surround your code in a code fence, and it will be highlighted via
|
114 | [highlight.js].
|
115 |
|
116 | #### Input
|
117 |
|
118 | See this code:
|
119 |
|
120 | ``` javascript
|
121 | $(function() {
|
122 | alert("Hello");
|
123 | });
|
124 | ```
|
125 |
|
126 | #### Output
|
127 |
|
128 | ``` html
|
129 | <p>See this code:</p>
|
130 |
|
131 | <pre class="sg-lang-javascript">
|
132 | $(<span class='hljs-function'>function</span>() {
|
133 | alert(<span class='hljs-string'>"hello"</span>);
|
134 | });
|
135 | </pre>
|
136 | ```
|
137 |
|
138 | Inline mode
|
139 | -----------
|
140 |
|
141 | You can put your Styledown definitions inline in your CSS files. Use
|
142 | JavaDoc-style `/** ... */` comment blocks, and begin your block with a line that
|
143 | ends in `:`.
|
144 |
|
145 | The rest of the syntax is the same as in the default Markdown mode.
|
146 |
|
147 | ```css
|
148 | /**
|
149 | * Section name:
|
150 | * `.your-section-here` - documentation on what your section is.
|
151 | *
|
152 | * @example
|
153 | * div.your-section-here
|
154 | * h3 Sample code
|
155 | * p goes here
|
156 | */
|
157 |
|
158 | .your-section-here {
|
159 | display: block;
|
160 | ...
|
161 | }
|
162 | ```
|
163 |
|
164 | Use `styledown -i` to generate an HTML.
|
165 |
|
166 | ```bash
|
167 | $ styledown -i *.css > styleguides.html
|
168 | ```
|
169 |
|
170 | Thanks
|
171 | ------
|
172 |
|
173 | **Styledown** © 2013+, Rico Sta. Cruz. Released under the [MIT License].<br>
|
174 | Authored and maintained by Rico Sta. Cruz with help from [contributors].
|
175 |
|
176 | > [ricostacruz.com](http://ricostacruz.com) ·
|
177 | > GitHub [@rstacruz](https://github.com/rstacruz) ·
|
178 | > Twitter [@rstacruz](https://twitter.com/rstacruz)
|
179 |
|
180 | [MIT License]: http://mit-license.org/
|
181 | [contributors]: http://github.com/rstacruz/styledown/contributors
|
182 | [highlight.js]: http://highlightjs.org/
|