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
@@ -30,7 +30,6 @@ module ReVIEW
30
30
  end
31
31
 
32
32
  def builder_init_file
33
- @blank_seen = true
34
33
  @noindent = nil
35
34
 
36
35
  @titles = {
@@ -44,27 +43,6 @@ module ReVIEW
44
43
  end
45
44
  private :builder_init_file
46
45
 
47
- def print(s)
48
- @blank_seen = false
49
- super
50
- end
51
- private :print
52
-
53
- def puts(s)
54
- @blank_seen = false
55
- super
56
- end
57
- private :puts
58
-
59
- def blank
60
- @output.puts unless @blank_seen
61
- @blank_seen = true
62
- end
63
- private :blank
64
-
65
- def result
66
- @output.string
67
- end
68
46
 
69
47
  def warn(msg)
70
48
  $stderr.puts "#{@location.filename}:#{@location.lineno}: warning: #{msg}"
@@ -79,22 +57,26 @@ module ReVIEW
79
57
  end
80
58
 
81
59
  def base_parablock(type, lines, caption=nil)
82
- puts "◆#{@titles[type]}/◆"
83
- puts "■■■■■#{compile_inline(caption)}" unless caption.nil?
84
- puts split_paragraph(lines).join("\n")
85
- puts "◆/#{@titles[type]}◆"
86
- blank
60
+ buf = ""
61
+ buf << "◆#{@titles[type]}/◆\n"
62
+ buf << "■■■■■#{caption}\n" unless caption.nil?
63
+ buf << lines.join("")
64
+ buf << "◆/#{@titles[type]}◆\n"
65
+ buf << "\n"
66
+ buf
87
67
  end
88
68
 
89
69
  def headline(level, label, caption)
90
70
  prefix = "■" * level
91
- puts "#{prefix}#{compile_inline(caption)}"
71
+ "#{prefix}#{caption}\n"
92
72
  end
93
73
 
94
74
  def paragraph(lines)
95
- print " " if @noindent.nil?
75
+ buf = ""
76
+ buf << " " if @noindent.nil?
96
77
  @noindent = nil
97
- puts lines.join
78
+ buf << lines.join + "\n"
79
+ buf
98
80
  end
99
81
 
100
82
  def noindent
@@ -119,10 +101,11 @@ module ReVIEW
119
101
 
120
102
  def footnote(id, str)
121
103
  #
104
+ ""
122
105
  end
123
106
 
124
107
  def inline_fn(id)
125
- "◆注/◆#{compile_inline(@chapter.footnote(id).content.strip)}◆/注◆"
108
+ "◆注/◆#{@chapter.footnote(id).content.strip}◆/注◆"
126
109
  end
127
110
 
128
111
  def inline_keytop(str)
@@ -140,39 +123,45 @@ module ReVIEW
140
123
  end
141
124
 
142
125
  def quote(lines)
143
- base_parablock "quote", lines, nil
126
+ lines_fixed = lines.map{|line| line.sub(/^ /,"")} ## インデントを消す
127
+ base_parablock "quote", lines_fixed, nil
144
128
  end
145
129
 
146
130
  def column_begin(level, label, caption)
147
- puts "◆column/◆"
148
- puts "■■■■#{compile_inline(caption)}"
149
-
131
+ buf = ""
132
+ buf << "◆column/◆\n"
133
+ buf << "■■■■#{caption}\n"
134
+ buf
150
135
  end
151
136
 
152
137
  def column_end(level)
153
- puts "◆/column"
138
+ "◆/column◆\n"
154
139
  end
155
140
 
156
141
  def ul_begin
142
+ ""
157
143
  end
158
144
 
159
145
  def ul_item(lines)
160
- puts "・#{lines.join}"
146
+ "・#{lines.join}\n"
161
147
  end
162
148
 
163
149
  def ul_end
150
+ ""
164
151
  end
165
152
 
166
153
  def ol_begin
167
154
  @olitem = 0
155
+ ""
168
156
  end
169
157
 
170
158
  def ol_item(lines, num)
171
- puts "(#{num})#{lines.join}"
159
+ "(#{num})#{lines.join}\n"
172
160
  end
173
161
 
174
162
  def ol_end
175
163
  @olitem = nil
164
+ ""
176
165
  end
177
166
 
178
167
  def inline_list(id)
@@ -185,35 +174,42 @@ module ReVIEW
185
174
  end
186
175
 
187
176
  def list_header(id, caption, lang)
188
- puts "◆list/◆"
177
+ buf = "◆list/◆\n"
189
178
  if get_chap.nil?
190
- puts %Q[●リスト#{@chapter.list(id).number} #{compile_inline(caption)}]
179
+ buf << %Q[●リスト#{@chapter.list(id).number} #{caption}\n]
191
180
  else
192
- puts %Q[●リスト#{get_chap}.#{@chapter.list(id).number} #{compile_inline(caption)}]
181
+ buf << %Q[●リスト#{get_chap}.#{@chapter.list(id).number} #{caption}\n]
193
182
  end
183
+ buf
194
184
  end
195
185
 
196
186
  def list_body(id, lines, lang)
187
+ buf = ""
197
188
  lines.each do |line|
198
- puts detab(line)
189
+ buf << detab(line) << "\n"
199
190
  end
200
- puts "◆/list"
191
+ buf << "◆/list◆\n"
192
+ buf
201
193
  end
202
194
 
203
195
  def listnum_body(lines, lang)
196
+ buf = ""
204
197
  lines.each_with_index do |line, i|
205
- puts detab((i+1).to_s.rjust(2) + " " +line)
198
+ buf << detab((i+1).to_s.rjust(2) + " " + line) << "\n"
206
199
  end
207
- puts "◆/list"
200
+ buf << "◆/list◆\n"
201
+ buf
208
202
  end
209
203
 
210
- def emlist(lines, caption=nil)
211
- puts "◆list/◆"
212
- puts %Q[●#{compile_inline(caption)}] unless caption.nil?
204
+ def emlist(lines, caption = nil)
205
+ buf = ""
206
+ buf << "◆list/◆\n"
207
+ buf << %Q[●#{caption}\n] unless caption.nil?
213
208
  lines.each do |line|
214
- puts detab(line)
209
+ buf << detab(line) << "\n"
215
210
  end
216
- puts "◆/list"
211
+ buf << "◆/list◆\n"
212
+ buf
217
213
  end
218
214
 
219
215
  # o1,o2のようなことはできない
@@ -227,13 +223,14 @@ module ReVIEW
227
223
  end
228
224
 
229
225
  # whiteリスト代用
230
- def cmd(lines, caption=nil)
231
- puts "◆list-white/◆"
232
- puts %Q[●#{compile_inline(caption)}] unless caption.nil?
226
+ def cmd(lines, caption = nil)
227
+ buf = "◆list-white/◆\n"
228
+ buf << %Q[●#{caption}\n] unless caption.nil?
233
229
  lines.each do |line|
234
- puts detab(line)
230
+ buf << detab(line) << "\n"
235
231
  end
236
- puts "◆/list-white"
232
+ buf << "◆/list-white◆\n"
233
+ buf
237
234
  end
238
235
 
239
236
  def inline_img(id)
@@ -246,18 +243,20 @@ module ReVIEW
246
243
  end
247
244
 
248
245
  def image(lines, id, caption, metric=nil)
246
+ buf = ""
249
247
  if get_chap.nil?
250
- puts "●図#{@chapter.image(id).number} #{compile_inline(caption)}"
248
+ buf << "●図#{@chapter.image(id).number} #{caption}\n"
251
249
  else
252
- puts "●図#{get_chap}.#{@chapter.image(id).number} #{compile_inline(caption)}"
250
+ buf << "●図#{get_chap}.#{@chapter.image(id).number} #{caption}\n"
253
251
  end
254
252
  if @chapter.image(id).bound?
255
- puts @chapter.image(id).path
253
+ buf << @chapter.image(id).path << "\n"
256
254
  else
257
255
  lines.each do |line|
258
- puts line
256
+ buf << line + "\n"
259
257
  end
260
258
  end
259
+ buf
261
260
  end
262
261
 
263
262
  def inline_table(id)
@@ -270,6 +269,7 @@ module ReVIEW
270
269
  end
271
270
 
272
271
  def table(lines, id = nil, caption = nil)
272
+ buf = ""
273
273
  rows = []
274
274
  sepidx = nil
275
275
  lines.each_with_index do |line, idx|
@@ -283,44 +283,46 @@ module ReVIEW
283
283
  end
284
284
  rows = adjust_n_cols(rows)
285
285
 
286
- puts "◆table/◆"
286
+ buf << "◆table/◆\n"
287
287
  begin
288
- table_header id, caption unless caption.nil?
288
+ buf << table_header(id, caption) unless caption.nil?
289
289
  rescue KeyError
290
290
  error "no such table: #{id}"
291
291
  end
292
- return if rows.empty?
293
- table_begin rows.first.size
292
+ return buf if rows.empty?
293
+ buf << table_begin(rows.first.size)
294
294
  if sepidx
295
295
  sepidx.times do
296
- print "◆table-title◆"
297
- tr rows.shift.map {|s| th(s) }
296
+ buf << "◆table-title◆"
297
+ buf << tr(rows.shift.map {|s| th(s) })
298
298
  end
299
299
  rows.each do |cols|
300
- tr cols.map {|s| td(s) }
300
+ buf << tr(cols.map {|s| td(s) })
301
301
  end
302
302
  else
303
303
  rows.each do |cols|
304
304
  h, *cs = *cols
305
- tr [th(h)] + cs.map {|s| td(s) }
305
+ buf << tr([th(h)] + cs.map {|s| td(s) })
306
306
  end
307
307
  end
308
- table_end
308
+ buf << table_end
309
+ buf
309
310
  end
310
311
 
311
312
  def table_header(id, caption)
312
313
  if get_chap.nil?
313
- puts "●表#{@chapter.table(id).number} #{compile_inline(caption)}"
314
+ "●表#{@chapter.table(id).number} #{caption}\n"
314
315
  else
315
- puts "●表#{get_chap}.#{@chapter.table(id).number} #{compile_inline(caption)}"
316
+ "●表#{get_chap}.#{@chapter.table(id).number} #{caption}\n"
316
317
  end
317
318
  end
318
319
 
319
320
  def table_begin(ncols)
321
+ ""
320
322
  end
321
323
 
322
324
  def tr(rows)
323
- puts rows.join("\t")
325
+ rows.join("\t") + "\n"
324
326
  end
325
327
 
326
328
  def th(str)
@@ -332,7 +334,7 @@ module ReVIEW
332
334
  end
333
335
 
334
336
  def table_end
335
- puts "◆/table"
337
+ "◆/table◆\n"
336
338
  end
337
339
 
338
340
  def inline_raw(str)
@@ -352,4 +354,4 @@ module ReVIEW
352
354
  end
353
355
  end
354
356
 
355
- end # module ReVIEW
357
+ end # module ReVIEW
@@ -47,23 +47,10 @@ module ReVIEW
47
47
  end
48
48
  private :blank
49
49
 
50
- def print(*s)
51
- if @blank_needed
52
- @output.puts
53
- @blank_needed = false
54
- end
55
- super
56
- end
57
- private :print
58
-
59
- def puts(*s)
60
- if @blank_needed
61
- @output.puts
62
- @blank_needed = false
63
- end
64
- super
50
+ def blank_reset
51
+ @blank_needed = false
65
52
  end
66
- private :puts
53
+ private :blank_reset
67
54
 
68
55
  HEADLINE = {
69
56
  1 => 'chapter',
@@ -75,6 +62,7 @@ module ReVIEW
75
62
  }
76
63
 
77
64
  def headline(level, label, caption)
65
+ buf = ""
78
66
  _, anchor = headline_prefix(level)
79
67
  headline_name = HEADLINE[level]
80
68
  if @chapter.kind_of? ReVIEW::Book::Part
@@ -84,144 +72,148 @@ module ReVIEW
84
72
  if level > @book.config["secnolevel"] || (@chapter.number.to_s.empty? && level > 1)
85
73
  prefix = "*"
86
74
  end
87
- blank unless @output.pos == 0
88
- puts macro(headline_name+prefix, compile_inline(caption))
75
+ buf << macro(headline_name+prefix, caption) << "\n"
89
76
  if prefix == "*" && level <= @book.config["toclevel"].to_i
90
- puts "\\addcontentsline{toc}{#{headline_name}}{#{compile_inline(caption)}}"
77
+ buf << "\\addcontentsline{toc}{#{headline_name}}{#{caption}}\n"
91
78
  end
92
79
  if level == 1
93
- puts macro('label', chapter_label)
80
+ buf << macro('label', chapter_label) << "\n"
94
81
  else
95
- puts macro('label', sec_label(anchor))
82
+ buf << macro('label', sec_label(anchor)) << "\n"
96
83
  end
84
+ buf
97
85
  rescue
98
86
  error "unknown level: #{level}"
99
87
  end
100
88
 
101
89
  def nonum_begin(level, label, caption)
102
- blank unless @output.pos == 0
103
- puts macro(HEADLINE[level]+"*", compile_inline(caption))
90
+ "\n" + macro(HEADLINE[level]+"*", caption) + "\n"
104
91
  end
105
92
 
106
93
  def nonum_end(level)
107
94
  end
108
95
 
109
96
  def column_begin(level, label, caption)
97
+ buf = ""
110
98
  blank
111
- puts "\\begin{reviewcolumn}\n"
99
+ if @blank_needed
100
+ buf << "\n"
101
+ blank_reset
102
+ end
103
+ buf << "\\begin{reviewcolumn}\n"
112
104
  if label
113
- puts "\\hypertarget{#{column_label(label)}}{}"
105
+ buf << "\\hypertarget{#{column_label(label)}}{}\n"
114
106
  else
115
- puts "\\hypertarget{#{column_label(caption)}}{}"
107
+ buf << "\\hypertarget{#{column_label(caption)}}{}\n"
116
108
  end
117
- puts macro('reviewcolumnhead', nil, compile_inline(caption))
109
+ buf << macro('reviewcolumnhead', nil, caption) << "\n"
118
110
  if level <= @book.config["toclevel"].to_i
119
- puts "\\addcontentsline{toc}{#{HEADLINE[level]}}{#{compile_inline(caption)}}"
111
+ buf << "\\addcontentsline{toc}{#{HEADLINE[level]}}{#{caption}}" << "\n"
120
112
  end
113
+ buf
121
114
  end
122
115
 
123
116
  def column_end(level)
124
- puts "\\end{reviewcolumn}\n"
117
+ buf = ""
118
+ buf << "\\end{reviewcolumn}\n"
125
119
  blank
120
+ buf
126
121
  end
127
122
 
128
123
  def captionblock(type, lines, caption)
129
- puts "\\begin{reviewminicolumn}\n"
124
+ buf = ""
125
+ buf << "\\begin{reviewminicolumn}\n"
130
126
  unless caption.nil?
131
- puts "\\reviewminicolumntitle{#{compile_inline(caption)}}\n"
127
+ buf << "\\reviewminicolumntitle{#{caption}}"
132
128
  end
133
129
 
134
130
  if @book.config["deprecated-blocklines"].nil?
135
- blocked_lines = split_paragraph(lines)
136
- puts blocked_lines.join("\n\n")
131
+ buf << lines.join("")
137
132
  else
138
- lines.each do |line|
139
- puts line
140
- end
133
+ error "deprecated-blocklines is obsoleted."
141
134
  end
142
135
 
143
- puts "\\end{reviewminicolumn}\n"
136
+ buf << "\\end{reviewminicolumn}\n"
137
+ buf
144
138
  end
145
139
 
146
140
  def box(lines, caption = nil)
147
- blank
141
+ buf = "\n"
148
142
  if caption
149
- puts macro('reviewboxcaption', "#{compile_inline(caption)}")
143
+ buf << macro('reviewboxcaption', "#{caption}") << "\n"
150
144
  end
151
- puts '\begin{reviewbox}'
145
+ buf << '\begin{reviewbox}' << "\n"
152
146
  lines.each do |line|
153
- puts detab(line)
154
- end
155
- puts '\end{reviewbox}'
156
- blank
147
+ buf << detab(line) << "\n"
148
+ end<
149
+ buf << '\end{reviewbox}' << "\n"
157
150
  end
158
151
 
159
152
  def ul_begin
160
- blank
161
- puts '\begin{itemize}'
153
+ buf = "\n"
154
+ buf << '\begin{itemize}' << "\n"
155
+ buf
162
156
  end
163
157
 
164
158
  def ul_item(lines)
165
159
  str = lines.join
166
160
  str.sub!(/\A(\[)/){'\lbrack{}'}
167
- puts '\item ' + str
161
+ '\item ' + str + "\n"
168
162
  end
169
163
 
170
164
  def ul_end
171
- puts '\end{itemize}'
172
- blank
165
+ '\end{itemize}' + "\n"
173
166
  end
174
167
 
175
168
  def ol_begin
176
- blank
177
- puts '\begin{enumerate}'
169
+ buf = "\n"
170
+ buf << '\begin{enumerate}' << "\n"
178
171
  if @ol_num
179
- puts "\\setcounter{enumi}{#{@ol_num - 1}}"
172
+ buf << "\\setcounter{enumi}{#{@ol_num - 1}}\n"
180
173
  @ol_num = nil
181
174
  end
175
+ buf
182
176
  end
183
177
 
184
178
  def ol_item(lines, num)
185
179
  str = lines.join
186
180
  str.sub!(/\A(\[)/){'\lbrack{}'}
187
- puts '\item ' + str
181
+ '\item ' + str + "\n"
188
182
  end
189
183
 
190
184
  def ol_end
191
- puts '\end{enumerate}'
192
- blank
185
+ '\end{enumerate}' + "\n"
193
186
  end
194
187
 
195
188
  def dl_begin
196
- blank
197
- puts '\begin{description}'
189
+ "\n" + '\begin{description}' + "\n"
198
190
  end
199
191
 
200
192
  def dt(str)
201
193
  str.sub!(/\[/){'\lbrack{}'}
202
194
  str.sub!(/\]/){'\rbrack{}'}
203
- puts '\item[' + str + '] \mbox{} \\\\'
195
+ '\item[' + str + '] \mbox{} \\\\' + "\n"
204
196
  end
205
197
 
206
198
  def dd(lines)
207
- puts lines.join
199
+ lines.join + "\n"
208
200
  end
209
201
 
210
202
  def dl_end
211
- puts '\end{description}'
212
- blank
203
+ '\end{description}' + "\n"
213
204
  end
214
205
 
215
206
  def paragraph(lines)
216
- blank
207
+ buf = "\n"
217
208
  lines.each do |line|
218
- puts line
209
+ buf << line
219
210
  end
220
- blank
211
+ buf << "\n"
212
+ buf
221
213
  end
222
214
 
223
215
  def parasep
224
- puts '\\parasep'
216
+ '\\parasep' + "\n"
225
217
  end
226
218
 
227
219
  def read(lines)
@@ -236,88 +228,100 @@ module ReVIEW
236
228
  private :highlight_listings?
237
229
 
238
230
  def emlist(lines, caption = nil, lang = nil)
239
- blank
231
+ buf = "\n"
240
232
  if highlight_listings?
241
- common_code_block_lst(nil, lines, 'reviewemlistlst', 'title', caption, lang)
233
+ buf << common_code_block_lst(lines, 'reviewemlistlst', 'title', caption, lang)
242
234
  else
243
- common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx|
235
+ buf << common_code_block(lines, 'reviewemlist', caption, lang) do |line, idx|
244
236
  detab(line) + "\n"
245
237
  end
246
238
  end
239
+ buf
247
240
  end
248
241
 
249
242
  def emlistnum(lines, caption = nil, lang = nil)
250
- blank
243
+ buf = "\n"
251
244
  if highlight_listings?
252
- common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang)
245
+ buf << common_code_block_lst(lines, 'reviewemlistnumlst', 'title', caption, lang)
253
246
  else
254
- common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx|
247
+ buf << common_code_block(lines, 'reviewemlist', caption, lang) do |line, idx|
255
248
  detab((idx+1).to_s.rjust(2)+": " + line) + "\n"
256
249
  end
257
250
  end
251
+ buf
258
252
  end
259
253
 
260
254
  ## override Builder#list
261
- def list(lines, id, caption, lang = nil)
255
+ def list(lines, id, caption = nil, lang = nil)
256
+ buf = ""
262
257
  if highlight_listings?
263
- common_code_block_lst(id, lines, 'reviewlistlst', 'caption', caption, lang)
258
+ buf << common_code_block_lst(lines, 'reviewlistlst', 'caption', caption, lang)
264
259
  else
265
- common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx|
260
+ begin
261
+ buf << macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}") + "\n"
262
+ rescue KeyError
263
+ error "no such list: #{id}"
264
+ end
265
+ buf << common_code_block(lines, 'reviewlist', nil, lang) do |line, idx|
266
266
  detab(line) + "\n"
267
267
  end
268
268
  end
269
+ buf
269
270
  end
270
271
 
272
+
271
273
  ## override Builder#listnum
272
- def listnum(lines, id, caption, lang = nil)
274
+ def listnum(lines, id, caption = nil, lang = nil)
275
+ buf = ""
273
276
  if highlight_listings?
274
- common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang)
277
+ buf << common_code_block_lst(lines, 'reviewlistnumlst', 'caption', caption, lang)
275
278
  else
276
- common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx|
279
+ begin
280
+ buf << macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}") + "\n"
281
+ rescue KeyError
282
+ error "no such list: #{id}"
283
+ end
284
+ buf << common_code_block(lines, 'reviewlist', caption, lang) do |line, idx|
277
285
  detab((idx+1).to_s.rjust(2)+": " + line) + "\n"
278
286
  end
279
287
  end
288
+ buf
280
289
  end
281
290
 
282
291
  def cmd(lines, caption = nil, lang = nil)
292
+ buf = ""
283
293
  if highlight_listings?
284
- common_code_block_lst(nil, lines, 'reviewcmdlst', 'title', caption, lang)
294
+ buf << common_code_block_lst(lines, 'reviewcmdlst', 'title', caption, lang)
285
295
  else
286
- blank
287
- common_code_block(nil, lines, 'reviewcmd', caption, lang) do |line, idx|
296
+ buf << "\n"
297
+ buf << common_code_block(lines, 'reviewcmd', caption, lang) do |line, idx|
288
298
  detab(line) + "\n"
289
299
  end
290
300
  end
301
+ buf
291
302
  end
292
303
 
293
- def common_code_block(id, lines, command, caption, lang)
304
+ def common_code_block(lines, command, caption, lang)
294
305
  buf = ""
295
306
  if caption
296
- if command =~ /emlist/ || command =~ /cmd/
297
- puts macro(command + 'caption', "#{compile_inline(caption)}")
298
- else
299
- begin
300
- puts macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{compile_inline(caption)}")
301
- rescue KeyError
302
- error "no such list: #{id}"
303
- end
304
- end
307
+ buf << macro(command + 'caption', "#{caption}") + "\n"
305
308
  end
306
309
  body = ""
307
310
  lines.each_with_index do |line, idx|
308
311
  body.concat(yield(line, idx))
309
312
  end
310
- puts macro('begin' ,command)
311
- print body
312
- puts macro('end' ,command)
313
- blank
313
+ buf << macro('begin' ,command) + "\n"
314
+ buf << body
315
+ buf << macro('end' ,command) + "\n"
316
+ buf
314
317
  end
315
318
 
316
- def common_code_block_lst(id, lines, command, title, caption, lang)
317
- caption_str = compile_inline((caption || ""))
319
+ def common_code_block_lst(lines, command, title, caption, lang)
320
+ buf = ""
321
+ caption_str = (caption || "")
318
322
  if title == "title" && caption_str == ""
319
323
  caption_str = "\\relax" ## dummy charactor to remove lstname
320
- print "\\vspace{-1.5em}"
324
+ buf << "\\vspace{-1.5em}"
321
325
  end
322
326
  if @book.config["highlight"] && @book.config["highlight"]["lang"]
323
327
  lexer = @book.config["highlight"]["lang"] # default setting
@@ -326,24 +330,32 @@ module ReVIEW
326
330
  end
327
331
  lexer = lang if lang.present?
328
332
  body = lines.inject(''){|i, j| i + detab(unescape_latex(j)) + "\n"}
329
- puts "\\begin{"+command+"}["+title+"={"+caption_str+"},language={"+ lexer+"}]"
330
- print body
331
- puts "\\end{"+ command + "}"
332
- blank
333
+ buf << "\\begin{"+command+"}["+title+"={"+caption_str+"},language={"+ lexer+"}]" + "\n"
334
+ buf << body
335
+ buf << "\\end{"+ command + "}" + "\n"
336
+ buf
333
337
  end
334
338
 
335
- def source(lines, caption, lang = nil)
336
- if highlight_listings?
337
- common_code_block_lst(nil, lines, 'reviewlistlst', 'title', caption, lang)
338
- else
339
- puts '\begin{reviewlist}'
340
- puts macro('reviewlistcaption', compile_inline(caption))
341
- lines.each do |line|
342
- puts detab(line)
343
- end
344
- puts '\end{reviewlist}'
345
- puts ""
339
+ def source(lines, caption = nil)
340
+ buf = "\n"
341
+ buf << '\begin{reviewlist}' << "\n"
342
+ buf << source_header(caption)
343
+ buf << source_body(lines)
344
+ buf << '\end{reviewlist}' << "\n"
345
+ buf << "\n"
346
+ buf
347
+ end
348
+
349
+ def source_header(caption)
350
+ macro('reviewlistcaption', caption) + "\n"
351
+ end
352
+
353
+ def source_body(lines)
354
+ buf = ""
355
+ lines.each do |line|
356
+ buf << detab(line) << "\n"
346
357
  end
358
+ buf
347
359
  end
348
360
 
349
361
 
@@ -355,31 +367,34 @@ module ReVIEW
355
367
  end
356
368
 
357
369
  def image_image(id, caption, metric)
370
+ buf = ""
358
371
  metrics = parse_metric("latex", metric)
359
372
  # image is always bound here
360
- puts '\begin{reviewimage}'
373
+ buf << '\begin{reviewimage}' << "\n"
361
374
  if metrics.present?
362
- puts "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}"
375
+ buf << "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}\n"
363
376
  else
364
- puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}"
377
+ buf << "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}\n"
365
378
  end
366
379
  if caption.present?
367
- puts macro('caption', compile_inline(caption))
380
+ buf << macro('caption', caption) << "\n"
368
381
  end
369
- puts macro('label', image_label(id))
370
- puts '\end{reviewimage}'
382
+ buf << macro('label', image_label(id)) << "\n"
383
+ buf << '\end{reviewimage}' << "\n"
384
+ buf
371
385
  end
372
386
 
373
387
  def image_dummy(id, caption, lines)
374
- puts '\begin{reviewdummyimage}'
388
+ buf << '\begin{reviewdummyimage}' << "\n"
375
389
  path = @chapter.image(id).path
376
- puts "--[[path = #{path} (#{existence(id)})]]--"
390
+ buf << "--[[path = #{path} (#{existence(id)})]]--\n"
377
391
  lines.each do |line|
378
- puts detab(line.rstrip)
392
+ buf << detab(line.rstrip) << "\n"
379
393
  end
380
- puts macro('label', image_label(id))
381
- puts compile_inline(caption)
382
- puts '\end{reviewdummyimage}'
394
+ buf << macro('label', image_label(id)) << "\n"
395
+ buf << caption << "\n"
396
+ buf << '\end{reviewdummyimage}' << "\n"
397
+ buf
383
398
  end
384
399
 
385
400
  def existence(id)
@@ -422,23 +437,26 @@ module ReVIEW
422
437
  private :column_label
423
438
 
424
439
  def indepimage(id, caption=nil, metric=nil)
440
+ buf = ""
425
441
  metrics = parse_metric("latex", metric)
426
- puts '\begin{reviewimage}'
442
+ buf << '\begin{reviewimage}' << "\n"
427
443
  if metrics.present?
428
- puts "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}"
444
+ buf << "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}\n"
429
445
  else
430
- puts "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}"
446
+ buf << "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}\n"
431
447
  end
432
448
  if caption.present?
433
- puts macro('reviewindepimagecaption',
434
- %Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{compile_inline(caption)}])
449
+ buf << macro('reviewindepimagecaption',
450
+ %Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{caption}]) << "\n"
435
451
  end
436
- puts '\end{reviewimage}'
452
+ buf << '\end{reviewimage}' << "\n"
453
+ buf
437
454
  end
438
455
 
439
456
  alias_method :numberlessimage, :indepimage
440
457
 
441
458
  def table(lines, id = nil, caption = nil)
459
+ buf = ""
442
460
  rows = []
443
461
  sepidx = nil
444
462
  lines.each_with_index do |line, idx|
@@ -453,49 +471,54 @@ module ReVIEW
453
471
  rows = adjust_n_cols(rows)
454
472
 
455
473
  begin
456
- table_header id, caption unless caption.nil?
474
+ buf << table_header(id, caption) unless caption.nil?
457
475
  rescue KeyError
458
476
  error "no such table: #{id}"
459
477
  end
460
- return if rows.empty?
461
- table_begin rows.first.size
478
+ return buf if rows.empty?
479
+ buf << table_begin(rows.first.size)
462
480
  if sepidx
463
481
  sepidx.times do
464
- tr rows.shift.map {|s| th(s) }
482
+ buf << tr(rows.shift.map {|s| th(s) })
465
483
  end
466
484
  rows.each do |cols|
467
- tr cols.map {|s| td(s) }
485
+ buf << tr(cols.map {|s| td(s) })
468
486
  end
469
487
  else
470
488
  rows.each do |cols|
471
489
  h, *cs = *cols
472
- tr [th(h)] + cs.map {|s| td(s) }
490
+ buf << tr([th(h)] + cs.map {|s| td(s) })
473
491
  end
474
492
  end
475
- table_end
493
+ buf << table_end
494
+ buf
476
495
  end
477
496
 
478
497
  def table_header(id, caption)
498
+ buf = ""
479
499
  if caption.present?
480
500
  @table_caption = true
481
- puts '\begin{table}[h]'
482
- puts macro('reviewtablecaption', compile_inline(caption))
501
+ buf << '\begin{table}[h]' << "\n"
502
+ buf << macro('reviewtablecaption', caption) << "\n"
483
503
  end
484
- puts macro('label', table_label(id))
504
+ buf << macro('label', table_label(id)) << "\n"
505
+ buf
485
506
  end
486
507
 
487
508
  def table_begin(ncols)
509
+ buf = ""
488
510
  if @latex_tsize
489
- puts macro('begin', 'reviewtable', @latex_tsize)
511
+ buf << macro('begin', 'reviewtable', @latex_tsize) << "\n"
490
512
  elsif @tsize
491
513
  cellwidth = @tsize.split(/\s*,\s*/)
492
- puts macro('begin', 'reviewtable', '|'+(cellwidth.collect{|i| "p{#{i}mm}"}.join('|'))+'|')
514
+ buf << macro('begin', 'reviewtable', '|'+(cellwidth.collect{|i| "p{#{i}mm}"}.join('|'))+'|') << "\n"
493
515
  else
494
- puts macro('begin', 'reviewtable', (['|'] * (ncols + 1)).join('l'))
516
+ buf << macro('begin', 'reviewtable', (['|'] * (ncols + 1)).join('l')) << "\n"
495
517
  end
496
- puts '\hline'
518
+ buf << '\hline' << "\n"
497
519
  @tsize = nil
498
520
  @latex_tsize = nil
521
+ buf
499
522
  end
500
523
 
501
524
  def table_separator
@@ -504,7 +527,7 @@ module ReVIEW
504
527
 
505
528
  def th(s)
506
529
  ## use shortstack for @<br>
507
- if /\\\\/i =~ s
530
+ if /\\\\/i =~ s
508
531
  macro('reviewth', macro('shortstack[l]', s))
509
532
  else
510
533
  macro('reviewth', s)
@@ -513,7 +536,7 @@ module ReVIEW
513
536
 
514
537
  def td(s)
515
538
  ## use shortstack for @<br>
516
- if /\\\\/ =~ s
539
+ if /\\\\/ =~ s
517
540
  macro('shortstack[l]', s)
518
541
  else
519
542
  s
@@ -521,17 +544,21 @@ module ReVIEW
521
544
  end
522
545
 
523
546
  def tr(rows)
524
- print rows.join(' & ')
525
- puts ' \\\\ \hline'
547
+ buf = ""
548
+ buf << rows.join(' & ') << "\n"
549
+ buf << ' \\\\ \hline' << "\n"
550
+ buf
526
551
  end
527
552
 
528
553
  def table_end
529
- puts macro('end', 'reviewtable')
554
+ buf = ""
555
+ buf << macro('end', 'reviewtable') << "\n"
530
556
  if @table_caption
531
- puts '\end{table}'
557
+ buf << '\end{table}' << "\n"
532
558
  end
533
559
  @table_caption = nil
534
- blank
560
+ buf << "\n"
561
+ buf
535
562
  end
536
563
 
537
564
  def quote(lines)
@@ -549,65 +576,72 @@ module ReVIEW
549
576
  end
550
577
 
551
578
  def texequation(lines)
552
- blank
553
- puts macro('begin','equation*')
579
+ buf = "\n"
580
+ buf << macro('begin','equation*') << "\n"
554
581
  lines.each do |line|
555
- puts unescape_latex(line)
582
+ buf << unescape_latex(line) << "\n"
556
583
  end
557
- puts macro('end', 'equation*')
558
- blank
584
+ buf << macro('end', 'equation*') << "\n"
585
+ buf << "\n"
586
+ buf
559
587
  end
560
588
 
561
589
  def latex_block(type, lines)
562
- blank
563
- puts macro('begin', type)
590
+ buf = "\n"
591
+ buf << macro('begin', type)
564
592
  if @book.config["deprecated-blocklines"].nil?
565
- blocked_lines = split_paragraph(lines)
566
- puts blocked_lines.join("\n\n")
593
+ buf << lines.join("")
567
594
  else
568
- lines.each do |line|
569
- puts line
570
- end
595
+ error "deprecated-blocklines is obsoleted."
571
596
  end
572
- puts macro('end', type)
573
- blank
597
+ buf << macro('end', type) << "\n"
598
+ buf
574
599
  end
575
600
  private :latex_block
576
601
 
577
602
  def direct(lines, fmt)
578
- return unless fmt == 'latex'
603
+ buf = ""
604
+ return buf unless fmt == 'latex'
579
605
  lines.each do |line|
580
- puts line
606
+ buf << line << "\n"
581
607
  end
608
+ buf
582
609
  end
583
610
 
584
611
  def comment(lines, comment = nil)
612
+ buf = ""
585
613
  lines ||= []
586
614
  lines.unshift comment unless comment.blank?
587
615
  if @book.config["draft"]
588
616
  str = lines.join("")
589
- puts macro('pdfcomment', escape(str))
617
+ buf << macro('pdfcomment', str) << "\n"
590
618
  end
619
+ buf
591
620
  end
592
621
 
593
622
  def hr
594
- puts '\hrule'
623
+ '\hrule' + "\n"
595
624
  end
596
625
 
597
626
  def label(id)
598
- puts macro('label', id)
627
+ macro('label', id) + "\n"
628
+ end
629
+
630
+ def node_label(node)
631
+ id = node.args[0].to_raw
632
+ macro('label', id) + "\n"
599
633
  end
600
634
 
601
635
  def pagebreak
602
- puts '\pagebreak'
636
+ '\pagebreak' + "\n"
603
637
  end
604
638
 
605
639
  def linebreak
606
- puts '\\\\'
640
+ '\\\\' + "\n"
607
641
  end
608
642
 
609
643
  def noindent
610
- print '\noindent'
644
+ '\noindent'
611
645
  end
612
646
 
613
647
  def inline_chapref(id)
@@ -664,8 +698,8 @@ module ReVIEW
664
698
 
665
699
  def footnote(id, content)
666
700
  if @book.config["footnotetext"]
667
- puts macro("footnotetext[#{@chapter.footnote(id).number}]",
668
- compile_inline(content.strip))
701
+ macro("footnotetext[#{@chapter.footnote(id).number}]",
702
+ content.strip) + "\n"
669
703
  end
670
704
  end
671
705
 
@@ -673,7 +707,7 @@ module ReVIEW
673
707
  if @book.config["footnotetext"]
674
708
  macro("footnotemark[#{@chapter.footnote(id).number}]", "")
675
709
  else
676
- macro('footnote', compile_inline(@chapter.footnote(id).content.strip))
710
+ macro('footnote', escape(@chapter.footnote(id).content.strip))
677
711
  end
678
712
  end
679
713
 
@@ -684,12 +718,16 @@ module ReVIEW
684
718
  end
685
719
 
686
720
  def compile_ruby(base, ruby)
687
- macro('ruby', escape(base), escape(ruby))
721
+ macro('ruby', base, ruby)
688
722
  end
689
723
 
690
724
  # math
691
- def inline_m(str)
692
- " $#{str}$ "
725
+ # def inline_m(str)
726
+ # " $#{str}$ "
727
+ # end
728
+
729
+ def node_inline_m(node)
730
+ " $#{node[0].to_raw}$ "
693
731
  end
694
732
 
695
733
  # hidden index
@@ -699,7 +737,7 @@ module ReVIEW
699
737
 
700
738
  # index -> italic
701
739
  def inline_i(str)
702
- macro('textit', escape(str))
740
+ macro('textit', str)
703
741
  end
704
742
 
705
743
  # index
@@ -707,14 +745,24 @@ module ReVIEW
707
745
  escape(str) + index(str)
708
746
  end
709
747
 
748
+ def node_inline_idx(nodelist)
749
+ content = nodelist[0].to_raw
750
+ escape(content) + index(content)
751
+ end
752
+
710
753
  # hidden index??
711
754
  def inline_hidx(str)
712
755
  index(str)
713
756
  end
714
757
 
758
+ def node_inline_hidx(nodelist)
759
+ content = nodelist[0].to_raw
760
+ index(content)
761
+ end
762
+
715
763
  # bold
716
764
  def inline_b(str)
717
- macro('textbf', escape(str))
765
+ macro('textbf', str)
718
766
  end
719
767
 
720
768
  # line break
@@ -729,7 +777,7 @@ module ReVIEW
729
777
 
730
778
  ## @<code> is same as @<tt>
731
779
  def inline_code(str)
732
- macro('texttt', escape(str))
780
+ macro('texttt', str)
733
781
  end
734
782
 
735
783
  def nofunc_text(str)
@@ -737,19 +785,19 @@ module ReVIEW
737
785
  end
738
786
 
739
787
  def inline_tt(str)
740
- macro('texttt', escape(str))
788
+ macro('texttt', str)
741
789
  end
742
790
 
743
791
  def inline_del(str)
744
- macro('reviewstrike', escape(str))
792
+ macro('reviewstrike', str)
745
793
  end
746
794
 
747
795
  def inline_tti(str)
748
- macro('texttt', macro('textit', escape(str)))
796
+ macro('texttt', macro('textit', str))
749
797
  end
750
798
 
751
799
  def inline_ttb(str)
752
- macro('texttt', macro('textbf', escape(str)))
800
+ macro('texttt', macro('textbf', str))
753
801
  end
754
802
 
755
803
  def inline_bib(id)
@@ -759,15 +807,15 @@ module ReVIEW
759
807
  def inline_hd_chap(chap, id)
760
808
  n = chap.headline_index.number(id)
761
809
  if chap.number and @book.config["secnolevel"] >= n.split('.').size
762
- str = I18n.t("chapter_quote", "#{chap.headline_index.number(id)} #{compile_inline(chap.headline(id).caption)}")
810
+ str = I18n.t("chapter_quote", "#{chap.headline_index.number(id)} #{chap.headline(id).caption}")
763
811
  else
764
- str = I18n.t("chapter_quote", compile_inline(chap.headline(id).caption))
812
+ str = I18n.t("chapter_quote", chap.headline(id).caption)
765
813
  end
766
814
  if @book.config["chapterlink"]
767
815
  anchor = n.gsub(/\./, "-")
768
- macro('reviewsecref', str, sec_label(anchor))
816
+ macro('reviewsecref', escape(str), sec_label(anchor))
769
817
  else
770
- str
818
+ escape(str)
771
819
  end
772
820
  end
773
821
 
@@ -780,27 +828,27 @@ module ReVIEW
780
828
  end
781
829
 
782
830
  def inline_sub(str)
783
- macro('textsubscript', escape(str))
831
+ macro('textsubscript', str)
784
832
  end
785
833
 
786
834
  def inline_sup(str)
787
- macro('textsuperscript', escape(str))
835
+ macro('textsuperscript', str)
788
836
  end
789
837
 
790
838
  def inline_em(str)
791
- macro('reviewem', escape(str))
839
+ macro('reviewem', str)
792
840
  end
793
841
 
794
842
  def inline_strong(str)
795
- macro('reviewstrong', escape(str))
843
+ macro('reviewstrong', str)
796
844
  end
797
845
 
798
846
  def inline_u(str)
799
- macro('Underline', escape(str))
847
+ macro('Underline', str)
800
848
  end
801
849
 
802
850
  def inline_ami(str)
803
- macro('reviewami', escape(str))
851
+ macro('reviewami', str)
804
852
  end
805
853
 
806
854
  def inline_icon(id)
@@ -809,7 +857,7 @@ module ReVIEW
809
857
 
810
858
  def inline_uchar(str)
811
859
  # with otf package
812
- macro('UTF', escape(str))
860
+ macro('UTF', str)
813
861
  end
814
862
 
815
863
  def inline_comment(str)
@@ -820,46 +868,44 @@ module ReVIEW
820
868
  end
821
869
  end
822
870
 
871
+ def bibpaper(lines, id, caption)
872
+ buf = ""
873
+ buf << bibpaper_header(id, caption)
874
+ if lines.empty?
875
+ buf << "\n"
876
+ else
877
+ buf << "\n"
878
+ buf << bibpaper_bibpaper(id, caption, lines)
879
+ end
880
+ buf << "\n"
881
+ buf
882
+ end
883
+
823
884
  def bibpaper_header(id, caption)
824
- puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}"
825
- puts macro('label', bib_label(id))
885
+ "[#{@chapter.bibpaper(id).number}] #{caption}\n" +
886
+ macro('label', bib_label(id))
826
887
  end
827
888
 
828
889
  def bibpaper_bibpaper(id, caption, lines)
829
- print split_paragraph(lines).join("")
830
- puts ""
890
+ lines.join("")
831
891
  end
832
892
 
833
893
  def index(str)
834
- str.sub!(/\(\)/, '')
835
- decl = ''
836
- if /@\z/ =~ str
837
- str.chop!
838
- decl = '|IndexDecl'
839
- end
840
- unless /[^ -~]/ =~ str
841
- if /\^/ =~ str
842
- macro('index', escape_index(str.gsub(/\^/, '')) + '@' + escape_index(text(str)) + decl)
843
- else
844
- '\index{' + escape_index(text(str)) + decl + '}'
845
- end
846
- else
847
- '\index{' + escape_index(@index_db[str]) + '@' + escape_index(text(str)) + '}'
848
- end
894
+ "\\index{" + str + "}"
849
895
  end
850
896
 
851
897
  def compile_kw(word, alt)
852
898
  if alt
853
- macro('reviewkw', escape(word)) + "(#{escape(alt.strip)})"
899
+ macro('reviewkw', word) + "(#{alt.strip})"
854
900
  else
855
- macro('reviewkw', escape(word))
901
+ macro('reviewkw', word)
856
902
  end
857
903
  end
858
904
 
859
905
  def compile_href(url, label)
860
906
  if /\A[a-z]+:/ =~ url
861
907
  if label
862
- macro("href", escape_url(url), escape(label))
908
+ macro("href", escape_url(url), label)
863
909
  else
864
910
  macro("url", escape_url(url))
865
911
  end