review 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +42 -0
  3. data/README.rdoc +31 -0
  4. data/bin/review-catalog-converter +129 -0
  5. data/bin/review-check +4 -2
  6. data/bin/review-compile +7 -7
  7. data/bin/review-index +4 -3
  8. data/bin/review-init +3 -1
  9. data/bin/review-pdfmaker +2 -258
  10. data/bin/review-vol +2 -2
  11. data/doc/catalog.rdoc +18 -3
  12. data/doc/format.rdoc +2 -3
  13. data/doc/quickstart.rdoc +1 -1
  14. data/lib/epubmaker/epubv2.rb +16 -8
  15. data/lib/epubmaker/epubv3.rb +44 -12
  16. data/lib/epubmaker/producer.rb +4 -2
  17. data/lib/review/book.rb +0 -1
  18. data/lib/review/book/base.rb +72 -35
  19. data/lib/review/book/chapter.rb +8 -12
  20. data/lib/review/book/compilable.rb +8 -8
  21. data/lib/review/book/image_finder.rb +7 -0
  22. data/lib/review/book/index.rb +23 -5
  23. data/lib/review/book/volume.rb +2 -1
  24. data/lib/review/builder.rb +10 -5
  25. data/lib/review/catalog.rb +5 -0
  26. data/lib/review/compiler.rb +1 -1
  27. data/lib/review/configure.rb +12 -0
  28. data/lib/review/epubmaker.rb +13 -7
  29. data/lib/review/htmlbuilder.rb +26 -12
  30. data/lib/review/i18n.rb +2 -2
  31. data/lib/review/i18n.yml +21 -0
  32. data/lib/review/idgxmlbuilder.rb +11 -9
  33. data/lib/review/latexbuilder.rb +3 -2
  34. data/lib/review/{review.tex.erb → layout.tex.erb} +9 -1
  35. data/lib/review/markdownbuilder.rb +126 -4
  36. data/lib/review/pdfmaker.rb +291 -0
  37. data/lib/review/tocparser.rb +6 -5
  38. data/lib/review/tocprinter.rb +5 -2
  39. data/lib/review/version.rb +1 -1
  40. data/review.gemspec +1 -1
  41. data/rubocop-todo.yml +13 -0
  42. data/test/test_book.rb +95 -133
  43. data/test/test_book_chapter.rb +16 -21
  44. data/test/test_builder.rb +12 -7
  45. data/test/test_catalog.rb +15 -3
  46. data/test/test_catalog_converter_cmd.rb +73 -0
  47. data/test/test_epubmaker.rb +5 -5
  48. data/test/test_helper.rb +32 -21
  49. data/test/test_htmlbuilder.rb +219 -192
  50. data/test/test_i18n.rb +46 -19
  51. data/test/test_idgxmlbuilder.rb +177 -182
  52. data/test/test_inaobuilder.rb +1 -2
  53. data/test/test_index.rb +20 -0
  54. data/test/test_latexbuilder.rb +175 -183
  55. data/test/test_markdownbuilder.rb +41 -5
  56. data/test/test_pdfmaker.rb +130 -0
  57. data/test/test_topbuilder.rb +92 -96
  58. metadata +10 -6
  59. data/lib/review/book/parameters.rb +0 -98
  60. data/test/test_book_parameter.rb +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ede64a20eecee63934877cb311e35313c6ffeb75
4
- data.tar.gz: 629a36d714fd028da9d7b7fda334406f6f128843
3
+ metadata.gz: 7003949429e45e08f404dd70af9d6cbe419d6b74
4
+ data.tar.gz: 081d336549a9141b9172c1dd1f0cc673bce73bbf
5
5
  SHA512:
