review 1.7.2 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -43
  3. data/.travis.yml +0 -9
  4. data/ChangeLog +0 -16
  5. data/Gemfile +1 -0
  6. data/README.rdoc +1 -1
  7. data/Rakefile +12 -1
  8. data/bin/review-check +21 -8
  9. data/bin/review-compile +15 -9
  10. data/bin/review-epubmaker-legacy +6 -6
  11. data/bin/review-index +13 -2
  12. data/bin/review-init +18 -12
  13. data/bin/review-preproc +14 -1
  14. data/bin/review-validate +1 -1
  15. data/bin/review-vol +13 -1
  16. data/doc/quickstart.ja.md +1 -1
  17. data/doc/quickstart.md +1 -1
  18. data/lib/epubmaker/content.rb +3 -3
  19. data/lib/epubmaker/epubcommon.rb +108 -91
  20. data/lib/epubmaker/epubv2.rb +67 -14
  21. data/lib/epubmaker/epubv3.rb +59 -25
  22. data/lib/epubmaker/producer.rb +1 -13
  23. data/lib/lineinput.rb +0 -48
  24. data/lib/review/book/base.rb +4 -12
  25. data/lib/review/book/compilable.rb +3 -1
  26. data/lib/review/book/index.rb +4 -4
  27. data/lib/review/builder.rb +54 -47
  28. data/lib/review/compiler.rb +4662 -326
  29. data/lib/review/compiler/literals_1_8.kpeg +19 -0
  30. data/lib/review/compiler/literals_1_8.rb +432 -0
  31. data/lib/review/compiler/literals_1_9.kpeg +22 -0
  32. data/lib/review/compiler/literals_1_9.rb +435 -0
  33. data/lib/review/configure.rb +8 -20
  34. data/lib/review/epubbuilder.rb +1 -1
  35. data/lib/review/epubmaker.rb +122 -52
  36. data/lib/review/ewbbuilder.rb +4 -4
  37. data/lib/review/exception.rb +1 -1
  38. data/lib/review/extentions.rb +1 -0
  39. data/lib/review/extentions/array.rb +25 -0
  40. data/lib/review/htmlbuilder.rb +286 -275
  41. data/lib/review/htmllayout.rb +0 -2
  42. data/lib/review/htmlutils.rb +4 -4
  43. data/lib/review/i18n.rb +2 -6
  44. data/lib/review/i18n.yml +1 -1
  45. data/lib/review/idgxmlbuilder.rb +239 -204
  46. data/lib/review/inaobuilder.rb +75 -73
  47. data/lib/review/latexbuilder.rb +265 -219
  48. data/lib/review/latexutils.rb +6 -6
  49. data/lib/review/layout.tex.erb +1 -1
  50. data/lib/review/location.rb +24 -0
  51. data/lib/review/markdownbuilder.rb +124 -79
  52. data/lib/review/node.rb +267 -0
  53. data/lib/review/pdfmaker.rb +92 -92
  54. data/lib/review/preprocessor.rb +51 -14
  55. data/lib/review/review.kpeg +724 -0
  56. data/lib/review/textbuilder.rb +1 -1
  57. data/lib/review/textutils.rb +24 -18
  58. data/lib/review/tocparser.rb +3 -3
  59. data/lib/review/tocprinter.rb +31 -8
  60. data/lib/review/topbuilder.rb +119 -111
  61. data/lib/review/unfold.rb +2 -2
  62. data/lib/review/version.rb +1 -1
  63. data/review.gemspec +2 -2
  64. data/rubocop-todo.yml +456 -0
  65. data/test/assets/test_template.tex +1 -1
  66. data/test/sample-book/src/config.yml +0 -1
  67. data/test/test.re +1 -1
  68. data/test/test_book.rb +4 -4
  69. data/test/test_book_chapter.rb +70 -0
  70. data/test/test_book_part.rb +1 -1
  71. data/test/test_builder.rb +6 -28
  72. data/test/test_compiler.rb +59 -14
  73. data/test/test_helper.rb +47 -4
  74. data/test/test_htmlbuilder.rb +104 -73
  75. data/test/test_i18n.rb +5 -3
  76. data/test/test_idgxmlbuilder.rb +5 -2
  77. data/test/test_inaobuilder.rb +4 -2
  78. data/test/test_latexbuilder.rb +18 -37
  79. data/test/test_lineinput.rb +25 -4
  80. data/test/test_markdownbuilder.rb +4 -22
  81. data/test/test_pdfmaker.rb +12 -11
  82. data/test/test_textutils.rb +0 -36
  83. data/test/test_topbuilder.rb +2 -0
  84. metadata +14 -28
  85. data/.rubocop_todo.yml +0 -605
  86. data/Dockerfile +0 -22
  87. data/doc/NEWS.ja.md +0 -362
  88. data/doc/NEWS.md +0 -366
  89. data/lib/review/htmltoc.rb +0 -45
  90. data/lib/review/template.rb +0 -21
  91. data/templates/html/layout-html5.html.erb +0 -17
  92. data/templates/html/layout-xhtml1.html.erb +0 -20
  93. data/templates/ncx/epubv2.ncx.erb +0 -11
  94. data/templates/opf/epubv2.opf.erb +0 -21
  95. data/templates/opf/epubv3.opf.erb +0 -18
  96. data/templates/xml/container.xml.erb +0 -6
  97. data/test/assets/test.xml.erb +0 -3
  98. data/test/sample-book/src/config-epub2.yml +0 -186
  99. data/test/test_configure.rb +0 -50
  100. data/test/test_htmltoc.rb +0 -32
  101. data/test/test_template.rb +0 -26
