bookshelf 1.2.1 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,36 +2,9 @@ module Bookshelf
2
2
  module Parser
3
3
  class PDF < Base
4
4
  def parse
5
- apply_footnotes!
6
- spawn_command ["prince", with_footnotes_file.to_s, "-o", pdf_file.to_s]
5
+ spawn_command ["prince", html_file.to_s, "-o", pdf_file.to_s]
7
6
  end
8
-
9
- def apply_footnotes!
10
- html = Nokogiri::HTML(html_file.read)
11
-
12
- # https://github.com/sparklemotion/nokogiri/issues/339
13
- html.css("html").first.tap do |element|
14
- next unless element
15
- element.delete("xmlns")
16
- element.delete("xml:lang")
17
- end
18
-
19
- html.css("p.footnote[id^='_fn']").each do |fn|
20
- fn.node_name = "span"
21
- fn.set_attribute("class", "fn")
22
-
23
- html.css("[href='##{fn["id"]}']").each do |link|
24
- link.add_next_sibling(fn)
25
- end
26
- end
27
-
28
- File.open(with_footnotes_file, "w") {|f| f << html.to_xhtml}
29
- end
30
-
31
- def with_footnotes_file
32
- Bookshelf.root_dir.join("output/#{name}.pdf.html")
33
- end
34
-
7
+
35
8
  def html_file
36
9
  Bookshelf.root_dir.join("output/#{name}.html")
37
10
  end
@@ -26,18 +26,10 @@ module Bookshelf
26
26
  @images ||= html.css("img").size
27
27
  end
28
28
 
29
- def footnotes
30
- @footnotes ||= html.css("p.footnote").size
31
- end
32
-
33
29
  def links
34
30
  @links ||= html.css("[href^='http']").size
35
31
  end
36
32
 
37
- def code_blocks
38
- @code_blocks ||= html.css("pre").size
39
- end
40
-
41
33
  def content
42
34
  @content ||= Parser::HTML.new(root_dir).content
43
35
  end
@@ -2,7 +2,7 @@ module Bookshelf
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 2
5
- PATCH = 1
5
+ PATCH = 4
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
@@ -2,13 +2,15 @@
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= language %>">
4
4
  <head>
5
+ <link rel="stylesheet" type="text/css" href="styles/epub.css"/>
6
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
5
7
  <title><%= title %></title>
6
- <link rel="stylesheet" href="styles/epub.css" type="text/css" />
7
- <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
8
8
  </head>
9
9
  <body>
10
- <div>
11
- <h1><%= title %></h1>
10
+ <div id="cover">
11
+ <h1><%= title %></h1>
12
+ <p class="subject"><%= subject %></p>
13
+ <p class="authors"><%= authors.to_sentence %></p>
12
14
  </div>
13
15
  </body>
14
16
  </html>
@@ -2,9 +2,9 @@
2
2
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= language %>">
4
4
  <head>
5
- <title></title>
5
+ <link rel="stylesheet" type="text/css" href="styles/epub.css"/>
6
6
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
7
- <link rel="stylesheet" type="text/css" href="assets/styles/epub.css"/>
7
+ <title></title>
8
8
  </head>
9
9
  <body>
10
10
  <div class="chapter">
@@ -1,29 +0,0 @@
1
- # Put any Ruby code in here.
2
- # Here's an example on how you can extend RedCloth (Textile) with new formatters.
3
- #
4
- # module RedCloth
5
- # module Formatters
6
- # module HTML
7
- # def attention(options)
8
- # %[<p class="attention">#{options[:text]}</p>]
9
- # end
10
- # end
11
- # end
12
- # end
13
- #
14
- # Then you can just use `attention. This is an important note!` on your text.
15
- #
16
- # You can add inline formatters as well. The approach is slightly different,
17
- # but pretty straightforward.
18
- #
19
- # Add your formatter to `RedCloth::INLINE_FORMATTERS` and implement the method, making sure that it
20
- # replaces the content using `String#gsub!`.
21
- #
22
- # module RedCloth
23
- # def my_formatter(text)
24
- # text.gsub!(/Hello/, "Hi")
25
- # end
26
- # end
27
- #
28
- # RedCloth::INLINE_FORMATTERS << :my_formatter
29
- #
@@ -1,26 +1,23 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
2
  <html>