6
- metadata.gz: a2b09524e28687e28c86df4cb5971bb999e09813db2c52fe1d4af4e25bb3f00ce66eb4570c21a907ca3d3f9d708fde6a82b101c3b8564f34c62ec01976ad19a8
7
- data.tar.gz: 0623f1131de71a1bfcc388c78fd2bce77ad191ba8c338d82f6390c92172457707220a18e626c24e5965dba643bf40aab7d2041a8759eae2de883b4d3d4b281bb
6
+ metadata.gz: 2b74a8d6ff2b7258b7fbcb51b27f2417f066734a96ec86cd75cc0a3d15d91c9d958630e4ed88519d3a0cde307309a08f124231cd0409b093ba337a7fab0c1544
7
+ data.tar.gz: 2fa797cd9ff23cddc563440e07d03de0fd75a130ca73ea7b5192a03175e2e79135c7c6b75e33ae1413981f595b64e69029531f4e499a2119603e84d62f8596a8
data/ChangeLog CHANGED
@@ -1,3 +1,45 @@
1
+ Wed Oct 29 18:54:28 2014 KADO Masanori <kdmsnr@gmail.com>
2
+
3
+ * Release 1.4.0.
4
+
5
+ Thu Sep 18 13:48:24 2014 KADO Masanori <kdmsnr@gmail.com>
6
+
7
+ * bin/review-init, doc/format.rdoc, lib/review/htmlbuilder.rb, lib/review/pdfmaker.rb, lib/review/tocprinter.rb, lib/review/review.tex.erb: change the name of layout template files to "layout.html.erb" and "layout.tex.erb"
8
+
9
+ Wed Aug 20 17:15:04 2014 Masayoshi Takahashi <takahashimm@gmail.com>
10
+
11
+ * lib/review/book/chapter.rb: remove unused method Chapter.for_stdin and Chapter.for_path
12
+
13
+ Wed Aug 20 01:51:02 2014 Masayoshi Takahashi <takahashimm@gmail.com>
14
+
15
+ * lib/review/book/parameters.rb: remove ReVIEW::Book::Parameters
16
+
17
+ Wed Aug 20 00:30:07 2014 Masayoshi Takahashi <takahashimm@gmail.com>
18
+
19
+ * lib/review/book/parameters.rb, lib/review/book/base.rb,
20
+ test/test_book.rb, test/test_book_parameter.rb:
21
+
22
+ remove unused method: ReVIEW::Book::Parameters.default and ReVIEW::Book::Parameters.load
23
+
24
+ Thu Aug 7 16:25:23 2014 KADO Masanori <kdmsnr@gmail.com>
25
+
26
+ * lib/review/book/base.rb (Base#prefaces, postscripts):
27
+ remove implicit prefaces and postscripts.
28
+
29
+ Wed Aug 6 18:55:31 2014 KADO Masanori <kdmsnr@gmail.com>
30
+
31
+ * bin/review-catalog-converter: add review-catalog-converter for
32
+ converting old style catalog files into a new style catalog.yml file.
33
+
34
+ Thu Jul 31 15:05:34 2014 Kenshi Muto <kmuto@debian.org>
35
+
36
+ * lib/review/htmlbuilder.rb, lib/review/idgxmlbuilder.rb:
37
+ provides warning message if image couldn't be found.
38
+
39
+ Sun Jun 29 22:12:58 2014 Masanori Kado <kdmsnr@gmail.com>
40
+
41
+ * Release 1.3.0.
42
+
1
43
  Sun Jun 29 10:40:02 2014 Kenshi Muto <kmuto@debian.org>
2
44
 
3
45
  * Now review-epubmaker-ng becomes review-epubmaker.
@@ -3,6 +3,11 @@
3
3
  {<img src="https://secure.travis-ci.org/kmuto/review.png"/>}[http://travis-ci.org/kmuto/review]
4
4
  {<img src="https://badge.fury.io/rb/review.png" alt="Gem Version" />}[http://badge.fury.io/rb/review]
5
5
 
6
+ home :: https://github.com/kmuto/review
7
+ gems :: https://rubygems.org/gems/review
8
+ wiki :: https://github.com/kmuto/review/wiki
9
+ bugs :: https://github.com/kmuto/review/issues
10
+
6
11
  Re:VIEW is an easy-to-use digital publishing system for books and ebooks.
7
12
 
8
13
  == Format
@@ -31,6 +36,32 @@ And some useful commands.
31
36
  * review-index: generate index with various format.
32
37
  * review-preproc: preprocessor.
33
38
 
39
+ == Installation
40
+
41
+ Install gem yourself as:
42
+
43
+ $ gem install review
44
+
45
+ Or build from source:
46
+
47
+ $ git clone https://github.com/kmuto/review.git
48
+ $ cd review
49
+ $ rake install
50
+
51
+ Or add the `./bin` directory to your $PATH:
52
+
53
+ $ echo "export PATH=PATH_OF_REVIEW/bin:$PATH" >> ~/.profile
54
+
55
+ == Resources
56
+ === Documents
57
+
58
+ * Wiki pages: https://github.com/kmuto/review/wiki
59
+ * doc/* files (in Japanese)
60
+
61
+ === Issues tracker
62
+
63
+ * GitHub: https://github.com/kmuto/review
64
+
34
65
  == Note on Patches/Pull Requests
35
66
 
36
67
  * Fork the project.
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ #
4
+ # Copyright (c) 2014 Masanori Kado
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
+ # Convert old PREDEF/CHAPS/PART/POSTDEF files into catalog.yml.
12
+
13
+ require 'pathname'
14
+ require 'optparse'
15
+ bindir = Pathname.new(__FILE__).realpath.dirname
16
+ $LOAD_PATH.unshift((bindir + '../lib').realpath)
17
+ require 'review/version'
18
+ require 'review/extentions'
19
+
20
+ def main
21
+ opts = OptionParser.new
22
+ opts.version = ReVIEW::VERSION
23
+ opts.banner = "Usage: #{File.basename($0)} dirname"
24
+ opts.on('-h', '--help', 'print this message and quit.') do
25
+ puts opts.help
26
+ exit 0
27
+ end
28
+
29
+ begin
30
+ opts.parse!
31
+ rescue OptionParser::ParseError => err
32
+ $stderr.puts err.message
33
+ $stderr.puts opts.help
34
+ exit 1
35
+ end
36
+
37
+ dir = Dir.pwd
38
+
39
+ # confirmation
40
+ if File.exist?("#{dir}/catalog.yml")
41
+ while true
42
+ print "The catalog.yml already exists. Do you want to overwrite it? [y/n]"
43
+ case gets
44
+ when /^[yY]/
45
+ puts "Start writing..."
46
+ break
47
+ when /^[nN]/, /^$/
48
+ puts "bye."
49
+ exit
50
+ end
51
+ end
52
+ end
53
+
54
+ File.open("#{dir}/catalog.yml", "w") do |catalog|
55
+ # predef
56
+ if File.exist?("#{dir}/PREDEF")
57
+ catalog << parse_predef(File.open("#{dir}/PREDEF").read)
58
+ end
59
+ # chaps and parts
60
+ if File.exist?("#{dir}/CHAPS")
61
+ if File.exist?("#{dir}/PART")
62
+ catalog << parse_parts(File.open("#{dir}/PART").read,
63
+ File.open("#{dir}/CHAPS").read)
64
+ else
65
+ catalog << parse_chaps(File.open("#{dir}/CHAPS").read)
66
+ end
67
+ end
68
+ # postdef
69
+ if File.exist?("#{dir}/POSTDEF")
70
+ postdef = File.open("#{dir}/POSTDEF").read
71
+ while true
72
+ print "Do you want to convert POSTDEF into APPENDIX? [y/n]"
73
+ case gets
74
+ when /^[yY]/
75
+ catalog << parse_postdef(postdef, true)
76
+ break
77
+ when /^[nN]/, /^$/
78
+ catalog << parse_postdef(postdef)
79
+ break
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ puts File.open("#{dir}/catalog.yml").read
86
+ end
87
+
88
+ def _parse(str, header)
89
+ if str.present?
90
+ header + str.split("\n").map{|i| " - #{i}\n" }.join
91
+ else
92
+ header
93
+ end
94
+ end
95
+
96
+ def parse_predef(str)
97
+ header = "PREDEF:\n"
98
+ _parse(str, header) + "\n"
99
+ end
100
+
101
+ def parse_chaps(str)
102
+ header = "CHAPS:\n"
103
+ _parse(str, header) + "\n"
104
+ end
105
+
106
+ def parse_postdef(str, to_appendix = false)
107
+ if to_appendix
108
+ header = "APPENDIX:\n"
109
+ else
110
+ header = "POSTDEF:\n"
111
+ end
112
+ _parse(str, header) + "\n"
113
+ end
114
+
115
+ def parse_parts(parts_str, chaps_str)
116
+ if parts_str.blank? or chaps_str.blank?
117
+ return "CHAPS:\n\n"
118
+ end
119
+
120
+ parts = parts_str.split("\n")
121
+ chaps = chaps_str.split("\n\n")
122
+ "CHAPS:\n" + parts.zip(chaps).map{|k, vs|
123
+ " - #{k}:\n" + vs.split("\n").map{|i| " - #{i}\n"}.join
124
+ }.join + "\n"
125
+ end
126
+
127
+ if File.basename($0) == File.basename(__FILE__)
128
+ main()
129
+ end
@@ -37,6 +37,8 @@ def main
37
37
  "inencoding" => "UTF-8",
38
38
  "outencoding" => "UTF-8"
39
39
  })
40
+ @book = ReVIEW::Book::Base.load_default
41
+ @book.config = @config
40
42
 
41
43
  modes = nil
42
44
  files = ARGV unless ARGV.empty?
@@ -49,7 +51,7 @@ def main
49
51
  @config["outencoding"] = enc
50
52
  }
51
53
  opts.on('-a', '--all-chapters', 'Check all chapters.') {
52
- files = ReVIEW.book.chapters.map {|ent| ent.path }
54
+ files = @book.chapters.map {|ent| ent.path }
53
55
  }
54
56
  opts.on('-s', '--section N', 'Check section N. (deprecated)') {|n|
55
57
  ents = ReVIEW.env.parts[Integer(n) - 1] or
@@ -87,7 +89,7 @@ def main
87
89
  end
88
90
 
89
91
  def check_text(files)
90
- re, neg = words_re(ReVIEW.book.basedir + ReVIEW.book.reject_file)
92
+ re, neg = words_re("#{@book.basedir}/#{@book.reject_file}")
91
93
  files.each do |path|
92
94
  File.open(path) {|f|
93
95
  each_paragraph(f) do |para, lineno|
@@ -90,8 +90,6 @@ def _main
90
90
  opts.on('--stylesheet=file', 'Stylesheet file for HTML (comma separated)') {|files| config["stylesheet"] = files.split(/\s*,\s*/) }
91
91
  opts.on('--mathml', 'Use MathML for TeX equation in HTML') do
92
92
  config["mathml"] = true
93
- require 'math_ml'
94
- require "math_ml/symbol/character_reference"
95
93
  end
96
94
  opts.on('--htmlversion=VERSION', 'HTML version.') do |v|
97
95
  v = v.to_i
@@ -146,7 +144,6 @@ def _main
146
144
  begin
147
145
  config["builder"] = target
148
146
 
149
- ReVIEW.book.config = config
150
147
  compiler = ReVIEW::Compiler.new(load_strategy_class(target, check_only))
151
148
  case mode
152
149
  when :files
@@ -157,7 +154,7 @@ def _main
157
154
 
158
155
  begin
159
156
  ReVIEW::Book::Chapter.intern_pathes(ARGV).each do |chap|
160
- chap.book.config = config
157
+ chap.book.config = config # needs only at the first time
161
158
  result = compiler.compile(chap)
162
159
  if output_filename
163
160
  write output_filename, result
@@ -167,8 +164,10 @@ def _main
167
164
  end
168
165
  rescue => e
169
166
  # PART
170
- part = ReVIEW.book.parts_in_file.select do |part|
171
- ARGV.map{|path| File.basename path}.include? part.path
167
+ book = ReVIEW::Book::Base.load_default
168
+ book.config = config
169
+ part = book.parts_in_file.select do |part_item|
170
+ ARGV.map{|path| File.basename path}.include? part_item.path
172
171
  end
173
172
  if part.present?
174
173
  result = compiler.compile(part.first)
@@ -182,7 +181,8 @@ def _main
182
181
  end
183
182
  end
184
183
  when :dir
185
- book = basedir ? ReVIEW::Book.load(basedir) : ReVIEW.book
184
+ book = basedir ? ReVIEW::Book.load(basedir) : ReVIEW::Book::Base.load_default
185
+ book.config = config
186
186
  book.chapters.each do |chap|
187
187
  str = compiler.compile(chap)
188
188
  write "#{chap.name}#{compiler.strategy.extname}", str unless check_only
@@ -41,6 +41,7 @@ def _main
41
41
  "inencoding" => "UTF-8",
42
42
  "outencoding" => "UTF-8"
43
43
  }
