octodown 0.0.1alpha1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ sudo: true
3
+ before_install:
4
+ - gem update --system
5
+ - sudo apt-get install -y libicu-dev build-essential
6
+ install: 'bundle install'
7
+ script: 'bundle exec rspec --format documentation'
8
+ rvm:
9
+ - '2.1.4'
10
+ - '2.0.0'
11
+ - '1.9.3'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in octodown.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ian Ker-Seymer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ :octocat: octodown
2
+ ==================
3
+ [![Build Status](https://travis-ci.org/ianks/octodown.svg)](https://travis-ci.org/ianks/octodown)
4
+
5
+ Ever wanted to easily preview what you markdown would look like *exactly* on
6
+ Github? Ever wanted to do that from inside of a Terminal? Well this Gem is for
7
+ you. Dead simple. Never get caught writing ugly markdown again.
8
+
9
+ ## Features:
10
+
11
+ * Uses the same markdown parsers and CSS as Github for true duplication.
12
+ - Yes emojis *are* included :clap:
13
+ * Fast. `octodown` uses native parsers to ensure performance.
14
+ * Multiple CSS styles. Choose from either:
15
+ - `$ octodown --style atom README.md`
16
+ - The `github.com` markdown (default)
17
+ - The `Atom` text editor markdown
18
+ * Properly parses `STDIN`
19
+ - `$ cat README.md | octodown`
20
+
21
+ ## Installation
22
+
23
+ 1. Install `icu4u` and `cmake`:
24
+ * Mac: `$ brew install icu4u cmake`
25
+ * Apt: `$ sudo apt-get install -y libicu-dev cmake`
26
+ 2. If you have a non-system Ruby (*highly recommended*):
27
+ * `$ gem install octodown`
28
+ 3. Else:
29
+ * `$ sudo gem install octodown --no-ri --no-rdoc`
30
+
31
+ ## Usage
32
+
33
+ $ octodown README.md
34
+
35
+ ## Notes
36
+
37
+ 1. With no arguments given, octodown will read STDIN until EOF is reached. In
38
+ order to work with this mode, type what you want into the input, then press
39
+ `Ctrl-D` when finished.
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/[my-github-username]/octodown/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,43 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'open-uri'
3
+ require 'fileutils'
4
+ require 'tempfile'
5
+
6
+ task :styles do
7
+ begin
8
+ FileUtils.mkdir 'tmp'
9
+ download_deps
10
+ compile_less
11
+ ensure
12
+ FileUtils.remove_dir 'tmp'
13
+ end
14
+ end
15
+
16
+ def download_deps
17
+ host = 'https://raw.githubusercontent.com/atom/'
18
+
19
+ deps = {
20
+ 'markdown-preview' => 'markdown-preview/master/stylesheets/markdown-preview.less',
21
+ 'syntax-variables' => 'template-syntax/master/stylesheets/syntax-variables.less',
22
+ 'colors' => 'template-syntax/master/stylesheets/colors.less'
23
+ }
24
+
25
+ deps.each do |k,v|
26
+ File.open("tmp/#{k}.less", 'w') do |out_file|
27
+ open(host + v, 'r') do |in_file|
28
+ out_file << in_file.read
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ def compile_less
35
+ tmp = 'tmp/github.css'
36
+ out_file = 'assets/markdown-preview.css'
37
+ `lessc tmp/markdown-preview.less #{tmp}`
38
+
39
+ File.open out_file, 'w' do |file|
40
+ css = File.read(tmp).gsub /markdown-preview/, 'markdown-body'
41
+ file << css
42
+ end
43
+ end
data/assets/atom.css ADDED
@@ -0,0 +1,396 @@
1
+ .markdown-body {
2
+ font-family: "Helvetica Neue", Helvetica, sans-serif;
3
+ font-size: 14px;
4
+ line-height: 1.6;
5
+ background-color: #fff;
6
+ overflow: scroll;
7
+ box-sizing: border-box;
8
+ padding: 20px;
9
+ }
10
+ .markdown-body code {
11
+ color: #333;
12
+ }
13
+ .markdown-spinner {
14
+ margin: auto;
15
+ background-image: url(images/octocat-spinner-128.gif);
16
+ background-repeat: no-repeat;
17
+ background-size: 64px;
18
+ background-position: top center;
19
+ padding-top: 70px;
20
+ text-align: center;
21
+ }
22
+ .markdown-body pre,
23
+ .markdown-body code,
24
+ .markdown-body tt {
25
+ font-size: 12px;
26
+ font-family: Consolas, "Liberation Mono", Courier, monospace;
27
+ }
28
+ .markdown-body a,
29
+ .markdown-body a code {
30
+ color: #4183c4;
31
+ }
32
+ .markdown-body ol > li {
33
+ list-style-type: decimal;
34
+ }
35
+ .markdown-body ul > li {
36
+ list-style-type: disc;
37
+ }
38
+ .markdown-body > *:first-child {
39
+ margin-top: 0 !important;
40
+ }
41
+ .markdown-body > *:last-child {
42
+ margin-bottom: 0 !important;
43
+ }
44
+ .markdown-body a.absent {
45
+ color: #c00;
46
+ }
47
+ .markdown-body a.anchor {
48
+ display: block;
49
+ padding-left: 30px;
50
+ margin-left: -30px;
51
+ cursor: pointer;
52
+ position: absolute;
53
+ top: 0;
54
+ left: 0;
55
+ bottom: 0;
56
+ }
57
+ .markdown-body h1,
58
+ .markdown-body h2,
59
+ .markdown-body h3,
60
+ .markdown-body h4,
61
+ .markdown-body h5,
62
+ .markdown-body h6 {
63
+ font-family: "Helvetica Neue", Helvetica, sans-serif;
64
+ margin: 20px 0 10px;
65
+ padding: 0 0 10px 0;
66
+ font-weight: bold;
67
+ -webkit-font-smoothing: antialiased;
68
+ cursor: text;
69
+ position: relative;
70
+ }
71
+ .markdown-body h1 .octicon-link,
72
+ .markdown-body h2 .octicon-link,
73
+ .markdown-body h3 .octicon-link,
74
+ .markdown-body h4 .octicon-link,
75
+ .markdown-body h5 .octicon-link,
76
+ .markdown-body h6 .octicon-link {
77
+ display: none;
78
+ color: #000;
79
+ }
80
+ .markdown-body h1:hover a.anchor,
81
+ .markdown-body h2:hover a.anchor,
82
+ .markdown-body h3:hover a.anchor,
83
+ .markdown-body h4:hover a.anchor,
84
+ .markdown-body h5:hover a.anchor,
85
+ .markdown-body h6:hover a.anchor {
86
+ text-decoration: none;
87
+ line-height: 1;
88
+ padding-left: 0;
89
+ margin-left: -22px;
90
+ top: 15%;
91
+ }
92
+ .markdown-body h1:hover a.anchor .octicon-link,
93
+ .markdown-body h2:hover a.anchor .octicon-link,
94
+ .markdown-body h3:hover a.anchor .octicon-link,
95
+ .markdown-body h4:hover a.anchor .octicon-link,
96
+ .markdown-body h5:hover a.anchor .octicon-link,
97
+ .markdown-body h6:hover a.anchor .octicon-link {
98
+ display: inline-block;
99
+ }
100
+ .markdown-body h1 tt,
101
+ .markdown-body h2 tt,
102
+ .markdown-body h3 tt,
103
+ .markdown-body h4 tt,
104
+ .markdown-body h5 tt,
105
+ .markdown-body h6 tt,
106
+ .markdown-body h1 code,
107
+ .markdown-body h2 code,
108
+ .markdown-body h3 code,
109
+ .markdown-body h4 code,
110
+ .markdown-body h5 code,
111
+ .markdown-body h6 code {
112
+ font-size: inherit;
113
+ }
114
+ .markdown-body h1 {
115
+ font-size: 28px;
116
+ border-bottom: 1px solid #ddd;
117
+ color: #000;
118
+ }
119
+ .markdown-body h2 {
120
+ font-size: 24px;
121
+ border-bottom: 1px solid #eee;
122
+ color: #000;
123
+ }
124
+ .markdown-body h3 {
125
+ font-size: 18px;
126
+ }
127
+ .markdown-body h4 {
128
+ font-size: 16px;
129
+ }
130
+ .markdown-body h5 {
131
+ font-size: 14px;
132
+ }
133
+ .markdown-body h6 {
134
+ color: #777;
135
+ font-size: 14px;
136
+ }
137
+ .markdown-body p,
138
+ .markdown-body blockquote,
139
+ .markdown-body ul,
140
+ .markdown-body ol,
141
+ .markdown-body dl,
142
+ .markdown-body table,
143
+ .markdown-body pre {
144
+ margin: 15px 0;
145
+ }
146
+ .markdown-body hr {
147
+ background: transparent url("atom://markdown-body/assets/hr.png") repeat-x 0 0;
148
+ border: 0 none;
149
+ color: #ccc;
150
+ height: 4px;
151
+ padding: 0;
152
+ margin: 15px 0;
153
+ }
154
+ .markdown-body > h2:first-child,
155
+ .markdown-body > h1:first-child,
156
+ .markdown-body > h1:first-child + h2,
157
+ .markdown-body > h3:first-child,
158
+ .markdown-body > h4:first-child,
159
+ .markdown-body > h5:first-child,
160
+ .markdown-body > h6:first-child {
161
+ margin-top: 0;
162
+ padding-top: 0;
163
+ }
164
+ .markdown-body a:first-child h1,
165
+ .markdown-body a:first-child h2,
166
+ .markdown-body a:first-child h3,
167
+ .markdown-body a:first-child h4,
168
+ .markdown-body a:first-child h5,
169
+ .markdown-body a:first-child h6 {
170
+ margin-top: 0;
171
+ padding-top: 0;
172
+ }
173
+ .markdown-body h1 + p,
174
+ .markdown-body h2 + p,
175
+ .markdown-body h3 + p,
176
+ .markdown-body h4 + p,
177
+ .markdown-body h5 + p,
178
+ .markdown-body h6 + p {
179
+ margin-top: 0;
180
+ }
181
+ .markdown-body li p.first {
182
+ display: inline-block;
183
+ }
184
+ .markdown-body ul,
185
+ .markdown-body ol {
186
+ padding-left: 30px;
187
+ }
188
+ .markdown-body ul.no-list,
189
+ .markdown-body ol.no-list {
190
+ list-style-type: none;
191
+ padding: 0;
192
+ }
193
+ .markdown-body ul li > :first-child,
194
+ .markdown-body ol li > :first-child,
195
+ .markdown-body ul li ul:first-of-type,
196
+ .markdown-body ol li ul:first-of-type {
197
+ margin-top: 0;
198
+ }
199
+ .markdown-body ul ul,
200
+ .markdown-body ul ol,
201
+ .markdown-body ol ol,
202
+ .markdown-body ol ul {
203
+ margin-bottom: 0;
204
+ }
205
+ .markdown-body dl {
206
+ padding: 0;
207
+ }
208
+ .markdown-body dl dt {
209
+ font-size: 14px;
210
+ font-weight: bold;
211
+ font-style: italic;
212
+ padding: 0;
213
+ margin: 15px 0 5px;
214
+ }
215
+ .markdown-body dl dt:first-child {
216
+ padding: 0;
217
+ }
218
+ .markdown-body dl dt > :first-child {
219
+ margin-top: 0;
220
+ }
221
+ .markdown-body dl dt > :last-child {
222
+ margin-bottom: 0;
223
+ }
224
+ .markdown-body dl dd {
225
+ margin: 0 0 15px;
226
+ padding: 0 15px;
227
+ }
228
+ .markdown-body dl dd > :first-child {
229
+ margin-top: 0;
230
+ }
231
+ .markdown-body dl dd > :last-child {
232
+ margin-bottom: 0;
233
+ }
234
+ .markdown-body blockquote {
235
+ border-left: 4px solid #DDD;
236
+ padding: 0 15px;
237
+ color: #777;
238
+ }
239
+ .markdown-body blockquote > :first-child {
240
+ margin-top: 0;
241
+ }
242
+ .markdown-body blockquote > :last-child {
243
+ margin-bottom: 0;
244
+ }
245
+ .markdown-body blockquote p {
246
+ font-size: 16px;
247
+ line-height: 1.5;
248
+ }
249
+ .markdown-body table th {
250
+ font-weight: bold;
251
+ }
252
+ .markdown-body table th,
253
+ .markdown-body table td {
254
+ border: 1px solid #ccc;
255
+ padding: 6px 13px;
256
+ }
257
+ .markdown-body table tr {
258
+ border-top: 1px solid #ccc;
259
+ background-color: #fff;
260
+ }
261
+ .markdown-body table tr:nth-child(2n) {
262
+ background-color: #f8f8f8;
263
+ }
264
+ .markdown-body img {
265
+ max-width: 100%;
266
+ }
267
+ .markdown-body span.frame {
268
+ display: block;
269
+ overflow: hidden;
270
+ }
271
+ .markdown-body span.frame > span {
272
+ border: 1px solid #ddd;
273
+ display: block;
274
+ float: left;
275
+ overflow: hidden;
276
+ margin: 13px 0 0;
277
+ padding: 7px;
278
+ width: auto;
279
+ }
280
+ .markdown-body span.frame span img {
281
+ display: block;
282
+ float: left;
283
+ }
284
+ .markdown-body span.frame span span {
285
+ clear: both;
286
+ color: #333;
287
+ display: block;
288
+ padding: 5px 0 0;
289
+ }
290
+ .markdown-body span.align-center {
291
+ display: block;
292
+ overflow: hidden;
293
+ clear: both;
294
+ }
295
+ .markdown-body span.align-center > span {
296
+ display: block;
297
+ overflow: hidden;
298
+ margin: 13px auto 0;
299
+ text-align: center;
300
+ }
301
+ .markdown-body span.align-center span img {
302
+ margin: 0 auto;
303
+ text-align: center;
304
+ }
305
+ .markdown-body span.align-right {
306
+ display: block;
307
+ overflow: hidden;
308
+ clear: both;
309
+ }
310
+ .markdown-body span.align-right > span {
311
+ display: block;
312
+ overflow: hidden;
313
+ margin: 13px 0 0;
314
+ text-align: right;
315
+ }
316
+ .markdown-body span.align-right span img {
317
+ margin: 0;
318
+ text-align: right;
319
+ }
320
+ .markdown-body span.float-left {
321
+ display: block;
322
+ margin-right: 13px;
323
+ overflow: hidden;
324
+ float: left;
325
+ }
326
+ .markdown-body span.float-left span {
327
+ margin: 13px 0 0;
328
+ }
329
+ .markdown-body span.float-right {
330
+ display: block;
331
+ margin-left: 13px;
332
+ overflow: hidden;
333
+ float: right;
334
+ }
335
+ .markdown-body span.float-right > span {
336
+ display: block;
337
+ overflow: hidden;
338
+ margin: 13px auto 0;
339
+ text-align: right;
340
+ }
341
+ .markdown-body code,
342
+ .markdown-body tt {
343
+ margin: 0 2px;
344
+ padding: 0 5px;
345
+ border: 1px solid #eaeaea;
346
+ background-color: #f8f8f8;
347
+ border-radius: 3px;
348
+ text-shadow: none;
349
+ }
350
+ .markdown-body code {
351
+ white-space: nowrap;
352
+ }
353
+ .markdown-body pre > code {
354
+ margin: 0;
355
+ padding: 0;
356
+ white-space: pre;
357
+ border: none;
358
+ background: transparent;
359
+ word-wrap: normal;
360
+ }
361
+ .markdown-body pre {
362
+ background: #f8f8f8;
363
+ border: 1px solid #ccc;
364
+ font-size: 13px;
365
+ line-height: 19px;
366
+ overflow: auto;
367
+ padding: 6px 10px;
368
+ border-radius: 3px;
369
+ }
370
+ .markdown-body pre.editor-colors {
371
+ background: #1d1f21;
372
+ border: 1px solid #050606;
373
+ }
374
+ .markdown-body pre code,
375
+ .markdown-body pre tt {
376
+ margin: 0;
377
+ padding: 0;
378
+ background-color: transparent;
379
+ border: none;
380
+ }
381
+ .markdown-body kbd {
382
+ background-color: #dddddd;
383
+ background-image: linear-gradient(#f1f1f1, #dddddd);
384
+ background-repeat: repeat-x;
385
+ border-radius: 2px;
386
+ border: 1px solid #ddd;
387
+ border-bottom-color: #ccc;
388
+ border-right-color: #ccc;
389
+ padding: 1px 4px;
390
+ line-height: 10px;
391
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
392
+ }
393
+ .markdown-body .emoji {
394
+ height: 20px;
395
+ width: 20px;
396
+ }