4
3
  <head>
5
- <title><%= title %></title>
6
4
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
7
- <link rel="stylesheet" type="text/css" href="assets/styles/html.css"/>
8
5
  <meta name="author" content="<%= authors.join(', ') %>" />
9
6
  <meta name="subject" content="<%= subject %>" />
10
7
  <meta name="keywords" content="<%= keywords %>" />
11
8
  <meta name="date" content="<%= published_at %>" />
9
+ <link rel="stylesheet" type="text/css" href="assets/styles/html.css"/>
10
+ <title><%= title %></title>
12
11
  </head>
13
12
  <body>
14
- <div class="frontcover container">
15
- <div>
16
- <h1><%= title %></h1>
17
- <p class="description"><%= subject %></p>
18
- <p class="authors"><%= authors.to_sentence %></p>
19
- </div>
13
+ <div class="frontcover">
14
+ <h1><%= title %></h1>
15
+ <p class="subject"><%= subject %></p>
16
+ <p class="authors"><%= authors.to_sentence %></p>
20
17
  </div>
21
18
 
22
19
  <div class="table-of-contents">
23
- <h2 class="no-toc">Content</h2>
20
+ <h2>Content</h2>
24
21
  <div id="toc">
25
22
  <%= toc %>
26
23
  </div>
@@ -30,12 +27,7 @@
30
27
  <%= content %>
31
28
  </div>
32
29
 
33
- <div class="imprint container">
34
- <div>
35
- <h2><%= title %></h2>
36
- <p><%= authors.to_sentence %></p>
37
- <p><%= copyright %></p>
38
- </div>
30
+ <div class="imprint">
39
31
  </div>
40
32
  </body>
41
33
  </html>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= language %>">
4
+ <head>
5
+ <link rel="stylesheet" type="text/css" href="styles/epub.css"/>
6
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
7
+ <title>Table of Contents</title>
8
+ </head>
9
+ <body>
10
+ <div id="toc">
11
+ <ul>
12
+ <% toc.each do |toc| %>
13
+ <li>
14
+ <a href="<%= toc[1] %>"><%= toc[0] %></a>
15
+ </li>
16
+ <% end %>
17
+ </ul>
18
+ </div>
19
+ </body>
20
+ </html>
metadata CHANGED
@@ -1,214 +1,221 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bookshelf
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 2
8
- - 1
9
- version: 1.2.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.4
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Brad Crawford
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2013-05-25 00:00:00 +12:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: activesupport
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
25
17
  - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
30
20
  type: :runtime
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
33
- name: nokogiri
34
21
  prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
37
31
  - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
42
34
  type: :runtime
43
- version_requirements: *id002
44
- - !ruby/object:Gem::Dependency
45
- name: RedCloth
46
35
  prerelease: false
47
- requirement: &id003 !ruby/object:Gem::Requirement
48
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
49
38
  - - ">="
50
- - !ruby/object:Gem::Version
51
- segments:
52
- - 0
53
- version: "0"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: maruku
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
54
48
  type: :runtime
55
- version_requirements: *id003
56
- - !ruby/object:Gem::Dependency
57
- name: rdiscount
58
49
  prerelease: false
59
- requirement: &id004 !ruby/object:Gem::Requirement
60
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
61
52
  - - ">="
62
- - !ruby/object:Gem::Version
63
- segments:
64
- - 0
65
- version: "0"
66
- type: :runtime
67
- version_requirements: *id004
68
- - !ruby/object:Gem::Dependency
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
69
56
  name: i18n
70
- prerelease: false
71
- requirement: &id005 !ruby/object:Gem::Requirement
72
- requirements:
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
73
59
  - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
