review 0.6.0 → 0.9.0

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.
Files changed (68) hide show
  1. data/ChangeLog +441 -0
  2. data/README.rdoc +25 -0
  3. data/Rakefile +13 -1
  4. data/VERSION +1 -1
  5. data/bin/review-check +1 -1
  6. data/bin/review-compile +19 -10
  7. data/bin/review-epubmaker +114 -17
  8. data/bin/review-index +8 -1
  9. data/bin/review-pdfmaker +378 -0
  10. data/bin/review-preproc +2 -3
  11. data/bin/review-vol +1 -2
  12. data/debian/README.Debian +12 -0
  13. data/debian/README.source +5 -0
  14. data/debian/changelog +5 -0
  15. data/debian/compat +1 -0
  16. data/debian/control +22 -0
  17. data/debian/copyright +60 -0
  18. data/debian/docs +5 -0
  19. data/debian/manpage.1.ex +59 -0
  20. data/debian/patches/path.diff +91 -0
  21. data/debian/patches/series +1 -0
  22. data/debian/review.install +13 -0
  23. data/debian/review.links +4 -0
  24. data/debian/rules +13 -0
  25. data/debian/source/format +1 -0
  26. data/doc/format.rdoc +477 -0
  27. data/doc/format.re +19 -0
  28. data/doc/format_idg.rdoc +180 -0
  29. data/doc/ruby-uuid/README +11 -0
  30. data/doc/ruby-uuid/README.ja +34 -0
  31. data/doc/sample.css +17 -0
  32. data/doc/sample.yaml +8 -4
  33. data/lib/lineinput.rb +1 -1
  34. data/lib/review/book.rb +43 -36
  35. data/lib/review/builder.rb +78 -33
  36. data/lib/review/compiler.rb +45 -48
  37. data/lib/review/epubbuilder.rb +1 -675
  38. data/lib/review/exception.rb +1 -1
  39. data/lib/review/htmlbuilder.rb +627 -49
  40. data/lib/review/htmlutils.rb +5 -0
  41. data/lib/review/idgxmlbuilder.rb +239 -250
  42. data/lib/review/index.rb +84 -7
  43. data/lib/review/latexbuilder.rb +261 -42
  44. data/lib/review/latexutils.rb +15 -6
  45. data/lib/review/preprocessor.rb +40 -6
  46. data/lib/review/textutils.rb +22 -0
  47. data/lib/review/topbuilder.rb +4 -1
  48. data/lib/uuid.rb +312 -0
  49. data/review.gemspec +44 -12
  50. data/test/CHAPS +2 -0
  51. data/test/bib.re +13 -0
  52. data/test/test.re +43 -0
  53. data/test/test_book.rb +1191 -0
  54. data/test/test_builder.rb +147 -0
  55. data/test/test_htmlbuilder.rb +191 -10
  56. data/test/test_htmlutils.rb +24 -0
  57. data/test/test_idgxmlbuilder.rb +310 -0
  58. data/test/test_index.rb +15 -0
  59. data/test/test_latexbuilder.rb +217 -6
  60. data/test/test_lineinput.rb +198 -0
  61. data/test/test_textutils.rb +68 -0
  62. data/test/test_uuid.rb +156 -0
  63. metadata +43 -10
  64. data/doc/format.txt +0 -434
  65. data/doc/format_idg.txt +0 -194
  66. data/doc/format_sjis.txt +0 -313
  67. data/setup.rb +0 -1587
  68. data/test/test_epubbuilder.rb +0 -73
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  Jeweler::Tasks.new do |gem|
9
9
  gem.name = "review"
10
10
  gem.summary = %Q{ReVIEW: a easy-to-use digital publishing system}
11
- gem.description = %Q{ReVIEW is a digital publishing system for books and ebooks. It supports InDesin, EPUB and LaTeX.}
11
+ gem.description = %Q{ReVIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX.}
12
12
  gem.email = "kmuto@debian.org"
13
13
  gem.homepage = "http://github.com/kmuto/review"
14
14
  gem.authors = ["kmuto", "takahashim"]
@@ -31,6 +31,18 @@ Rake::TestTask.new("test") do |t|
31
31
  t.verbose = true
32
32
  end
33
33
 