@@ -14,4 +14,4 @@ module ReVIEW
14
14
  class TEXTBuilder < TOPBuilder
15
15
  end
16
16
 
17
- end # module ReVIEW
17
+ end # module ReVIEW
@@ -13,26 +13,32 @@ module ReVIEW
13
13
  }
14
14
  end
15
15
 
16
- def split_paragraph(lines)
17
- pre = pre_paragraph
18
- post = post_paragraph
19
-
20
- blocked_lines = [[]]
21
- lines.each {|element|
22
- if element == ""
23
- if blocked_lines.last != []
24
- blocked_lines << []
25
- end
26
- else
27
- blocked_lines.last << element
28
- end
29
- }
30
-
31
- if !pre.nil? and !post.nil?
32
- blocked_lines.map!{|i| [pre] + i + [post] }
16
+ def convert_inencoding(str, enc)
17
+ case enc
18
+ when /^EUC$/i
19
+ NKF.nkf("-E -w -m0x", str)
20
+ when /^SJIS$/i
21
+ NKF.nkf("-S -w -m0x", str)
22
+ when /^JIS$/i
23
+ NKF.nkf("-J -w -m0x", str)
24
+ when /^UTF-8$/i
25
+ NKF.nkf("-W -w -m0x", str)
26
+ else
27
+ NKF.nkf("-w -m0 -m0x", str)
33
28
  end
29
+ end
34
30
 
35
- blocked_lines.map{|l| l.join("")}
31
+ def convert_outencoding(str, enc)
32
+ case enc
33
+ when /^EUC$/i
34
+ NKF.nkf("-W -e -m0x", str)
35
+ when /^SJIS$/i
36
+ NKF.nkf("-W -s -m0x", str)
37
+ when /^JIS$/i
38
+ NKF.nkf("-W -j -m0x", str)
39
+ else
40
+ str
41
+ end
36
42
  end
37
43
  end
38
44
  end
@@ -323,11 +323,11 @@ module ReVIEW
323
323
  end
324
324
  end
325
325
 
326
- class Book::Base # reopen
326
+ class Book::Base # reopen
327
327
  include TOCRoot
328
328
  end
329
329
 
330
- class Book::ChapterSet # reopen
330
+ class Book::ChapterSet # reopen
331
331
  include TOCRoot
332
332
  end
333
333
 
@@ -335,7 +335,7 @@ module ReVIEW
335
335
  include TOCRoot
336
336
  end
337
337
 