- version: "0"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
78
62
  type: :runtime
79
- version_requirements: *id005
80
- - !ruby/object:Gem::Dependency
81
- name: thor
82
63
  prerelease: false
83
- requirement: &id006 !ruby/object:Gem::Requirement
84
- requirements:
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
85
66
  - - ">="
86
- - !ruby/object:Gem::Version
87
- segments:
88
- - 0
89
- version: "0"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
90
76
  type: :runtime
91
- version_requirements: *id006
92
- - !ruby/object:Gem::Dependency
93
- name: eeepub-with-cover-support
94
77
  prerelease: false
95
- requirement: &id007 !ruby/object:Gem::Requirement
96
- requirements:
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
97
80
  - - ">="
98
- - !ruby/object:Gem::Version
99
- segments:
100
- - 0
101
- version: "0"
102
- type: :runtime
103
- version_requirements: *id007
104
- - !ruby/object:Gem::Dependency
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
105
84
  name: notifier
106
- prerelease: false
107
- requirement: &id008 !ruby/object:Gem::Requirement
108
- requirements:
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
109
87
  - - ">="
110
- - !ruby/object:Gem::Version
111
- segments:
112
- - 0
113
- version: "0"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
114
90
  type: :runtime
115
- version_requirements: *id008
116
- - !ruby/object:Gem::Dependency
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
117
98
  name: sass
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
118
105
  prerelease: false
119
- requirement: &id009 !ruby/object:Gem::Requirement
120
- requirements:
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
121
108
  - - ">="
122
- - !ruby/object:Gem::Version
123
- segments:
124
- - 0
125
- version: "0"
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubyzip
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
126
118
  type: :runtime
127
- version_requirements: *id009
128
- - !ruby/object:Gem::Dependency
129
- name: rspec
130
119
  prerelease: false
131
- requirement: &id010 !ruby/object:Gem::Requirement
132
- requirements:
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
133
122
  - - ">="
134
- - !ruby/object:Gem::Version
135
- segments:
136
- - 0
137
- version: "0"
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
138
132
  type: :development
139
- version_requirements: *id010
140
- - !ruby/object:Gem::Dependency
141
- name: test_notifier
142
133
  prerelease: false
143
- requirement: &id011 !ruby/object:Gem::Requirement
144
- requirements:
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: test_notifier
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
145
143
  - - ">="
146
- - !ruby/object:Gem::Version
147
- segments:
148
- - 0
149
- version: "0"
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
150
146
  type: :development
151
- version_requirements: *id011
152
- - !ruby/object:Gem::Dependency
153
- name: rake
154
147
  prerelease: false
155
- requirement: &id012 !ruby/object:Gem::Requirement
156
- requirements:
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rake
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
157
  - - ">="
158
- - !ruby/object:Gem::Version
159
- segments:
160
- - 0
161
- version: "0"
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
162
160
  type: :development
163
- version_requirements: *id012
164
- - !ruby/object:Gem::Dependency
165
- name: pry
166
161
  prerelease: false
167
- requirement: &id013 !ruby/object:Gem::Requirement
168
- requirements:
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
169
164
  - - ">="
170
- - !ruby/object:Gem::Version
171
- segments:
172
- - 0
173
- version: "0"
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
174
  type: :development
175
- version_requirements: *id013
176
- - !ruby/object:Gem::Dependency
177
- name: pry-nav
178
175
  prerelease: false
179
- requirement: &id014 !ruby/object:Gem::Requirement
180
- requirements:
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
181
178
  - - ">="
182
- - !ruby/object:Gem::Version
183
- segments:
184
- - 0
185
- version: "0"
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: pry-nav
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
186
188
  type: :development
187
- version_requirements: *id014
188
- - !ruby/object:Gem::Dependency
189
- name: awesome_print
190
189
  prerelease: false
191
- requirement: &id015 !ruby/object:Gem::Requirement
192
- requirements:
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
193
192
  - - ">="