44
+ book = ReVIEW::Book::Base.load_default
44
45
 
45
46
  opts = OptionParser.new
46
47
  opts.version = ReVIEW::VERSION
@@ -52,18 +53,18 @@ def _main
52
53
  }
53
54
  opts.on('-a', '--all', 'print all chapters.') {
54
55
  begin
55
- source = ReVIEW.book
56
+ source = book
56
57
  rescue ReVIEW::Error => err
57
58
  error_exit err.message
58
59
  end
59
60
  }
60
61
  opts.on('-p', '--part N', 'list only part N.') {|n|
61
- source = ReVIEW.book.part(Integer(n)) or
62
+ source = book.part(Integer(n)) or
62
63
  error_exit "part #{n} does not exist in this book"
63
64
  }
64
65
  opts.on('-c', '--chapter C', 'list only chapter C.') {|c|
65
66
  begin
66
- source = ReVIEW::Book::Part.new(nil, 1, [ReVIEW.book.chapter(c)])
67
+ source = ReVIEW::Book::Part.new(nil, 1, [book.chapter(c)])
67
68
  rescue
68
69
  error_exit "chapter #{c} does not exist in this book"
69
70
  end
@@ -71,7 +71,7 @@ end
71
71
 
72
72
  def generate_layout(dir)
73
73
  Dir.mkdir dir + '/layouts'
74
- File.open("#{dir}/layouts/layout.erb", "w") do |file|
74
+ File.open("#{dir}/layouts/layout.html.erb", "w") do |file|
75
75
  file.write <<-EOS
76
76
  <?xml version="1.0" encoding="UTF-8"?>
77
77
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@@ -99,6 +99,8 @@ PREDEF:
99
99
  CHAPS:
100
100
  - #{File.basename(dir)}.re
101
101
 
102
+ APPENDIX:
103
+
102
104
  POSTDEF:
103
105
 
104
106
  EOS
@@ -9,266 +9,10 @@
9
9
  # For details of the GNU LGPL, see the file "COPYING".
10
10
  #
11
11
 
12
- require 'tmpdir'
13
- require 'yaml'
14
- require 'fileutils'
15
- require 'erb'
16
- require 'optparse'
17
-
18
12
  require 'pathname'
19
13
  bindir = Pathname.new(__FILE__).realpath.dirname
20
14
  $LOAD_PATH.unshift((bindir + '../lib').realpath)
21
15
 
22
- require 'review'
23
- require 'review/i18n'
24
-
25
- include ReVIEW::LaTeXUtils
26
-
27
- include FileUtils
28
-
29
- def error(msg)
30
- $stderr.puts "#{File.basename($0, '.*')}: error: #{msg}"
31
- exit 1
32
- end
33
-
34
- def warn(msg)
35
- $stderr.puts "#{File.basename($0, '.*')}: warning: #{msg}"
36
- end
37
-
38
- def check_book(config)
39
- pdf_file = config["bookname"]+".pdf"
40
- if File.exist? pdf_file
41
- error "file already exists:#{pdf_file}"
42
- end
43
- end
44
-
45
- def build_path(config)
46
- "./#{config["bookname"]}-pdf"
47
- end
48
-
49
- def check_compile_status(ignore_errors)
50
- return unless @compile_errors
51
-
52
- if ignore_errors
53
- $stderr.puts "compile error, but try to generate PDF file"
54
- else
55
- error "compile error, No PDF file output."
56
- end
57
- end
58
-
59
-
60
- def main
61
- config = ReVIEW::Configure.values
62
- cmd_config = Hash.new
63
-
64
- opts = OptionParser.new
65
- opts.banner = "Usage: #{File.basename($0)} configfile"
66
- opts.version = ReVIEW::VERSION
67
- opts.on('--help', 'Prints this message and quit.') do
68
- puts opts.help
69
- exit 0
70
- end
71
- opts.on('--[no-]debug', 'Keep temporary files.') do |debug|
72
- cmd_config["debug"] = debug
73
- end
74
- opts.on('--ignore-errors', 'Ignore review-compile errors.') do
75
- cmd_config["ignore-errors"] = true
76
- end
77
-
78
- opts.parse!(ARGV)
79
- if ARGV.size != 1
80
- puts opts.help
81
- exit 0
82
- end
83
- yamlfile = ARGV[0]
84
- config.merge!(YAML.load_file(yamlfile))
85
- # YAML configs will be overridden by command line options.
86
- config.merge!(cmd_config)
87
-
88
- check_book(config)
89
- @basedir = Dir.pwd
90
- @path = build_path(config)
91
- bookname = config["bookname"]
92
- Dir.mkdir(@path)
93
-
94
- @chaps_fnames = Hash.new{|h, key| h[key] = ""}
95
- @compile_errors = nil
96
-
97
- ReVIEW::Book.load(@basedir).parts.each do |part|
98
- if part.name.present?
99
- if part.file?
100
- output_parts(part.name, config)
101
- @chaps_fnames["CHAPS"] << %Q|\\input{#{part.name}.tex}\n|
102
- else
103
- @chaps_fnames["CHAPS"] << %Q|\\part{#{part.name}}\n|
104
- end
105
- end
106
-
107
- part.chapters.each do |chap|
108
- filename = "#{File.basename(chap.path, ".*")}.tex"
109
- output_chaps(filename, config)
110
- @chaps_fnames["PREDEF"] << "\\input{#{filename}}\n" if chap.on_PREDEF?
111
- @chaps_fnames["CHAPS"] << "\\input{#{filename}}\n" if chap.on_CHAPS?
112
- @chaps_fnames["POSTDEF"] << "\\input{#{filename}}\n" if chap.on_POSTDEF?
113
- end
114
- end
115
-
116
- check_compile_status(config["ignore-errors"])
117
-
118
- config["pre_str"] = @chaps_fnames["PREDEF"]
119
- config["chap_str"] = @chaps_fnames["CHAPS"]
120
- config["post_str"] = @chaps_fnames["POSTDEF"]
121
-
122
- config["usepackage"] = ""
123
- if config["texstyle"]
124
- config["usepackage"] = "\\usepackage{#{config['texstyle']}}"
125
- end
126
-
127
- %w[aut csl trl dsr ill cov edt].each do |item|
128
- config[item] = [config[item]] if !config[item].nil? && config[item].instance_of?(String)
129
- end
130
-
131
- copy_images("./images", "#{@path}/images")
132
- copyStyToDir(Dir.pwd + "/sty", @path)
133
- copyStyToDir(Dir.pwd, @path, "tex")
134
-
135
- Dir.chdir(@path) {
136
- template = get_template(config)
137
- File.open("./book.tex", "wb"){|f| f.write(template)}
138
-
139
- ## do compile
140
- enc = config["params"].to_s.split(/\s+/).find{|i| i =~ /\A--outencoding=/ }
141
- kanji = 'utf8'
142
- if enc
143
- kanji = enc.split(/\=/).last.gsub(/-/, '').downcase
144
- end
145
- texcommand = config["texcommand"] || "platex"
146
- 3.times do
147
- system("#{texcommand} -kanji=#{kanji} book.tex")
148
- end
149
- if File.exist?("book.dvi")
150
- system("dvipdfmx -d 5 book.dvi")
151
- end
152
- }
153
- FileUtils.cp("#{@path}/book.pdf", "#{@basedir}/#{bookname}.pdf")
154
-
155
- unless config["debug"]
156
- remove_entry_secure @path
157
- end
158
- end
159
-
160
- def output_chaps(filename, config)
161
- $stderr.puts "compiling #{filename}"
162
- cmd = "#{ReVIEW::MakerHelper.bindir}/review-compile --target=latex --level=#{config["secnolevel"]} --toclevel=#{config["toclevel"]} #{config["params"]} #{filename} > #{@path}/#{filename}"
163
- if system cmd
164
- # OK
165
- else
166
- @compile_errors = true
167
- warn cmd
168
- end
169
- end
170
-
171
- def output_parts(filename, config)
172
- $stderr.puts "compiling #{filename}.tex"
173
- cmd = "review-compile --target=latex --level=#{config["secnolevel"]} --toclevel=#{config["toclevel"]} #{config["params"]} #{filename}.re | sed -e s/\\chapter{/\\part{/ > #{@path}/#{filename}.tex"
174
- if system cmd
175
- # OK
176
- else
177
- @compile_errors = true
178
- warn cmd
179
- end
180
- end
181
-
182
-
183
- def copy_images(from, to)
184
- if File.exist?(from)
185
- Dir.mkdir(to)
186
- ReVIEW::MakerHelper.copy_images_to_dir(from, to)
187
- Dir.chdir(to) do
188
- images = Dir.glob("**/*").find_all{|f|
189
- File.file?(f) and f =~ /\.(jpg|jpeg|png|pdf)\z/
190
- }
191
- system("extractbb", *images)
192
- unless system("extractbb", "-m", *images)
193
- system("ebb", *images)
194
- end
195
- end
196
- end
197
- end
198
-
199
- def make_custom_titlepage(coverfile)
200
- coverfile_sty = coverfile.to_s.sub(/\.[^.]+$/, ".tex")
201
- if File.exist?(coverfile_sty)
202
- File.read(coverfile_sty)
203
- else
204
- nil
205
- end
206
- end
207
-
208
- def get_template(config)
209
- dclass = config["texdocumentclass"] || []
210
- documentclass = dclass[0] || "jsbook"
211
- documentclassoption = dclass[1] || "oneside"
212
-
213
- okuduke = ""
214
- authors = ""
215
- if !config["aut"].nil? && !config["aut"].empty?
216
- okuduke += "著 者 & #{escape_latex(config["aut"].join(ReVIEW::I18n.t("names_splitter")))} \\\\\n"
217
- authors = config["aut"].join(ReVIEW::I18n.t("names_splitter")) + ReVIEW::I18n.t("author_postfix")
218
- end
219
- if !config["csl"].nil? && !config["csl"].empty?
220
- okuduke += "監 修 & #{escape_latex(config["csl"].join(ReVIEW::I18n.t("names_splitter")))} \\\\\n"
221
- authors += " \\\\\n"+config["csl"].join(ReVIEW::I18n.t("names_splitter")) + ReVIEW::I18n.t("supervisor_postfix")
222
- end
223
- if !config["trl"].nil? && !config["trl"].empty?
224
- okuduke += "翻 訳 & #{escape_latex(config["trl"].join(ReVIEW::I18n.t("names_splitter")))} \\\\\n"
225
- authors += " \\\\\n"+config["trl"].join(ReVIEW::I18n.t("names_splitter")) + ReVIEW::I18n.t("translator_postfix")
226
- end
227
- if !config["dsr"].nil? && !config["dsr"].empty?
228
- okuduke += "デザイン & #{escape_latex(config["dsr"].join(ReVIEW::I18n.t("names_splitter")))} \\\\\n"
229
- end
230
- if !config["ill"].nil? && !config["ill"].empty?
231
- okuduke += "イラスト & #{escape_latex(config["ill"].join(ReVIEW::I18n.t("names_splitter")))} \\\\\n"
232
- end
233
- if !config["cov"].nil? && !config["cov"].empty?
234
- okuduke += "表 紙 & #{escape_latex(config["cov"].join(ReVIEW::I18n.t("names_splitter")))} \\\\\n"
235
- end
236
- if !config["edt"].nil? && !config["edt"].empty?
237
- okuduke += "編集者 & #{escape_latex(config["edt"].join(ReVIEW::I18n.t("names_splitter")))} \\\\\n"
238
- end
239
- okuduke += <<EOB
240
- 発行所 & #{config["prt"]} \\\\
241
- EOB
242
-
243
- custom_titlepage = make_custom_titlepage(config["coverfile"])
244
-
245
- template = File.expand_path(File.dirname(__FILE__) +
246
- '/../lib/review/review.tex.erb')
247
- layout_file = File.join(@basedir, "layouts", "layout.tex.erb")
248
- if File.exist?(layout_file)
249
- template = layout_file
250
- end
251
-
252
- erb = ERB.new(File.open(template).read)
253
- values = config # must be 'values' for legacy files
254
- erb.result(binding)
255
- end
256
-
257
- def copyStyToDir(dirname, copybase, extname = "sty")
258
- unless File.directory?(dirname)
259
- $stderr.puts "No such directory - #{dirname}"
260
- return
261
- end
262
-
263
- Dir.open(dirname) {|dir|
264
- dir.each {|fname|
265
- next if fname =~ /^\./
266
- if fname =~ /\.(#{extname})$/i
267
- Dir.mkdir(copybase) unless File.exist?(copybase)
268
- FileUtils.cp "#{dirname}/#{fname}", copybase
269
- end
270
- }
271
- }
272
- end
16
+ require 'review/pdfmaker'
273
17
 
274
- main
18
+ ReVIEW::PDFMaker.execute(*ARGV)