338
- class Book::Chapter # reopen
338
+ class Book::Chapter # reopen
339
339
  def toc
340
340
  @toc ||= TOCParser.parse(self)
341
341
  unless @toc.size == 1
@@ -13,13 +13,14 @@
13
13
 
14
14
  require 'review/htmlutils'
15
15
  require 'review/htmllayout'
16
+ require 'nkf'
16
17
 
17
18
  module ReVIEW
18
19
 
19
20
  class TOCPrinter
20
21
 
21
22
  def TOCPrinter.default_upper_level
22
- 99 # no one use 99 level nest
23
+ 99 # no one use 99 level nest
23
24
  end
24
25
 
25
26
  def initialize(print_upper, param)
@@ -30,6 +31,28 @@ module ReVIEW
30
31
  def print?(level)
31
32
  level <= @print_upper
32
33
  end
34
+
35
+ def nkffilter(line)
36
+ inc = ""
37
+ outc = "-w"
38
+ if @config["inencoding"] =~ /^EUC$/
39
+ inc = "-E"
40
+ elsif @config["inencoding"] =~ /^SJIS$/
41
+ inc = "-S"
42
+ elsif @config["inencoding"] =~ /^JIS$/
43
+ inc = "-J"
44
+ end
45
+
46
+ if @config["outencoding"] =~ /^EUC$/
47
+ outc = "-e"
48
+ elsif @config["outencoding"] =~ /^SJIS$/
49
+ outc = "-s"
50
+ elsif @config["outencoding"] =~ /^JIS$/
51
+ outc = "-j"
52
+ end
53
+
54
+ NKF.nkf("#{inc} #{outc}", line)
55
+ end
33
56
  end
34
57
 
35
58
 
@@ -56,11 +79,11 @@ module ReVIEW
56
79
  printf "%3s %3dKB %6dC %5dL %s (%s)\n",
57
80
  chapnumstr(node.number),
58
81
  vol.kbytes, vol.chars, vol.lines,
59
- node.label, node.chapter_id
82
+ nkffilter(node.label), node.chapter_id
60
83
  else
61
84
  printf "%17s %5dL %s\n",
62
85
  '', node.estimated_lines,
63
- " #{' ' * (node.level - 1)}#{number} #{node.label}"
86
+ nkffilter(" #{' ' * (node.level - 1)}#{number} #{node.label}")
64
87
  end
65
88
  end
66
89
 
@@ -71,7 +94,7 @@ module ReVIEW
71
94
  def volume_columns(level, volstr)
72
95
  cols = ["", "", "", nil]
73
96
  cols[level - 1] = volstr
74
- cols[0, 3] # does not display volume of level-4 section
97
+ cols[0, 3] # does not display volume of level-4 section
75
98
  end
76
99
 
77
100
  end
@@ -163,7 +186,7 @@ module ReVIEW
163
186
  class IDGTOCPrinter < TOCPrinter
164
187
  def print_book(book)
165
188
  puts %Q(<?xml version="1.0" encoding="UTF-8"?>)
166
- puts %Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには?
189
+ puts nkffilter(%Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>)) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには?
167
190
  puts %Q(<ul aid:pstyle='ul-partblock'>)
168
191
  print_children book
169
192
  puts %Q(</ul></doc>)
@@ -185,15 +208,15 @@ module ReVIEW
185
208
  if node.chapter?
186
209
  vol = node.volume
187
210
  printf "<li aid:pstyle='ul-part'>%s</li>\n",
188
- "#{chapnumstr(node.number)}#{node.label}"
211
+ nkffilter("#{chapnumstr(node.number)}#{node.label}")
189
212
  else
190
213
  printf "<li>%-#{LABEL_LEN}s\n",
191
- " #{' ' * (node.level - 1)}#{seq} #{node.label}</li>"
214
+ nkffilter(" #{' ' * (node.level - 1)}#{seq} #{node.label}</li>")
192
215
  end
193
216
  end
194
217
 
195
218
  def chapnumstr(n)
196
- n ? sprintf('第%d章 ', n) : ''
219
+ n ? nkffilter(sprintf('第%d章 ', n)) : ''
197
220
  end
