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
@@ -11,8 +11,6 @@ class HTMLLayout
11
11
  @next = params['next']
12
12
  @prev = params['prev']
13
13
  @builder = params['builder']
14
- @language = params['language']
15
- @stylesheets = params['stylesheets']
16
14
  @template = template
17
15
  end
18
16
  attr_reader :body, :title, :toc
@@ -40,7 +40,7 @@ module ReVIEW
40
40
  str.gsub('-', '-')
41
41
  end
42
42
 
43
- def highlight?
43
+ def highlight_pygments?
44
44
  @book.config["pygments"].present? ||
45
45
  @book.config["highlight"] && @book.config["highlight"]["html"] == "pygments"
46
46
  end
@@ -58,7 +58,7 @@ module ReVIEW
58
58
  if ops[:options] && ops[:options].kind_of?(Hash)
59
59
  options.merge!(ops[:options])
60
60
  end
61
- return body if !highlight?
61
+ return body if !highlight_pygments?
62
62
 
63
63
  begin
64
64
  require 'pygments'
@@ -72,7 +72,7 @@ module ReVIEW
72
72
  body
73
73
  end
74
74
  rescue LoadError
75
- body
75
+ body
76
76
  end
77
77
  end
78
78
 
@@ -87,4 +87,4 @@ module ReVIEW
87
87
  end
88
88
  end
89
89
 
90
- end # module ReVIEW
90
+ end # module ReVIEW
data/lib/review/i18n.rb CHANGED
@@ -38,7 +38,7 @@ module ReVIEW
38
38
  end
39
39
 
40
40
  class << self
41
- alias_method :v, :t ## for EPUBMaker backward compatibility
41
+ alias v t ## for EPUBMaker backward compatibility
42
42
  end
43
43
 
44
44
  def self.update(user_i18n, locale = nil)
@@ -65,11 +65,7 @@ module ReVIEW
65
65
  locale = user_i18n["locale"]
66
66
  if locale
67
67
  user_i18n.delete("locale")
68
- if @store[locale]
69
- @store[locale].merge!(user_i18n)
70
- else
71
- @store[locale] = user_i18n
72
- end
68
+ @store[locale].merge!(user_i18n)
73
69
  else
74
70
  user_i18n.each do |key, values|
75
71
  raise KeyError, "Invalid locale file: #{path}" unless values.kind_of? Hash
data/lib/review/i18n.yml CHANGED
@@ -116,7 +116,7 @@ en:
116
116
  profiletitle: "Profile"
117
117
  backcovertitle: "Back Cover"
118
118
 
119
- zh-TW:
119
+ zh_TW:
120
120
  image: 圖
121
121
  table: 表
122
122
  list: List
@@ -23,7 +23,7 @@ module ReVIEW
23
23
  [:ttbold, :hint, :maru, :keytop, :labelref, :ref, :pageref, :balloon].each {|e| Compiler.definline(e) }
24
24
  Compiler.defsingle(:dtp, 1)
25
25
 
26
- Compiler.defblock(:insn, 0..1)
26
+ Compiler.defcodeblock(:insn, 1)
27
27
  Compiler.defblock(:memo, 0..1)
28
28
  Compiler.defblock(:tip, 0..1)
29
29
  Compiler.defblock(:info, 0..1)
@@ -42,14 +42,6 @@ module ReVIEW
42
42
  Compiler.defblock(:expert, 0)
43
43
  Compiler.defblock(:rawblock, 0)
44
44
 
45
- def pre_paragraph
46
- '<p>'
47
- end
48
-
49
- def post_paragraph
50
- '</p>'
51
- end
52
-
53
45
  def extname
54
46
  '.xml'
55
47
  end
@@ -74,14 +66,13 @@ module ReVIEW
74
66
  @tsize = nil
75
67
  @texblockequation = 0
76
68
  @texinlineequation = 0
