cheepub 0.7.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d46005c2a2b8119f4d2a4857af8c580744899c3eadfcacb1266cf4bc6eea597
4
- data.tar.gz: 1d435ca56cbf866f59dd33fd881ce0239a16be20840bd63326193a03d38847d3
3
+ metadata.gz: 275407b281784acb45225fe33947a403dbae8764a86b1e999ff91c178356791d
4
+ data.tar.gz: 78268645254fa5940f46ba260ce867a90ba04dc018bdcc7831f461ae49dbd3be
5
5
  SHA512:
6
- metadata.gz: e0d9fdc72911149b535024b7c6031a7015c65d2a6b2264fcf3b8e51a886e144c22facbb7eb425670347693c7844295a2c049dfa2e8038f2624afeacdd4595a53
7
- data.tar.gz: 0bb2e7d84eb8c7ce37cba962718a21048c6c04e3e4dede3e7de897416c485c463990551a8e54fb94a87ca3819d985bb3990a7db0ae0e2d0086e683901b2cf082
6
+ metadata.gz: a316b539db435c146a41eb9ae04ca8570076a22017eabe829b3c9df685b04f2f0400e8f9a3595dfd184b34bf3baeb04eb63d9fd6da730248bdc8ead7d1ee76ef
7
+ data.tar.gz: c83555f1732b3693ac2bf490f30a7b80e5232ac4a2f2b233e37d2124241ed29a2dd3a473094a97613dcc3bbfa15f6c88a78f355fe401a45c4227addb5cc61da1
data/README.md CHANGED
@@ -88,6 +88,13 @@ In a little district west of Washington Square the streets have run crazy and br
88
88
 
89
89
  ## History
90
90
 
91
+ ### 0.7.1
92
+
93
+ - show backtrace when `--debug` mode
94
+ - use `rouge` for EPUB instead of `coderay`
95
+ - add more samples
96
+ - add scripts `conv_entity.rb`
97
+
91
98
  ### 0.7.0
92
99
 
93
100
  - support option `--debug`
data/Rakefile CHANGED
@@ -9,6 +9,8 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList["test/**/*_test.rb"]
10
10
  end
11
11
 
12
+ CLEAN << ".rblatex_work"
13
+
12
14
  task :default => [:test, :rufo]
13
15
 
14
16
  desc "Run rufo"
data/cheepub.gemspec CHANGED
@@ -24,7 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "clamp", "~> 1.2"
25
25
  spec.add_dependency "oga", "~> 2.15"
26
26
  spec.add_dependency "coderay"
27
- spec.add_dependency "rb_latex", "~> 0.1.3"
27
+ spec.add_dependency "rouge"
28
+ spec.add_dependency "rb_latex", "~> 0.2.1"
28
29
 
29
30
  spec.add_development_dependency "rufo", "~> 0.3"
30
31
  spec.add_development_dependency "bundler", "~> 1.16"
data/lib/cheepub/cli.rb CHANGED
@@ -35,7 +35,7 @@ module Cheepub
35
35
  gen.execute
36
36
  rescue Cheepub::Error => e
37
37
  puts "Error: #{e.message}"
38
- if $DEBUG
38
+ if params[:debug]
39
39
  puts e.backtrace
40
40
  end
41
41
  exit(1)
@@ -3,6 +3,29 @@ require "kramdown/converter/latex"
3
3
  module Cheepub
4
4
  module Converter
5
5
  module CheeLatex
6
+
7
+ def convert_codeblock(el, opts)
8
+ show_whitespace = el.attr['class'].to_s =~ /\bshow-whitespaces\b/
9
+ lang = extract_code_language(el.attr)
10
+
11
+ if @options[:syntax_highlighter] == :minted &&
12
+ (highlighted_code = highlight_code(el.value, lang, :block))
13
+ @data[:packages] << 'minted'
14
+ "#{latex_link_target(el)}#{highlighted_code}\n"
15
+ elsif (show_whitespace || lang) && @options[:syntax_highlighter]
16
+ options = []
17
+ options << "showspaces=%s,showtabs=%s" % (show_whitespace ? ['true', 'true'] : ['false', 'false'])
18
+ options << "language=#{lang}" if lang
19
+ options << "basicstyle=\\ttfamily\\footnotesize,columns=fixed,frame=tlbr"
20
+ id = el.attr['id']
21
+ options << "label=#{id}" if id
22
+ attrs = attribute_list(el)
23
+ "#{latex_link_target(el)}\\begin{lstlisting}[#{options.join(',')}]\n#{el.value}\n\\end{lstlisting}#{attrs}\n"
24
+ else
25
+ "#{latex_link_target(el)}\\begin{verbatim}#{el.value}\\end{verbatim}\n"
26
+ end
27
+ end
28
+
6
29
  def convert_html_element(el, opts)
