-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.html
More file actions
executable file
·181 lines (139 loc) · 2.74 KB
/
Copy pathrender.html
File metadata and controls
executable file
·181 lines (139 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<xmp style="display:none;">
# Render
## Use Case
You want to do a quick rendering of your litcoffee masterpiece,
potentially with a custom template and stylesheet.
Common enough scenario.
## Example
> coffee render.coffee.md render.coffee.md | browser
## Code
fs = require 'fs'
coffee = require 'coffeescript'
Yep, we require coffee itself.
Pull in optimist for command-line argument handling.
argv = require('optimist')
.default('template', 'html.cst')
.default('style', 'style.css')
.alias('t', 'template')
.alias('s', 'style')
#.demand('f')
#.alias('f', 'file')
#.describe('f', 'Load a file')
.argv
console.log 'argv', argv
OK, let's read and render.
file = argv.file
read = (file) -> fs.readFileSync file, 'utf8'
print = console.log
render = (file, data) ->
text = read(file)
.toString()
.replace(/\n/g, '\\n')
.replace(/"/g, '\\"')
template = coffee.eval '(data) -> "' + text + '"'
print template data
for file in argv._ when file.match /\.(litcoffee|markdown|md)/i
data =
md: read file
css: read argv.style
render argv.template, data</xmp>
<script src="http://strapdownjs.com/v/0.2/strapdown.js"></script>
<style>@import url(http://fonts.googleapis.com/css?family=Source+Code+Pro:200,400,600);
.navbar { display: none }
.container { width: 600px; }
body {
font-family: "Source Code Pro", sans-serif;
padding: 0 0 0 50px;
width: 600px;
color: #555;
background: whiteSmoke;
}
h1 {
font-size: 64px;
font-weight: 200;
letter-spacing: -6px;
margin: .8em 0 .8em 0;
-webkit-font-smoothing: antialiased;
}
h2 {
font-size: 100%;
margin-top: 2em;
}
h1, h2 {
text-rendering: optimizeLegibility;
}
h2 a {
color: #ccc;
left: -20px;
position: absolute;
width: 740px;
}
h3, h4, h5 {
font-size: 100%;
font-weight: 400;
margin-top: .8em;
}
h3, h4 {
text-transform: uppercase;
}
h4 {
color: #AAA;
}
footer {
font-size: small;
margin-top: 8em;
}
header aside {
margin-top: 80px;
}
header aside,
footer aside {
text-align: right;
}
aside {
font-size: small;
right: 0;
position: absolute;
width: 180px;
color: #AAA;
}
.attribution {
font-size: small;
margin-bottom: 2em;
}
i, cite, em, var, address, dfn {
font-style: normal;
border-bottom: 1px solid #CCC;
}
body > p, li > p {
line-height: 1.5em;
}
body > p {
width: 600px;
}
blockquote {
border-left: 4px solid #999
}
blockquote p {
width: 500px;
font-weight: normal;
}
li {
width: 500px;
}
a {
color: steelblue;
}
a:not(:hover) {
text-decoration: none;
}
pre, code, textarea {
border: 0px solid;
font-family: "Source Code Pro", monospace;
font-size: 100%;
color: #444;
}
code {
line-height: 1em;
}</style>