77
- print %Q(<?xml version="1.0" encoding="UTF-8"?>\n)
78
- print %Q(<#{@rootelement} xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">)
69
+
70
+ @output << %Q(<?xml version="1.0" encoding="UTF-8"?>\n)
71
+ @output << %Q(<#{@rootelement} xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">)
79
72
  if @book.config["nolf"].present?
80
- IDGXMLBuilder.class_eval do
81
- def puts(arg)
82
- print arg
83
- end
84
- end
73
+ @lf = ""
74
+ else
75
+ @lf = "\n"
85
76
  end
86
77
  @secttags = true unless @book.config["structuredxml"].nil?
87
78
  end
@@ -102,7 +93,7 @@ module ReVIEW
102
93
  def warn(msg)
103
94
  if @no_error
104
95
  @warns.push [@location.filename, @location.lineno, msg]
105
- puts "----WARNING: #{escape_html(msg)}----"
96
+ buf << "----WARNING: #{escape_html(msg)}----" << @lf
106
97
  else
107
98
  $stderr.puts "#{@location}: warning: #{msg}"
108
99
  end
@@ -111,7 +102,7 @@ module ReVIEW
111
102
  def error(msg)
112
103
  if @no_error
113
104
  @errors.push [@location.filename, @location.lineno, msg]
114
- puts "----ERROR: #{escape_html(msg)}----"
105
+ buf << "----ERROR: #{escape_html(msg)}----" << @lf
115
106
  else
116
107
  $stderr.puts "#{@location}: error: #{msg}"
117
108
  end
@@ -142,63 +133,57 @@ module ReVIEW
142
133
  end
143
134
 
144
135
  def headline(level, label, caption)
136
+ buf = ""
145
137
  case level
146
138
  when 1
147
139
  unless @secttags.nil?
148
- print "</sect4>" if @subsubsubsection > 0
149
- print "</sect3>" if @subsubsection > 0
150
- print "</sect2>" if @subsection > 0
151
- print "</sect>" if @section > 0
140
+ buf << "</sect4>" if @subsubsubsection > 0
141
+ buf << "</sect3>" if @subsubsection > 0
142
+ buf << "</sect2>" if @subsection > 0
143
+ buf << "</sect>" if @section > 0
152
144
  end
153
-
154
- print %Q(<chapter id="chap:#{@chapter.number}">) unless @secttags.nil?
155
-
145
+ buf << %Q(<chapter id="chap:#{@chapter.number}">) unless @secttags.nil?
156
146
  @section = 0
157
147
  @subsection = 0
158
148
  @subsubsection = 0
159
149
  @subsubsubsection = 0
160
150
  when 2
161
151
  unless @secttags.nil?
162
- print "</sect4>" if @subsubsubsection > 0
163
- print "</sect3>" if @subsubsection > 0
164
- print "</sect2>" if @subsection > 0
165
- print "</sect>" if @section > 0
152
+ buf << "</sect4>" if @subsubsubsection > 0
153
+ buf << "</sect3>" if @subsubsection > 0
154
+ buf << "</sect2>" if @subsection > 0
155
+ buf << "</sect>" if @section > 0
166
156
  end
167
157
  @section += 1
168
- print %Q(<sect id="sect:#{@chapter.number}.#{@section}">) unless @secttags.nil?
169
-
158
+ buf << %Q(<sect id="sect:#{@chapter.number}.#{@section}">) unless @secttags.nil?
170
159
  @subsection = 0
171
160
  @subsubsection = 0
172
161
  @subsubsubsection = 0
173
162
  when 3
174
163
  unless @secttags.nil?
175
- print "</sect4>" if @subsubsubsection > 0
176
- print "</sect3>" if @subsubsection > 0
177
- print "</sect2>" if @subsection > 0
164
+ buf << "</sect4>" if @subsubsubsection > 0
165
+ buf << "</sect3>" if @subsubsection > 0
166
+ buf << "</sect2>" if @subsection > 0
178
167
  end
179
-
180
168
  @subsection += 1
181
- print %Q(<sect2 id="sect:#{@chapter.number}.#{@section}.#{@subsection}">) unless @secttags.nil?
182
-
169
+ buf << %Q(<sect2 id="sect:#{@chapter.number}.#{@section}.#{@subsection}">) unless @secttags.nil?
183
170
  @subsubsection = 0
184
171
  @subsubsubsection = 0
185
172
  when 4
186
173
  unless @secttags.nil?
187
- print "</sect4>" if @subsubsubsection > 0
188
- print "</sect3>" if @subsubsection > 0
174
+ buf << "</sect4>" if @subsubsubsection > 0
175
+ buf << "</sect3>" if @subsubsection > 0
189
176
  end
190
-
191
177
  @subsubsection += 1
192
- print %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) unless @secttags.nil?
193
-
178
+ buf << %Q(<sect3 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}">) unless @secttags.nil?
194
179
  @subsubsubsection = 0
195
180
  when 5
196
181
  unless @secttags.nil?
197
- print "</sect4>" if @subsubsubsection > 0
182
+ buf << "</sect4>" if @subsubsubsection > 0
198
183
  end
199
184
 
200
185
  @subsubsubsection += 1
201
- print %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) unless @secttags.nil?
186
+ buf << %Q(<sect4 id="sect:#{@chapter.number}.#{@section}.#{@subsection}.#{@subsubsection}.#{@subsubsubsection}">) unless @secttags.nil?
202
187
  else
203
188
  raise "caption level too deep or unsupported: #{level}"
204
189
  end
@@ -206,65 +191,68 @@ module ReVIEW
206
191
  prefix, anchor = headline_prefix(level)
207
192
 
208
193
  label = label.nil? ? "" : " id=\"#{label}\""