34
+ begin
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |t|
37
+ t.rcov_opts << '-x /gems/'
38
+ t.rcov_opts << '-x /tmp/'
39
+ t.libs << 'test'
40
+ t.pattern = 'test/test_*.rb'
41
+ t.verbose = true
42
+ end
43
+ rescue LoadError
44
+ end
45
+
34
46
  require 'rake/rdoctask'
35
47
  Rake::RDocTask.new do |rdoc|
36
48
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.9.0
@@ -46,7 +46,7 @@ def main
46
46
  parser.on('-a', '--all-chapters', 'Check all chapters.') {
47
47
  files = ReVIEW.book.chapters.map {|ent| ent.path }
48
48
  }
49
- parser.on('-s', '--section N', 'Check section N.') {|n|
49
+ parser.on('-s', '--section N', 'Check section N. (deprecated)') {|n|
50
50
  ents = ReVIEW.env.parts[Integer(n) - 1] or
51
51
  raise ReVIEW::ApplicationError, "section #{n} not exist"
52
52
  files = ents.map {|ent| ent.path }
@@ -41,14 +41,16 @@ def _main
41
41
  check_only = false
42
42
 
43
43
  param = {
44
- "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
45
- "tableopt" => nil, # for IDGXMLBuilder
46
- "nolf" => nil, # for IDGXMLBuilder
47
- "chapref" => nil, # for IDGXMLBuilder
44
+ "secnolevel" => 2, # for IDGXML and HTML
45
+ "tableopt" => nil, # for IDGXML
46
+ "nolf" => nil, # for IDGXML
47
+ "chapref" => nil, # for IDGXML
48
48
  "inencoding" => "UTF-8",
49
49
  "outencoding" => "UTF-8",
50
50
  "subdirmode" => nil,
51
- "stylesheet" => nil, # for EPUBBuilder
51
+ "stylesheet" => nil, # for HTML
52
+ "mathml" => nil, # for HTML
53
+ "deprecated-blocklines" => nil,
52
54
  }
53
55
 
54
56
  parser = OptionParser.new
@@ -80,9 +82,19 @@ def _main
80
82
  parser.on('--subdirmode', 'Use chapter/id.ext path style to find images.') {
81
83
  param["subdirmode"] = true
82
84
  }
83
- parser.on('--stylesheet=file', 'Stylesheet file for EPUB. (epub)') {|file|
85
+ parser.on('--stylesheet=file', 'Stylesheet file for HTML') {|file|
84
86
  param["stylesheet"] = file
85
87
  }
88
+ parser.on('--mathml', 'Use MathML for TeX equation in HTML') {
89
+ param["mathml"] = true
90
+ require 'math_ml'
91
+ }
92
+ parser.on('--hdnumberingmode', 'Output numbering headlines. (deprecated)') {
93
+ param["hdnumberingmode"] = true
94
+ }
95
+ parser.on('--deprecated-blocklines', 'Disable paragrahs in block tags. Treat physical line as a paragraph. (deprecated)') {
96
+ param["deprecated-blocklines"] = true
97
+ }
86
98
  unless target
87
99
  parser.on('--target=FMT', 'Target format.') {|fmt|
88
100
  target = fmt
@@ -117,7 +129,7 @@ def _main
117
129
 
118
130
  begin
119
131
  compiler = ReVIEW::Compiler.new(load_strategy_class(target, check_only))
120
- compiler.setParameter(param)
132
+ ReVIEW.book.param = param
121
133
  case mode
122
134
  when :files
123
135
  if ARGV.empty?
@@ -125,15 +137,12 @@ def _main
125
137
  exit 1
126
138
  end
127
139
  ReVIEW::Chapter.intern_pathes(ARGV).each do |chap|
128
- chap.setParameter(param)
129
140
  result = compiler.compile(chap)
130
141
  print result unless check_only
131
142
  end
132
143
  when :dir
133
144
  book = basedir ? ReVIEW::Book.load(basedir) : ReVIEW.book
134
- book.setParameter(param)
135
145
  book.chapters.each do |chap|
136
- chap.setParameter(param)
137
146
  str = compiler.compile(chap)
138
147
  write "#{chap.name}#{compiler.strategy.extname}", str unless check_only
139
148
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: utf-8
2
3
  #
3
4
  # Copyright (c) 2010 Kenshi Muto and Masayoshi Takahashi
4
5
  #
@@ -14,9 +15,16 @@ require 'yaml'
14
15
  require 'optparse'
15
16
  require 'rexml/document'
16
17
 
18
+ require 'pathname'
19
+
20
+ bindir = Pathname.new(__FILE__).realpath.dirname
21
+ $LOAD_PATH.unshift((bindir + '../lib').realpath)
22
+
23
+ require 'uuid'
24
+
17
25
  def main
18
26
  values = { # These parameters can be overridden by YAML file.
19
- "bookname"=> "sample", # it defines epub file name also
27
+ "bookname"=> nil, # it defines epub file name also
20
28
  "booktitle" => "ReVIEW EPUBサンプル",
21
29
  "aut" => "吟遊詩人", # author
22
30
  "prt" => nil, # printer(publisher)
@@ -31,23 +39,23 @@ def main
31
39
  "date" => nil, # publishing date
32
40
  "rights" => nil, # Copyright messages
33
41
  "description" => nil, # Description
34
- "urnid" => "example.jp", # just used for unique ID
42
+ "urnid" => nil, # Identifier (nil makes random uuid)
35
43
  "stylesheet" => "stylesheet.css", # stylesheet file
36
44
  "coverfile" => nil, # content file of body of cover page
37
45
  "mytoc" => nil, # whether make own table of contents or not
38
- "params" => "", # specify review2epub parameters
46
+ "params" => "", # specify review2html parameters
39
47
  "toclevel" => 3, # level of toc
40
48
  "secnolevel" => 2, # level of section #
41
49
  "posthook" => nil, # command path of post hook
42
50
  "debug" => nil, # debug flag
43
51
  }
44
- yamlfile = ""
45
-
46
- if ARGV.size == 1
47
- values = values.merge(YAML.load_file(ARGV[0]))
48
- yamlfile = ARGV[0]
52
+ if ARGV.size != 1
53
+ puts "Usage: #{$0} configfile"
54
+ exit 0
49
55
  end
50
56
 
57
+ yamlfile = ARGV[0]
58
+ values = values.merge(YAML.load_file(yamlfile))
51
59
  bookname = values["bookname"]
52
60
 
53
61
  if File.exist?("#{bookname}.epub")
@@ -59,7 +67,7 @@ def main
59
67
  exit 1
60
68
  end
61
69
 
62
- identifier = "urn:uuid:#{values["urnid"]}_#{bookname}"
70
+ identifier = values["urnid"].nil? ? "urn:uuid:#{UUID.create}" : values["urnid"]
63
71
 
64
72
  tmp = values["debug"].nil? ? Dir.mktmpdir : "."
65
73
  Dir.mkdir("#{tmp}/#{bookname}")
@@ -87,7 +95,7 @@ def main
87
95
  toccount = toccount + 1
88
96
  fork {
89
97
  STDOUT.reopen("#{tmp}/#{bookname}/OEBPS/pre#{pre}.html")
90
- exec("review-compile --target=epub --level=#{values["secnolevel"]} #{values["params"]} #{l}")
98
+ exec("review-compile --target=html --level=#{values["secnolevel"]} #{values["params"]} #{l}")
91
99
  }
92
100
  Process.waitall
93
101
  getanchors("#{tmp}/#{bookname}/OEBPS/pre#{pre}.html")
@@ -104,7 +112,7 @@ def main
104
112
  next if l =~ /^#/
105
113
  fork {
106
114
  STDOUT.reopen("#{tmp}/#{bookname}/OEBPS/chap#{body}.html")
107
- exec("review-compile --target=epub --level=#{values["secnolevel"]} #{values["params"]} #{l}")
115
+ exec("review-compile --target=html --level=#{values["secnolevel"]} #{values["params"]} #{l}")
108
116
  }
109
117
  Process.waitall
110
118
  getanchors("#{tmp}/#{bookname}/OEBPS/chap#{body}.html")
@@ -121,7 +129,7 @@ def main
121
129
  toccount = toccount + 1
122
130
  fork {
123
131
  STDOUT.reopen("#{tmp}/#{bookname}/OEBPS/post#{post}.html")
124
- exec("review-compile --target=epub --level=#{values["secnolevel"]} #{values["params"]} #{l}")
132
+ exec("review-compile --target=html --level=#{values["secnolevel"]} #{values["params"]} #{l}")
125
133
  }
126
134
  Process.waitall
127
135
  getanchors("#{tmp}/#{bookname}/OEBPS/post#{post}.html")
@@ -196,14 +204,29 @@ EOT
196
204
  end
197
205
 
198
206
  f.puts @manifeststr
207
+ unless values["colophon"].nil?
208
+ f.puts <<EOT
209
+ <item id="colophon" href="colophon.html" media-type="application/xhtml+xml" />
210
+ EOT
211
+ end
199
212
  f.puts <<EOT
200
213
  </manifest>
201
214
  <spine toc="ncx">
202
215
  <itemref idref="#{bookname}" linear="no" />
203
216
  <itemref idref="top" />
217
+ EOT
218
+ unless values["mytoc"].nil?
219
+ f.puts <<EOT
204
220
  <itemref idref="toc" />
205
221
  EOT
222
+ end
223
+
206
224
  f.puts @ncxstr
225
+ unless values["colophon"].nil?
226
+ f.puts <<EOT
227
+ <itemref idref="colophon" />
228
+ EOT
229
+ end
207
230
  f.puts <<EOT
208
231
  </spine>
209
232
  <guide>
@@ -295,7 +318,7 @@ EOT
295
318
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
296
319
  <meta http-equiv="Content-Style-Type" content="text/css"/>
297
320
  <link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
298
- <meta name="generator" content="ReVIEW EPUB Maker"/>
321
+ <meta name="generator" content="ReVIEW"/>
299
322
  <title>#{values["booktitle"]}</title>
300
323
  </head>
301
324
  <body>
@@ -445,6 +468,11 @@ EOT
445
468
  FileUtils.cp values["stylesheet"], "#{tmp}/#{bookname}/OEBPS/#{values["stylesheet"]}"
446
469
  end
447
470
 
471
+ # Colophon page
472
+ if !values["colophon"].nil?
473
+ make_colophon_page(tmp, bookname, values)
474
+ end
475
+
448
476
  # hook
449
477
  if !values["posthook"].nil? && !values["posthook"].empty? && FileTest.executable?(values["posthook"])
450
478
  fork {
@@ -485,10 +513,14 @@ def copyImagesToDir(dirname, copybase)
485
513
  figid = getFigId(fname)
486
514
  mime = nil
487
515
  case fname.downcase.match(/\.(png|gif|jpg|jpeg|svg)$/)[1]
488
- when "png": mime = "image/png"
489
- when "gif": mime = "image/gif"
490
- when "jpg", "jpeg": mime = "image/jpeg"
491
- when "svg": mime = "image/svg+xml"
516
+ when "png"
517
+ mime = "image/png"
518
+ when "gif"
519
+ mime = "image/gif"
520
+ when "jpg", "jpeg"
521
+ mime = "image/jpeg"
522
+ when "svg"
523
+ mime = "image/svg+xml"
492
524
  else
493
525
  raise "unsupported type #{fname}"
494
526
  end
@@ -522,4 +554,69 @@ def getanchors(filename)
522
554
  }
523
555
  end
524
556
 
557
+ def make_colophon_page(tmp,bookname,values)
558
+
559
+ header = <<EOT
560
+ <?xml version="1.0" encoding="UTF-8"?>
561
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
562
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="ja">
563
+ <head>
564
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
565
+ <meta http-equiv="Content-Style-Type" content="text/css"/>
566
+ <link rel="stylesheet" type="text/css" href="#{values["stylesheet"]}"/>
567
+ <meta name="generator" content="ReVIEW EPUB Maker"/>
568
+ <title>#{values["booktitle"]}</title>
569
+ </head>
570
+ <body>
571
+ EOT
572
+
573
+ footer = <<EOT
574
+ </body>
575
+ </html>
576
+ EOT
577
+
578
+ colophon_path = "#{tmp}/#{bookname}/OEBPS/colophon.html"
579
+ colophon = values["colophon"]
580
+ if colophon.kind_of?(String) && File.exist?(colophon)
581
+ File.open(colophon_path, "w") {|f|
582
+ f.puts header
583
+ File.open(values["colophon"]) {|f2|
584
+ f2.each_line {|l|
585
+ f.puts l
586
+ }
587
+ }
588
+ f.puts footer
589
+ }
590
+ else
591
+ File.open(colophon_path, "w") {|f|
592
+ f.puts header
593
+ f.puts <<EOT
594
+ <div class="colophon">
595
+ <p class="title">#{values["booktitle"]}</p>
596
+ EOT
597
+ if values["pubhistory"]
598
+ f.puts %Q[<div class="pubhistory">\n<p>#{values["pubhistory"].gsub(/\n/,"<br />")}</p>\n</div>]
599
+ end
600
+
601
+ f.puts <<EOT
602
+ <table>
603
+ EOT
604
+ f.puts %Q[<tr>\n <th>著 者</th><td>#{values["aut"]}</td>\n</tr>] if values["aut"]
605
+ f.puts %Q[<tr>\n <th>デザイン</th><td>#{values["dsr"]}</td>\n</tr>] if values["dsr"]
606
+ f.puts %Q[<tr>\n <th>イラスト</th><td>#{values["ill"]}</td>\n</tr>] if values["ill"]
607
+ f.puts %Q[<tr>\n <th>編 集</th><td>#{values["edt"]}</td>\n</tr>] if values["edt"]
608
+ f.puts %Q[<tr>\n <th>発行所</th><td>#{values["prt"]}</td>\n</tr>] if values["prt"]
609
+ f.puts <<EOT
610
+ </table>
611
+ EOT
612
+ if values["rights"]
613
+ f.puts %Q[<p class="copyright">#{values["rights"]}</p>]
614
+ end
615
+
616
+ f.puts "</div>"
617
+ f.puts footer
618
+ }
619
+ end
620
+ end
621
+
525
622
  main
@@ -57,6 +57,13 @@ def _main
57
57
  source = ReVIEW.book.part(Integer(n)) or
58
58
  error_exit "part #{n} does not exist in this book"
59
59
  }
60
+ parser.on('-c', '--chapter C', 'list only chapter C.') {|c|
61
+ begin
62
+ source = ReVIEW::Part.new(1, [ReVIEW.book.chapter(c)])
63
+ rescue
64
+ error_exit "chapter #{c} does not exist in this book"
65
+ end
66
+ }
60
67
  parser.on('-l', '--level N', 'list upto N level (1..4, default=4)') {|n|
61
68
  upper = Integer(n)
62
69
  unless (0..4).include?(upper) # 0 is hidden option
@@ -67,7 +74,7 @@ def _main
67
74
  parser.on('--text', 'output in plain text (default)') {
68
75
  printer_class = ReVIEW::TextTOCPrinter
69
76
  }
70
- parser.on('--html', 'output in HTML') {
77
+ parser.on('--html', 'output in HTML (deprecated)') {
71
78
  printer_class = ReVIEW::HTMLTOCPrinter
72
79
  }
73
80
  parser.on('--idg', 'output in InDesign XML') {
@@ -0,0 +1,378 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # Copyright (c) 2010 Kenshi Muto and Masayoshi Takahashi
5
+ #
6
+ # This program is free software.
7
+ # You can distribute or modify this program under the terms of
8
+ # the GNU LGPL, Lesser General Public License version 2.1.
9
+ # For details of the GNU LGPL, see the file "COPYING".
10
+ #
11
+
12
+ require 'tmpdir'
13
+ require 'yaml'
14
+ require 'fileutils'
15
+
16
+ def error(msg)
17
+ $stderr.puts "#{File.basename($0, '.*')}: error: #{msg}"
18
+ exit 1
19
+ end
20
+
21
+ def usage
22
+ $stderr.puts "Usage: #{$0} configfile"
23
+ exit 0
24
+ end
25
+
26
+ def check_book(values)
27
+ pdf_file = values["bookname"]+".pdf"
28
+ if File.exists? pdf_file
29
+ error "file already exists:#{pdf_file}"
30
+ end
31
+ end
32
+
33
+ def build_path(values)
34
+ if values["debug"].nil?
35
+ Dir.mktmpdir+"/#{values["bookname"]}"
36
+ else
37
+ "./#{values["bookname"]}"
38
+ end
39
+ end
40
+
41
+ def main
42
+ usage if ARGV.size != 1
43
+
44
+ yamlfile = ARGV[0]
45
+ values = YAML.load_file(yamlfile)
46
+ check_book(values)
47
+ basedir = Dir.pwd
48
+ path = build_path(values)
49
+ bookname = values["bookname"]
50
+ Dir.mkdir(path)
51
+
52
+ pre = 0
53
+ body = 0
54
+ post = 0
55
+ @pre_str = ""
56
+ @chap_str = ""
57
+ @post_str = ""
58
+ toccount = 2
59
+
60
+ if File.exists?("PREDEF")
61
+ File.open("PREDEF") {|chaps|
62
+ chaps.each_line {|l|
63
+ next if l =~ /^#/
64
+ pre = pre + 1
65
+ toccount = toccount + 1
66
+ fork {
67
+ STDOUT.reopen("#{path}/pre#{pre}.tex")
68
+ exec("review-compile --target=latex --level=1 #{values["params"]} #{l}")
69
+ }
70
+ Process.waitall
71
+ @pre_str << %Q|\\input{pre#{pre}.tex}\n|
72
+ }
73
+ }
74
+ end
75
+ if File.exists?("CHAPS")
76
+ File.open("CHAPS") {|chaps|
77
+ chaps.each_line {|l|
78
+ body = body + 1
79
+ toccount = toccount + 1
80
+ next if l =~ /^#/
81
+ fork {
82
+ STDOUT.reopen("#{path}/chap#{body}.tex")
83
+ exec("review-compile --target=latex --level=#{values["secnolevel"]} #{values["params"]} #{l}")
84
+ }
85
+ Process.waitall
86
+ @chap_str << %Q|\\input{chap#{body}.tex}\n|
87
+ }
88
+ }
89
+ end
90
+ if File.exists?("POSTDEF")
91
+ File.open("POSTDEF") {|chaps|
92
+ chaps.each_line {|l|
93
+ next if l =~ /^#/
94
+ post = post + 1
95
+ toccount = toccount + 1
96
+ fork {
97
+ STDOUT.reopen("#{path}/post#{post}.tex")
98
+ exec("review-compile --target=latex --level=1 #{values["params"]} #{l}")
99
+ }
100
+ Process.waitall
101
+ @post_str << %Q|\\input{post#{post}.tex}\n|
102
+ }
103
+ }
104
+ end
105
+ values["pre_str"] = @pre_str
106
+ values["chap_str"] = @chap_str
107
+ values["post_str"] = @post_str
108
+
109
+ values["usepackage"] = ""
110
+ if values["texstyle"]
111
+ values["usepackage"] = "\\usepackage{#{values['texstyle']}}"
112
+ end
113
+
114
+ copy_images("./images", "#{path}/images")
115
+ copyStyToDir(Dir.pwd + "/sty", path)
116
+
117
+ Dir.chdir(path) {
118
+ template = get_template(values)
119
+ File.open("./book.tex", "wb"){|f| f.write(template)}
120
+
121
+ ## do compile
122
+ fork {
123
+ exec("platex book.tex")
124
+ }
125
+ Process.waitall
126
+ fork {
127
+ exec("platex book.tex")
128
+ }
129
+ Process.waitall
130
+ fork {
131
+ exec("dvipdfmx -d 5 book.dvi")
132
+ }
133
+ Process.waitall
134
+ }
135
+ FileUtils.cp("#{path}/book.pdf", "#{basedir}/#{bookname}.pdf")
136
+
137
+ end
138
+
139
+ def copy_images(from, to)
140
+ if File.exist?(from)
141
+ Dir.mkdir(to)
142
+ copyImagesToDir(from, to)
143
+ Dir.chdir(to) {
144
+ fork {
145
+ exec("ebb *.png *.jpg")
146
+ }
147
+ }
148
+ Process.waitall
149
+ end
150
+ end
151
+
152
+ def get_template(values)
153
+ str = <<EOB
154
+ \\documentclass[oneside]{jsbook}
155
+ \\usepackage[deluxe]{otf}
156
+ \\usepackage[dvipdfmx]{color}
157
+ \\usepackage[dvipdfmx]{graphicx}
158
+ \\usepackage{framed}
159
+ \\usepackage{wrapfig}
160
+ \\definecolor{shadecolor}{gray}{0.9}
161
+ \\definecolor{shadecolorb}{gray}{0.1}
162
+
163
+ \\usepackage[utf8]{inputenc}
164
+
165
+ \\usepackage{jumoline}
166
+
167
+ \\usepackage{ascmac}
168
+
169
+ \\usepackage{float}
170
+ \\usepackage{alltt}
171
+
172
+ \\newenvironment{shadedb}{%
173
+ \\def\\FrameCommand{\\fboxsep=\\FrameSep \\colorbox{shadecolorb}}%
174
+ \\MakeFramed {\\FrameRestore}}%
175
+ {\\endMakeFramed}
176
+
177
+
178
+ \\usepackage[top=10zw,bottom=12zw,left=10zw,right=10zw]{geometry}
179
+ %\\usepackage[top=5zw,bottom=5zw,left=1zw,right=1zw]{geometry}
180
+
181
+
182
+ \\newcommand{\\parasep}{\\vspace*{3zh}}
183
+ \\setlength{\\footskip}{30pt}
184
+
185
+ \\usepackage[dvipdfm,bookmarks=true,bookmarksnumbered=true,colorlinks=true,%
186
+ pdftitle={#{values["booktitle"]}},%
187
+ pdfauthor={#{values["aut"]}}]{hyperref}
188
+
189
+ %% Bookmarkの文字化け対策(日本語向け)
190
+ \\ifnum 46273=\\euc"B4C1 % 46273 == 0xB4C1 == 漢(EUC-JP)
191
+ \\AtBeginDvi{\\special{pdf:tounicode EUC-UCS2}}%
192
+ \\else
193
+ \\AtBeginDvi{\\special{pdf:tounicode 90ms-RKSJ-UCS2}}%
194
+ \\fi
195
+
196
+ \\newenvironment{reviewimage}{%
197
+ \\begin{figure}[H]
198
+ \\begin{center}}{%
199
+ \\end{center}
200
+ \\end{figure}}
201
+
202
+ \\newenvironment{reviewdummyimage}{%
203
+ \\begin{figure}[H]
204
+ \\begin{center}}{%
205
+ \\end{center}
206
+ \\end{figure}}
207
+
208
+ \\newenvironment{reviewemlist}{%
209
+ \\medskip\\small\\begin{shaded}\\setlength{\\baselineskip}{1.3zw}}{%
210
+ \\end{shaded}}
211
+
212
+ \\newenvironment{reviewlist}{%
213
+ \\begin{shaded}\\small\\setlength{\\baselineskip}{1.3zw}}{%
214
+ \\end{shaded}\\par\\vspace*{0.5zw}}
215
+
216
+ \\newenvironment{reviewcmd}{%
217
+ \\color{white}\\medskip\\small\\begin{shadedb}\\setlength{\\baselineskip}{1.3zw}}{%
218
+ \\end{shadedb}}
219
+
220
+ \\newenvironment{reviewtable}[1]{%
221
+ \\begin{center}\\small\\setlength{\\baselineskip}{1.2zw}
222
+ \\begin{tabular}{#1}}{%
223
+ \\end{tabular}
224
+ \\end{center}}
225
+
226
+ \\newenvironment{reviewcolumn}{%
227
+ \\begin{framed}
228
+ }{%
229
+ \\end{framed}
230
+ \\vspace{2zw}}
231
+
232
+ \\newcommand{\\reviewcolumnhead}[2]{%
233
+ {\\noindent\\large ■コラム: #2}}
234
+
235
+ \\newcommand{\\reviewtablecaption}[1]{%
236
+ \\caption{#1}}
237
+
238
+ \\newcommand{\\reviewbackslash}[0]{%
239
+ \\textbackslash{}}
240
+
241
+ \\newcommand{\\reviewlistcaption}[1]{%
242
+ \\medskip{\\small\\noindent #1}\\vspace*{-1.3zw}}
243
+
244
+ \\newcommand{\\reviewimageref}[1]{%
245
+ 図 #1}
246
+ \\newcommand{\\reviewtableref}[1]{%
247
+ 表 #1}
248
+ \\newcommand{\\reviewlistref}[1]{%
249
+ リスト #1}
250
+
251
+ \\newcommand{\\reviewminicolumntitle}[1]{%
252
+ {\\large ■メモ:#1}\\\\}
253
+
254
+ \\newenvironment{reviewminicolumn}{%
255
+ \\vspace{1.5zw}\\begin{screen}}{%
256
+ \\end{screen}\\vspace{2zw}}
257
+
258
+ \\newcommand{\\reviewkw}[1]{%
259
+ \\textbf{\\textgt{#1}}}
260
+
261
+ \\newcommand{\\reviewtitlefont}[0]{%
262
+ \\usefont{T1}{phv}{b}{n}\\gtfamily}
263
+
264
+ \\newcommand{\\reviewmainfont}[0]{%
265
+ }
266
+
267
+ #{values["usepackage"]}
268
+
269
+ \\usepackage[T1]{fontenc}
270
+
271
+ \\begin{document}
272
+
273
+ \\reviewmainfont
274
+
275
+ \\begin{titlepage}
276
+ EOB
277
+ if values["coverimage"]
278
+ str += <<EOB
279
+ \\begin{center}
280
+ \\mbox{}\\vskip5zw%
281
+ \\includegraphics[scale=1.0]{./images/#{values["coverimage"]}}
282
+ \\end{center}
283
+ \\clearpage
284
+ EOB
285
+ end
286
+ str += <<EOB
287
+ \\thispagestyle{empty}
288
+ \\begin{center}%
289
+ \\mbox{} \\vskip5zw
290
+ \\reviewtitlefont%
291
+ {\\Huge #{values["booktitle"]} \\par}%
292
+ \\vskip 15em%
293
+ {\\huge
294
+ \\lineskip .75em
295
+ \\begin{tabular}[t]{c}%
296
+ #{values["aut"]}\\vspace*{1zh} 著
297
+ \\end{tabular}\\par}%
298
+ \\vfill
299
+ {\\large #{values["date"]} 版\\hspace{2zw}#{values["prt"]} 発行\\par}%
300
+ \\vskip4zw\\mbox{}
301
+ \\end{center}%
302
+ \\end{titlepage}
303
+
304
+ \\renewcommand{\\chaptermark}[1]{{}}
305
+ \\frontmatter
306
+
307
+ %% preface
308
+ #{values["pre_str"]}
309
+
310
+ \\tableofcontents
311
+
312
+ \\renewcommand{\\chaptermark}[1]{\\markboth{\\prechaptername\\thechapter\\postchaptername~#1}{}}
313
+ \\mainmatter
314
+
315
+ #{values["chap_str"]}
316
+
317
+ \\renewcommand{\\chaptermark}[1]{\\markboth{\\appendixname\\thechapter~#1}{}}
318
+ \\appendix
319
+
320
+ #{values["post_str"]}
321
+
322
+ %% okuduke
323
+ \\backmatter
324
+ \\clearpage
325
+ \\thispagestyle{empty}
326
+
327
+ \\vspace*{\\fill}
328
+
329
+ {\\noindent\\reviewtitlefont\\Large #{values["booktitle"]}} \\\\
330
+ \\rule[8pt]{14cm}{1pt} \\\\
331
+ {\\noindent
332
+ #{values["pubhistory"].to_s.gsub(/\n/){"\n\n\\noindent"} }
333
+ }
334
+
335
+ \\begin{tabular}{ll}
336
+ 著 者 & #{values["aut"]} \\\\
337
+ 編集者 & #{values["edt"]} \\\\
338
+ 発行所 & #{values["prt"]} \\\\
339
+ \\end{tabular}
340
+  \\\\
341
+ \\rule[0pt]{14cm}{1pt} \\\\
342
+ #{values["rights"]} \\\\
343
+
344
+ \\end{document}
345
+
346
+ EOB
347
+ end
348
+
349
+ def copyImagesToDir(dirname, copybase)
350
+ Dir.open(dirname) {|dir|
351
+ dir.each {|fname|
352
+ next if fname =~ /^\./
353
+ if FileTest.directory?("#{dirname}/#{fname}")
354
+ copyImagesToDir("#{dirname}/#{fname}", "#{copybase}/#{fname}")
355
+ else
356
+ if fname =~ /\.(png|gif|jpg|jpeg|svg)$/i
357
+ Dir.mkdir(copybase) unless File.exist?(copybase)
358
+ FileUtils.cp "#{dirname}/#{fname}", copybase
359
+ end
360
+ end
361
+ }
362
+ }
363
+ end
364
+
365
+ def copyStyToDir(dirname, copybase)
366
+ Dir.open(dirname) {|dir|
367
+ dir.each {|fname|
368
+ next if fname =~ /^\./
369
+ if fname =~ /\.(sty)$/i
370
+ Dir.mkdir(copybase) unless File.exist?(copybase)
371
+ FileUtils.cp "#{dirname}/#{fname}", copybase
372
+ end
373
+ }
374
+ }
375
+ end
376
+
377
+
378
+ main