194
- - !ruby/object:Gem::Version
195
- segments:
196
- - 0
197
- version: "0"
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: awesome_print
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
198
202
  type: :development
199
- version_requirements: *id015
200
- description: A framework that generates PDF and e-Pub from Markdown, Textile, and HTML files.
201
- email:
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description: A framework that generates PDF and e-Pub from Markdown, and HTML files.
210
+ email:
202
211
  - brad.robert.crawford@gmail.com
203
- executables:
212
+ executables:
204
213
  - bookshelf
205
214
  extensions: []
206
-
207
215
  extra_rdoc_files: []
208
-
209
- files:
210
- - .gitignore
211
- - .gitmodules
216
+ files:
217
+ - ".gitignore"
218
+ - ".gitmodules"
212
219
  - Gemfile
213
220
  - Gemfile.lock
214
221
  - README.md
@@ -219,23 +226,13 @@ files:
219
226
  - lib/bookshelf/adapters/markdown.rb
220
227
  - lib/bookshelf/cli.rb
221
228
  - lib/bookshelf/dependency.rb
222
- - lib/bookshelf/errors.rb
223
229
  - lib/bookshelf/exporter.rb
224
- - lib/bookshelf/extensions/redcloth.rb
225
- - lib/bookshelf/extensions/string.rb
226
230
  - lib/bookshelf/generator.rb
227
231
  - lib/bookshelf/parser.rb
228
232
  - lib/bookshelf/parser/epub.rb
229
233
  - lib/bookshelf/parser/html.rb
230
- - lib/bookshelf/parser/mobi.rb
231
234
  - lib/bookshelf/parser/pdf.rb
232
- - lib/bookshelf/parser/txt.rb
233
235
  - lib/bookshelf/stats.rb
234
- - lib/bookshelf/stream.rb
235
- - lib/bookshelf/syntax.rb
236
- - lib/bookshelf/toc.rb
237
- - lib/bookshelf/toc/epub.rb
238
- - lib/bookshelf/toc/html.rb
239
236
  - lib/bookshelf/version.rb
240
237
  - templates/Gemfile
241
238
  - templates/README.md
@@ -247,36 +244,29 @@ files:
247
244
  - templates/helper.rb
248
245
  - templates/html.scss
249
246
  - templates/layout.erb
250
- has_rdoc: true
247
+ - templates/toc.erb
251
248
  homepage: https://bitbucket.org/bradcrawford/bookshelf
252
- licenses:
249
+ licenses:
253
250
  - MIT
251
+ metadata: {}
254
252
  post_install_message:
255
253
  rdoc_options: []
256
-
257
- require_paths:
254
+ require_paths:
258
255
  - lib
259
- required_ruby_version: !ruby/object:Gem::Requirement
260
- requirements:
256
+ required_ruby_version: !ruby/object:Gem::Requirement
257
+ requirements:
261
258
  - - ">="
262
- - !ruby/object:Gem::Version
263
- segments:
264
- - 1
265
- - 9
266
- version: "1.9"
267
- required_rubygems_version: !ruby/object:Gem::Requirement
268
- requirements:
259
+ - !ruby/object:Gem::Version
260
+ version: '1.9'
261
+ required_rubygems_version: !ruby/object:Gem::Requirement
262
+ requirements:
269
263
  - - ">="
270
- - !ruby/object:Gem::Version
271
- segments:
272
- - 0
273
- version: "0"
264
+ - !ruby/object:Gem::Version
265
+ version: '0'
274
266
  requirements: []
275
-
276
267
  rubyforge_project:
277
- rubygems_version: 1.3.6
268
+ rubygems_version: 2.2.2
278
269
  signing_key:
279
- specification_version: 3
280
- summary: A framework that generates PDF and e-Pub from Markdown, Textile, and HTML files.
270
+ specification_version: 4
271
+ summary: A framework that generates PDF and e-Pub from Markdown, and HTML files.
281
272
  test_files: []
282
-