markdown_to_html 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in markdown_to_html.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 bom.d.van
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,29 @@
1
+ # MarkdownToHtml
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'markdown_to_html'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install markdown_to_html
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'markdown_to_html'
4
+
5
+ MarkdownToHtml::Renderer.new(ARGV[0], ARGV[1])
@@ -0,0 +1,34 @@
1
+ require "version"
2
+ require 'erb'
3
+ require 'redcarpet'
4
+ require 'pygments'
5
+
6
+ module MarkdownToHtml
7
+ class HTMLWithPygments < Redcarpet::Render::HTML
8
+ include Redcarpet::Render::SmartyPants
9
+
10
+ def block_code(code, language)
11
+ options = { :encoding => 'utf-8'}
12
+ options[:lexer] = language unless language.nil?
13
+ Pygments.highlight(code, options)
14
+ end
15
+ end
16
+
17
+ class Renderer
18
+ def initialize(markdown_file, html_file = nil)
19
+ markdown = Redcarpet::Markdown.new(HTMLWithPygments,
20
+ :fenced_code_blocks => true,
21
+ :no_intra_emphasis => true)
22
+
23
+ article = markdown.render(File.new(markdown_file).read)
24
+
25
+ html_file = "#{File.basename(markdown_file, File.extname(markdown_file))}.html" if html_file.nil?
26
+
27
+ File.open(html_file, 'w') do |html|
28
+ template = File.new(File.dirname(__FILE__) + '/markdown_to_html/template.html.erb').read
29
+
30
+ html << ERB.new(template).result(binding)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,355 @@
1
+ <html>
2
+ <head>
3
+ <style>
4
+ body {
5
+ font: 13px Helvetica, arial, freesans, clean, sans-serif;
6
+ color: #333;
7
+ font-size: 14px;
8
+ line-height: 1.6;
9
+ padding: 20px 100px 0;
10
+ }
11
+ body>*:first-child {
12
+ margin-top: 0 !important;
13
+ }
14
+ body>*:last-child {
15
+ margin-bottom: 0 !important;
16
+ }
17
+ a.absent {
18
+ color: #c00;
19
+ }
20
+ a.anchor {
21
+ display: block;
22
+ padding-left: 30px;
23
+ margin-left: -30px;
24
+ cursor: pointer;
25
+ position: absolute;
26
+ top: 0;
27
+ left: 0;
28
+ bottom: 0;
29
+ }
30
+ h1, h2, h3, h4, h5, h6 {
31
+ margin: 20px 0 10px;
32
+ padding: 0;
33
+ font-weight: bold;
34
+ -webkit-font-smoothing: antialiased;
35
+ cursor: text;
36
+ position: relative;
37
+ }
38
+ h1 .mini-icon-link, h2 .mini-icon-link, h3 .mini-icon-link, h4 .mini-icon-link, h5 .mini-icon-link, h6 .mini-icon-link {
39
+ display: none;
40
+ color: #000;
41
+ }
42
+ h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
43
+ text-decoration: none;
44
+ line-height: 1;
45
+ padding-left: 0;
46
+ margin-left: -22px;
47
+ top: 15%;
48
+ }
49
+ h1:hover a.anchor .mini-icon-link, h2:hover a.anchor .mini-icon-link, h3:hover a.anchor .mini-icon-link, h4:hover a.anchor .mini-icon-link, h5:hover a.anchor .mini-icon-link, h6:hover a.anchor .mini-icon-link {
50
+ display: inline-block;
51
+ }
52
+ h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
53
+ font-size: inherit;
54
+ }
55
+ h1 {
56
+ font-size: 28px;
57
+ color: #000;
58
+ }
59
+ h2 {
60
+ font-size: 24px;
61
+ border-bottom: 1px solid #ccc;
62
+ color: #000;
63
+ }
64
+ h3 {
65
+ font-size: 18px;
66
+ }
67
+ h4 {
68
+ font-size: 16px;
69
+ }
70
+ h5 {
71
+ font-size: 14px;
72
+ }
73
+ h6 {
74
+ color: #777;
75
+ font-size: 14px;
76
+ }
77
+ p, blockquote, ul, ol, dl, table, pre {
78
+ margin: 15px 0;
79
+ }
80
+ hr {
81
+ background: transparent url("https://a248.e.akamai.net/assets.github.com/assets/primer/markdown/dirty-shade-0e7d81b119cc9beae17b0c98093d121fa0050a74.png") repeat-x 0 0;
82
+ border: 0 none;
83
+ color: #ccc;
84
+ height: 4px;
85
+ padding: 0;
86
+ }
87
+ body>h2:first-child,body>>h1:first-child,body>>h1:first-child+h2,body>>h3:first-child,body>>h4:first-child,body>>h5:first-child,body>>h6:first-child {
88
+ margin-top: 0;
89
+ padding-top: 0;
90
+ }
91
+ a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
92
+ margin-top: 0;
93
+ padding-top: 0;
94
+ }
95
+ h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
96
+ margin-top: 0;
97
+ }
98
+ li p.first {
99
+ display: inline-block;
100
+ }
101
+ ul, ol {
102
+ padding-left: 30px;
103
+ }
104
+ ul.no-list, ol.no-list {
105
+ list-style-type: none;
106
+ padding: 0;
107
+ }
108
+ ul li>:first-child, ul li ul:first-of-type, ul li ol:first-of-type, ol li>:first-child, ol li ul:first-of-type, ol li ol:first-of-type {
109
+ margin-top: 0px;
110
+ }
111
+ ul li p:last-of-type, ol li p:last-of-type {
112
+ margin-bottom: 0;
113
+ }
114
+ ul ul, ul ol, ol ol, ol ul {
115
+ margin-bottom: 0;
116
+ }
117
+ dl {
118
+ padding: 0;
119
+ }
120
+ dl dt {
121
+ font-size: 14px;
122
+ font-weight: bold;
123
+ font-style: italic;
124
+ padding: 0;
125
+ margin: 15px 0 5px;
126
+ }
127
+ dl dt:first-child {
128
+ padding: 0;
129
+ }
130
+ dl dt>:first-child {
131
+ margin-top: 0px;
132
+ }
133
+ dl dt>:last-child {
134
+ margin-bottom: 0px;
135
+ }
136
+ dl dd {
137
+ margin: 0 0 15px;
138
+ padding: 0 15px;
139
+ }
140
+ dl dd>:first-child {
141
+ margin-top: 0px;
142
+ }
143
+ dl dd>:last-child {
144
+ margin-bottom: 0px;
145
+ }
146
+ blockquote {
147
+ border-left: 4px solid #DDD;
148
+ padding: 0 15px;
149
+ color: #777;
150
+ }
151
+ blockquote>:first-child {
152
+ margin-top: 0px;
153
+ }
154
+ blockquote>:last-child {
155
+ margin-bottom: 0px;
156
+ }
157
+ table th {
158
+ font-weight: bold;
159
+ }
160
+ table th, table td {
161
+ border: 1px solid #ccc;
162
+ padding: 6px 13px;
163
+ }
164
+ table tr {
165
+ border-top: 1px solid #ccc;
166
+ background-color: #fff;
167
+ }
168
+ table tr:nth-child(2n) {
169
+ background-color: #f8f8f8;
170
+ }
171
+ img {
172
+ max-width: 100%;
173
+ -moz-box-sizing: border-box;
174
+ box-sizing: border-box;
175
+ }
176
+ span.frame {
177
+ display: block;
178
+ overflow: hidden;
179
+ }
180
+ span.frame>span {
181
+ border: 1px solid #ddd;
182
+ display: block;
183
+ float: left;
184
+ overflow: hidden;
185
+ margin: 13px 0 0;
186
+ padding: 7px;
187
+ width: auto;
188
+ }
189
+ span.frame span img {
190
+ display: block;
191
+ float: left;
192
+ }
193
+ span.frame span span {
194
+ clear: both;
195
+ color: #333;
196
+ display: block;
197
+ padding: 5px 0 0;
198
+ }
199
+ span.align-center {
200
+ display: block;
201
+ overflow: hidden;
202
+ clear: both;
203
+ }
204
+ span.align-center>span {
205
+ display: block;
206
+ overflow: hidden;
207
+ margin: 13px auto 0;
208
+ text-align: center;
209
+ }
210
+ span.align-center span img {
211
+ margin: 0 auto;
212
+ text-align: center;
213
+ }
214
+ span.align-right {
215
+ display: block;
216
+ overflow: hidden;
217
+ clear: both;
218
+ }
219
+ span.align-right>span {
220
+ display: block;
221
+ overflow: hidden;
222
+ margin: 13px 0 0;
223
+ text-align: right;
224
+ }
225
+ span.align-right span img {
226
+ margin: 0;
227
+ text-align: right;
228
+ }
229
+ span.float-left {
230
+ display: block;
231
+ margin-right: 13px;
232
+ overflow: hidden;
233
+ float: left;
234
+ }
235
+ span.float-left span {
236
+ margin: 13px 0 0;
237
+ }
238
+ span.float-right {
239
+ display: block;
240
+ margin-left: 13px;
241
+ overflow: hidden;
242
+ float: right;
243
+ }
244
+ span.float-right>span {
245
+ display: block;
246
+ overflow: hidden;
247
+ margin: 13px auto 0;
248
+ text-align: right;
249
+ }
250
+ code, tt {
251
+ margin: 0 2px;
252
+ padding: 0px 5px;
253
+ border: 1px solid #eaeaea;
254
+ background-color: #f8f8f8;
255
+ border-radius: 3px;
256
+ }
257
+ code {
258
+ white-space: nowrap;
259
+ }
260
+ pre>code {
261
+ margin: 0;
262
+ padding: 0;
263
+ white-space: pre;
264
+ border: none;
265
+ background: transparent;
266
+ }
267
+ .highlight pre, pre {
268
+ background-color: #f8f8f8;
269
+ border: 1px solid #ccc;
270
+ font-size: 13px;
271
+ line-height: 19px;
272
+ overflow: auto;
273
+ padding: 6px 10px;
274
+ border-radius: 3px;
275
+ }
276
+ pre code, pre tt {
277
+ margin: 0;
278
+ padding: 0;
279
+ background-color: transparent;
280
+ border: none;
281
+ }
282
+ blockquote {
283
+ border: 0 none;
284
+ padding: 0 0 0 40px;
285
+ }
286
+ .activity-tab .news blockquote {
287
+ padding-left: 0;
288
+ }
289
+ .hll { background-color: #ffffcc }
290
+ .c { color: #408080; font-style: italic } /* Comment */
291
+ .err { border: 1px solid #FF0000 } /* Error */
292
+ .k { color: #008000; font-weight: bold } /* Keyword */
293
+ .o { color: #666666 } /* Operator */
294
+ .cm { color: #408080; font-style: italic } /* Comment.Multiline */
295
+ .cp { color: #BC7A00 } /* Comment.Preproc */
296
+ .c1 { color: #408080; font-style: italic } /* Comment.Single */
297
+ .cs { color: #408080; font-style: italic } /* Comment.Special */
298
+ .gd { color: #A00000 } /* Generic.Deleted */
299
+ .ge { font-style: italic } /* Generic.Emph */
300
+ .gr { color: #FF0000 } /* Generic.Error */
301
+ .gh { color: #000080; font-weight: bold } /* Generic.Heading */
302
+ .gi { color: #00A000 } /* Generic.Inserted */
303
+ .go { color: #888888 } /* Generic.Output */
304
+ .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
305
+ .gs { font-weight: bold } /* Generic.Strong */
306
+ .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
307
+ .gt { color: #0044DD } /* Generic.Traceback */
308
+ .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
309
+ .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
310
+ .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
311
+ .kp { color: #008000 } /* Keyword.Pseudo */
312
+ .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
313
+ .kt { color: #B00040 } /* Keyword.Type */
314
+ .m { color: #666666 } /* Literal.Number */
315
+ .s { color: #BA2121 } /* Literal.String */
316
+ .na { color: #7D9029 } /* Name.Attribute */
317
+ .nb { color: #008000 } /* Name.Builtin */
318
+ .nc { color: #0000FF; font-weight: bold } /* Name.Class */
319
+ .no { color: #880000 } /* Name.Constant */
320
+ .nd { color: #AA22FF } /* Name.Decorator */
321
+ .ni { color: #999999; font-weight: bold } /* Name.Entity */
322
+ .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
323
+ .nf { color: #0000FF } /* Name.Function */
324
+ .nl { color: #A0A000 } /* Name.Label */
325
+ .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
326
+ .nt { color: #008000; font-weight: bold } /* Name.Tag */
327
+ .nv { color: #19177C } /* Name.Variable */
328
+ .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
329
+ .w { color: #bbbbbb } /* Text.Whitespace */
330
+ .mf { color: #666666 } /* Literal.Number.Float */
331
+ .mh { color: #666666 } /* Literal.Number.Hex */
332
+ .mi { color: #666666 } /* Literal.Number.Integer */
333
+ .mo { color: #666666 } /* Literal.Number.Oct */
334
+ .sb { color: #BA2121 } /* Literal.String.Backtick */
335
+ .sc { color: #BA2121 } /* Literal.String.Char */
336
+ .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
337
+ .s2 { color: #BA2121 } /* Literal.String.Double */
338
+ .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
339
+ .sh { color: #BA2121 } /* Literal.String.Heredoc */
340
+ .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
341
+ .sx { color: #008000 } /* Literal.String.Other */
342
+ .sr { color: #BB6688 } /* Literal.String.Regex */
343
+ .s1 { color: #BA2121 } /* Literal.String.Single */
344
+ .ss { color: #19177C } /* Literal.String.Symbol */
345
+ .bp { color: #008000 } /* Name.Builtin.Pseudo */
346
+ .vc { color: #19177C } /* Name.Variable.Class */
347
+ .vg { color: #19177C } /* Name.Variable.Global */
348
+ .vi { color: #19177C } /* Name.Variable.Instance */
349
+ .il { color: #666666 } /* Literal.Number.Integer.Long */
350
+ </style>
351
+ </head>
352
+ <body>
353
+ <%= article %>
354
+ </body>
355
+ </html>