7
30
  if el.value == :ruby
8
31
  str = inner(el, opts)
@@ -31,6 +31,13 @@ module Cheepub
31
31
  @maker.date= params[:date] || Time.now
32
32
  @maker.lastmodified = params[:lastModified] || Time.now
33
33
  @maker.page_progression_direction = params[:pageDirection]
34
+ if params.key?(:latexCommand)
35
+ @maker.latex_command = params[:latexCommand]
36
+ end
37
+ if params.key?(:dvipdfCommand)
38
+ @maker.dvipdf_command = params[:dvipdfCommand]
39
+ end
40
+ @maker.debug = params[:debug]
34
41
  if params[:documentClass]
35
42
  @maker.document_class = params[:documentClass]
36
43
  end
@@ -14,6 +14,7 @@ module Cheepub
14
14
  lang: "ja",
15
15
  title: "content",
16
16
  cssfile: "style.css",
17
+ syntax_highlighter: nil,
17
18
  generator: "Cheepub #{Cheepub::VERSION} with kramdown #{Kramdown::VERSION}",
18
19
  input: "cheemarkdown",
19
20
  }
@@ -23,7 +24,7 @@ module Cheepub
23
24
 
24
25
  def convert
25
26
  params = @params.dup
26
- params[:syntax_highlighter] = "coderay"
27
+ params[:syntax_highlighter] = "rouge"
27
28
  Kramdown::Document.new(@text, params).to_html
28
29
  end
29
30
 
