review 1.7.2 → 2.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -43
- data/.travis.yml +0 -9
- data/ChangeLog +0 -16
- data/Gemfile +1 -0
- data/README.rdoc +1 -1
- data/Rakefile +12 -1
- data/bin/review-check +21 -8
- data/bin/review-compile +15 -9
- data/bin/review-epubmaker-legacy +6 -6
- data/bin/review-index +13 -2
- data/bin/review-init +18 -12
- data/bin/review-preproc +14 -1
- data/bin/review-validate +1 -1
- data/bin/review-vol +13 -1
- data/doc/quickstart.ja.md +1 -1
- data/doc/quickstart.md +1 -1
- data/lib/epubmaker/content.rb +3 -3
- data/lib/epubmaker/epubcommon.rb +108 -91
- data/lib/epubmaker/epubv2.rb +67 -14
- data/lib/epubmaker/epubv3.rb +59 -25
- data/lib/epubmaker/producer.rb +1 -13
- data/lib/lineinput.rb +0 -48
- data/lib/review/book/base.rb +4 -12
- data/lib/review/book/compilable.rb +3 -1
- data/lib/review/book/index.rb +4 -4
- data/lib/review/builder.rb +54 -47
- data/lib/review/compiler.rb +4662 -326
- data/lib/review/compiler/literals_1_8.kpeg +19 -0
- data/lib/review/compiler/literals_1_8.rb +432 -0
- data/lib/review/compiler/literals_1_9.kpeg +22 -0
- data/lib/review/compiler/literals_1_9.rb +435 -0
- data/lib/review/configure.rb +8 -20
- data/lib/review/epubbuilder.rb +1 -1
- data/lib/review/epubmaker.rb +122 -52
- data/lib/review/ewbbuilder.rb +4 -4
- data/lib/review/exception.rb +1 -1
- data/lib/review/extentions.rb +1 -0
- data/lib/review/extentions/array.rb +25 -0
- data/lib/review/htmlbuilder.rb +286 -275
- data/lib/review/htmllayout.rb +0 -2
- data/lib/review/htmlutils.rb +4 -4
- data/lib/review/i18n.rb +2 -6
- data/lib/review/i18n.yml +1 -1
- data/lib/review/idgxmlbuilder.rb +239 -204
- data/lib/review/inaobuilder.rb +75 -73
- data/lib/review/latexbuilder.rb +265 -219
- data/lib/review/latexutils.rb +6 -6
- data/lib/review/layout.tex.erb +1 -1
- data/lib/review/location.rb +24 -0
- data/lib/review/markdownbuilder.rb +124 -79
- data/lib/review/node.rb +267 -0
- data/lib/review/pdfmaker.rb +92 -92
- data/lib/review/preprocessor.rb +51 -14
- data/lib/review/review.kpeg +724 -0
- data/lib/review/textbuilder.rb +1 -1
- data/lib/review/textutils.rb +24 -18
- data/lib/review/tocparser.rb +3 -3
- data/lib/review/tocprinter.rb +31 -8
- data/lib/review/topbuilder.rb +119 -111
- data/lib/review/unfold.rb +2 -2
- data/lib/review/version.rb +1 -1
- data/review.gemspec +2 -2
- data/rubocop-todo.yml +456 -0
- data/test/assets/test_template.tex +1 -1
- data/test/sample-book/src/config.yml +0 -1
- data/test/test.re +1 -1
- data/test/test_book.rb +4 -4
- data/test/test_book_chapter.rb +70 -0
- data/test/test_book_part.rb +1 -1
- data/test/test_builder.rb +6 -28
- data/test/test_compiler.rb +59 -14
- data/test/test_helper.rb +47 -4
- data/test/test_htmlbuilder.rb +104 -73
- data/test/test_i18n.rb +5 -3
- data/test/test_idgxmlbuilder.rb +5 -2
- data/test/test_inaobuilder.rb +4 -2
- data/test/test_latexbuilder.rb +18 -37
- data/test/test_lineinput.rb +25 -4
- data/test/test_markdownbuilder.rb +4 -22
- data/test/test_pdfmaker.rb +12 -11
- data/test/test_textutils.rb +0 -36
- data/test/test_topbuilder.rb +2 -0
- metadata +14 -28
- data/.rubocop_todo.yml +0 -605
- data/Dockerfile +0 -22
- data/doc/NEWS.ja.md +0 -362
- data/doc/NEWS.md +0 -366
- data/lib/review/htmltoc.rb +0 -45
- data/lib/review/template.rb +0 -21
- data/templates/html/layout-html5.html.erb +0 -17
- data/templates/html/layout-xhtml1.html.erb +0 -20
- data/templates/ncx/epubv2.ncx.erb +0 -11
- data/templates/opf/epubv2.opf.erb +0 -21
- data/templates/opf/epubv3.opf.erb +0 -18
- data/templates/xml/container.xml.erb +0 -6
- data/test/assets/test.xml.erb +0 -3
- data/test/sample-book/src/config-epub2.yml +0 -186
- data/test/test_configure.rb +0 -50
- data/test/test_htmltoc.rb +0 -32
- data/test/test_template.rb +0 -26
data/lib/review/inaobuilder.rb
CHANGED
@@ -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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
71
|
+
"#{prefix}#{caption}\n"
|
92
72
|
end
|
93
73
|
|
94
74
|
def paragraph(lines)
|
95
|
-
|
75
|
+
buf = ""
|
76
|
+
buf << " " if @noindent.nil?
|
96
77
|
@noindent = nil
|
97
|
-
|
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
|
-
"◆注/◆#{
|
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
|
-
|
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
|
-
|
148
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
177
|
+
buf = "◆list/◆\n"
|
189
178
|
if get_chap.nil?
|
190
|
-
|
179
|
+
buf << %Q[●リスト#{@chapter.list(id).number} #{caption}\n]
|
191
180
|
else
|
192
|
-
|
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
|
-
|
189
|
+
buf << detab(line) << "\n"
|
199
190
|
end
|
200
|
-
|
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
|
-
|
198
|
+
buf << detab((i+1).to_s.rjust(2) + " " + line) << "\n"
|
206
199
|
end
|
207
|
-
|
200
|
+
buf << "◆/list◆\n"
|
201
|
+
buf
|
208
202
|
end
|
209
203
|
|
210
|
-
def emlist(lines, caption=nil)
|
211
|
-
|
212
|
-
|
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
|
-
|
209
|
+
buf << detab(line) << "\n"
|
215
210
|
end
|
216
|
-
|
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
|
-
|
232
|
-
|
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
|
-
|
230
|
+
buf << detab(line) << "\n"
|
235
231
|
end
|
236
|
-
|
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
|
-
|
248
|
+
buf << "●図#{@chapter.image(id).number} #{caption}\n"
|
251
249
|
else
|
252
|
-
|
250
|
+
buf << "●図#{get_chap}.#{@chapter.image(id).number} #{caption}\n"
|
253
251
|
end
|
254
252
|
if @chapter.image(id).bound?
|
255
|
-
|
253
|
+
buf << @chapter.image(id).path << "\n"
|
256
254
|
else
|
257
255
|
lines.each do |line|
|
258
|
-
|
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
|
-
|
286
|
+
buf << "◆table/◆\n"
|
287
287
|
begin
|
288
|
-
table_header
|
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
|
292
|
+
return buf if rows.empty?
|
293
|
+
buf << table_begin(rows.first.size)
|
294
294
|
if sepidx
|
295
295
|
sepidx.times do
|
296
|
-
|
297
|
-
tr
|
296
|
+
buf << "◆table-title◆"
|
297
|
+
buf << tr(rows.shift.map {|s| th(s) })
|
298
298
|
end
|
299
299
|
rows.each do |cols|
|
300
|
-
tr
|
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
|
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
|
-
|
314
|
+
"●表#{@chapter.table(id).number} #{caption}\n"
|
314
315
|
else
|
315
|
-
|
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
|
-
|
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
|
-
|
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
|
357
|
+
end # module ReVIEW
|
data/lib/review/latexbuilder.rb
CHANGED
@@ -47,23 +47,10 @@ module ReVIEW
|
|
47
47
|
end
|
48
48
|
private :blank
|
49
49
|
|
50
|
-
def
|
51
|
-
|
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 :
|
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
|
-
|
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
|
-
|
77
|
+
buf << "\\addcontentsline{toc}{#{headline_name}}{#{caption}}\n"
|
91
78
|
end
|
92
79
|
if level == 1
|
93
|
-
|
80
|
+
buf << macro('label', chapter_label) << "\n"
|
94
81
|
else
|
95
|
-
|
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
|
-
|
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
|
-
|
99
|
+
if @blank_needed
|
100
|
+
buf << "\n"
|
101
|
+
blank_reset
|
102
|
+
end
|
103
|
+
buf << "\\begin{reviewcolumn}\n"
|
112
104
|
if label
|
113
|
-
|
105
|
+
buf << "\\hypertarget{#{column_label(label)}}{}\n"
|
114
106
|
else
|
115
|
-
|
107
|
+
buf << "\\hypertarget{#{column_label(caption)}}{}\n"
|
116
108
|
end
|
117
|
-
|
109
|
+
buf << macro('reviewcolumnhead', nil, caption) << "\n"
|
118
110
|
if level <= @book.config["toclevel"].to_i
|
119
|
-
|
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
|
-
|
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
|
-
|
124
|
+
buf = ""
|
125
|
+
buf << "\\begin{reviewminicolumn}\n"
|
130
126
|
unless caption.nil?
|
131
|
-
|
127
|
+
buf << "\\reviewminicolumntitle{#{caption}}"
|
132
128
|
end
|
133
129
|
|
134
130
|
if @book.config["deprecated-blocklines"].nil?
|
135
|
-
|
136
|
-
puts blocked_lines.join("\n\n")
|
131
|
+
buf << lines.join("")
|
137
132
|
else
|
138
|
-
|
139
|
-
puts line
|
140
|
-
end
|
133
|
+
error "deprecated-blocklines is obsoleted."
|
141
134
|
end
|
142
135
|
|
143
|
-
|
136
|
+
buf << "\\end{reviewminicolumn}\n"
|
137
|
+
buf
|
144
138
|
end
|
145
139
|
|
146
140
|
def box(lines, caption = nil)
|
147
|
-
|
141
|
+
buf = "\n"
|
148
142
|
if caption
|
149
|
-
|
143
|
+
buf << macro('reviewboxcaption', "#{caption}") << "\n"
|
150
144
|
end
|
151
|
-
|
145
|
+
buf << '\begin{reviewbox}' << "\n"
|
152
146
|
lines.each do |line|
|
153
|
-
|
154
|
-
end
|
155
|
-
|
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
|
-
|
161
|
-
|
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
|
-
|
161
|
+
'\item ' + str + "\n"
|
168
162
|
end
|
169
163
|
|
170
164
|
def ul_end
|
171
|
-
|
172
|
-
blank
|
165
|
+
'\end{itemize}' + "\n"
|
173
166
|
end
|
174
167
|
|
175
168
|
def ol_begin
|
176
|
-
|
177
|
-
|
169
|
+
buf = "\n"
|
170
|
+
buf << '\begin{enumerate}' << "\n"
|
178
171
|
if @ol_num
|
179
|
-
|
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
|
-
|
181
|
+
'\item ' + str + "\n"
|
188
182
|
end
|
189
183
|
|
190
184
|
def ol_end
|
191
|
-
|
192
|
-
blank
|
185
|
+
'\end{enumerate}' + "\n"
|
193
186
|
end
|
194
187
|
|
195
188
|
def dl_begin
|
196
|
-
|
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
|
-
|
195
|
+
'\item[' + str + '] \mbox{} \\\\' + "\n"
|
204
196
|
end
|
205
197
|
|
206
198
|
def dd(lines)
|
207
|
-
|
199
|
+
lines.join + "\n"
|
208
200
|
end
|
209
201
|
|
210
202
|
def dl_end
|
211
|
-
|
212
|
-
blank
|
203
|
+
'\end{description}' + "\n"
|
213
204
|
end
|
214
205
|
|
215
206
|
def paragraph(lines)
|
216
|
-
|
207
|
+
buf = "\n"
|
217
208
|
lines.each do |line|
|
218
|
-
|
209
|
+
buf << line
|
219
210
|
end
|
220
|
-
|
211
|
+
buf << "\n"
|
212
|
+
buf
|
221
213
|
end
|
222
214
|
|
223
215
|
def parasep
|
224
|
-
|
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
|
-
|
231
|
+
buf = "\n"
|
240
232
|
if highlight_listings?
|
241
|
-
common_code_block_lst(
|
233
|
+
buf << common_code_block_lst(lines, 'reviewemlistlst', 'title', caption, lang)
|
242
234
|
else
|
243
|
-
common_code_block(
|
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
|
-
|
243
|
+
buf = "\n"
|
251
244
|
if highlight_listings?
|
252
|
-
common_code_block_lst(
|
245
|
+
buf << common_code_block_lst(lines, 'reviewemlistnumlst', 'title', caption, lang)
|
253
246
|
else
|
254
|
-
common_code_block(
|
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(
|
258
|
+
buf << common_code_block_lst(lines, 'reviewlistlst', 'caption', caption, lang)
|
264
259
|
else
|
265
|
-
|
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(
|
277
|
+
buf << common_code_block_lst(lines, 'reviewlistnumlst', 'caption', caption, lang)
|
275
278
|
else
|
276
|
-
|
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(
|
294
|
+
buf << common_code_block_lst(lines, 'reviewcmdlst', 'title', caption, lang)
|
285
295
|
else
|
286
|
-
|
287
|
-
common_code_block(
|
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(
|
304
|
+
def common_code_block(lines, command, caption, lang)
|
294
305
|
buf = ""
|
295
306
|
if caption
|
296
|
-
|
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
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
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(
|
317
|
-
|
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
|
-
|
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
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
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
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
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
|
-
|
373
|
+
buf << '\begin{reviewimage}' << "\n"
|
361
374
|
if metrics.present?
|
362
|
-
|
375
|
+
buf << "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}\n"
|
363
376
|
else
|
364
|
-
|
377
|
+
buf << "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}\n"
|
365
378
|
end
|
366
379
|
if caption.present?
|
367
|
-
|
380
|
+
buf << macro('caption', caption) << "\n"
|
368
381
|
end
|
369
|
-
|
370
|
-
|
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
|
-
|
388
|
+
buf << '\begin{reviewdummyimage}' << "\n"
|
375
389
|
path = @chapter.image(id).path
|
376
|
-
|
390
|
+
buf << "--[[path = #{path} (#{existence(id)})]]--\n"
|
377
391
|
lines.each do |line|
|
378
|
-
|
392
|
+
buf << detab(line.rstrip) << "\n"
|
379
393
|
end
|
380
|
-
|
381
|
-
|
382
|
-
|
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
|
-
|
442
|
+
buf << '\begin{reviewimage}' << "\n"
|
427
443
|
if metrics.present?
|
428
|
-
|
444
|
+
buf << "\\includegraphics[#{metrics}]{#{@chapter.image(id).path}}\n"
|
429
445
|
else
|
430
|
-
|
446
|
+
buf << "\\includegraphics[width=\\maxwidth]{#{@chapter.image(id).path}}\n"
|
431
447
|
end
|
432
448
|
if caption.present?
|
433
|
-
|
434
|
-
%Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{
|
449
|
+
buf << macro('reviewindepimagecaption',
|
450
|
+
%Q[#{I18n.t("numberless_image")}#{I18n.t("caption_prefix")}#{caption}]) << "\n"
|
435
451
|
end
|
436
|
-
|
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
|
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
|
478
|
+
return buf if rows.empty?
|
479
|
+
buf << table_begin(rows.first.size)
|
462
480
|
if sepidx
|
463
481
|
sepidx.times do
|
464
|
-
tr
|
482
|
+
buf << tr(rows.shift.map {|s| th(s) })
|
465
483
|
end
|
466
484
|
rows.each do |cols|
|
467
|
-
tr
|
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
|
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
|
-
|
482
|
-
|
501
|
+
buf << '\begin{table}[h]' << "\n"
|
502
|
+
buf << macro('reviewtablecaption', caption) << "\n"
|
483
503
|
end
|
484
|
-
|
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
|
-
|
511
|
+
buf << macro('begin', 'reviewtable', @latex_tsize) << "\n"
|
490
512
|
elsif @tsize
|
491
513
|
cellwidth = @tsize.split(/\s*,\s*/)
|
492
|
-
|
514
|
+
buf << macro('begin', 'reviewtable', '|'+(cellwidth.collect{|i| "p{#{i}mm}"}.join('|'))+'|') << "\n"
|
493
515
|
else
|
494
|
-
|
516
|
+
buf << macro('begin', 'reviewtable', (['|'] * (ncols + 1)).join('l')) << "\n"
|
495
517
|
end
|
496
|
-
|
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
|
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
|
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
|
-
|
525
|
-
|
547
|
+
buf = ""
|
548
|
+
buf << rows.join(' & ') << "\n"
|
549
|
+
buf << ' \\\\ \hline' << "\n"
|
550
|
+
buf
|
526
551
|
end
|
527
552
|
|
528
553
|
def table_end
|
529
|
-
|
554
|
+
buf = ""
|
555
|
+
buf << macro('end', 'reviewtable') << "\n"
|
530
556
|
if @table_caption
|
531
|
-
|
557
|
+
buf << '\end{table}' << "\n"
|
532
558
|
end
|
533
559
|
@table_caption = nil
|
534
|
-
|
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
|
-
|
553
|
-
|
579
|
+
buf = "\n"
|
580
|
+
buf << macro('begin','equation*') << "\n"
|
554
581
|
lines.each do |line|
|
555
|
-
|
582
|
+
buf << unescape_latex(line) << "\n"
|
556
583
|
end
|
557
|
-
|
558
|
-
|
584
|
+
buf << macro('end', 'equation*') << "\n"
|
585
|
+
buf << "\n"
|
586
|
+
buf
|
559
587
|
end
|
560
588
|
|
561
589
|
def latex_block(type, lines)
|
562
|
-
|
563
|
-
|
590
|
+
buf = "\n"
|
591
|
+
buf << macro('begin', type)
|
564
592
|
if @book.config["deprecated-blocklines"].nil?
|
565
|
-
|
566
|
-
puts blocked_lines.join("\n\n")
|
593
|
+
buf << lines.join("")
|
567
594
|
else
|
568
|
-
|
569
|
-
puts line
|
570
|
-
end
|
595
|
+
error "deprecated-blocklines is obsoleted."
|
571
596
|
end
|
572
|
-
|
573
|
-
|
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
|
-
|
603
|
+
buf = ""
|
604
|
+
return buf unless fmt == 'latex'
|
579
605
|
lines.each do |line|
|
580
|
-
|
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
|
-
|
617
|
+
buf << macro('pdfcomment', str) << "\n"
|
590
618
|
end
|
619
|
+
buf
|
591
620
|
end
|
592
621
|
|
593
622
|
def hr
|
594
|
-
|
623
|
+
'\hrule' + "\n"
|
595
624
|
end
|
596
625
|
|
597
626
|
def label(id)
|
598
|
-
|
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
|
-
|
636
|
+
'\pagebreak' + "\n"
|
603
637
|
end
|
604
638
|
|
605
639
|
def linebreak
|
606
|
-
|
640
|
+
'\\\\' + "\n"
|
607
641
|
end
|
608
642
|
|
609
643
|
def noindent
|
610
|
-
|
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
|
-
|
668
|
-
|
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',
|
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',
|
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',
|
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',
|
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',
|
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',
|
788
|
+
macro('texttt', str)
|
741
789
|
end
|
742
790
|
|
743
791
|
def inline_del(str)
|
744
|
-
macro('reviewstrike',
|
792
|
+
macro('reviewstrike', str)
|
745
793
|
end
|
746
794
|
|
747
795
|
def inline_tti(str)
|
748
|
-
macro('texttt', macro('textit',
|
796
|
+
macro('texttt', macro('textit', str))
|
749
797
|
end
|
750
798
|
|
751
799
|
def inline_ttb(str)
|
752
|
-
macro('texttt', macro('textbf',
|
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)} #{
|
810
|
+
str = I18n.t("chapter_quote", "#{chap.headline_index.number(id)} #{chap.headline(id).caption}")
|
763
811
|
else
|
764
|
-
str = I18n.t("chapter_quote",
|
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',
|
831
|
+
macro('textsubscript', str)
|
784
832
|
end
|
785
833
|
|
786
834
|
def inline_sup(str)
|
787
|
-
macro('textsuperscript',
|
835
|
+
macro('textsuperscript', str)
|
788
836
|
end
|
789
837
|
|
790
838
|
def inline_em(str)
|
791
|
-
macro('reviewem',
|
839
|
+
macro('reviewem', str)
|
792
840
|
end
|
793
841
|
|
794
842
|
def inline_strong(str)
|
795
|
-
macro('reviewstrong',
|
843
|
+
macro('reviewstrong', str)
|
796
844
|
end
|
797
845
|
|
798
846
|
def inline_u(str)
|
799
|
-
macro('Underline',
|
847
|
+
macro('Underline', str)
|
800
848
|
end
|
801
849
|
|
802
850
|
def inline_ami(str)
|
803
|
-
macro('reviewami',
|
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',
|
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
|
-
|
825
|
-
|
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
|
-
|
830
|
-
puts ""
|
890
|
+
lines.join("")
|
831
891
|
end
|
832
892
|
|
833
893
|
def index(str)
|
834
|
-
|
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',
|
899
|
+
macro('reviewkw', word) + "(#{alt.strip})"
|
854
900
|
else
|
855
|
-
macro('reviewkw',
|
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),
|
908
|
+
macro("href", escape_url(url), label)
|
863
909
|
else
|
864
910
|
macro("url", escape_url(url))
|
865
911
|
end
|