UNPKG

4.1 kBMarkdownView Raw
1Styledown
2=========
3
4A 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
8Warning
9-------
10
11**Work-in-progress** (but usable), not feature-complete (but near), and not
12fully documented (but will be). Use if you're adventurous (via git clone + npm
13link).
14
15What to do
16----------
17
18Write your CSS documentation with an `h3`, and a code block that begins with
19`@example`.
20
21``` markdown
22### Button
23
24Create your buttons with a `.button` class.
25
26 @example
27 <a class="button">Button</a>
28 <a class="button primary">Button</a>
29```
30
31Jade is also supported. It's auto-detected for you when you want Jade or HTML.
32
33``` markdown
34### Tables
35
36Tables 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
46Differences from regular markdown
47---------------------------------
48
49Styledown works like Markdown: it merely transforms a document into HTML. In
50fact, any and all Markdown documents will work as expected in Styledown.
51
52With a few key extensions:
53
54### Example blocks
55
56Example blocks are regular code blocks that begin with `@example`. They're
57rendered into HTML + source code blocks.
58
59#### Input
60
61``` markdown
62Consider 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 &lt;a class="button"&gt;...
84 </pre>
85</div>
86```
87
88### Syntax highlighting
89
90Syntax highlighting comes for free, without any client-side code. Simply
91surround 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
123Installation
124------------
125
126``` bash
127$ npm install -g styledown
128```
129
130Usage
131-----
132
133### Command line
134
135``` bash
136$ styledown < Styles.md > index.html
137```
138
139### Node.js
140
141``` js
142var Styledown = require('styledown');
143Styledown.parse(string);
144```
145
146### Node.js - Express
147
148Use the middleware.
149
150``` js
151var styledownHandler = require('styledown/connect');
152app.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
164To come soon.
165
166### Ruby - Rails
167
168Middleware to come soon.
169
170Getting started
171---------------
172
173Write your files in Markdown.
174
175License
176-------
177
178Released under the MIT License. Copyright (c) 2014 Rico Sta. Cruz.
179
180> Permission is hereby granted, free of charge, to any person obtaining
181a copy of this software and associated documentation files (the
182'Software'), to deal in the Software without restriction, including
183without limitation the rights to use, copy, modify, merge, publish,
184distribute, sublicense, and/or sell copies of the Software, and to
185permit persons to whom the Software is furnished to do so, subject to
186the following conditions:
187>
188> The above copyright notice and this permission notice shall be
189included in all copies or substantial portions of the Software.
190>
191> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
192EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
193MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
194IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
195CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
196TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
197SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.