mdexport 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.
- checksums.yaml +7 -0
- data/bin/mdexport +5 -0
- data/lib/mdexport.rb +203 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e36df78b607692b922e328db3ec82b7637181460
|
4
|
+
data.tar.gz: ed5bb3c4d559929aaa5b962d74c3cc639a38f932
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19d235aec22e3de6cd9b465b5b96c532667c234b726104b50a8348207ba16196305f1db82d00a45df829d55497d2e68e2b69ca577325b0c5165c9cc381549a07
|
7
|
+
data.tar.gz: 10c33facc69263312dbf0e941ad2921aa139ecc829db19475b2c7e93ba11024e04ffe17708364f9bff6aca9cde335127fdc623fcc1c70ef684b85f8391ea62e4
|
data/bin/mdexport
ADDED
data/lib/mdexport.rb
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'github/markdown'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class Mdexport
|
7
|
+
def self.run
|
8
|
+
|
9
|
+
files = []
|
10
|
+
files += Dir["*.md"]
|
11
|
+
files += Dir["*.markdown"]
|
12
|
+
|
13
|
+
if files.size == 0
|
14
|
+
puts "There is no markdown files here"
|
15
|
+
end
|
16
|
+
|
17
|
+
output_dir = "html_files"
|
18
|
+
|
19
|
+
files.each do |file|
|
20
|
+
|
21
|
+
extension = File.extname(file)
|
22
|
+
basename = File.basename(file, extension)
|
23
|
+
content = File.read file
|
24
|
+
html_body = GitHub::Markdown.render_gfm content
|
25
|
+
html_title = basename
|
26
|
+
html_filename = output_dir + "/" + basename + ".html"
|
27
|
+
|
28
|
+
html_header = <<HEADER
|
29
|
+
<!doctype html>
|
30
|
+
<html>
|
31
|
+
<head>
|
32
|
+
<meta charset="utf-8">
|
33
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
34
|
+
<style>
|
35
|
+
h1,
|
36
|
+
h2,
|
37
|
+
h3,
|
38
|
+
h4,
|
39
|
+
h5,
|
40
|
+
h6,
|
41
|
+
p,
|
42
|
+
blockquote {
|
43
|
+
margin: 0;
|
44
|
+
padding: 0;
|
45
|
+
}
|
46
|
+
body {
|
47
|
+
font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", Arial, sans-serif;
|
48
|
+
font-size: 13px;
|
49
|
+
line-height: 18px;
|
50
|
+
color: #737373;
|
51
|
+
background-color: white;
|
52
|
+
margin: 10px 13px 10px 13px;
|
53
|
+
}
|
54
|
+
table {
|
55
|
+
margin: 10px 0 15px 0;
|
56
|
+
border-collapse: collapse;
|
57
|
+
}
|
58
|
+
td,th {
|
59
|
+
border: 1px solid #ddd;
|
60
|
+
padding: 3px 10px;
|
61
|
+
}
|
62
|
+
th {
|
63
|
+
padding: 5px 10px;
|
64
|
+
}
|
65
|
+
|
66
|
+
a {
|
67
|
+
color: #0069d6;
|
68
|
+
}
|
69
|
+
a:hover {
|
70
|
+
color: #0050a3;
|
71
|
+
text-decoration: none;
|
72
|
+
}
|
73
|
+
a img {
|
74
|
+
border: none;
|
75
|
+
}
|
76
|
+
p {
|
77
|
+
margin-bottom: 9px;
|
78
|
+
}
|
79
|
+
h1,
|
80
|
+
h2,
|
81
|
+
h3,
|
82
|
+
h4,
|
83
|
+
h5,
|
84
|
+
h6 {
|
85
|
+
color: #404040;
|
86
|
+
line-height: 36px;
|
87
|
+
}
|
88
|
+
h1 {
|
89
|
+
margin-bottom: 18px;
|
90
|
+
font-size: 30px;
|
91
|
+
}
|
92
|
+
h2 {
|
93
|
+
font-size: 24px;
|
94
|
+
}
|
95
|
+
h3 {
|
96
|
+
font-size: 18px;
|
97
|
+
}
|
98
|
+
h4 {
|
99
|
+
font-size: 16px;
|
100
|
+
}
|
101
|
+
h5 {
|
102
|
+
font-size: 14px;
|
103
|
+
}
|
104
|
+
h6 {
|
105
|
+
font-size: 13px;
|
106
|
+
}
|
107
|
+
hr {
|
108
|
+
margin: 0 0 19px;
|
109
|
+
border: 0;
|
110
|
+
border-bottom: 1px solid #ccc;
|
111
|
+
}
|
112
|
+
blockquote {
|
113
|
+
padding: 13px 13px 21px 15px;
|
114
|
+
margin-bottom: 18px;
|
115
|
+
font-family:georgia,serif;
|
116
|
+
font-style: italic;
|
117
|
+
}
|
118
|
+
blockquote:before {
|
119
|
+
content:"\201C";
|
120
|
+
font-size:40px;
|
121
|
+
margin-left:-10px;
|
122
|
+
font-family:georgia,serif;
|
123
|
+
color:#eee;
|
124
|
+
}
|
125
|
+
blockquote p {
|
126
|
+
font-size: 14px;
|
127
|
+
font-weight: 300;
|
128
|
+
line-height: 18px;
|
129
|
+
margin-bottom: 0;
|
130
|
+
font-style: italic;
|
131
|
+
}
|
132
|
+
code, pre {
|
133
|
+
font-family: Monaco, Andale Mono, Courier New, monospace;
|
134
|
+
}
|
135
|
+
code {
|
136
|
+
background-color: #fee9cc;
|
137
|
+
color: rgba(0, 0, 0, 0.75);
|
138
|
+
padding: 1px 3px;
|
139
|
+
font-size: 12px;
|
140
|
+
-webkit-border-radius: 3px;
|
141
|
+
-moz-border-radius: 3px;
|
142
|
+
border-radius: 3px;
|
143
|
+
}
|
144
|
+
pre {
|
145
|
+
display: block;
|
146
|
+
padding: 14px;
|
147
|
+
margin: 0 0 18px;
|
148
|
+
line-height: 16px;
|
149
|
+
font-size: 11px;
|
150
|
+
border: 1px solid #d9d9d9;
|
151
|
+
white-space: pre-wrap;
|
152
|
+
word-wrap: break-word;
|
153
|
+
}
|
154
|
+
pre code {
|
155
|
+
background-color: #fff;
|
156
|
+
color:#737373;
|
157
|
+
font-size: 11px;
|
158
|
+
padding: 0;
|
159
|
+
}
|
160
|
+
sup {
|
161
|
+
font-size: 0.83em;
|
162
|
+
vertical-align: super;
|
163
|
+
line-height: 0;
|
164
|
+
}
|
165
|
+
* {
|
166
|
+
-webkit-print-color-adjust: exact;
|
167
|
+
}
|
168
|
+
@media screen and (min-width: 914px) {
|
169
|
+
body {
|
170
|
+
width: 854px;
|
171
|
+
margin:10px auto;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
@media print {
|
175
|
+
body,code,pre code,h1,h2,h3,h4,h5,h6 {
|
176
|
+
color: black;
|
177
|
+
}
|
178
|
+
table, pre {
|
179
|
+
page-break-inside: avoid;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
</style>
|
183
|
+
<title>#{html_title}</title>
|
184
|
+
|
185
|
+
</head>
|
186
|
+
<body>
|
187
|
+
HEADER
|
188
|
+
|
189
|
+
html_footer = <<FOOTER
|
190
|
+
</body>
|
191
|
+
</html>
|
192
|
+
FOOTER
|
193
|
+
|
194
|
+
html_content = html_header + html_body + html_footer
|
195
|
+
FileUtils.mkdir(output_dir) unless File.exist?(output_dir)
|
196
|
+
FileUtils.rm(html_filename) if File.exist?(html_filename)
|
197
|
+
File.write(html_filename, html_content)
|
198
|
+
|
199
|
+
end # end files.each
|
200
|
+
|
201
|
+
end # end def
|
202
|
+
|
203
|
+
end # end class
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mdexport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Madson Cardoso
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple gem that exports all markdown files from current folder to html
|
14
|
+
files.
|
15
|
+
email: madsonmac@gmail.com
|
16
|
+
executables:
|
17
|
+
- mdexport
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/mdexport.rb
|
22
|
+
- bin/mdexport
|
23
|
+
homepage: http://github.com/madson/mdexport
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.0.14
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: mdexport is a gem that exports markdown files into html files.
|
47
|
+
test_files: []
|