review 5.5.0 → 5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yml +31 -0
- data/.github/workflows/ruby-tex.yml +1 -1
- data/.github/workflows/ruby-win.yml +1 -1
- data/.github/workflows/ruby.yml +2 -2
- data/.rubocop.yml +13 -2
- data/NEWS.ja.md +40 -0
- data/NEWS.md +39 -0
- data/README.md +1 -1
- data/doc/format.ja.md +70 -33
- data/doc/format.md +69 -34
- data/doc/quickstart.ja.md +7 -1
- data/doc/quickstart.md +7 -1
- data/lib/review/book/base.rb +1 -1
- data/lib/review/builder.rb +6 -10
- data/lib/review/epubmaker/epubcommon.rb +13 -7
- data/lib/review/epubmaker/epubv2.rb +0 -5
- data/lib/review/epubmaker/epubv3.rb +9 -1
- data/lib/review/epubmaker/producer.rb +2 -3
- data/lib/review/epubmaker.rb +2 -4
- data/lib/review/htmlbuilder.rb +2 -2
- data/lib/review/i18n.yml +24 -2
- data/lib/review/idgxmlbuilder.rb +29 -10
- data/lib/review/idgxmlmaker.rb +11 -1
- data/lib/review/img_math.rb +9 -2
- data/lib/review/init.rb +10 -5
- data/lib/review/latexbuilder.rb +2 -2
- data/lib/review/lineinput.rb +2 -2
- data/lib/review/makerhelper.rb +2 -2
- data/lib/review/pdfmaker.rb +3 -5
- data/lib/review/update.rb +3 -7
- data/lib/review/version.rb +1 -1
- data/lib/review/yamlloader.rb +0 -3
- data/review.gemspec +3 -3
- data/samples/syntax-book/Gemfile +1 -1
- data/templates/latex/config.erb +6 -1
- data/templates/latex/review-jlreq/review-base.sty +11 -8
- data/templates/latex/review-jsbook/review-base.sty +15 -11
- data/templates/opf/epubv2.opf.erb +2 -0
- data/templates/opf/epubv3.opf.erb +2 -0
- data/templates/opf/opf_manifest_epubv2.opf.erb +2 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +2 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +2 -0
- metadata +24 -139
- data/test/assets/black.eps +0 -280
- data/test/assets/fit.png +0 -0
- data/test/assets/header_listener.html +0 -35
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/large.gif +0 -0
- data/test/assets/large.jpg +0 -0
- data/test/assets/large.png +0 -0
- data/test/assets/large.svg +0 -65
- data/test/assets/syntax_book_index_detail.txt +0 -60
- data/test/assets/test.xml.erb +0 -3
- data/test/assets/test_template.tex +0 -179
- data/test/assets/test_template_backmatter.tex +0 -190
- data/test/book_test_helper.rb +0 -44
- data/test/run_test.rb +0 -12
- data/test/test_book.rb +0 -588
- data/test/test_book_chapter.rb +0 -329
- data/test/test_book_part.rb +0 -53
- data/test/test_builder.rb +0 -126
- data/test/test_catalog.rb +0 -174
- data/test/test_catalog_converter_cmd.rb +0 -73
- data/test/test_compiler.rb +0 -52
- data/test/test_configure.rb +0 -91
- data/test/test_converter.rb +0 -21
- data/test/test_epub3maker.rb +0 -733
- data/test/test_epubmaker.rb +0 -931
- data/test/test_epubmaker_cmd.rb +0 -56
- data/test/test_extentions_hash.rb +0 -66
- data/test/test_helper.rb +0 -62
- data/test/test_htmlbuilder.rb +0 -3312
- data/test/test_htmltoc.rb +0 -29
- data/test/test_htmlutils.rb +0 -43
- data/test/test_i18n.rb +0 -300
- data/test/test_idgxmlbuilder.rb +0 -1487
- data/test/test_idgxmlmaker_cmd.rb +0 -50
- data/test/test_image_finder.rb +0 -81
- data/test/test_img_math.rb +0 -120
- data/test/test_index.rb +0 -287
- data/test/test_indexbuilder.rb +0 -52
- data/test/test_latexbuilder.rb +0 -2964
- data/test/test_latexbuilder_v2.rb +0 -1654
- data/test/test_lineinput.rb +0 -104
- data/test/test_location.rb +0 -30
- data/test/test_logger.rb +0 -33
- data/test/test_makerhelper.rb +0 -44
- data/test/test_markdownbuilder.rb +0 -371
- data/test/test_md2inaobuilder.rb +0 -90
- data/test/test_pdfmaker.rb +0 -354
- data/test/test_pdfmaker_cmd.rb +0 -130
- data/test/test_plaintextbuilder.rb +0 -1211
- data/test/test_preprocessor.rb +0 -196
- data/test/test_review_ext.rb +0 -30
- data/test/test_reviewheaderlistener.rb +0 -49
- data/test/test_rstbuilder.rb +0 -616
- data/test/test_sec_counter.rb +0 -156
- data/test/test_template.rb +0 -33
- data/test/test_textmaker_cmd.rb +0 -58
- data/test/test_textutils.rb +0 -187
- data/test/test_tocprinter.rb +0 -46
- data/test/test_topbuilder.rb +0 -1298
- data/test/test_update.rb +0 -473
- data/test/test_webtocprinter.rb +0 -195
- data/test/test_yamlloader.rb +0 -186
- data/test/test_zip_exporter.rb +0 -106
data/test/test_topbuilder.rb
DELETED
@@ -1,1298 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'review/compiler'
|
3
|
-
require 'review/book'
|
4
|
-
require 'review/topbuilder'
|
5
|
-
require 'review/i18n'
|
6
|
-
|
7
|
-
class TOPBuidlerTest < Test::Unit::TestCase
|
8
|
-
include ReVIEW
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@builder = TOPBuilder.new
|
12
|
-
@config = ReVIEW::Configure.values
|
13
|
-
@config['secnolevel'] = 2
|
14
|
-
@config['language'] = 'ja'
|
15
|
-
@book = Book::Base.new
|
16
|
-
@book.config = @config
|
17
|
-
@log_io = StringIO.new
|
18
|
-
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
19
|
-
@compiler = ReVIEW::Compiler.new(@builder)
|
20
|
-
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
21
|
-
location = Location.new(nil, nil)
|
22
|
-
@builder.bind(@compiler, @chapter, location)
|
23
|
-
|
24
|
-
I18n.setup(@config['language'])
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_headline_level1
|
28
|
-
actual = compile_block("={test} this is test.\n")
|
29
|
-
assert_equal %Q(■H1■第1章 this is test.\n), actual
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_headline_level1_without_secno
|
33
|
-
@config['secnolevel'] = 0
|
34
|
-
actual = compile_block("={test} this is test.\n")
|
35
|
-
assert_equal %Q(■H1■this is test.\n), actual
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_headline_level2
|
39
|
-
actual = compile_block("=={test} this is test.\n")
|
40
|
-
assert_equal %Q(■H2■1.1 this is test.\n), actual
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_headline_level3
|
44
|
-
actual = compile_block("==={test} this is test.\n")
|
45
|
-
assert_equal %Q(■H3■this is test.\n), actual
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_headline_level3_with_secno
|
49
|
-
@config['secnolevel'] = 3
|
50
|
-
actual = compile_block("==={test} this is test.\n")
|
51
|
-
assert_equal %Q(■H3■1.0.1 this is test.\n), actual
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_href
|
55
|
-
actual = compile_inline('@<href>{http://github.com, GitHub}')
|
56
|
-
assert_equal 'GitHub(△http://github.com☆)', actual
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_href_without_label
|
60
|
-
actual = compile_inline('@<href>{http://github.com}')
|
61
|
-
assert_equal '△http://github.com☆', actual
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_inline_raw
|
65
|
-
actual = compile_inline('@<raw>{@<tt>{inline\}}')
|
66
|
-
assert_equal '@<tt>{inline}', actual
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_inline_ruby
|
70
|
-
actual = compile_inline('@<ruby>{coffin,bed}')
|
71
|
-
assert_equal 'coffin◆→DTP連絡:「coffin」に「bed」とルビ←◆', actual
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_inline_kw
|
75
|
-
actual = compile_inline('@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}')
|
76
|
-
assert_equal '★ISO☆(International Organization for Standardization) ★Ruby<>☆', actual
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_inline_maru
|
80
|
-
actual = compile_inline('@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}')
|
81
|
-
assert_equal '1◆→丸数字1←◆20◆→丸数字20←◆A◆→丸数字A←◆z◆→丸数字z←◆', actual
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_inline_br
|
85
|
-
actual = compile_inline('@<br>{}')
|
86
|
-
assert_equal "\n", actual
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_inline_i
|
90
|
-
actual = compile_inline('test @<i>{inline test} test2')
|
91
|
-
assert_equal 'test ▲inline test☆ test2', actual
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_inline_i_and_escape
|
95
|
-
actual = compile_inline('test @<i>{inline<&;\\ test} test2')
|
96
|
-
assert_equal 'test ▲inline<&;\\ test☆ test2', actual
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_inline_b
|
100
|
-
actual = compile_inline('test @<b>{inline test} test2')
|
101
|
-
assert_equal 'test ★inline test☆ test2', actual
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_inline_b_and_escape
|
105
|
-
actual = compile_inline('test @<b>{inline<&;\\ test} test2')
|
106
|
-
assert_equal 'test ★inline<&;\\ test☆ test2', actual
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_inline_tt
|
110
|
-
actual = compile_inline('test @<tt>{inline test} test2@<tt>{\\}}')
|
111
|
-
assert_equal 'test △inline test☆ test2△}☆', actual
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_inline_tti
|
115
|
-
actual = compile_inline('test @<tti>{inline test} test2')
|
116
|
-
assert_equal 'test ▲inline test☆◆→等幅フォントイタ←◆ test2', actual
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_inline_ttb
|
120
|
-
actual = compile_inline('test @<ttb>{inline test} test2')
|
121
|
-
assert_equal 'test ★inline test☆◆→等幅フォント太字←◆ test2', actual
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_inline_tcy
|
125
|
-
actual = compile_inline('test @<tcy>{A} test2')
|
126
|
-
assert_equal 'test ◆→開始:回転←◆A◆→終了:縦回転←◆ test2', actual
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_inline_uchar
|
130
|
-
actual = compile_inline('test @<uchar>{2460} test2')
|
131
|
-
assert_equal 'test ① test2', actual
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_inline_comment
|
135
|
-
actual = compile_inline('test @<comment>{コメント} test2')
|
136
|
-
assert_equal 'test test2', actual
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_inline_comment_for_draft
|
140
|
-
@config['draft'] = true
|
141
|
-
actual = compile_inline('test @<comment>{コメント} test2')
|
142
|
-
assert_equal 'test ◆→コメント←◆ test2', actual
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_inline_fence
|
146
|
-
actual = compile_inline('@<m>|a|, @<m>{\\frac{1\\}{2\\}}, @<m>$\\frac{1}{2}$, @<m>{\\{ \\\\\\}}, @<m>|\\{ \\}|, test @<code>|@<code>{$サンプル$}|')
|
147
|
-
assert_equal '◆→TeX式ここから←◆a◆→TeX式ここまで←◆, ◆→TeX式ここから←◆\\frac{1}{2}◆→TeX式ここまで←◆, ◆→TeX式ここから←◆\\frac{1}{2}◆→TeX式ここまで←◆, ◆→TeX式ここから←◆\\{ \\}◆→TeX式ここまで←◆, ◆→TeX式ここから←◆\\{ \\}◆→TeX式ここまで←◆, test △@<code>{$サンプル$}☆', actual
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_inline_in_table
|
151
|
-
actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
|
152
|
-
expected = <<-EOS
|
153
|
-
◆→開始:表←◆
|
154
|
-
★1☆\t▲2☆
|
155
|
-
------------
|
156
|
-
★3☆\t▲4☆<>&
|
157
|
-
◆→終了:表←◆
|
158
|
-
|
159
|
-
EOS
|
160
|
-
assert_equal expected, actual
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_dlist_beforeulol
|
164
|
-
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
|
165
|
-
expected = <<-EOS
|
166
|
-
★foo☆
|
167
|
-
\tfoo.
|
168
|
-
|
169
|
-
para
|
170
|
-
|
171
|
-
★foo☆
|
172
|
-
\tfoo.
|
173
|
-
|
174
|
-
1\tbar
|
175
|
-
|
176
|
-
★foo☆
|
177
|
-
\tfoo.
|
178
|
-
|
179
|
-
●\tbar
|
180
|
-
|
181
|
-
EOS
|
182
|
-
assert_equal expected, actual
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_dt_inline
|
186
|
-
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
187
|
-
|
188
|
-
expected = <<-EOS
|
189
|
-
【注1】bar
|
190
|
-
|
191
|
-
★foo【注1】[]<>&◆→TeX式ここから←◆\\alpha[]◆→TeX式ここまで←◆☆
|
192
|
-
|
193
|
-
|
194
|
-
EOS
|
195
|
-
assert_equal expected, actual
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_paragraph
|
199
|
-
actual = compile_block("foo\nbar\n")
|
200
|
-
assert_equal %Q(foobar\n), actual
|
201
|
-
|
202
|
-
@book.config['join_lines_by_lang'] = true
|
203
|
-
actual = compile_block("foo\nbar\n")
|
204
|
-
assert_equal %Q(foo bar\n), actual
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_tabbed_paragraph
|
208
|
-
actual = compile_block("\tfoo\nbar\n")
|
209
|
-
assert_equal %Q(\tfoobar\n), actual
|
210
|
-
|
211
|
-
@book.config['join_lines_by_lang'] = true
|
212
|
-
actual = compile_block("\tfoo\nbar\n")
|
213
|
-
assert_equal %Q(\tfoo bar\n), actual
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_flushright
|
217
|
-
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
218
|
-
expected = <<-EOS
|
219
|
-
◆→開始:右寄せ←◆
|
220
|
-
foobar
|
221
|
-
buz
|
222
|
-
◆→終了:右寄せ←◆
|
223
|
-
|
224
|
-
EOS
|
225
|
-
assert_equal expected, actual
|
226
|
-
|
227
|
-
@book.config['join_lines_by_lang'] = true
|
228
|
-
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
229
|
-
expected = <<-EOS
|
230
|
-
◆→開始:右寄せ←◆
|
231
|
-
foo bar
|
232
|
-
buz
|
233
|
-
◆→終了:右寄せ←◆
|
234
|
-
|
235
|
-
EOS
|
236
|
-
assert_equal expected, actual
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_blankline
|
240
|
-
actual = compile_block("//blankline\nfoo\n")
|
241
|
-
assert_equal %Q(\nfoo\n), actual
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_noindent
|
245
|
-
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
246
|
-
expected = <<-EOS
|
247
|
-
◆→DTP連絡:次の1行インデントなし←◆
|
248
|
-
foobar
|
249
|
-
foo2bar2
|
250
|
-
EOS
|
251
|
-
assert_equal expected, actual
|
252
|
-
|
253
|
-
@book.config['join_lines_by_lang'] = true
|
254
|
-
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
255
|
-
expected = <<-EOS
|
256
|
-
◆→DTP連絡:次の1行インデントなし←◆
|
257
|
-
foo bar
|
258
|
-
foo2 bar2
|
259
|
-
EOS
|
260
|
-
assert_equal expected, actual
|
261
|
-
end
|
262
|
-
|
263
|
-
def test_comment
|
264
|
-
actual = compile_block('//comment[コメント]')
|
265
|
-
assert_equal '', actual
|
266
|
-
end
|
267
|
-
|
268
|
-
def test_comment_for_draft
|
269
|
-
@config['draft'] = true
|
270
|
-
actual = compile_block('//comment[コメント<]')
|
271
|
-
assert_equal %Q(◆→コメント<←◆\n), actual
|
272
|
-
actual = compile_block("//comment{\nA<>\nB&\n//}")
|
273
|
-
assert_equal %Q(◆→A<>\nB&←◆\n), actual
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_list
|
277
|
-
def @chapter.list(_id)
|
278
|
-
Book::Index::Item.new('test', 1)
|
279
|
-
end
|
280
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
281
|
-
expected = <<-EOS
|
282
|
-
◆→開始:リスト←◆
|
283
|
-
リスト1.1 this is ★test☆<&>_
|
284
|
-
|
285
|
-
foo
|
286
|
-
bar
|
287
|
-
◆→終了:リスト←◆
|
288
|
-
|
289
|
-
EOS
|
290
|
-
assert_equal expected, actual
|
291
|
-
end
|
292
|
-
|
293
|
-
def test_listnum
|
294
|
-
def @chapter.list(_id)
|
295
|
-
Book::Index::Item.new('test', 1)
|
296
|
-
end
|
297
|
-
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
298
|
-
expected = <<-EOS
|
299
|
-
◆→開始:リスト←◆
|
300
|
-
リスト1.1 this is ★test☆<&>_
|
301
|
-
|
302
|
-
1: foo
|
303
|
-
2: bar
|
304
|
-
◆→終了:リスト←◆
|
305
|
-
|
306
|
-
EOS
|
307
|
-
assert_equal expected, actual
|
308
|
-
|
309
|
-
@config['caption_position']['list'] = 'bottom'
|
310
|
-
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
311
|
-
expected = <<-EOS
|
312
|
-
◆→開始:リスト←◆
|
313
|
-
1: foo
|
314
|
-
2: bar
|
315
|
-
|
316
|
-
リスト1.1 this is ★test☆<&>_
|
317
|
-
◆→終了:リスト←◆
|
318
|
-
|
319
|
-
EOS
|
320
|
-
assert_equal expected, actual
|
321
|
-
end
|
322
|
-
|
323
|
-
def test_source
|
324
|
-
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
325
|
-
expected = <<-EOS
|
326
|
-
◆→開始:ソースコードリスト←◆
|
327
|
-
■foo/bar/test.rb
|
328
|
-
foo
|
329
|
-
bar
|
330
|
-
|
331
|
-
buz
|
332
|
-
◆→終了:ソースコードリスト←◆
|
333
|
-
|
334
|
-
EOS
|
335
|
-
assert_equal expected, actual
|
336
|
-
|
337
|
-
@config['caption_position']['list'] = 'bottom'
|
338
|
-
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
339
|
-
expected = <<-EOS
|
340
|
-
◆→開始:ソースコードリスト←◆
|
341
|
-
foo
|
342
|
-
bar
|
343
|
-
|
344
|
-
buz
|
345
|
-
■foo/bar/test.rb
|
346
|
-
◆→終了:ソースコードリスト←◆
|
347
|
-
|
348
|
-
EOS
|
349
|
-
assert_equal expected, actual
|
350
|
-
end
|
351
|
-
|
352
|
-
def test_source_empty_caption
|
353
|
-
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
354
|
-
expected = <<-EOS
|
355
|
-
◆→開始:ソースコードリスト←◆
|
356
|
-
foo
|
357
|
-
bar
|
358
|
-
|
359
|
-
buz
|
360
|
-
◆→終了:ソースコードリスト←◆
|
361
|
-
|
362
|
-
EOS
|
363
|
-
assert_equal expected, actual
|
364
|
-
end
|
365
|
-
|
366
|
-
def test_box
|
367
|
-
actual = compile_block("//box{\nfoo\nbar\n//}\n")
|
368
|
-
expected = <<-EOS
|
369
|
-
◆→開始:書式←◆
|
370
|
-
foo
|
371
|
-
bar
|
372
|
-
◆→終了:書式←◆
|
373
|
-
|
374
|
-
EOS
|
375
|
-
assert_equal expected, actual
|
376
|
-
|
377
|
-
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
378
|
-
expected = <<-EOS
|
379
|
-
◆→開始:書式←◆
|
380
|
-
■FOO
|
381
|
-
foo
|
382
|
-
bar
|
383
|
-
◆→終了:書式←◆
|
384
|
-
|
385
|
-
EOS
|
386
|
-
assert_equal expected, actual
|
387
|
-
|
388
|
-
@config['caption_position']['list'] = 'bottom'
|
389
|
-
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
390
|
-
expected = <<-EOS
|
391
|
-
◆→開始:書式←◆
|
392
|
-
foo
|
393
|
-
bar
|
394
|
-
■FOO
|
395
|
-
◆→終了:書式←◆
|
396
|
-
|
397
|
-
EOS
|
398
|
-
assert_equal expected, actual
|
399
|
-
end
|
400
|
-
|
401
|
-
def test_cmd
|
402
|
-
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
403
|
-
expected = <<-EOS
|
404
|
-
◆→開始:コマンド←◆
|
405
|
-
lineA
|
406
|
-
lineB
|
407
|
-
◆→終了:コマンド←◆
|
408
|
-
|
409
|
-
EOS
|
410
|
-
assert_equal expected, actual
|
411
|
-
|
412
|
-
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
413
|
-
expected = <<-EOS
|
414
|
-
◆→開始:コマンド←◆
|
415
|
-
■cap1
|
416
|
-
lineA
|
417
|
-
lineB
|
418
|
-
◆→終了:コマンド←◆
|
419
|
-
|
420
|
-
EOS
|
421
|
-
assert_equal expected, actual
|
422
|
-
|
423
|
-
@config['caption_position']['list'] = 'bottom'
|
424
|
-
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
425
|
-
expected = <<-EOS
|
426
|
-
◆→開始:コマンド←◆
|
427
|
-
lineA
|
428
|
-
lineB
|
429
|
-
■cap1
|
430
|
-
◆→終了:コマンド←◆
|
431
|
-
|
432
|
-
EOS
|
433
|
-
assert_equal expected, actual
|
434
|
-
end
|
435
|
-
|
436
|
-
def test_emlist
|
437
|
-
actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
|
438
|
-
expected = <<-EOS
|
439
|
-
◆→開始:インラインリスト←◆
|
440
|
-
lineA
|
441
|
-
lineB
|
442
|
-
◆→終了:インラインリスト←◆
|
443
|
-
|
444
|
-
EOS
|
445
|
-
assert_equal expected, actual
|
446
|
-
end
|
447
|
-
|
448
|
-
def test_emlist_caption
|
449
|
-
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
450
|
-
expected = <<-EOS
|
451
|
-
◆→開始:インラインリスト←◆
|
452
|
-
■cap1
|
453
|
-
lineA
|
454
|
-
lineB
|
455
|
-
◆→終了:インラインリスト←◆
|
456
|
-
|
457
|
-
EOS
|
458
|
-
assert_equal expected, actual
|
459
|
-
|
460
|
-
@config['caption_position']['list'] = 'bottom'
|
461
|
-
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
462
|
-
expected = <<-EOS
|
463
|
-
◆→開始:インラインリスト←◆
|
464
|
-
lineA
|
465
|
-
lineB
|
466
|
-
■cap1
|
467
|
-
◆→終了:インラインリスト←◆
|
468
|
-
|
469
|
-
EOS
|
470
|
-
assert_equal expected, actual
|
471
|
-
end
|
472
|
-
|
473
|
-
def test_emlistnum
|
474
|
-
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
475
|
-
expected = <<-EOS
|
476
|
-
◆→開始:インラインリスト←◆
|
477
|
-
■this is ★test☆<&>_
|
478
|
-
1: foo
|
479
|
-
2: bar
|
480
|
-
◆→終了:インラインリスト←◆
|
481
|
-
|
482
|
-
EOS
|
483
|
-
assert_equal expected, actual
|
484
|
-
|
485
|
-
@config['caption_position']['list'] = 'bottom'
|
486
|
-
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
487
|
-
expected = <<-EOS
|
488
|
-
◆→開始:インラインリスト←◆
|
489
|
-
1: foo
|
490
|
-
2: bar
|
491
|
-
■this is ★test☆<&>_
|
492
|
-
◆→終了:インラインリスト←◆
|
493
|
-
|
494
|
-
EOS
|
495
|
-
assert_equal expected, actual
|
496
|
-
end
|
497
|
-
|
498
|
-
def test_bib
|
499
|
-
def @chapter.bibpaper(_id)
|
500
|
-
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
501
|
-
end
|
502
|
-
|
503
|
-
assert_equal '[1]', compile_inline('@<bib>{samplebib}')
|
504
|
-
end
|
505
|
-
|
506
|
-
def test_table
|
507
|
-
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
508
|
-
expected = <<-EOS
|
509
|
-
◆→開始:表←◆
|
510
|
-
aaa\tbbb
|
511
|
-
------------
|
512
|
-
ccc\tddd<>&
|
513
|
-
◆→終了:表←◆
|
514
|
-
|
515
|
-
EOS
|
516
|
-
assert_equal expected, actual
|
517
|
-
|
518
|
-
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
519
|
-
expected = <<-EOS
|
520
|
-
◆→開始:表←◆
|
521
|
-
表1.1 FOO
|
522
|
-
|
523
|
-
aaa\tbbb
|
524
|
-
------------
|
525
|
-
ccc\tddd<>&
|
526
|
-
◆→終了:表←◆
|
527
|
-
|
528
|
-
EOS
|
529
|
-
assert_equal expected, actual
|
530
|
-
|
531
|
-
@config['caption_position']['table'] = 'bottom'
|
532
|
-
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
533
|
-
expected = <<-EOS
|
534
|
-
◆→開始:表←◆
|
535
|
-
aaa\tbbb
|
536
|
-
------------
|
537
|
-
ccc\tddd<>&
|
538
|
-
|
539
|
-
表1.1 FOO
|
540
|
-
◆→終了:表←◆
|
541
|
-
|
542
|
-
EOS
|
543
|
-
assert_equal expected, actual
|
544
|
-
end
|
545
|
-
|
546
|
-
def test_table_th_bold
|
547
|
-
@config['textmaker']['th_bold'] = true
|
548
|
-
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
549
|
-
expected = <<-EOS
|
550
|
-
◆→開始:表←◆
|
551
|
-
★aaa☆\t★bbb☆
|
552
|
-
ccc\tddd<>&
|
553
|
-
◆→終了:表←◆
|
554
|
-
|
555
|
-
EOS
|
556
|
-
assert_equal expected, actual
|
557
|
-
|
558
|
-
actual = compile_block("//table{\naaa\tbbb\nccc\tddd<>&\n//}\n")
|
559
|
-
expected = <<-EOS
|
560
|
-
◆→開始:表←◆
|
561
|
-
★aaa☆\tbbb
|
562
|
-
★ccc☆\tddd<>&
|
563
|
-
◆→終了:表←◆
|
564
|
-
|
565
|
-
EOS
|
566
|
-
assert_equal expected, actual
|
567
|
-
end
|
568
|
-
|
569
|
-
def test_empty_table
|
570
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
571
|
-
assert_equal 'no rows in the table', e.message
|
572
|
-
|
573
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
574
|
-
assert_equal 'no rows in the table', e.message
|
575
|
-
end
|
576
|
-
|
577
|
-
def test_inline_table
|
578
|
-
def @chapter.table(_id)
|
579
|
-
Book::Index::Item.new('sampletable', 1)
|
580
|
-
end
|
581
|
-
actual = compile_block("@<table>{sampletest}\n")
|
582
|
-
assert_equal "表1.1\n", actual
|
583
|
-
end
|
584
|
-
|
585
|
-
def test_emtable
|
586
|
-
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
587
|
-
expected = <<-EOS
|
588
|
-
◆→開始:表←◆
|
589
|
-
foo
|
590
|
-
|
591
|
-
aaa\tbbb
|
592
|
-
------------
|
593
|
-
ccc\tddd<>&
|
594
|
-
◆→終了:表←◆
|
595
|
-
|
596
|
-
◆→開始:表←◆
|
597
|
-
aaa\tbbb
|
598
|
-
------------
|
599
|
-
ccc\tddd<>&
|
600
|
-
◆→終了:表←◆
|
601
|
-
|
602
|
-
EOS
|
603
|
-
assert_equal expected, actual
|
604
|
-
end
|
605
|
-
|
606
|
-
def test_emtable_thbold
|
607
|
-
@config['textmaker']['th_bold'] = true
|
608
|
-
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
609
|
-
expected = <<-EOS
|
610
|
-
◆→開始:表←◆
|
611
|
-
foo
|
612
|
-
|
613
|
-
★aaa☆\t★bbb☆
|
614
|
-
ccc\tddd<>&
|
615
|
-
◆→終了:表←◆
|
616
|
-
|
617
|
-
◆→開始:表←◆
|
618
|
-
★aaa☆\t★bbb☆
|
619
|
-
ccc\tddd<>&
|
620
|
-
◆→終了:表←◆
|
621
|
-
|
622
|
-
EOS
|
623
|
-
assert_equal expected, actual
|
624
|
-
end
|
625
|
-
|
626
|
-
def test_imgtable
|
627
|
-
def @chapter.image(_id)
|
628
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
629
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
630
|
-
item
|
631
|
-
end
|
632
|
-
|
633
|
-
actual = compile_block("//imgtable[sampleimg][sample photo]{\nfoo\n//}\n")
|
634
|
-
expected = <<-EOS
|
635
|
-
◆→開始:表←◆
|
636
|
-
表1.1 sample photo
|
637
|
-
|
638
|
-
◆→./images/chap1-sampleimg.png←◆
|
639
|
-
◆→終了:表←◆
|
640
|
-
|
641
|
-
EOS
|
642
|
-
assert_equal expected, actual
|
643
|
-
|
644
|
-
@config['caption_position']['table'] = 'bottom'
|
645
|
-
actual = compile_block("//imgtable[sampleimg][sample photo]{\nfoo\n//}\n")
|
646
|
-
expected = <<-EOS
|
647
|
-
◆→開始:表←◆
|
648
|
-
◆→./images/chap1-sampleimg.png←◆
|
649
|
-
|
650
|
-
表1.1 sample photo
|
651
|
-
◆→終了:表←◆
|
652
|
-
|
653
|
-
EOS
|
654
|
-
assert_equal expected, actual
|
655
|
-
end
|
656
|
-
|
657
|
-
def test_table_row_separator
|
658
|
-
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
659
|
-
expected = <<-EOS
|
660
|
-
◆→開始:表←◆
|
661
|
-
1 2 3 4| 5
|
662
|
-
------------
|
663
|
-
a b c d |e
|
664
|
-
◆→終了:表←◆
|
665
|
-
|
666
|
-
EOS
|
667
|
-
actual = compile_block(src)
|
668
|
-
assert_equal expected, actual
|
669
|
-
|
670
|
-
@config['table_row_separator'] = 'singletab'
|
671
|
-
actual = compile_block(src)
|
672
|
-
expected = <<-EOS
|
673
|
-
◆→開始:表←◆
|
674
|
-
1 2 3 4| 5
|
675
|
-
------------
|
676
|
-
a b c d |e
|
677
|
-
◆→終了:表←◆
|
678
|
-
|
679
|
-
EOS
|
680
|
-
assert_equal expected, actual
|
681
|
-
|
682
|
-
@config['table_row_separator'] = 'spaces'
|
683
|
-
actual = compile_block(src)
|
684
|
-
expected = <<-EOS
|
685
|
-
◆→開始:表←◆
|
686
|
-
1 2 3 4| 5
|
687
|
-
------------
|
688
|
-
a b c d |e
|
689
|
-
◆→終了:表←◆
|
690
|
-
|
691
|
-
EOS
|
692
|
-
assert_equal expected, actual
|
693
|
-
|
694
|
-
@config['table_row_separator'] = 'verticalbar'
|
695
|
-
actual = compile_block(src)
|
696
|
-
expected = <<-EOS
|
697
|
-
◆→開始:表←◆
|
698
|
-
1 2 3 4 5
|
699
|
-
------------
|
700
|
-
a b c d e
|
701
|
-
◆→終了:表←◆
|
702
|
-
|
703
|
-
EOS
|
704
|
-
assert_equal expected, actual
|
705
|
-
end
|
706
|
-
|
707
|
-
def test_major_blocks
|
708
|
-
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
709
|
-
expected = <<-EOS
|
710
|
-
◆→開始:ノート←◆
|
711
|
-
A
|
712
|
-
B
|
713
|
-
◆→終了:ノート←◆
|
714
|
-
|
715
|
-
◆→開始:ノート←◆
|
716
|
-
■caption
|
717
|
-
A
|
718
|
-
◆→終了:ノート←◆
|
719
|
-
|
720
|
-
EOS
|
721
|
-
assert_equal expected, actual
|
722
|
-
|
723
|
-
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
724
|
-
expected = <<-EOS
|
725
|
-
◆→開始:メモ←◆
|
726
|
-
A
|
727
|
-
B
|
728
|
-
◆→終了:メモ←◆
|
729
|
-
|
730
|
-
◆→開始:メモ←◆
|
731
|
-
■caption
|
732
|
-
A
|
733
|
-
◆→終了:メモ←◆
|
734
|
-
|
735
|
-
EOS
|
736
|
-
assert_equal expected, actual
|
737
|
-
|
738
|
-
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
739
|
-
expected = <<-EOS
|
740
|
-
◆→開始:情報←◆
|
741
|
-
A
|
742
|
-
B
|
743
|
-
◆→終了:情報←◆
|
744
|
-
|
745
|
-
◆→開始:情報←◆
|
746
|
-
■caption
|
747
|
-
A
|
748
|
-
◆→終了:情報←◆
|
749
|
-
|
750
|
-
EOS
|
751
|
-
assert_equal expected, actual
|
752
|
-
|
753
|
-
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
754
|
-
expected = <<-EOS
|
755
|
-
◆→開始:重要←◆
|
756
|
-
A
|
757
|
-
B
|
758
|
-
◆→終了:重要←◆
|
759
|
-
|
760
|
-
◆→開始:重要←◆
|
761
|
-
■caption
|
762
|
-
A
|
763
|
-
◆→終了:重要←◆
|
764
|
-
|
765
|
-
EOS
|
766
|
-
assert_equal expected, actual
|
767
|
-
|
768
|
-
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
769
|
-
expected = <<-EOS
|
770
|
-
◆→開始:警告←◆
|
771
|
-
A
|
772
|
-
B
|
773
|
-
◆→終了:警告←◆
|
774
|
-
|
775
|
-
◆→開始:警告←◆
|
776
|
-
■caption
|
777
|
-
A
|
778
|
-
◆→終了:警告←◆
|
779
|
-
|
780
|
-
EOS
|
781
|
-
assert_equal expected, actual
|
782
|
-
|
783
|
-
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
784
|
-
expected = <<-EOS
|
785
|
-
◆→開始:注意←◆
|
786
|
-
A
|
787
|
-
B
|
788
|
-
◆→終了:注意←◆
|
789
|
-
|
790
|
-
◆→開始:注意←◆
|
791
|
-
■caption
|
792
|
-
A
|
793
|
-
◆→終了:注意←◆
|
794
|
-
|
795
|
-
EOS
|
796
|
-
assert_equal expected, actual
|
797
|
-
|
798
|
-
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
799
|
-
expected = <<-EOS
|
800
|
-
◆→開始:危険←◆
|
801
|
-
A
|
802
|
-
B
|
803
|
-
◆→終了:危険←◆
|
804
|
-
|
805
|
-
◆→開始:危険←◆
|
806
|
-
■caption
|
807
|
-
A
|
808
|
-
◆→終了:危険←◆
|
809
|
-
|
810
|
-
EOS
|
811
|
-
assert_equal expected, actual
|
812
|
-
|
813
|
-
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
814
|
-
expected = <<-EOS
|
815
|
-
◆→開始:TIP←◆
|
816
|
-
A
|
817
|
-
B
|
818
|
-
◆→終了:TIP←◆
|
819
|
-
|
820
|
-
◆→開始:TIP←◆
|
821
|
-
■caption
|
822
|
-
A
|
823
|
-
◆→終了:TIP←◆
|
824
|
-
|
825
|
-
EOS
|
826
|
-
assert_equal expected, actual
|
827
|
-
end
|
828
|
-
|
829
|
-
def test_minicolumn_blocks
|
830
|
-
titles = {
|
831
|
-
'note' => 'ノート',
|
832
|
-
'memo' => 'メモ',
|
833
|
-
'important' => '重要',
|
834
|
-
'info' => '情報',
|
835
|
-
'notice' => '注意',
|
836
|
-
'caution' => '警告',
|
837
|
-
'warning' => '危険',
|
838
|
-
'tip' => 'TIP'
|
839
|
-
}
|
840
|
-
|
841
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
842
|
-
@builder.doc_status.clear
|
843
|
-
src = <<-EOS
|
844
|
-
//#{type}[#{type}1]{
|
845
|
-
|
846
|
-
//}
|
847
|
-
|
848
|
-
//#{type}[#{type}2]{
|
849
|
-
//}
|
850
|
-
EOS
|
851
|
-
|
852
|
-
expected = <<-EOS
|
853
|
-
◆→開始:#{titles[type]}←◆
|
854
|
-
■#{type}1
|
855
|
-
◆→終了:#{titles[type]}←◆
|
856
|
-
|
857
|
-
◆→開始:#{titles[type]}←◆
|
858
|
-
■#{type}2
|
859
|
-
◆→終了:#{titles[type]}←◆
|
860
|
-
|
861
|
-
EOS
|
862
|
-
assert_equal expected, compile_block(src)
|
863
|
-
|
864
|
-
src = <<-EOS
|
865
|
-
//#{type}[#{type}2]{
|
866
|
-
|
867
|
-
//}
|
868
|
-
|
869
|
-
//#{type}[#{type}3]{
|
870
|
-
|
871
|
-
//}
|
872
|
-
|
873
|
-
//#{type}[#{type}4]{
|
874
|
-
|
875
|
-
//}
|
876
|
-
|
877
|
-
//#{type}[#{type}5]{
|
878
|
-
|
879
|
-
//}
|
880
|
-
|
881
|
-
//#{type}[#{type}6]{
|
882
|
-
|
883
|
-
//}
|
884
|
-
EOS
|
885
|
-
|
886
|
-
expected = <<-EOS
|
887
|
-
◆→開始:#{titles[type]}←◆
|
888
|
-
■#{type}2
|
889
|
-
◆→終了:#{titles[type]}←◆
|
890
|
-
|
891
|
-
◆→開始:#{titles[type]}←◆
|
892
|
-
■#{type}3
|
893
|
-
◆→終了:#{titles[type]}←◆
|
894
|
-
|
895
|
-
◆→開始:#{titles[type]}←◆
|
896
|
-
■#{type}4
|
897
|
-
◆→終了:#{titles[type]}←◆
|
898
|
-
|
899
|
-
◆→開始:#{titles[type]}←◆
|
900
|
-
■#{type}5
|
901
|
-
◆→終了:#{titles[type]}←◆
|
902
|
-
|
903
|
-
◆→開始:#{titles[type]}←◆
|
904
|
-
■#{type}6
|
905
|
-
◆→終了:#{titles[type]}←◆
|
906
|
-
|
907
|
-
EOS
|
908
|
-
assert_equal expected, compile_block(src)
|
909
|
-
|
910
|
-
src = <<-EOS
|
911
|
-
//#{type}{
|
912
|
-
|
913
|
-
* A
|
914
|
-
|
915
|
-
1. B
|
916
|
-
|
917
|
-
//}
|
918
|
-
|
919
|
-
//#{type}[OMITEND1]{
|
920
|
-
|
921
|
-
//emlist{
|
922
|
-
LIST
|
923
|
-
//}
|
924
|
-
|
925
|
-
//}
|
926
|
-
//#{type}[OMITEND2]{
|
927
|
-
//}
|
928
|
-
EOS
|
929
|
-
|
930
|
-
expected = <<-EOS
|
931
|
-
◆→開始:#{titles[type]}←◆
|
932
|
-
|
933
|
-
● A
|
934
|
-
|
935
|
-
1 B
|
936
|
-
|
937
|
-
◆→終了:#{titles[type]}←◆
|
938
|
-
|
939
|
-
◆→開始:#{titles[type]}←◆
|
940
|
-
■OMITEND1
|
941
|
-
|
942
|
-
◆→開始:インラインリスト←◆
|
943
|
-
LIST
|
944
|
-
◆→終了:インラインリスト←◆
|
945
|
-
|
946
|
-
◆→終了:#{titles[type]}←◆
|
947
|
-
|
948
|
-
◆→開始:#{titles[type]}←◆
|
949
|
-
■OMITEND2
|
950
|
-
◆→終了:#{titles[type]}←◆
|
951
|
-
|
952
|
-
EOS
|
953
|
-
assert_equal expected, compile_block(src)
|
954
|
-
end
|
955
|
-
end
|
956
|
-
|
957
|
-
def test_minicolumn_blocks_nest_error1
|
958
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
959
|
-
@builder.doc_status.clear
|
960
|
-
src = <<-EOS
|
961
|
-
//#{type}{
|
962
|
-
|
963
|
-
//#{type}{
|
964
|
-
//}
|
965
|
-
|
966
|
-
//}
|
967
|
-
EOS
|
968
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
969
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
970
|
-
end
|
971
|
-
end
|
972
|
-
|
973
|
-
def test_minicolumn_blocks_nest_error2
|
974
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
975
|
-
@builder.doc_status.clear
|
976
|
-
src = <<-EOS
|
977
|
-
//#{type}{
|
978
|
-
|
979
|
-
//#{type}{
|
980
|
-
|
981
|
-
//}
|
982
|
-
|
983
|
-
//}
|
984
|
-
EOS
|
985
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
986
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
987
|
-
end
|
988
|
-
end
|
989
|
-
|
990
|
-
def test_minicolumn_blocks_nest_error3
|
991
|
-
%w[memo tip info warning important caution notice].each do |type|
|
992
|
-
@builder.doc_status.clear
|
993
|
-
src = <<-EOS
|
994
|
-
//#{type}{
|
995
|
-
|
996
|
-
//note{
|
997
|
-
//}
|
998
|
-
|
999
|
-
//}
|
1000
|
-
EOS
|
1001
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1002
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
1003
|
-
end
|
1004
|
-
end
|
1005
|
-
|
1006
|
-
def test_image
|
1007
|
-
def @chapter.image(_id)
|
1008
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
1009
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1010
|
-
item
|
1011
|
-
end
|
1012
|
-
|
1013
|
-
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
|
1014
|
-
expected = <<-EOS
|
1015
|
-
◆→開始:図←◆
|
1016
|
-
◆→./images/chap1-sampleimg.png←◆
|
1017
|
-
|
1018
|
-
図1.1 sample photo
|
1019
|
-
◆→終了:図←◆
|
1020
|
-
|
1021
|
-
EOS
|
1022
|
-
assert_equal expected, actual
|
1023
|
-
|
1024
|
-
@config['caption_position']['image'] = 'top'
|
1025
|
-
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
|
1026
|
-
expected = <<-EOS
|
1027
|
-
◆→開始:図←◆
|
1028
|
-
図1.1 sample photo
|
1029
|
-
|
1030
|
-
◆→./images/chap1-sampleimg.png←◆
|
1031
|
-
◆→終了:図←◆
|
1032
|
-
|
1033
|
-
EOS
|
1034
|
-
assert_equal expected, actual
|
1035
|
-
end
|
1036
|
-
|
1037
|
-
def test_image_with_metric
|
1038
|
-
def @chapter.image(_id)
|
1039
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
1040
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1041
|
-
item
|
1042
|
-
end
|
1043
|
-
|
1044
|
-
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
|
1045
|
-
expected = <<-EOS
|
1046
|
-
◆→開始:図←◆
|
1047
|
-
◆→./images/chap1-sampleimg.png scale=1.2←◆
|
1048
|
-
|
1049
|
-
図1.1 sample photo
|
1050
|
-
◆→終了:図←◆
|
1051
|
-
|
1052
|
-
EOS
|
1053
|
-
assert_equal expected, actual
|
1054
|
-
end
|
1055
|
-
|
1056
|
-
def test_image_dummy
|
1057
|
-
actual = compile_block("//image[dummy][sample photo]{\nDUMMY\n//}\n")
|
1058
|
-
expected = <<-EOS
|
1059
|
-
◆→開始:図←◆
|
1060
|
-
DUMMY
|
1061
|
-
|
1062
|
-
図1.1 sample photo
|
1063
|
-
◆→終了:図←◆
|
1064
|
-
|
1065
|
-
EOS
|
1066
|
-
assert_equal expected, actual
|
1067
|
-
end
|
1068
|
-
|
1069
|
-
def test_indepimage
|
1070
|
-
def @chapter.image(_id)
|
1071
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
1072
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1073
|
-
item
|
1074
|
-
end
|
1075
|
-
|
1076
|
-
actual = compile_block("//indepimage[sampleimg][sample photo]{\nfoo\n//}\n")
|
1077
|
-
expected = <<-EOS
|
1078
|
-
◆→開始:図←◆
|
1079
|
-
◆→./images/chap1-sampleimg.png←◆
|
1080
|
-
|
1081
|
-
図 sample photo
|
1082
|
-
◆→終了:図←◆
|
1083
|
-
|
1084
|
-
EOS
|
1085
|
-
assert_equal expected, actual
|
1086
|
-
|
1087
|
-
@config['caption_position']['image'] = 'top'
|
1088
|
-
actual = compile_block("//indepimage[sampleimg][sample photo]{\nfoo\n//}\n")
|
1089
|
-
expected = <<-EOS
|
1090
|
-
◆→開始:図←◆
|
1091
|
-
図 sample photo
|
1092
|
-
|
1093
|
-
◆→./images/chap1-sampleimg.png←◆
|
1094
|
-
◆→終了:図←◆
|
1095
|
-
|
1096
|
-
EOS
|
1097
|
-
assert_equal expected, actual
|
1098
|
-
end
|
1099
|
-
|
1100
|
-
def test_indepimage_dummy
|
1101
|
-
actual = compile_block("//indepimage[dummy][sample photo]{\nDUMMY\n//}\n")
|
1102
|
-
expected = <<-EOS
|
1103
|
-
◆→開始:図←◆
|
1104
|
-
DUMMY
|
1105
|
-
|
1106
|
-
図 sample photo
|
1107
|
-
◆→終了:図←◆
|
1108
|
-
|
1109
|
-
EOS
|
1110
|
-
assert_equal expected, actual
|
1111
|
-
end
|
1112
|
-
|
1113
|
-
def test_texequation
|
1114
|
-
actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
|
1115
|
-
expected = <<-EOS
|
1116
|
-
◆→開始:TeX式←◆
|
1117
|
-
\\sin
|
1118
|
-
1^{2}
|
1119
|
-
◆→終了:TeX式←◆
|
1120
|
-
|
1121
|
-
EOS
|
1122
|
-
assert_equal expected, actual
|
1123
|
-
end
|
1124
|
-
|
1125
|
-
def test_inline_w
|
1126
|
-
Dir.mktmpdir do |dir|
|
1127
|
-
File.write(File.join(dir, 'words.csv'), <<EOB
|
1128
|
-
"F","foo"
|
1129
|
-
"B","bar""\\<>_@<b>{BAZ}"
|
1130
|
-
EOB
|
1131
|
-
)
|
1132
|
-
@book.config['words_file'] = File.join(dir, 'words.csv')
|
1133
|
-
|
1134
|
-
io = StringIO.new
|
1135
|
-
@builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
1136
|
-
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
1137
|
-
assert_equal %Q(foo bar"\\<>_@<b>{BAZ} ★bar"\\<>_@<b>{BAZ}☆ [missing word: N]\n), actual
|
1138
|
-
assert_match(/WARN --: :1: word not bound: N/, io.string)
|
1139
|
-
end
|
1140
|
-
end
|
1141
|
-
|
1142
|
-
def test_endnote
|
1143
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
1144
|
-
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
1145
|
-
|
1146
|
-
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
1147
|
-
expected = <<-'EOS'
|
1148
|
-
【後注1】
|
1149
|
-
◆→開始:後注←◆
|
1150
|
-
【後注1】bar
|
1151
|
-
◆→終了:後注←◆
|
1152
|
-
EOS
|
1153
|
-
assert_equal expected, actual
|
1154
|
-
end
|
1155
|
-
|
1156
|
-
def test_inline_unknown
|
1157
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1158
|
-
assert_match(/unknown image: n/, @log_io.string)
|
1159
|
-
|
1160
|
-
@log_io.string = ''
|
1161
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1162
|
-
assert_match(/unknown footnote: n/, @log_io.string)
|
1163
|
-
|
1164
|
-
@log_io.string = ''
|
1165
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<endnote>{n}\n") }
|
1166
|
-
assert_match(/unknown endnote: n/, @log_io.string)
|
1167
|
-
|
1168
|
-
@log_io.string = ''
|
1169
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1170
|
-
assert_match(/unknown headline: n/, @log_io.string)
|
1171
|
-
%w[list table column].each do |name|
|
1172
|
-
@log_io.string = ''
|
1173
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1174
|
-
assert_match(/unknown #{name}: n/, @log_io.string)
|
1175
|
-
end
|
1176
|
-
%w[chap chapref title].each do |name|
|
1177
|
-
@log_io.string = ''
|
1178
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1179
|
-
assert_match(/key not found: "n"/, @log_io.string)
|
1180
|
-
end
|
1181
|
-
end
|
1182
|
-
|
1183
|
-
def test_inline_raw0
|
1184
|
-
assert_equal 'normal', compile_inline('@<raw>{normal}')
|
1185
|
-
end
|
1186
|
-
|
1187
|
-
def test_inline_raw1
|
1188
|
-
assert_equal 'body', compile_inline('@<raw>{|top|body}')
|
1189
|
-
end
|
1190
|
-
|
1191
|
-
def test_inline_raw2
|
1192
|
-
assert_equal 'body', compile_inline('@<raw>{|top, latex|body}')
|
1193
|
-
end
|
1194
|
-
|
1195
|
-
def test_inline_raw3
|
1196
|
-
assert_equal '', compile_inline('@<raw>{|idgxml, html|body}')
|
1197
|
-
end
|
1198
|
-
|
1199
|
-
def test_inline_raw4
|
1200
|
-
assert_equal '|top body', compile_inline('@<raw>{|top body}')
|
1201
|
-
end
|
1202
|
-
|
1203
|
-
def test_inline_raw5
|
1204
|
-
assert_equal "nor\nmal", compile_inline('@<raw>{|top|nor\\nmal}')
|
1205
|
-
end
|
1206
|
-
|
1207
|
-
def test_block_raw0
|
1208
|
-
actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
|
1209
|
-
expected = %Q(<>!"\n& )
|
1210
|
-
assert_equal expected.chomp, actual
|
1211
|
-
end
|
1212
|
-
|
1213
|
-
def test_block_raw1
|
1214
|
-
actual = compile_block(%Q(//raw[|top|<>!"\\n& ]\n))
|
1215
|
-
expected = %Q(<>!"\n& )
|
1216
|
-
assert_equal expected.chomp, actual
|
1217
|
-
end
|
1218
|
-
|
1219
|
-
def test_block_raw2
|
1220
|
-
actual = compile_block(%Q(//raw[|top, latex|<>!"\\n& ]\n))
|
1221
|
-
expected = %Q(<>!"\n& )
|
1222
|
-
assert_equal expected.chomp, actual
|
1223
|
-
end
|
1224
|
-
|
1225
|
-
def test_block_raw3
|
1226
|
-
actual = compile_block(%Q(//raw[|latex, idgxml|<>!"\\n& ]\n))
|
1227
|
-
expected = ''
|
1228
|
-
assert_equal expected.chomp, actual
|
1229
|
-
end
|
1230
|
-
|
1231
|
-
def test_block_raw4
|
1232
|
-
actual = compile_block(%Q(//raw[|top <>!"\\n& ]\n))
|
1233
|
-
expected = %Q(|top <>!"\n& )
|
1234
|
-
assert_equal expected.chomp, actual
|
1235
|
-
end
|
1236
|
-
|
1237
|
-
def column_helper(review)
|
1238
|
-
compile_block(review)
|
1239
|
-
end
|
1240
|
-
|
1241
|
-
def test_column_ref
|
1242
|
-
review = <<-EOS
|
1243
|
-
===[column]{foo} test
|
1244
|
-
|
1245
|
-
inside column
|
1246
|
-
|
1247
|
-
=== next level
|
1248
|
-
|
1249
|
-
this is @<column>{foo}.
|
1250
|
-
EOS
|
1251
|
-
expected = <<-EOS
|
1252
|
-
◆→開始:コラム←◆
|
1253
|
-
■test
|
1254
|
-
inside column
|
1255
|
-
◆→終了:コラム←◆
|
1256
|
-
|
1257
|
-
■H3■next level
|
1258
|
-
this is コラム「test」.
|
1259
|
-
EOS
|
1260
|
-
|
1261
|
-
assert_equal expected, column_helper(review)
|
1262
|
-
end
|
1263
|
-
|
1264
|
-
def test_texequation_with_caption
|
1265
|
-
src = <<-EOS
|
1266
|
-
@<eq>{emc2}
|
1267
|
-
|
1268
|
-
//texequation[emc2][The Equivalence of Mass @<i>{and} Energy]{
|
1269
|
-
e=mc^2
|
1270
|
-
//}
|
1271
|
-
EOS
|
1272
|
-
expected = <<-EOS
|
1273
|
-
式1.1
|
1274
|
-
|
1275
|
-
◆→開始:TeX式←◆
|
1276
|
-
式1.1 The Equivalence of Mass ▲and☆ Energy
|
1277
|
-
e=mc^2
|
1278
|
-
◆→終了:TeX式←◆
|
1279
|
-
|
1280
|
-
EOS
|
1281
|
-
actual = compile_block(src)
|
1282
|
-
assert_equal expected, actual
|
1283
|
-
|
1284
|
-
@config['caption_position']['equation'] = 'bottom'
|
1285
|
-
|
1286
|
-
expected = <<-EOS
|
1287
|
-
式1.1
|
1288
|
-
|
1289
|
-
◆→開始:TeX式←◆
|
1290
|
-
e=mc^2
|
1291
|
-
式1.1 The Equivalence of Mass ▲and☆ Energy
|
1292
|
-
◆→終了:TeX式←◆
|
1293
|
-
|
1294
|
-
EOS
|
1295
|
-
actual = compile_block(src)
|
1296
|
-
assert_equal expected, actual
|
1297
|
-
end
|
1298
|
-
end
|