198
221
 
199
222
  def volume_columns(level, volstr)
@@ -22,7 +22,7 @@ module ReVIEW
22
22
  }
23
23
  Compiler.defsingle(:dtp, 1)
24
24
 
25
- Compiler.defblock(:insn, 1)
25
+ Compiler.defcodeblock(:insn, 1)
26
26
  Compiler.defblock(:memo, 0..1)
27
27
  Compiler.defblock(:tip, 0..1)
28
28
  Compiler.defblock(:info, 0..1)
@@ -55,7 +55,6 @@ module ReVIEW
55
55
  @subsection = 0
56
56
  @subsubsection = 0
57
57
  @subsubsubsection = 0
58
- @blank_seen = true
59
58
 
60
59
  @titles = {
61
60
  "emlist" => "インラインリスト",
@@ -102,28 +101,6 @@ module ReVIEW
102
101
  end
103
102
  private :builder_init_file
104
103
 
105
- def print(s)
106
- @blank_seen = false
107
- super
108
- end
109
- private :print
110
-
111
- def puts(s)
112
- @blank_seen = false
113
- super
114
- end
115
- private :puts
116
-
117
- def blank
118
- @output.puts unless @blank_seen
119
- @blank_seen = true
120
- end
121
- private :blank
122
-
123
- def result
124
- @output.string
125
- end
126
-
127
104
  def warn(msg)
128
105
  $stderr.puts "#{@location.filename}:#{@location.lineno}: warning: #{msg}"
129
106
  end
@@ -137,8 +114,8 @@ module ReVIEW
137
114
  end
138
115
 
139
116
  def headline(level, label, caption)
117
+ buf = ""
140
118
  prefix = ""
141
- blank
142
119
  case level
143
120
  when 1
144
121
  if @chapter.number.to_s =~ /\A\d+\Z/
@@ -172,62 +149,67 @@ module ReVIEW
172
149
  raise "caption level too deep or unsupported: #{level}"
173
150
  end
174
151
  prefix = "" if (level.to_i > @book.config["secnolevel"])
175
- puts "■H#{level}■#{prefix}#{compile_inline(caption)}"
152
+ buf << "■H#{level}■#{prefix}#{caption}\n"
153
+ buf
176
154
  end
177
155
 
178
156
  def ul_begin
179
- blank
157
+ "\n"
180
158
  end
181
159
 
182
160
  def ul_item(lines)
183
- puts "●\t#{lines.join}"
161
+ "●\t#{lines.join}\n"
184
162
  end
185
163
 
186
164
  def ul_end
187
- blank
165
+ "\n"
188
166
  end
189
167
 
190
168
  def ol_begin
191
- blank
192
169
  @olitem = 0
170
+ "\n"
193
171
  end
194
172
 
195
173
  def ol_item(lines, num)
196
- puts "#{num}\t#{lines.join}"
174
+ "#{num}\t#{lines.join}\n"
197
175
  end
198
176
 
199
177
  def ol_end
200
- blank
201
178
  @olitem = nil
179
+ "\n"
202
180
  end
203
181
 
204
182
  def dl_begin
205
- blank
183
+ "\n"
206
184
  end
207
185
 
208
186
  def dt(line)
209
- puts "★#{line}"
187
+ "★#{line}☆\n"
210
188
  end
211
189
 
212
190
  def dd(lines)
213
- split_paragraph(lines).each do |paragraph|
214
- puts "\t#{paragraph.gsub(/\n/, '')}"
191
+ buf = ""
192
+ lines.each do |paragraph|
193
+ buf << "\t#{paragraph.gsub(/\n/, '')}\n"
215
194
  end
195
+ buf
216
196
  end
217
197
 
218
198
  def dl_end
219
- blank
199
+ "\n"
220
200
  end
221
201
 
222
202
  def paragraph(lines)
223
- puts lines.join
203
+ lines.join+"\n"
224
204
  end
225
205
 
226
206
  def read(lines)
227
- puts "◆→開始:#{@titles["lead"]}←◆"
228
- puts split_paragraph(lines).join("\n")
229
- puts "◆→終了:#{@titles["lead"]}←◆"
230
- blank
207
+ buf = ""
208
+ buf << "◆→開始:#{@titles["lead"]}←◆\n"
209
+ buf << lines.join("\n") << "\n"
210
+ buf << "◆→終了:#{@titles["lead"]}←◆\n"
211
+ buf << "\n"
212
+ buf
231
213
  end
232
214
 
233
215
  alias_method :lead, :read
@@ -239,44 +221,50 @@ module ReVIEW
239
221
  else
240
222
  %Q[#{I18n.t("list")}#{I18n.t("format_number", [get_chap(chapter), @chapter.list(id).number])}]
241
223
  end
242
-
243
224
  end
244
225
 
245
226
  def list_header(id, caption, lang)
246
- blank
247
- puts "◆→開始:#{@titles["list"]}←◆"
227
+ buf = ""
228
+ #buf << "\n"
229
+ buf << "◆→開始:#{@titles["list"]}←◆\n"
248
230
  if get_chap.nil?
249
- puts %Q[#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}]
231
+ buf << %Q[#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}] << "\n"
250
232
  else
251
- puts %Q[#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}]
233
+ buf << %Q[#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}] << "\n"
252
234
  end
253
- blank
235
+ buf << "\n"
236
+ buf
254
237
  end
255
238
 
256
239
  def list_body(id, lines, lang)
240
+ buf = ""
257
241
  lines.each do |line|
258
- puts detab(line)
242
+ buf << detab(line) << "\n"
259
243
  end
260
- puts "◆→終了:#{@titles["list"]}←◆"
261
- blank
244
+ buf << "◆→終了:#{@titles["list"]}←◆\n"
245
+ buf << "\n"
246
+ buf
262
247
  end
263
248
 
264
249
  def base_block(type, lines, caption = nil)
265
- blank
266
- puts "◆→開始:#{@titles[type]}←◆"
267
- puts "■#{compile_inline(caption)}" unless caption.nil?
268
- puts lines.join("\n")
269
- puts "◆→終了:#{@titles[type]}←◆"
270
- blank
250
+ buf = ""
251
+ buf << "\n"
252
+ buf << "◆→開始:#{@titles[type]}←◆\n"
253
+ buf << "■#{caption}\n" unless caption.nil?
254
+ buf << lines.join("")
255
+ buf << "◆→終了:#{@titles[type]}←◆\n"
256
+ buf << "\n"
257
+ buf
271
258
  end
272
259
 
273
260
  def base_parablock(type, lines, caption = nil)
274
- blank
275
- puts "◆→開始:#{@titles[type]}←◆"
276
- puts "■#{compile_inline(caption)}" unless caption.nil?
277
- puts split_paragraph(lines).join("\n")
278
- puts "◆→終了:#{@titles[type]}←◆"
279
- blank
261
+ buf = ""
262
+ buf << "◆→開始:#{@titles[type]}←◆\n"
263
+ buf << "■#{caption}\n" unless caption.nil?
264
+ buf << lines.join("")
265
+ buf << "◆→終了:#{@titles[type]}←◆\n"
266
+ buf << "\n"
267
+ buf
280
268
  end
281
269
 
282
270
  def emlist(lines, caption = nil, lang = nil)
@@ -284,23 +272,26 @@ module ReVIEW
284
272
  end
285
273
 
286
274
  def emlistnum(lines, caption = nil, lang = nil)
287
- blank
288
- puts "◆→開始:#{@titles["emlist"]}←◆"
289
- puts "■#{compile_inline(caption)}" unless caption.nil?
275
+ buf = ""
276
+ buf << "◆→開始:#{@titles["emlist"]}←◆\n"
277
+ buf << "■#{caption}\n" unless caption.nil?
290
278
  _lines = []
291
279
  lines.each_with_index do |line, i|
292
- puts (i + 1).to_s.rjust(2) + ": #{line}"
280
+ buf << (i + 1).to_s.rjust(2) + ": #{line}\n"
293
281
  end
294
- puts "◆→終了:#{@titles["emlist"]}←◆"
295
- blank
282
+ buf << "◆→終了:#{@titles["emlist"]}←◆\n"
283
+ buf << "\n"
284
+ buf
296
285
  end
297
286
 
298
287
  def listnum_body(lines, lang)
288
+ buf = ""
299
289
  lines.each_with_index do |line, i|
300
- puts (i + 1).to_s.rjust(2) + ": #{line}"
290
+ buf << (i + 1).to_s.rjust(2) + ": #{line}\n"
301
291
  end
302
- puts "◆→終了:#{@titles["list"]}←◆"
303
- blank
292
+ buf << "◆→終了:#{@titles["list"]}←◆\n"
293
+ buf << "\n"
294
+ buf
304
295
  end
305
296
 
306
297
  def cmd(lines, caption = nil)
@@ -330,48 +321,57 @@ module ReVIEW
330
321
  end
331
322
 
332
323
  def image(lines, id, caption, metric=nil)
333
- blank
334
- puts "◆→開始:#{@titles["image"]}←◆"
324
+ buf = ""
325
+ #buf << "\n"
326
+ buf << "◆→開始:#{@titles["image"]}←◆\n"
335
327
  if get_chap.nil?
336
- puts "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
328
+ buf << "#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}\n"
337
329
  else
338
- puts "#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
330
+ buf << "#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}\n"
339
331
  end
340
- blank
332
+ buf << "\n"
341
333
  if @chapter.image(id).bound?
342
- puts "◆→#{@chapter.image(id).path}←◆"
334
+ buf << "◆→#{@chapter.image(id).path}←◆\n"
343
335
  else
344
336
  lines.each do |line|
345
- puts line
337
+ buf << line << "\n"
346
338
  end
347
339
  end
348
- puts "◆→終了:#{@titles["image"]}←◆"
349
- blank
340
+ buf << "◆→終了:#{@titles["image"]}←◆\n"
341
+ buf << "\n"
342
+ buf
350
343
  end
351
344
 
352
345
  def texequation(lines)
353
- puts "◆→開始:#{@titles["texequation"]}←◆"
354
- puts "#{lines.join("\n")}"
355
- puts "◆→終了:#{@titles["texequation"]}←◆"
356
- blank
346
+ buf = ""
347
+ buf << "◆→開始:#{@titles["texequation"]}←◆\n"
348
+ buf << "#{lines.join("\n")}\n"
349
+ buf << "◆→終了:#{@titles["texequation"]}←◆\n"
350
+ buf << "\n"
351
+ buf
357
352
  end
358
353
 
359
354
  def table_header(id, caption)
360
- blank
361
- puts "◆→開始:#{@titles["table"]}←◆"
355
+ buf = ""
356
+ buf << "\n"
357
+ buf << "◆→開始:#{@titles["table"]}←◆\n"
362
358
  if get_chap.nil?
363
- puts "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
359
+ buf << "#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}\n"
364
360
  else
365
- puts "#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}"
361
+ buf << "#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}\n"
366
362
  end
367
- blank
363
+ buf << "\n"
364
+ buf
368
365
  end
369
366
 
370
367
  def table_begin(ncols)
368
+ ""
371
369
  end
372
370
 
373
371
  def tr(rows)
374
- puts rows.join("\t")
372
+ buf = ""
373
+ buf << rows.join("\t") << "\n"
374
+ buf
375
375
  end
376
376
 
377
377
  def th(str)
@@ -383,19 +383,21 @@ module ReVIEW
383
383
  end
384
384
 
385
385
  def table_end
386
- puts "◆→終了:#{@titles["table"]}←◆"
387
- blank
386
+ buf = ""
387
+ buf << "◆→終了:#{@titles["table"]}←◆\n"
388
+ buf << "\n"
389
+ buf
388
390
  end
389
391
 
390
392
  def comment(lines, comment = nil)
391
393
  lines ||= []
392
394
  lines.unshift comment unless comment.blank?
393
395
  str = lines.join("")
394
- puts "◆→DTP連絡:#{str}←◆"
396
+ "◆→DTP連絡:#{str}←◆\n"
395
397
  end
396
398
 
397
399
  def footnote(id, str)
398
- puts "【注#{@chapter.footnote(id).number}】#{compile_inline(str)}"
400
+ "【注#{@chapter.footnote(id).number}】#{str}\n"
399
401
  end
400
402
 
401
403
  def inline_fn(id)
@@ -511,25 +513,28 @@ module ReVIEW
511
513
  end
512
514
 
513
515
  def noindent
514
- puts "◆→DTP連絡:次の1行インデントなし←◆"
516
+ "◆→DTP連絡:次の1行インデントなし←◆\n"
515
517
  end
516
518
 
517
519
  def nonum_begin(level, label, caption)
518
- puts "■H#{level}■#{compile_inline(caption)}"
520
+ "■H#{level}■#{caption}\n"
519
521
  end
520
522
 
521
523
  def nonum_end(level)
522
524
  end
523
525
 
524
526
  def common_column_begin(type, caption)
525
- blank
526
- puts "◆→開始:#{@titles[type]}←◆"
527
- puts %Q[■#{compile_inline(caption)}]
527
+ buf = ""
528
+ buf << "◆→開始:#{@titles[type]}←◆\n"
529
+ buf << %Q[■#{caption}\n]
530
+ buf
528
531
  end
529
532
 
530
533
  def common_column_end(type)
531
- puts %Q[◆→終了:#{@titles[type]}←◆]
532
- blank
534
+ buf = ""
535
+ buf << %Q[◆→終了:#{@titles[type]}←◆\n]
536
+ buf << "\n"
537
+ buf
533
538
  end
534
539
 
535
540
  def column_begin(level, label, caption)
@@ -679,15 +684,17 @@ module ReVIEW
679
684
  alias_method :box, :insn
680
685
 
681
686
  def indepimage(id, caption=nil, metric=nil)
682
- blank
687
+ buf = ""
688
+ buf << "\n"
683
689
  begin
684
- puts "◆→画像 #{@chapter.image(id).path.sub(/\A\.\//, "")} #{metric.join(" ")}←◆"
690
+ buf << "◆→画像 #{@chapter.image(id).path.sub(/\A\.\//, "")} #{metric.join(" ")}←◆\n"
685
691
  rescue
686
692
  warn "no such image: #{id}"
687
- puts "◆→画像 #{id}←◆"
693
+ buf << "◆→画像 #{id}←◆\n"
688
694
  end
689
- puts "図 #{compile_inline(caption)}" if caption.present?
690
- blank
695
+ buf << "図 #{caption}\n" if caption.present?
696
+ buf << "\n"
697
+ buf
691
698
  end
692
699
 
693
700
  alias_method :numberlessimage, :indepimage
@@ -741,7 +748,8 @@ module ReVIEW
741
748
  def inline_chapref(id)
742
749
  chs = ["", "「", "」"]
743
750
  unless @book.config["chapref"].nil?
744
- _chs = @book.config["chapref"].split(",")
751
+ _chs = convert_inencoding(@book.config["chapref"],
752
+ @book.config["inencoding"]).split(",")
745
753
  if _chs.size != 3
746
754
  error "--chapsplitter must have exactly 3 parameters with comma."
747
755
  else
@@ -755,7 +763,7 @@ module ReVIEW
755
763
  nofunc_text("[UnknownChapter:#{id}]")
756
764
  end
757
765
 
758
- def source(lines, caption = nil, lang = nil)
766
+ def source(lines, caption = nil)
759
767
  base_block "source", lines, caption
760
768
  end
761
769
 
@@ -774,7 +782,7 @@ module ReVIEW
774
782
  end
775
783
 
776
784
  def circle_begin(level, label, caption)
777
- puts "・\t#{caption}"
785
+ "・\t#{caption}\n"
778
786
  end
779
787
 
780
788
  def circle_end(level)
@@ -786,4 +794,4 @@ module ReVIEW
786
794
 
787
795
  end
788
796
 
789
- end # module ReVIEW
797
+ end # module ReVIEW