209
- toccaption = escape_html(compile_inline(caption.gsub(/@<fn>\{.+?\}/, '')).gsub(/<[^>]+>/, ''))
210
- puts %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{prefix}#{toccaption}"?>)
194
+ toccaption = escape_html(caption.gsub(/@<fn>\{.+?\}/, '').gsub(/<[^>]+>/, ''))
195
+ buf << %Q(<title#{label} aid:pstyle="h#{level}">#{prefix}#{caption}</title><?dtp level="#{level}" section="#{prefix}#{toccaption}"?>) << @lf
196
+
197
+ buf
211
198
  end
212
199
 
213
200
  def ul_begin
214
201
  level = block_given? ? yield : ""
215
202
  level = nil if level == 1
216
- puts "<ul#{level == 1 ? nil : level}>"
203
+ "<ul#{level == 1 ? nil : level}>" + @lf
217
204
  end
218
205
 
219
206
  def ul_item(lines)
220
- puts %Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>)
207
+ %Q(<li aid:pstyle="ul-item">#{lines.join.chomp}</li>) + @lf
221
208
  end
222
209
 
223
210
  def ul_item_begin(lines)
224
- print %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
211
+ %Q(<li aid:pstyle="ul-item">#{lines.join.chomp})
225
212
  end
226
213
 
227
214
  def ul_item_end
228
- puts "</li>"
215
+ "</li>" + @lf
229
216
  end
230
217
 
231
218
  def choice_single_begin
232
- puts "<choice type='single'>"
219
+ "<choice type='single'>" + @lf
233
220
  end
234
221
 
235
222
  def choice_multi_begin
236
- puts "<choice type='multi'>"
223
+ "<choice type='multi'>" + @lf
237
224
  end
238
225
 
239
226
  def choice_single_end
240
- puts "</choice>"
227
+ "</choice>" + @lf
241
228
  end
242
229
 
243
230
  def choice_multi_end
244
- puts "</choice>"
231
+ "</choice>" + @lf
245
232
  end
246
233
 
247
234
  def ul_end
248
235
  level = block_given? ? yield : ""
249
236
  level = nil if level == 1
250
- puts "</ul#{level}>"
237
+ "</ul#{level}>" + @lf
251
238
  end
252
239
 
253
240
  def ol_begin
254
- puts '<ol>'
255
241
  if !@ol_num
256
242
  @ol_num = 1
257
243
  end
244
+ '<ol>' + @lf
258
245
  end
259
246
 
260
247
  def ol_item(lines, num)
261
- puts %Q(<li aid:pstyle="ol-item" olnum="#{@ol_num}" num="#{num}">#{lines.join.chomp}</li>)
248
+ buf = %Q(<li aid:pstyle="ol-item" olnum="#{@ol_num}" num="#{num}">#{lines.join.chomp}</li>) + @lf
262
249
  @ol_num += 1
250
+ buf
263
251
  end
264
252
 
265
253
  def ol_end
266
- puts '</ol>'
267
254
  @ol_num = nil
255
+ '</ol>' + @lf
268
256
  end
269
257
 
270
258
  def olnum(num)
@@ -272,39 +260,42 @@ module ReVIEW
272
260
  end
273
261
 
274
262
  def dl_begin
275
- puts '<dl>'
263
+ '<dl>' + @lf
276
264
  end
277
265
 
278
266
  def dt(line)
279
- puts "<dt>#{line}</dt>"
267
+ "<dt>#{line}</dt>" + @lf
280
268
  end
281
269
 
282
270
  def dd(lines)
283
- puts "<dd>#{lines.join.chomp}</dd>"
271
+ "<dd>#{lines.join.chomp}</dd>" + @lf
284
272
  end
285
273
 
286
274
  def dl_end
287
- puts '</dl>'
275
+ '</dl>' + @lf
288
276
  end
289
277
 
290
278
  def paragraph(lines)
279
+ buf = ""
291
280
  if @noindent.nil?
292
281
  if lines[0] =~ /\A(\t+)/
293
- puts %Q(<p inlist="#{$1.size}">#{lines.join('').sub(/\A\t+/, "")}</p>)
282
+ buf << %Q(<p inlist="#{$1.size}">#{lines.join('').sub(/\A\t+/, "")}</p>) << @lf
294
283
  else
295
- puts "<p>#{lines.join}</p>"
284
+ buf << "<p>#{lines.join}</p>" << @lf
296
285
  end
297
286
  else
298
- puts %Q(<p aid:pstyle="noindent" noindent='1'>#{lines.join}</p>)
287
+ buf << %Q(<p aid:pstyle="noindent" noindent='1'>#{lines.join}</p>) << @lf
299
288
  @noindent = nil
300
289
  end
290
+ buf
301
291
  end
302
292
 
303
293
  def read(lines)
304
294
  if @book.config["deprecated-blocklines"].nil?
305
- puts %Q[<lead>#{split_paragraph(lines).join}</lead>]
295
+ %Q[<lead>#{lines.join}</lead>] + @lf
306
296
  else
307
- puts %Q[<p aid:pstyle="lead">#{lines.join}</p>]
297
+ str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join()
298
+ %Q[<p aid:pstyle="lead">#{str}</p>] + @lf
308
299
  end
309
300
  end
310
301
 
@@ -337,34 +328,40 @@ module ReVIEW
337
328
  end
338
329
 
339
330
  def list_header(id, caption, lang)
340
- puts %Q[<codelist>]
331
+ buf = ""
332
+ buf << %Q[<codelist>] << @lf
341
333
  if get_chap.nil?
342
- puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
334
+ buf << %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number_without_chapter", [@chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>] << @lf
343
335
  else
344
- puts %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
336
+ buf << %Q[<caption>#{I18n.t("list")}#{I18n.t("format_number", [get_chap, @chapter.list(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>] << @lf
345
337
  end
338
+ buf
346
339
  end
347
340
 
348
341
  def codelines_body(lines)
342
+ buf = ""
349
343
  no = 1
350
344
  lines.each do |line|
351
345
  unless @book.config["listinfo"].nil?
352
- print "<listinfo line=\"#{no}\""
353
- print " begin=\"1\"" if no == 1
354
- print " end=\"#{no}\"" if no == lines.size
355
- print ">"
346
+ buf << "<listinfo line=\"#{no}\""
347
+ buf << " begin=\"1\"" if no == 1
348
+ buf << " end=\"#{no}\"" if no == lines.size
349
+ buf << ">"
356
350
  end
357
- print detab(line)
358
- print "\n"
359
- print "</listinfo>" unless @book.config["listinfo"].nil?
351
+ buf << detab(line)
352
+ buf << "\n"
353
+ buf << "</listinfo>" unless @book.config["listinfo"].nil?
360
354
  no += 1
361
355
  end
356
+ buf
362
357
  end
363
358
 
364
359
  def list_body(id, lines, lang)
365
- print %Q(<pre>)
366
- codelines_body(lines)
367
- puts "</pre></codelist>"
360
+ buf = ""
361
+ buf << %Q(<pre>)
362
+ buf << codelines_body(lines)
363
+ buf << "</pre></codelist>" << @lf
364
+ buf
368
365
  end
369
366
 
370
367
  def emlist(lines, caption = nil, lang = nil)
@@ -374,27 +371,30 @@ module ReVIEW
374
371
  def emlistnum(lines, caption = nil, lang = nil)
375
372
  _lines = []
376
373
  lines.each_with_index do |line, i|
374
+ line.chomp! ## new parser don't remove LF in table (code block)
377
375
  _lines << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
378
376
  end
379
377
  quotedlist _lines, 'emlistnum', caption
380
378
  end
381
379
 
382
380
  def listnum_body(lines, lang)
383
- print %Q(<pre>)
381
+ buf = ""
382
+ buf << %Q(<pre>)
384
383
  no = 1
385
384
  lines.each_with_index do |line, i|
386
385
  unless @book.config["listinfo"].nil?
387
- print "<listinfo line=\"#{no}\""
388
- print " begin=\"1\"" if no == 1
389
- print " end=\"#{no}\"" if no == lines.size
390
- print ">"
386
+ buf << "<listinfo line=\"#{no}\""
387
+ buf << " begin=\"1\"" if no == 1
388
+ buf << " end=\"#{no}\"" if no == lines.size
389
+ buf << ">"
391
390
  end
392
- print detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
393
- print "\n"
394
- print "</listinfo>" unless @book.config["listinfo"].nil?
391
+ buf << detab("<span type='lineno'>" + (i + 1).to_s.rjust(2) + ": </span>" + line)
392
+ buf << "\n"
393
+ buf << "</listinfo>" unless @book.config["listinfo"].nil?
395
394
  no += 1
396
395
  end
397
- puts "</pre></codelist>"
396
+ buf << "</pre></codelist>" << @lf
397
+ buf
398
398
  end
399
399
 
400
400
  def cmd(lines, caption = nil)
@@ -402,32 +402,34 @@ module ReVIEW
402
402
  end
403
403
 
404
404
  def quotedlist(lines, css_class, caption)
405
- print %Q[<list type='#{css_class}'>]
406
- puts "<caption aid:pstyle='#{css_class}-title'>#{compile_inline(caption)}</caption>" unless caption.nil?
407
- print %Q[<pre>]
405
+ buf = ""
406
+ buf << %Q[<list type='#{css_class}'>]
407
+ buf << "<caption aid:pstyle='#{css_class}-title'>#{caption}</caption>" + @lf unless caption.nil?
408
+ buf << %Q[<pre>]
408
409
  no = 1
409
410
  lines.each do |line|
410
411
  unless @book.config["listinfo"].nil?
411
- print "<listinfo line=\"#{no}\""
412
- print " begin=\"1\"" if no == 1
413
- print " end=\"#{no}\"" if no == lines.size
414
- print ">"
412
+ buf << "<listinfo line=\"#{no}\""
413
+ buf << " begin=\"1\"" if no == 1
414
+ buf << " end=\"#{no}\"" if no == lines.size
415
+ buf << ">"
415
416
  end
416
- print detab(line)
417
- print "\n"
418
- print "</listinfo>" unless @book.config["listinfo"].nil?
417
+ buf << detab(line)
418
+ buf << "\n"
419
+ buf << "</listinfo>" unless @book.config["listinfo"].nil?
419
420
  no += 1
420
421
  end
421
- puts '</pre></list>'
422
+ buf << '</pre></list>' << @lf
423
+ buf
422
424
  end
423
425
  private :quotedlist
424
426
 
425
427
  def quote(lines)
426
428
  if @book.config["deprecated-blocklines"].nil?
427
- blocked_lines = split_paragraph(lines)
428
- puts "<quote>#{blocked_lines.join("")}</quote>"
429
+ "<quote>#{lines.join("")}</quote>" + @lf
429
430
  else
430
- puts "<quote>#{lines.join("\n")}</quote>"
431
+ str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join("\n")
432
+ "<quote>#{str}</quote>" + @lf
431
433
  end
432
434
  end
433
435
 
@@ -472,53 +474,59 @@ module ReVIEW
472
474
  end
473
475
 
474
476
  def image_image(id, caption, metric=nil)
477
+ buf = ""
475
478
  metrics = parse_metric("idgxml", metric)
476
- puts "<img>"
477
- puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}"#{metrics} />]
478
- image_header id, caption
479
- puts "</img>"
479
+ buf << "<img>" << @lf
480
+ buf << %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A.\//, "")}"#{metrics} />] << @lf
481
+ buf << image_header(id, caption)
482
+ buf << "</img>" << @lf
483
+ buf
480
484
  end
481
485
 
482
486
  def image_dummy(id, caption, lines)
483
- puts "<img>"
484
- print %Q[<pre aid:pstyle="dummyimage">]
487
+ buf << "<img>" << @lf
488
+ buf << %Q[<pre aid:pstyle="dummyimage">]
485
489
  lines.each do |line|
486
- print detab(line)
487
- print "\n"
490
+ buf << detab(line)
491
+ buf << "\n"
488
492
  end
489
- print %Q[</pre>]
493
+ buf << %Q[</pre>]
490
494
  image_header id, caption
491
- puts "</img>"
495
+ buf << "</img>" << @lf
492
496
  warn "no such image: #{id}"
497
+ buf
493
498
  end
494
499
 
495
500
  def image_header(id, caption)
496
501
  if get_chap.nil?
497
- puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
502
+ %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [@chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>] + @lf
498
503
  else
499
- puts %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
504
+ %Q[<caption>#{I18n.t("image")}#{I18n.t("format_number", [get_chap, @chapter.image(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>] + @lf
500
505
  end
501
506
  end
502
507
 
503
508
  def texequation(lines)
509
+ buf = ""
504
510
  @texblockequation += 1
505
- puts %Q[<replace idref="texblock-#{@texblockequation}">]
506
- puts '<pre>'
507
- puts "#{lines.join("\n")}"
508
- puts '</pre>'
509
- puts '</replace>'
511
+ buf << %Q[<replace idref="texblock-#{@texblockequation}">] << @lf
512
+ buf << '<pre>' << @lf
513
+ buf << "#{lines.join("\n")}" << @lf
514
+ buf << '</pre>' << @lf
515
+ buf << '</replace>' << @lf
510
516
  end
511
517
 
512
518
  def table(lines, id = nil, caption = nil)
519
+ buf = ""
513
520
  tablewidth = nil
514
521
  col = 0
515
522
  unless @book.config["tableopt"].nil?
516
523
  tablewidth = @book.config["tableopt"].split(",")[0].to_f / 0.351 # mm -> pt
517
524
  end
518
- puts "<table>"
525
+ buf << "<table>"
519
526
  rows = []
520
527
  sepidx = nil
521
528
  lines.each_with_index do |line, idx|
529
+ line.chomp! ## new parser don't remove LF in table (code block)
522
530
  if /\A[\=\-]{12}/ =~ line
523
531
  sepidx ||= idx
524
532
  next
@@ -541,7 +549,7 @@ module ReVIEW
541
549
  totallength = 0
542
550
  cellwidth.size.times do |n|
543
551
  cellwidth[n] = cellwidth[n].to_f / 0.351 # mm -> pt
544
- totallength += cellwidth[n]
552
+ totallength = totallength + cellwidth[n]
545
553
  warn "total length exceeds limit for table: #{id}" if totallength > tablewidth
546
554
  end
547
555
  if cellwidth.size < col
@@ -555,66 +563,71 @@ module ReVIEW
555
563
  end
556
564
 
557
565
  begin
558
- table_header id, caption unless caption.nil?
566
+ buf << table_header(id, caption) unless caption.nil?
559
567
  rescue KeyError
560
568
  error "no such table: #{id}"
561
569
  end
562
570
  return if rows.empty?
563
571
 
564
572
  if tablewidth.nil?
565
- print "<tbody>"
573
+ buf << "<tbody>"
566
574
  else
567
- print %Q[<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">]
575
+ buf << %Q[<tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="#{rows.length}" aid:tcols="#{col}">]
568
576
  end
569
577
 
570
578
  if sepidx
571
579
  sepidx.times do |y|
572
580
  if tablewidth.nil?
573
- puts %Q[<tr type="header">#{rows.shift}</tr>]
581
+ buf << %Q[<tr type="header">#{rows.shift}</tr>] << @lf
574
582
  else
575
583
  i = 0
576
584
  rows.shift.split(/\t/).each_with_index do |cell, x|
577
- print %Q[<td xyh="#{x + 1},#{y + 1},#{sepidx}" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
585
+ buf << %Q[<td xyh="#{x + 1},#{y + 1},#{sepidx}" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
578
586
  i += 1
579
587
  end
580
588
  end
581
589
  end
582
590
  end
583
- trputs(tablewidth, rows, cellwidth, sepidx)
584
- puts "</tbody></table>"
591
+ buf << trputs(tablewidth, rows, cellwidth, sepidx)
592
+ buf << "</tbody></table>" << @lf
585
593
  @tsize = nil
594
+ buf
586
595
  end
587
596
 
588
597
  def trputs(tablewidth, rows, cellwidth, sepidx)
598
+ buf = ""
589
599
  sepidx = 0 if sepidx.nil?
590
600
  if tablewidth.nil?
591
601
  lastline = rows.pop
592
- rows.each {|row| puts %Q[<tr>#{row}</tr>] }
593
- puts %Q[<tr type="lastline">#{lastline}</tr>] unless lastline.nil?
602
+ rows.each {|row| buf << %Q[<tr>#{row}</tr>] }
603
+ buf << %Q[<tr type="lastline">#{lastline}</tr>] + @lf unless lastline.nil?
594
604
  else
595
605
  rows.each_with_index do |row, y|
596
606
  i = 0
597
607
  row.split(/\t/).each_with_index do |cell, x|
598
- print %Q[<td xyh="#{x + 1},#{y + 1 + sepidx},#{sepidx}" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
608
+ buf << %Q[<td xyh="#{x + 1},#{y + 1 + sepidx},#{sepidx}" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="#{sprintf("%.13f", cellwidth[i])}">#{cell.sub("DUMMYCELLSPLITTER", "")}</td>]
599
609
  i += 1
600
610
  end
601
611
  end
602
612
  end
613
+ buf
603
614
  end
604
615
 
605
616
  def table_header(id, caption)
617
+ buf = ""
606
618
  if get_chap.nil?
607
- puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
619
+ buf << %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number_without_chapter", [@chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>] + @lf
608
620
  else
609
- puts %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{compile_inline(caption)}</caption>]
621
+ buf << %Q[<caption>#{I18n.t("table")}#{I18n.t("format_number", [get_chap, @chapter.table(id).number])}#{I18n.t("caption_prefix_idgxml")}#{caption}</caption>] + @lf
610
622
  end
623
+ buf
611
624
  end
612
625
 
613
626
  def table_begin(ncols)
614
627
  end
615
628
 
616
629
  def tr(rows)
617
- puts %Q[<tr>#{rows.join("\t")}</tr>]
630
+ %Q[<tr>#{rows.join("\t")}</tr>] + @lf
618
631
  end
619
632
 
620
633
  def th(str)
@@ -626,11 +639,11 @@ module ReVIEW
626
639
  end
627
640
 
628
641
  def table_end
629
- print "<?dtp tablerow last?>"
642
+ "<?dtp tablerow last?>"
630
643
  end
631
644
 
632
645
  def comment(str)
633
- print %Q(<!-- [Comment] #{escape_html(str)} -->)
646
+ %Q(<!-- [Comment] #{escape_html(str)} -->)
634
647
  end
635
648
 
636
649
  def footnote(id, str)
@@ -638,7 +651,7 @@ module ReVIEW
638
651
  end
639
652
 
640
653
  def inline_fn(id)
641
- %Q[<footnote>#{compile_inline(@chapter.footnote(id).content.strip)}</footnote>]
654
+ %Q[<footnote>#{@chapter.footnote(id).content.strip}</footnote>]
642
655
  end
643
656
 
644
657
  def compile_ruby(base, ruby)
@@ -648,13 +661,13 @@ module ReVIEW
648
661
  def compile_kw(word, alt)
649
662
  '<keyword>' +
650
663
  if alt
651
- then escape_html("#{word}(#{alt.strip})")
652
- else escape_html(word)
664
+ then ("#{word}(#{alt.strip})")
665
+ else (word)
653
666
  end +
654
667
  '</keyword>' +
655
- %Q[<index value="#{escape_html(word)}" />] +
668
+ %Q[<index value="#{word}" />] +
656
669
  if alt
657
- alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{escape_html(e.strip)}" />] }.join
670
+ alt.split(/\s*,\s*/).collect! {|e| %Q[<index value="#{(e.strip)}" />] }.join
658
671
  else
659
672
  ""
660
673
  end
@@ -725,11 +738,11 @@ module ReVIEW
725
738
  end
726
739
 
727
740
  def inline_tt(str)
728
- %Q(<tt>#{escape_html(str)}</tt>)
741
+ %Q(<tt>#{str}</tt>)
729
742
  end
730
743
 
731
744
  def inline_ttb(str)
732
- %Q(<tt style='bold'>#{escape_html(str)}</tt>)
745
+ %Q(<tt style='bold'>#{str}</tt>)
733
746
  end
734
747
 
735
748
  alias_method :inline_ttbold, :inline_ttb
@@ -760,13 +773,13 @@ module ReVIEW
760
773
  end
761
774
 
762
775
  def inline_labelref(idref)
763
- %Q[<ref idref='#{escape_html(idref)}'>「#{I18n.t("label_marker")}#{escape_html(idref)}」</ref>] # FIXME:節名とタイトルも込みで要出力
776
+ %Q[<ref idref='#{(idref)}'>「#{I18n.t("label_marker")}#{(idref)}」</ref>] # FIXME:節名とタイトルも込みで要出力
764
777
  end
765
778
 
766
779
  alias_method :inline_ref, :inline_labelref
767
780
 
768
781
  def inline_pageref(idref)
769
- %Q[<pageref idref='#{escape_html(idref)}'>●●</pageref>] # ページ番号を参照
782
+ %Q[<pageref idref='#{(idref)}'>●●</pageref>] # ページ番号を参照
770
783
  end
771
784
 
772
785
  def inline_balloon(str)
@@ -784,40 +797,43 @@ module ReVIEW
784
797
 
785
798
  def noindent
786
799
  @noindent = true
800
+ ""
787
801
  end
788
802
 
789
803
  def linebreak
790
804
  # FIXME:pが閉じちゃってるので一度戻らないといけないが、難しい…。
791
- puts "<br />"
805
+ "<br />" + @lf
792
806
  end
793
807
 
794
808
  def pagebreak
795
- puts "<pagebreak />"
809
+ "<pagebreak />" + @lf
796
810
  end
797
811
 
798
812
  def nonum_begin(level, label, caption)
799
- puts %Q[<title aid:pstyle="h#{level}">#{compile_inline(caption)}</title><?dtp level="#{level}" section="#{escape_html(compile_inline(caption))}"?>]
813
+ %Q[<title aid:pstyle="h#{level}">#{caption}</title><?dtp level="#{level}" section="#{escape_html(caption)}"?>] + @lf
800
814
  end
801
815
 
802
816
  def nonum_end(level)
803
817
  end
804
818
 
805
819
  def circle_begin(level, label, caption)
806
- puts %Q[<title aid:pstyle="smallcircle">&#x2022;#{compile_inline(caption)}</title>]
820
+ %Q[<title aid:pstyle="smallcircle">&#x2022;#{caption}</title>] + @lf
807
821
  end
808
822
 
809
823
  def circle_end(level)
810
824
  end
811
825
 
812
826
  def common_column_begin(type, caption)
827
+ buf = ""
813
828
  @column += 1
814
829
  a_id = %Q[id="column-#{@column}"]
815
- print "<#{type}column #{a_id}>"
816
- puts %Q[<title aid:pstyle="#{type}column-title">#{compile_inline(caption)}</title>]
830
+ buf << "<#{type}column #{a_id}>"
831
+ buf << %Q[<title aid:pstyle="#{type}column-title">#{compile_inline(caption)}</title>] << @lf
832
+ buf
817
833
  end
818
834
 
819
835
  def common_column_end(type)
820
- puts "</#{type}column>"
836
+ "</#{type}column>" + @lf
821
837
  end
822
838
 
823
839
  def column_begin(level, label, caption)
@@ -870,50 +886,53 @@ module ReVIEW
870
886
 
871
887
  def ref_begin(level, label, caption)
872
888
  if !label.nil?
873
- puts "<reference id='#{label}'>"
889
+ "<reference id='#{label}'>" + @lf
874
890
  else
875
- puts "<reference>"
891
+ "<reference>" + @lf
876
892
  end
877
893
  end
878
894
 
879
895
  def ref_end(level)
880
- puts "</reference>"
896
+ "</reference>" + @lf
881
897
  end
882
898
 
883
899
  def sup_begin(level, label, caption)
884
900
  if !label.nil?
885
- puts "<supplement id='#{label}'>"
901
+ "<supplement id='#{label}'>" + @lf
886
902
  else
887
- puts "<supplement>"
903
+ "<supplement>" + @lf
888
904
  end
889
905
  end
890
906
 
891
907
  def sup_end(level)
892
- puts "</supplement>"
908
+ "</supplement>" + @lf
893
909
  end
894
910
 
895
911
  def flushright(lines)
896
912
  if @book.config["deprecated-blocklines"].nil?
897
- puts split_paragraph(lines).join.gsub("<p>", "<p align='right'>")
913
+ lines.join("").gsub("<p>", "<p align='right'>") + @lf
898
914
  else
899
- puts "<p align='right'>#{lines.join("\n")}</p>"
915
+ str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join("\n")
916
+ "<p align='right'>#{str}</p>" + @lf
900
917
  end
901
918
  end
902
919
 
903
920
  def centering(lines)
904
- puts split_paragraph(lines).join.gsub("<p>", "<p align='center'>")
921
+ lines.join("").gsub("<p>", "<p align='center'>") + @lf
905
922
  end
906
923
 
907
924
  def captionblock(type, lines, caption, specialstyle = nil)
908
- print "<#{type}>"
925
+ buf = ""
926
+ buf << "<#{type}>"
909
927
  style = specialstyle.nil? ? "#{type}-title" : specialstyle
910
- puts "<title aid:pstyle='#{style}'>#{compile_inline(caption)}</title>" unless caption.nil?
928
+ buf << "<title aid:pstyle='#{style}'>#{(caption)}</title>" + @lf unless caption.nil?
911
929
  if @book.config["deprecated-blocklines"].nil?
912
- blocked_lines = split_paragraph(lines)
913
- puts "#{blocked_lines.join}</#{type}>"
930
+ buf << "#{lines.join}</#{type}>" << @lf
914
931
  else
915
- puts "#{lines.join("\n")}</#{type}>"
932
+ str = lines.map{|l| l.sub(/^<p>/,"").sub(/<\/p>$/,"")}.join("\n")
933
+ buf << "#{str}</#{type}>" << @lf
916
934
  end
935
+ buf
917
936
  end
918
937
 
919
938
  def note(lines, caption = nil)
@@ -997,8 +1016,9 @@ module ReVIEW
997
1016
  end
998
1017
 
999
1018
  def syntaxblock(type, lines, caption)
1019
+ buf = ""
1000
1020
  if caption.nil?
1001
- puts %Q[<#{type}>]
1021
+ buf << %Q[<#{type}>] << @lf
1002
1022
  else
1003
1023
  titleopentag = %Q[caption aid:pstyle="#{type}-title"]
1004
1024
  titleclosetag = "caption"
@@ -1006,22 +1026,24 @@ module ReVIEW
1006
1026
  titleopentag = %Q[floattitle type="insn"]
1007
1027
  titleclosetag = "floattitle"
1008
1028
  end
1009
- puts %Q[<#{type}><#{titleopentag}>#{compile_inline(caption)}</#{titleclosetag}>]
1029
+ buf << %Q[<#{type}><#{titleopentag}>#{caption}</#{titleclosetag}>] << @lf
1010
1030
  end
1011
1031
  no = 1
1012
1032
  lines.each do |line|
1033
+ line.chomp!
1013
1034
  unless @book.config["listinfo"].nil?
1014
- print %Q[<listinfo line="#{no}"]
1015
- print %Q[ begin="1"] if no == 1
1016
- print %Q[ end="#{no}"] if no == lines.size
1017
- print %Q[>]
1035
+ buf << %Q[<listinfo line="#{no}"]
1036
+ buf << %Q[ begin="1"] if no == 1
1037
+ buf << %Q[ end="#{no}"] if no == lines.size
1038
+ buf << %Q[>]
1018
1039
  end
1019
- print detab(line)
1020
- print "\n"
1021
- print "</listinfo>" unless @book.config["listinfo"].nil?
1040
+ buf << detab(line)
1041
+ buf << "\n"
1042
+ buf << "</listinfo>" unless @book.config["listinfo"].nil?
1022
1043
  no += 1
1023
1044
  end
1024
- puts "</#{type}>"
1045
+ buf << "</#{type}>" << @lf
1046
+ buf
1025
1047
  end
1026
1048
 
1027
1049
  def insn(lines, caption = nil)
@@ -1033,22 +1055,24 @@ module ReVIEW
1033
1055
  end
1034
1056
 
1035
1057
  def indepimage(id, caption=nil, metric=nil)
1058
+ buf = ""
1036
1059
  metrics = parse_metric("idgxml", metric)
1037
- puts "<img>"
1060
+ buf << "<img>" << @lf
1038
1061
  begin
1039
- puts %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}"#{metrics} />]
1062
+ buf << %Q[<Image href="file://#{@chapter.image(id).path.sub(/\A\.\//, "")}"#{metrics} />] << @lf
1040
1063
  rescue
1041
1064
  warn %Q[no such image: #{id}]
1042
1065
  end
1043
- puts %Q[<caption>#{compile_inline(caption)}</caption>] if caption.present?
1044
- puts "</img>"
1066
+ buf << %Q[<caption>#{caption}</caption>] + @lf if caption.present?
1067
+ buf << "</img>" << @lf
1068
+ buf
1045
1069
  end
1046
1070
 
1047
1071
  alias_method :numberlessimage, :indepimage
1048
1072
 
1049
1073
  def label(id)
1050
1074
  # FIXME
1051
- print "<label id='#{id}' />"
1075
+ "<label id='#{id}' />"
1052
1076
  end
1053
1077
 
1054
1078
  def tsize(str)
@@ -1056,15 +1080,15 @@ module ReVIEW
1056
1080
  end
1057
1081
 
1058
1082
  def dtp(str)
1059
- print %Q(<?dtp #{str} ?>)
1083
+ %Q(<?dtp #{str} ?>)
1060
1084
  end
1061
1085
 
1062
1086
  def hr
1063
- print "<hr />"
1087
+ "<hr />"
1064
1088
  end
1065
1089
 
1066
1090
  def bpo(lines)
1067
- puts %Q[<bpo>#{lines.join("\n")}</bpo>]
1091
+ %Q[<bpo>#{lines.join("\n")}</bpo>] + @lf
1068
1092
  end
1069
1093
 
1070
1094
  def inline_dtp(str)
@@ -1080,12 +1104,14 @@ module ReVIEW
1080
1104
  end
1081
1105
 
1082
1106
  def rawblock(lines)
1107
+ buf = ""
1083
1108
  no = 1
1084
1109
  lines.each do |l|
1085
- print l.gsub("&lt;", "<").gsub("&gt;", ">").gsub("&quot;", "\"").gsub("&amp;", "&")
1086
- print "\n" unless lines.length == no
1087
- no += 1
1110
+ buf << l.gsub("&lt;", "<").gsub("&gt;", ">").gsub("&quot;", "\"").gsub("&amp;", "&")
1111
+ buf << "\n" unless lines.length == no
1112
+ no = no + 1
1088
1113
  end
1114
+ buf
1089
1115
  end
1090
1116
 
1091
1117
  def text(str)
@@ -1095,7 +1121,8 @@ module ReVIEW
1095
1121
  def inline_chapref(id)
1096
1122
  chs = ["", "「", "」"]
1097
1123
  unless @book.config["chapref"].nil?
1098
- _chs = @book.config["chapref"].split(",")
1124
+ _chs = convert_inencoding(@book.config["chapref"],
1125
+ @book.config["inencoding"]).split(",")
1099
1126
  if _chs.size != 3
1100
1127
  error "--chapsplitter must have exactly 3 parameters with comma."
1101
1128
  else
@@ -1138,31 +1165,39 @@ module ReVIEW
1138
1165
  end
1139
1166
 
1140
1167
  def source_header(caption)
1141
- puts %Q[<source>]
1142
- puts %Q[<caption>#{compile_inline(caption)}</caption>]
1168
+ buf = ""
1169
+ buf << %Q[<source>] << @lf
1170
+ buf << %Q[<caption>#{caption}</caption>] << @lf
1171
+ buf
1143
1172
  end
1144
1173
 
1145
- def source_body(lines, lang)
1146
- puts %Q[<pre>]
1147
- codelines_body(lines)
1148
- puts %Q[</pre></source>]
1174
+ def source_body(lines)
1175
+ buf = ""
1176
+ buf << %Q[<pre>] << @lf
1177
+ buf << codelines_body(lines)
1178
+ buf << %Q[</pre></source>] << @lf
1179
+ buf
1149
1180
  end
1150
1181
 
1151
1182
  def bibpaper(lines, id, caption)
1152
- bibpaper_header id, caption
1183
+ buf = ""
1184
+ buf << bibpaper_header(id, caption)
1153
1185
  unless lines.empty?
1154
- bibpaper_bibpaper id, caption, lines
1186
+ buf << bibpaper_bibpaper(id, caption, lines)
1155
1187
  end
1156
- puts %Q(</bibitem>)
1188
+ buf << %Q(</bibitem>) << @lf
1189
+ buf
1157
1190
  end
1158
1191
 
1159
1192
  def bibpaper_header(id, caption)
1160
- puts %Q(<bibitem id="bib-#{id}">)
1161
- puts "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{compile_inline(caption)}</caption>"
1193
+ buf = ""
1194
+ buf << %Q(<bibitem id="bib-#{id}">) << @lf
1195
+ buf << "<caption><span type='bibno'>[#{@chapter.bibpaper(id).number}] </span>#{caption}</caption>" << @lf
1196
+ buf
1162
1197
  end
1163
1198
 
1164
1199
  def bibpaper_bibpaper(id, caption, lines)
1165
- print split_paragraph(lines).join("")
1200
+ lines.join("")
1166
1201
  end
1167
1202
 
1168
1203
  def inline_bib(id)
@@ -1173,10 +1208,10 @@ module ReVIEW
1173
1208
  if chap.number
1174
1209
  n = chap.headline_index.number(id)
1175
1210
  if @book.config["secnolevel"] >= n.split('.').size
1176
- return I18n.t("chapter_quote", "#{n} #{compile_inline(chap.headline(id).caption)}")
1211
+ return I18n.t("chapter_quote", "#{n} #{chap.headline(id).caption}")
1177
1212
  end
1178
1213
  end
1179
- I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
1214
+ I18n.t("chapter_quote", chap.headline(id).caption)
1180
1215
  end
1181
1216
 
1182
1217
  def inline_recipe(id)
@@ -1194,4 +1229,4 @@ module ReVIEW
1194
1229
 
1195
1230
  end
1196
1231
 
1197
- end # module ReVIEW
1232
+ end # module ReVIEW