@@ -143,3 +143,218 @@ em {
143
143
  .text-pre-wrap {
144
144
  white-space: pre-wrap;
145
145
  }
146
+
147
+ code {
148
+ font-size: 1.0em;
149
+ }
150
+
151
+ /*** from syntax.css in rouge ***/
152
+ .highlight table td { padding: 5px; }
153
+ .highlight table pre { margin: 0; }
154
+ .highlight .cm {
155
+ color: #999988;
156
+ font-style: italic;
157
+ }
158
+ .highlight .cp {
159
+ color: #999999;
160
+ font-weight: bold;
161
+ }
162
+ .highlight .c1 {
163
+ color: #999988;
164
+ font-style: italic;
165
+ }
166
+ .highlight .cs {
167
+ color: #999999;
168
+ font-weight: bold;
169
+ font-style: italic;
170
+ }
171
+ .highlight .c, .highlight .cd {
172
+ color: #999988;
173
+ font-style: italic;
174
+ }
175
+ .highlight .err {
176
+ color: #a61717;
177
+ background-color: #e3d2d2;
178
+ }
179
+ .highlight .gd {
180
+ color: #000000;
181
+ background-color: #ffdddd;
182
+ }
183
+ .highlight .ge {
184
+ color: #000000;
185
+ font-style: italic;
186
+ }
187
+ .highlight .gr {
188
+ color: #aa0000;
189
+ }
190
+ .highlight .gh {
191
+ color: #999999;
192
+ }
193
+ .highlight .gi {
194
+ color: #000000;
195
+ background-color: #ddffdd;
196
+ }
197
+ .highlight .go {
198
+ color: #888888;
199
+ }
200
+ .highlight .gp {
201
+ color: #555555;
202
+ }
203
+ .highlight .gs {
204
+ font-weight: bold;
205
+ }
206
+ .highlight .gu {
207
+ color: #aaaaaa;
208
+ }
209
+ .highlight .gt {
210
+ color: #aa0000;
211
+ }
212
+ .highlight .kc {
213
+ color: #000000;
214
+ font-weight: bold;
215
+ }
216
+ .highlight .kd {
217
+ color: #000000;
218
+ font-weight: bold;
219
+ }
220
+ .highlight .kn {
221
+ color: #000000;
222
+ font-weight: bold;
223
+ }
224
+ .highlight .kp {
225
+ color: #000000;
226
+ font-weight: bold;
227
+ }
228
+ .highlight .kr {
229
+ color: #000000;
230
+ font-weight: bold;
231
+ }
232
+ .highlight .kt {
233
+ color: #445588;
234
+ font-weight: bold;
235
+ }
236
+ .highlight .k, .highlight .kv {
237
+ color: #000000;
238
+ font-weight: bold;
239
+ }
240
+ .highlight .mf {
241
+ color: #009999;
242
+ }
243
+ .highlight .mh {
244
+ color: #009999;
245
+ }
246
+ .highlight .il {
247
+ color: #009999;
248
+ }
249
+ .highlight .mi {
250
+ color: #009999;
251
+ }
252
+ .highlight .mo {
253
+ color: #009999;
254
+ }
255
+ .highlight .m, .highlight .mb, .highlight .mx {
256
+ color: #009999;
257
+ }
258
+ .highlight .sb {
259
+ color: #d14;
260
+ }
261
+ .highlight .sc {
262
+ color: #d14;
263
+ }
264
+ .highlight .sd {
265
+ color: #d14;
266
+ }
267
+ .highlight .s2 {
268
+ color: #d14;
269
+ }
270
+ .highlight .se {
271
+ color: #d14;
272
+ }
273
+ .highlight .sh {
274
+ color: #d14;
275
+ }
276
+ .highlight .si {
277
+ color: #d14;
278
+ }
279
+ .highlight .sx {
280
+ color: #d14;
281
+ }
282
+ .highlight .sr {
283
+ color: #009926;
284
+ }
285
+ .highlight .s1 {
286
+ color: #d14;
287
+ }
288
+ .highlight .ss {
289
+ color: #990073;
290
+ }
291
+ .highlight .s {
292
+ color: #d14;
293
+ }
294
+ .highlight .na {
295
+ color: #008080;
296
+ }
297
+ .highlight .bp {
298
+ color: #999999;
299
+ }
300
+ .highlight .nb {
301
+ color: #0086B3;
302
+ }
303
+ .highlight .nc {
304
+ color: #445588;
305
+ font-weight: bold;
306
+ }
307
+ .highlight .no {
308
+ color: #008080;
309
+ }
310
+ .highlight .nd {
311
+ color: #3c5d5d;
312
+ font-weight: bold;
313
+ }
314
+ .highlight .ni {
315
+ color: #800080;
316
+ }
317
+ .highlight .ne {
318
+ color: #990000;
319
+ font-weight: bold;
320
+ }
321
+ .highlight .nf {
322
+ color: #990000;
323
+ font-weight: bold;
324
+ }
325
+ .highlight .nl {
326
+ color: #990000;
327
+ font-weight: bold;
328
+ }
329
+ .highlight .nn {
330
+ color: #555555;
331
+ }
332
+ .highlight .nt {
333
+ color: #000080;
334
+ }
335
+ .highlight .vc {
336
+ color: #008080;
337
+ }
338
+ .highlight .vg {
339
+ color: #008080;
340
+ }
341
+ .highlight .vi {
342
+ color: #008080;
343
+ }
344
+ .highlight .nv {
345
+ color: #008080;
346
+ }
347
+ .highlight .ow {
348
+ color: #000000;
349
+ font-weight: bold;
350
+ }
351
+ .highlight .o {
352
+ color: #000000;
353
+ font-weight: bold;
354
+ }
355
+ .highlight .w {
356
+ color: #bbbbbb;
357
+ }
358
+ .highlight {
359
+ background-color: #f8f8f8;
360
+ }
@@ -1,3 +1,3 @@
1
1
  module Cheepub
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
data/lib/cheepub.rb CHANGED
@@ -1,4 +1,10 @@
1
+ tmp = $VERBOSE
2
+ $VERBOSE = false
1
3
  require "clamp"
4
+ require "oga"
5
+ require "rouge"
6
+ $VERBOSE = tmp
7
+
2
8
  require "cheepub/version"
3
9
  require "cheepub/error"
4
10
  require "cheepub/ext_hash"
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # convert HTML character entity into UTF-8 character
4
+ #
5
+
6
+ ENT_PATTERN = /&#([0-9A-Fa-f]+);/
7
+ ENT_X_PATTERN = /&#x([0-9A-Fa-f]+);/
8
+
9
+ def conv_ruby(str)
10
+ str.gsub(ENT_PATTERN) do |matched|
11
+ sprintf("%c", $1.to_i)
12
+ end.gsub(ENT_X_PATTERN) do |matched|
13
+ sprintf("%c", $1.to_i(16))
14
+ end
15
+ end
16
+
17
+ if ARGV.empty?
18
+ print "usage: ruby conv_entity.rb [htmlfile]\n"
19
+ exit 0
20
+ end
21
+
22
+ ARGV.each do |file|
23
+ File.open(file) do |f|
24
+ f.each_line do |line|
25
+ conved = conv_ruby(line)
26
+ print conved
27
+ end
28
+ end
29
+ end