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 | Warning
|
9 | -------
|
10 |
|
11 | **Work-in-progress** (but usable), not feature-complete (but near), and not
|
12 | fully documented (but will be). Use if you're adventurous (via git clone + npm
|
13 | link).
|
14 |
|
15 | What to do
|
16 | ----------
|
17 |
|
18 | Write your CSS documentation with an `h3`, and a code block that begins with
|
19 | `@example`.
|
20 |
|
21 | ``` markdown
|
22 | ### Button
|
23 |
|
24 | Create your buttons with a `.button` class.
|
25 |
|
26 | @example
|
27 | <a class="button">Button</a>
|
28 | <a class="button primary">Button</a>
|
29 | ```
|
30 |
|
31 | Jade is also supported. It's auto-detected for you when you want Jade or HTML.
|
32 |
|
33 | ``` markdown
|
34 | ### Tables
|
35 |
|
36 | Tables have a class `.table`.
|
37 |
|
38 | @example
|
39 | table.table
|
40 | tr
|
41 | td Item 1
|
42 | td Item 2
|
43 | td Item 3
|
44 | ```
|
45 |
|
46 | Differences from regular markdown
|
47 | ---------------------------------
|
48 |
|
49 | Styledown works like Markdown: it merely transforms a document into HTML. In
|
50 | fact, any and all Markdown documents will work as expected in Styledown.
|
51 |
|
52 | With a few key extensions:
|
53 |
|
54 | ### Example blocks
|
55 |
|
56 | Example blocks are regular code blocks that begin with `@example`. They're
|
57 | rendered into HTML + source code blocks.
|
58 |
|
59 | #### Input
|
60 |
|
61 | ``` markdown
|
62 | Consider this example:
|
63 |
|
64 | @example
|
65 | <a class="button">Button</a>
|
66 | <a class="button primary">Button</a>
|
67 | ```
|
68 |
|
69 | #### Output
|
70 |
|
71 | ``` html
|
72 | <p>Consider this example:</p>
|
73 |
|
74 | <div class="sg-example">
|
75 | <!-- Actual HTML code is rendered here in `.sg-canvas` -->
|
76 | <div class="sg-canvas">
|
77 | <a class="button">Button</a>
|
78 | <a class="button primary">Button</a>
|
79 | </div>
|
80 |
|
81 | <!-- Syntax-highlighted source code here in `.sg-code` -->
|
82 | <pre class="sg-code">
|
83 | <a class="button">...
|
84 | </pre>
|
85 | </div>
|
86 | ```
|
87 |
|
88 | ### Syntax highlighting
|
89 |
|
90 | Syntax highlighting comes for free, without any client-side code. Simply
|
91 | surround your code in a code fence, and it will be highlighted via
|
92 | [highlight.js].
|
93 |
|
94 | #### Input
|
95 |
|
96 | See this code:
|
97 |
|
98 | ``` javascript
|
99 | $(function() {
|
100 | alert("Hello");
|
101 | });
|
102 | ```
|
103 |
|
104 | #### Output
|
105 |
|
106 | ``` html
|
107 | <p>See this code:</p>
|
108 |
|
109 | <pre class="sg-lang-javascript">
|
110 | $(<span class='hljs-function'>function</span>() {
|
111 | alert(<span class='hljs-string'>"hello"</span>);
|
112 | });
|
113 | </pre>
|
114 | ```
|
115 |
|
116 | ### Also
|
117 |
|
118 | * Sections
|
119 | * blocks
|
120 | * Syntax highlighting
|
121 | * Example blocks
|
122 |
|
123 | Installation
|
124 | ------------
|
125 |
|
126 | ``` bash
|
127 | $ npm install -g styledown
|
128 | ```
|
129 |
|
130 | Usage
|
131 | -----
|
132 |
|
133 | ### Command line
|
134 |
|
135 | ``` bash
|
136 | $ styledown < Styles.md > index.html
|
137 | ```
|
138 |
|
139 | ### Node.js
|
140 |
|
141 | ``` js
|
142 | var Styledown = require('styledown');
|
143 | Styledown.parse(string);
|
144 | ```
|
145 |
|
146 | ### Node.js - Express
|
147 |
|
148 | Use the middleware.
|
149 |
|
150 | ``` js
|
151 | var styledownHandler = require('styledown/connect');
|
152 | app.use(styledownHandler({
|
153 | path: '/styleguides',
|
154 | root: Dir.cwd(),
|
155 | guides: {
|
156 | index: 'styles.md',
|
157 | forms: 'forms.md'
|
158 | }
|
159 | });
|
160 | ```
|
161 |
|
162 | ### Ruby
|
163 |
|
164 | To come soon.
|
165 |
|
166 | ### Ruby - Rails
|
167 |
|
168 | Middleware to come soon.
|
169 |
|
170 | Getting started
|
171 | ---------------
|
172 |
|
173 | Write your files in Markdown.
|
174 |
|
175 | License
|
176 | -------
|
177 |
|
178 | Released under the MIT License. Copyright (c) 2014 Rico Sta. Cruz.
|
179 |
|
180 | > Permission is hereby granted, free of charge, to any person obtaining
|
181 | a copy of this software and associated documentation files (the
|
182 | 'Software'), to deal in the Software without restriction, including
|
183 | without limitation the rights to use, copy, modify, merge, publish,
|
184 | distribute, sublicense, and/or sell copies of the Software, and to
|
185 | permit persons to whom the Software is furnished to do so, subject to
|
186 | the following conditions:
|
187 | >
|
188 | > The above copyright notice and this permission notice shall be
|
189 | included in all copies or substantial portions of the Software.
|
190 | >
|
191 | > THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
192 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
193 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
194 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
195 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
196 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
197 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|