review 5.6.0 → 5.7.0
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/.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 +22 -0
- data/NEWS.md +21 -0
- data/README.md +1 -1
- data/lib/review/book/base.rb +1 -1
- data/lib/review/builder.rb +4 -8
- 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/idgxmlbuilder.rb +4 -3
- data/lib/review/img_math.rb +9 -2
- data/lib/review/init.rb +3 -3
- data/lib/review/latexbuilder.rb +1 -1
- 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 +2 -3
- data/samples/syntax-book/Gemfile +1 -1
- 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 +10 -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 -189
- data/test/assets/test_template_backmatter.tex +0 -200
- 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 -128
- 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 -3315
- 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 -1529
- 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 -2972
- 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 -1214
- 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 -619
- 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 -1301
- 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
|
@@ -1,1214 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'review/compiler'
|
|
3
|
-
require 'review/book'
|
|
4
|
-
require 'review/plaintextbuilder'
|
|
5
|
-
require 'review/i18n'
|
|
6
|
-
|
|
7
|
-
class PLAINTEXTBuidlerTest < Test::Unit::TestCase
|
|
8
|
-
include ReVIEW
|
|
9
|
-
|
|
10
|
-
def setup
|
|
11
|
-
@builder = PLAINTEXTBuilder.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
|
-
@builder.instance_eval do
|
|
25
|
-
# to ignore lineno in original method
|
|
26
|
-
def warn(msg)
|
|
27
|
-
puts msg
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
I18n.setup(@config['language'])
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def test_headline_level1
|
|
34
|
-
actual = compile_block("={test} this is test.\n")
|
|
35
|
-
assert_equal %Q(第1章 this is test.\n), actual
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_headline_level1_without_secno
|
|
39
|
-
@config['secnolevel'] = 0
|
|
40
|
-
actual = compile_block("={test} this is test.\n")
|
|
41
|
-
assert_equal %Q(this is test.\n), actual
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_headline_level2
|
|
45
|
-
actual = compile_block("=={test} this is test.\n")
|
|
46
|
-
assert_equal %Q(1.1 this is test.\n), actual
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_headline_level3
|
|
50
|
-
actual = compile_block("==={test} this is test.\n")
|
|
51
|
-
assert_equal %Q(this is test.\n), actual
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def test_headline_level3_with_secno
|
|
55
|
-
@config['secnolevel'] = 3
|
|
56
|
-
actual = compile_block("==={test} this is test.\n")
|
|
57
|
-
assert_equal %Q(1.0.1 this is test.\n), actual
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def test_href
|
|
61
|
-
actual = compile_inline('@<href>{http://github.com, GitHub}')
|
|
62
|
-
assert_equal 'GitHub(http://github.com)', actual
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_href_without_label
|
|
66
|
-
actual = compile_inline('@<href>{http://github.com}')
|
|
67
|
-
assert_equal 'http://github.com', actual
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_inline_sec
|
|
71
|
-
def @chapter.headline_index
|
|
72
|
-
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st<>')
|
|
73
|
-
idx = Book::HeadlineIndex.new(self)
|
|
74
|
-
idx.add_item(item)
|
|
75
|
-
idx
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
@config['secnolevel'] = 3
|
|
79
|
-
actual = compile_inline('test @<secref>{test}')
|
|
80
|
-
assert_equal 'test 「1.1.1 te_st<>」', actual
|
|
81
|
-
actual = compile_inline('test @<sectitle>{test}')
|
|
82
|
-
assert_equal 'test te_st<>', actual
|
|
83
|
-
actual = compile_inline('test @<sec>{test}')
|
|
84
|
-
assert_equal 'test 1.1.1', actual
|
|
85
|
-
|
|
86
|
-
@config['secnolevel'] = 2
|
|
87
|
-
actual = compile_inline('test @<secref>{test}')
|
|
88
|
-
assert_equal 'test 「te_st<>」', actual
|
|
89
|
-
actual = compile_inline('test @<sectitle>{test}')
|
|
90
|
-
assert_equal 'test te_st<>', actual
|
|
91
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block('test @<sec>{test}') }
|
|
92
|
-
assert_match(/the target headline doesn't have a number/, @log_io.string)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def test_inline_raw
|
|
96
|
-
actual = compile_inline('@<raw>{@<tt>{inline\}}')
|
|
97
|
-
assert_equal '@<tt>{inline}', actual
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def test_inline_ruby
|
|
101
|
-
actual = compile_inline('@<ruby>{coffin,bed}')
|
|
102
|
-
assert_equal 'coffin', actual
|
|
103
|
-
|
|
104
|
-
actual = compile_inline('@<ruby>{ coffin , bed }')
|
|
105
|
-
assert_equal 'coffin', actual
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def test_inline_kw
|
|
109
|
-
actual = compile_inline('@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}')
|
|
110
|
-
assert_equal 'ISO(International Organization for Standardization) Ruby<>', actual
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def test_inline_maru
|
|
114
|
-
actual = compile_inline('@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}')
|
|
115
|
-
assert_equal '120Az', actual
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def test_inline_br
|
|
119
|
-
actual = compile_inline('@<br>{}')
|
|
120
|
-
assert_equal "\n", actual
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def test_inline_asis
|
|
124
|
-
%w[i b tti ttb bou ami u strong em code ins tcy].each do |tag|
|
|
125
|
-
actual = compile_inline("test @<#{tag}>{inline test} test2")
|
|
126
|
-
assert_equal 'test inline test test2', actual
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def test_inline_del
|
|
131
|
-
actual = compile_inline('test @<del>{inline test} test2')
|
|
132
|
-
assert_equal 'test test2', actual
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def test_inline_i_and_escape
|
|
136
|
-
actual = compile_inline('test @<i>{inline<&;\\ test} test2')
|
|
137
|
-
assert_equal 'test inline<&;\\ test test2', actual
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def test_inline_b_and_escape
|
|
141
|
-
actual = compile_inline('test @<b>{inline<&;\\ test} test2')
|
|
142
|
-
assert_equal 'test inline<&;\\ test test2', actual
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def test_inline_tt
|
|
146
|
-
actual = compile_inline('test @<tt>{inline test} test2@<tt>{\\}}')
|
|
147
|
-
assert_equal 'test inline test test2}', actual
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def test_inline_uchar
|
|
151
|
-
actual = compile_inline('test @<uchar>{2460} test2')
|
|
152
|
-
assert_equal 'test ① test2', actual
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def test_inline_comment
|
|
156
|
-
actual = compile_inline('test @<comment>{コメント} test2')
|
|
157
|
-
assert_equal 'test test2', actual
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def test_inline_comment_for_draft
|
|
161
|
-
@config['draft'] = true
|
|
162
|
-
actual = compile_inline('test @<comment>{コメント} test2')
|
|
163
|
-
assert_equal 'test test2', actual
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def test_inline_in_table
|
|
167
|
-
actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
|
|
168
|
-
expected = <<-EOS
|
|
169
|
-
★1☆\t▲2☆
|
|
170
|
-
★3☆\t▲4☆<>&
|
|
171
|
-
|
|
172
|
-
EOS
|
|
173
|
-
assert_equal expected, actual
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
def test_dlist_beforeulol
|
|
177
|
-
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")
|
|
178
|
-
expected = <<-EOS
|
|
179
|
-
foo
|
|
180
|
-
foo.
|
|
181
|
-
|
|
182
|
-
para
|
|
183
|
-
|
|
184
|
-
foo
|
|
185
|
-
foo.
|
|
186
|
-
|
|
187
|
-
1 bar
|
|
188
|
-
|
|
189
|
-
foo
|
|
190
|
-
foo.
|
|
191
|
-
|
|
192
|
-
bar
|
|
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
|
-
foobar
|
|
220
|
-
buz
|
|
221
|
-
|
|
222
|
-
EOS
|
|
223
|
-
assert_equal expected, actual
|
|
224
|
-
|
|
225
|
-
@book.config['join_lines_by_lang'] = true
|
|
226
|
-
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
|
227
|
-
expected = <<-EOS
|
|
228
|
-
foo bar
|
|
229
|
-
buz
|
|
230
|
-
|
|
231
|
-
EOS
|
|
232
|
-
assert_equal expected, actual
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
def test_noindent
|
|
236
|
-
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
237
|
-
expected = <<-EOS
|
|
238
|
-
foobar
|
|
239
|
-
foo2bar2
|
|
240
|
-
EOS
|
|
241
|
-
assert_equal expected, actual
|
|
242
|
-
|
|
243
|
-
@book.config['join_lines_by_lang'] = true
|
|
244
|
-
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
245
|
-
expected = <<-EOS
|
|
246
|
-
foo bar
|
|
247
|
-
foo2 bar2
|
|
248
|
-
EOS
|
|
249
|
-
assert_equal expected, actual
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
def test_comment
|
|
253
|
-
actual = compile_block('//comment[コメント]')
|
|
254
|
-
assert_equal '', actual
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def test_comment_for_draft
|
|
258
|
-
@config['draft'] = true
|
|
259
|
-
actual = compile_block('//comment[コメント]')
|
|
260
|
-
assert_equal '', actual
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
def test_list
|
|
264
|
-
def @chapter.list(_id)
|
|
265
|
-
Book::Index::Item.new('test', 1)
|
|
266
|
-
end
|
|
267
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
268
|
-
expected = <<-EOS
|
|
269
|
-
リスト1.1 this is test<&>_
|
|
270
|
-
|
|
271
|
-
foo
|
|
272
|
-
bar
|
|
273
|
-
|
|
274
|
-
EOS
|
|
275
|
-
assert_equal expected, actual
|
|
276
|
-
|
|
277
|
-
@config['caption_position']['list'] = 'bottom'
|
|
278
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
279
|
-
expected = <<-EOS
|
|
280
|
-
foo
|
|
281
|
-
bar
|
|
282
|
-
|
|
283
|
-
リスト1.1 this is test<&>_
|
|
284
|
-
|
|
285
|
-
EOS
|
|
286
|
-
assert_equal expected, actual
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
def test_listnum
|
|
290
|
-
def @chapter.list(_id)
|
|
291
|
-
Book::Index::Item.new('test', 1)
|
|
292
|
-
end
|
|
293
|
-
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
294
|
-
expected = <<-EOS
|
|
295
|
-
リスト1.1 this is test<&>_
|
|
296
|
-
|
|
297
|
-
1: foo
|
|
298
|
-
2: bar
|
|
299
|
-
|
|
300
|
-
EOS
|
|
301
|
-
assert_equal expected, actual
|
|
302
|
-
|
|
303
|
-
@config['caption_position']['list'] = 'bottom'
|
|
304
|
-
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
305
|
-
expected = <<-EOS
|
|
306
|
-
1: foo
|
|
307
|
-
2: bar
|
|
308
|
-
|
|
309
|
-
リスト1.1 this is test<&>_
|
|
310
|
-
|
|
311
|
-
EOS
|
|
312
|
-
assert_equal expected, actual
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
def test_source
|
|
316
|
-
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
317
|
-
expected = <<-EOS
|
|
318
|
-
foo/bar/test.rb
|
|
319
|
-
foo
|
|
320
|
-
bar
|
|
321
|
-
|
|
322
|
-
buz
|
|
323
|
-
|
|
324
|
-
EOS
|
|
325
|
-
assert_equal expected, actual
|
|
326
|
-
|
|
327
|
-
@config['caption_position']['list'] = 'bottom'
|
|
328
|
-
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
329
|
-
expected = <<-EOS
|
|
330
|
-
foo
|
|
331
|
-
bar
|
|
332
|
-
|
|
333
|
-
buz
|
|
334
|
-
foo/bar/test.rb
|
|
335
|
-
|
|
336
|
-
EOS
|
|
337
|
-
assert_equal expected, actual
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
def test_source_empty_caption
|
|
341
|
-
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
342
|
-
expected = <<-EOS
|
|
343
|
-
foo
|
|
344
|
-
bar
|
|
345
|
-
|
|
346
|
-
buz
|
|
347
|
-
|
|
348
|
-
EOS
|
|
349
|
-
assert_equal expected, actual
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
def test_box
|
|
353
|
-
actual = compile_block("//box{\nfoo\nbar\n//}\n")
|
|
354
|
-
expected = <<-EOS
|
|
355
|
-
foo
|
|
356
|
-
bar
|
|
357
|
-
|
|
358
|
-
EOS
|
|
359
|
-
assert_equal expected, actual
|
|
360
|
-
|
|
361
|
-
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
|
362
|
-
expected = <<-EOS
|
|
363
|
-
FOO
|
|
364
|
-
foo
|
|
365
|
-
bar
|
|
366
|
-
|
|
367
|
-
EOS
|
|
368
|
-
assert_equal expected, actual
|
|
369
|
-
|
|
370
|
-
@config['caption_position']['list'] = 'bottom'
|
|
371
|
-
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
|
372
|
-
expected = <<-EOS
|
|
373
|
-
foo
|
|
374
|
-
bar
|
|
375
|
-
FOO
|
|
376
|
-
|
|
377
|
-
EOS
|
|
378
|
-
assert_equal expected, actual
|
|
379
|
-
end
|
|
380
|
-
|
|
381
|
-
def test_cmd
|
|
382
|
-
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
|
383
|
-
expected = <<-EOS
|
|
384
|
-
lineA
|
|
385
|
-
lineB
|
|
386
|
-
|
|
387
|
-
EOS
|
|
388
|
-
assert_equal expected, actual
|
|
389
|
-
|
|
390
|
-
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
|
391
|
-
expected = <<-EOS
|
|
392
|
-
cap1
|
|
393
|
-
lineA
|
|
394
|
-
lineB
|
|
395
|
-
|
|
396
|
-
EOS
|
|
397
|
-
assert_equal expected, actual
|
|
398
|
-
|
|
399
|
-
@config['caption_position']['list'] = 'bottom'
|
|
400
|
-
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
|
401
|
-
expected = <<-EOS
|
|
402
|
-
lineA
|
|
403
|
-
lineB
|
|
404
|
-
cap1
|
|
405
|
-
|
|
406
|
-
EOS
|
|
407
|
-
assert_equal expected, actual
|
|
408
|
-
end
|
|
409
|
-
|
|
410
|
-
def test_emlist
|
|
411
|
-
actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
|
|
412
|
-
expected = <<-EOS
|
|
413
|
-
lineA
|
|
414
|
-
lineB
|
|
415
|
-
|
|
416
|
-
EOS
|
|
417
|
-
assert_equal expected, actual
|
|
418
|
-
end
|
|
419
|
-
|
|
420
|
-
def test_emlist_caption
|
|
421
|
-
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
|
422
|
-
expected = <<-EOS
|
|
423
|
-
cap1
|
|
424
|
-
lineA
|
|
425
|
-
lineB
|
|
426
|
-
|
|
427
|
-
EOS
|
|
428
|
-
assert_equal expected, actual
|
|
429
|
-
|
|
430
|
-
@config['caption_position']['list'] = 'bottom'
|
|
431
|
-
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
|
432
|
-
expected = <<-EOS
|
|
433
|
-
lineA
|
|
434
|
-
lineB
|
|
435
|
-
cap1
|
|
436
|
-
|
|
437
|
-
EOS
|
|
438
|
-
assert_equal expected, actual
|
|
439
|
-
end
|
|
440
|
-
|
|
441
|
-
def test_emlistnum
|
|
442
|
-
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
443
|
-
expected = <<-EOS
|
|
444
|
-
this is test<&>_
|
|
445
|
-
1: foo
|
|
446
|
-
2: bar
|
|
447
|
-
|
|
448
|
-
EOS
|
|
449
|
-
assert_equal expected, actual
|
|
450
|
-
|
|
451
|
-
@config['caption_position']['list'] = 'bottom'
|
|
452
|
-
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
|
453
|
-
expected = <<-EOS
|
|
454
|
-
1: foo
|
|
455
|
-
2: bar
|
|
456
|
-
this is test<&>_
|
|
457
|
-
|
|
458
|
-
EOS
|
|
459
|
-
assert_equal expected, actual
|
|
460
|
-
end
|
|
461
|
-
|
|
462
|
-
def test_bib
|
|
463
|
-
def @chapter.bibpaper(_id)
|
|
464
|
-
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
|
465
|
-
end
|
|
466
|
-
|
|
467
|
-
assert_equal '1 ', compile_inline('@<bib>{samplebib}')
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
def test_table
|
|
471
|
-
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
|
472
|
-
expected = <<-EOS
|
|
473
|
-
aaa\tbbb
|
|
474
|
-
ccc\tddd<>&
|
|
475
|
-
|
|
476
|
-
EOS
|
|
477
|
-
assert_equal expected, actual
|
|
478
|
-
|
|
479
|
-
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
|
480
|
-
expected = <<-EOS
|
|
481
|
-
表1.1 FOO
|
|
482
|
-
|
|
483
|
-
aaa\tbbb
|
|
484
|
-
ccc\tddd<>&
|
|
485
|
-
|
|
486
|
-
EOS
|
|
487
|
-
assert_equal expected, actual
|
|
488
|
-
|
|
489
|
-
@config['caption_position']['table'] = 'bottom'
|
|
490
|
-
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
|
491
|
-
expected = <<-EOS
|
|
492
|
-
aaa\tbbb
|
|
493
|
-
ccc\tddd<>&
|
|
494
|
-
|
|
495
|
-
表1.1 FOO
|
|
496
|
-
EOS
|
|
497
|
-
assert_equal expected, actual
|
|
498
|
-
end
|
|
499
|
-
|
|
500
|
-
def test_empty_table
|
|
501
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
|
502
|
-
assert_equal 'no rows in the table', e.message
|
|
503
|
-
|
|
504
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
|
505
|
-
assert_equal 'no rows in the table', e.message
|
|
506
|
-
end
|
|
507
|
-
|
|
508
|
-
def test_inline_table
|
|
509
|
-
def @chapter.table(_id)
|
|
510
|
-
Book::Index::Item.new('sampletable', 1)
|
|
511
|
-
end
|
|
512
|
-
actual = compile_block("@<table>{sampletest}\n")
|
|
513
|
-
assert_equal "表1.1\n", actual
|
|
514
|
-
end
|
|
515
|
-
|
|
516
|
-
def test_emtable
|
|
517
|
-
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
|
518
|
-
expected = <<-EOS
|
|
519
|
-
foo
|
|
520
|
-
|
|
521
|
-
aaa\tbbb
|
|
522
|
-
ccc\tddd<>&
|
|
523
|
-
|
|
524
|
-
aaa\tbbb
|
|
525
|
-
ccc\tddd<>&
|
|
526
|
-
|
|
527
|
-
EOS
|
|
528
|
-
assert_equal expected, actual
|
|
529
|
-
end
|
|
530
|
-
|
|
531
|
-
def test_major_blocks
|
|
532
|
-
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
|
533
|
-
expected = <<-EOS
|
|
534
|
-
A
|
|
535
|
-
B
|
|
536
|
-
|
|
537
|
-
caption
|
|
538
|
-
A
|
|
539
|
-
|
|
540
|
-
EOS
|
|
541
|
-
assert_equal expected, actual
|
|
542
|
-
|
|
543
|
-
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
|
544
|
-
expected = <<-EOS
|
|
545
|
-
A
|
|
546
|
-
B
|
|
547
|
-
|
|
548
|
-
caption
|
|
549
|
-
A
|
|
550
|
-
|
|
551
|
-
EOS
|
|
552
|
-
assert_equal expected, actual
|
|
553
|
-
|
|
554
|
-
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
|
555
|
-
expected = <<-EOS
|
|
556
|
-
A
|
|
557
|
-
B
|
|
558
|
-
|
|
559
|
-
caption
|
|
560
|
-
A
|
|
561
|
-
|
|
562
|
-
EOS
|
|
563
|
-
assert_equal expected, actual
|
|
564
|
-
|
|
565
|
-
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
|
566
|
-
expected = <<-EOS
|
|
567
|
-
A
|
|
568
|
-
B
|
|
569
|
-
|
|
570
|
-
caption
|
|
571
|
-
A
|
|
572
|
-
|
|
573
|
-
EOS
|
|
574
|
-
assert_equal expected, actual
|
|
575
|
-
|
|
576
|
-
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
|
577
|
-
expected = <<-EOS
|
|
578
|
-
A
|
|
579
|
-
B
|
|
580
|
-
|
|
581
|
-
caption
|
|
582
|
-
A
|
|
583
|
-
|
|
584
|
-
EOS
|
|
585
|
-
assert_equal expected, actual
|
|
586
|
-
|
|
587
|
-
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
|
588
|
-
expected = <<-EOS
|
|
589
|
-
A
|
|
590
|
-
B
|
|
591
|
-
|
|
592
|
-
caption
|
|
593
|
-
A
|
|
594
|
-
|
|
595
|
-
EOS
|
|
596
|
-
assert_equal expected, actual
|
|
597
|
-
|
|
598
|
-
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
|
599
|
-
expected = <<-EOS
|
|
600
|
-
A
|
|
601
|
-
B
|
|
602
|
-
|
|
603
|
-
caption
|
|
604
|
-
A
|
|
605
|
-
|
|
606
|
-
EOS
|
|
607
|
-
assert_equal expected, actual
|
|
608
|
-
|
|
609
|
-
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
|
610
|
-
expected = <<-EOS
|
|
611
|
-
A
|
|
612
|
-
B
|
|
613
|
-
|
|
614
|
-
caption
|
|
615
|
-
A
|
|
616
|
-
|
|
617
|
-
EOS
|
|
618
|
-
assert_equal expected, actual
|
|
619
|
-
end
|
|
620
|
-
|
|
621
|
-
def test_minicolumn_blocks
|
|
622
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
|
623
|
-
@builder.doc_status.clear
|
|
624
|
-
src = <<-EOS
|
|
625
|
-
//#{type}[#{type}1]{
|
|
626
|
-
|
|
627
|
-
//}
|
|
628
|
-
|
|
629
|
-
//#{type}[#{type}2]{
|
|
630
|
-
//}
|
|
631
|
-
EOS
|
|
632
|
-
|
|
633
|
-
expected = <<-EOS
|
|
634
|
-
#{type}1
|
|
635
|
-
|
|
636
|
-
#{type}2
|
|
637
|
-
|
|
638
|
-
EOS
|
|
639
|
-
assert_equal expected, compile_block(src)
|
|
640
|
-
|
|
641
|
-
src = <<-EOS
|
|
642
|
-
//#{type}[#{type}2]{
|
|
643
|
-
|
|
644
|
-
//}
|
|
645
|
-
|
|
646
|
-
//#{type}[#{type}3]{
|
|
647
|
-
|
|
648
|
-
//}
|
|
649
|
-
|
|
650
|
-
//#{type}[#{type}4]{
|
|
651
|
-
|
|
652
|
-
//}
|
|
653
|
-
|
|
654
|
-
//#{type}[#{type}5]{
|
|
655
|
-
|
|
656
|
-
//}
|
|
657
|
-
|
|
658
|
-
//#{type}[#{type}6]{
|
|
659
|
-
|
|
660
|
-
//}
|
|
661
|
-
EOS
|
|
662
|
-
|
|
663
|
-
expected = <<-EOS
|
|
664
|
-
#{type}2
|
|
665
|
-
|
|
666
|
-
#{type}3
|
|
667
|
-
|
|
668
|
-
#{type}4
|
|
669
|
-
|
|
670
|
-
#{type}5
|
|
671
|
-
|
|
672
|
-
#{type}6
|
|
673
|
-
|
|
674
|
-
EOS
|
|
675
|
-
assert_equal expected, compile_block(src)
|
|
676
|
-
|
|
677
|
-
src = <<-EOS
|
|
678
|
-
//#{type}{
|
|
679
|
-
|
|
680
|
-
* A
|
|
681
|
-
|
|
682
|
-
1. B
|
|
683
|
-
|
|
684
|
-
//}
|
|
685
|
-
|
|
686
|
-
//#{type}[OMITEND1]{
|
|
687
|
-
|
|
688
|
-
//emlist{
|
|
689
|
-
LIST
|
|
690
|
-
//}
|
|
691
|
-
|
|
692
|
-
//}
|
|
693
|
-
//#{type}[OMITEND2]{
|
|
694
|
-
//}
|
|
695
|
-
EOS
|
|
696
|
-
|
|
697
|
-
expected = <<-EOS
|
|
698
|
-
A
|
|
699
|
-
|
|
700
|
-
1 B
|
|
701
|
-
|
|
702
|
-
OMITEND1
|
|
703
|
-
|
|
704
|
-
LIST
|
|
705
|
-
|
|
706
|
-
OMITEND2
|
|
707
|
-
|
|
708
|
-
EOS
|
|
709
|
-
assert_equal expected, compile_block(src)
|
|
710
|
-
end
|
|
711
|
-
end
|
|
712
|
-
|
|
713
|
-
def test_minicolumn_blocks_nest_error1
|
|
714
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
|
715
|
-
@builder.doc_status.clear
|
|
716
|
-
src = <<-EOS
|
|
717
|
-
//#{type}{
|
|
718
|
-
|
|
719
|
-
//#{type}{
|
|
720
|
-
//}
|
|
721
|
-
|
|
722
|
-
//}
|
|
723
|
-
EOS
|
|
724
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
725
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
|
726
|
-
end
|
|
727
|
-
end
|
|
728
|
-
|
|
729
|
-
def test_minicolumn_blocks_nest_error2
|
|
730
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
|
731
|
-
@builder.doc_status.clear
|
|
732
|
-
src = <<-EOS
|
|
733
|
-
//#{type}{
|
|
734
|
-
|
|
735
|
-
//#{type}{
|
|
736
|
-
|
|
737
|
-
//}
|
|
738
|
-
|
|
739
|
-
//}
|
|
740
|
-
EOS
|
|
741
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
742
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
|
743
|
-
end
|
|
744
|
-
end
|
|
745
|
-
|
|
746
|
-
def test_minicolumn_blocks_nest_error3
|
|
747
|
-
%w[memo tip info warning important caution notice].each do |type|
|
|
748
|
-
@builder.doc_status.clear
|
|
749
|
-
src = <<-EOS
|
|
750
|
-
//#{type}{
|
|
751
|
-
|
|
752
|
-
//note{
|
|
753
|
-
//}
|
|
754
|
-
|
|
755
|
-
//}
|
|
756
|
-
EOS
|
|
757
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
758
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
|
759
|
-
end
|
|
760
|
-
end
|
|
761
|
-
|
|
762
|
-
def test_image
|
|
763
|
-
def @chapter.image(_id)
|
|
764
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
|
765
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
766
|
-
item
|
|
767
|
-
end
|
|
768
|
-
|
|
769
|
-
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
|
|
770
|
-
assert_equal %Q(図1.1 sample photo\n\n), actual
|
|
771
|
-
|
|
772
|
-
@config['caption_position']['image'] = 'top'
|
|
773
|
-
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
|
|
774
|
-
assert_equal %Q(図1.1 sample photo\n\n), actual
|
|
775
|
-
end
|
|
776
|
-
|
|
777
|
-
def test_image_with_metric
|
|
778
|
-
def @chapter.image(_id)
|
|
779
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
|
780
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
781
|
-
item
|
|
782
|
-
end
|
|
783
|
-
|
|
784
|
-
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
|
|
785
|
-
assert_equal %Q(図1.1 sample photo\n\n), actual
|
|
786
|
-
end
|
|
787
|
-
|
|
788
|
-
def test_texequation
|
|
789
|
-
actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
|
|
790
|
-
assert_equal %Q(\\sin\n1^{2}\n\n), actual
|
|
791
|
-
end
|
|
792
|
-
|
|
793
|
-
def test_endnote
|
|
794
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
|
795
|
-
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
|
796
|
-
|
|
797
|
-
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
|
798
|
-
expected = <<-'EOS'
|
|
799
|
-
(1)
|
|
800
|
-
(1) bar
|
|
801
|
-
EOS
|
|
802
|
-
assert_equal expected, actual
|
|
803
|
-
end
|
|
804
|
-
|
|
805
|
-
def test_inline_unknown
|
|
806
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
|
807
|
-
assert_match(/unknown image: n/, @log_io.string)
|
|
808
|
-
|
|
809
|
-
@log_io.string = ''
|
|
810
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
|
811
|
-
assert_match(/unknown footnote: n/, @log_io.string)
|
|
812
|
-
|
|
813
|
-
@log_io.string = ''
|
|
814
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<endnote>{n}\n") }
|
|
815
|
-
assert_match(/unknown endnote: n/, @log_io.string)
|
|
816
|
-
|
|
817
|
-
@log_io.string = ''
|
|
818
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
|
819
|
-
assert_match(/unknown headline: n/, @log_io.string)
|
|
820
|
-
%w[list table column].each do |name|
|
|
821
|
-
@log_io.string = ''
|
|
822
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
|
823
|
-
assert_match(/unknown #{name}: n/, @log_io.string)
|
|
824
|
-
end
|
|
825
|
-
%w[chap chapref title].each do |name|
|
|
826
|
-
@log_io.string = ''
|
|
827
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
|
828
|
-
assert_match(/key not found: "n"/, @log_io.string)
|
|
829
|
-
end
|
|
830
|
-
end
|
|
831
|
-
|
|
832
|
-
def test_inline_raw0
|
|
833
|
-
assert_equal 'normal', compile_inline('@<raw>{normal}')
|
|
834
|
-
end
|
|
835
|
-
|
|
836
|
-
def test_inline_raw1
|
|
837
|
-
assert_equal 'body', compile_inline('@<raw>{|plaintext|body}')
|
|
838
|
-
end
|
|
839
|
-
|
|
840
|
-
def test_inline_raw2
|
|
841
|
-
assert_equal 'body', compile_inline('@<raw>{|plaintext, latex|body}')
|
|
842
|
-
end
|
|
843
|
-
|
|
844
|
-
def test_inline_raw3
|
|
845
|
-
assert_equal '', compile_inline('@<raw>{|idgxml, html|body}')
|
|
846
|
-
end
|
|
847
|
-
|
|
848
|
-
def test_inline_raw4
|
|
849
|
-
assert_equal '|plaintext body', compile_inline('@<raw>{|plaintext body}')
|
|
850
|
-
end
|
|
851
|
-
|
|
852
|
-
def test_inline_raw5
|
|
853
|
-
assert_equal "nor\nmal", compile_inline('@<raw>{|plaintext|nor\\nmal}')
|
|
854
|
-
end
|
|
855
|
-
|
|
856
|
-
def test_block_raw0
|
|
857
|
-
actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
|
|
858
|
-
expected = %Q(<>!"\n& )
|
|
859
|
-
assert_equal expected.chomp, actual
|
|
860
|
-
end
|
|
861
|
-
|
|
862
|
-
def test_block_raw1
|
|
863
|
-
actual = compile_block(%Q(//raw[|plaintext|<>!"\\n& ]\n))
|
|
864
|
-
expected = %Q(<>!"\n& )
|
|
865
|
-
assert_equal expected.chomp, actual
|
|
866
|
-
end
|
|
867
|
-
|
|
868
|
-
def test_block_raw2
|
|
869
|
-
actual = compile_block(%Q(//raw[|plaintext, latex|<>!"\\n& ]\n))
|
|
870
|
-
expected = %Q(<>!"\n& )
|
|
871
|
-
assert_equal expected.chomp, actual
|
|
872
|
-
end
|
|
873
|
-
|
|
874
|
-
def test_block_raw3
|
|
875
|
-
actual = compile_block(%Q(//raw[|latex, idgxml|<>!"\\n& ]\n))
|
|
876
|
-
expected = ''
|
|
877
|
-
assert_equal expected.chomp, actual
|
|
878
|
-
end
|
|
879
|
-
|
|
880
|
-
def test_block_raw4
|
|
881
|
-
actual = compile_block(%Q(//raw[|plaintext <>!"\\n& ]\n))
|
|
882
|
-
expected = %Q(|plaintext <>!"\n& )
|
|
883
|
-
assert_equal expected.chomp, actual
|
|
884
|
-
end
|
|
885
|
-
|
|
886
|
-
def column_helper(review)
|
|
887
|
-
compile_block(review)
|
|
888
|
-
end
|
|
889
|
-
|
|
890
|
-
def test_column_ref
|
|
891
|
-
review = <<-EOS
|
|
892
|
-
===[column]{foo} test
|
|
893
|
-
|
|
894
|
-
inside column
|
|
895
|
-
|
|
896
|
-
=== next level
|
|
897
|
-
|
|
898
|
-
this is @<column>{foo}.
|
|
899
|
-
EOS
|
|
900
|
-
expected = <<-EOS
|
|
901
|
-
test
|
|
902
|
-
inside column
|
|
903
|
-
|
|
904
|
-
next level
|
|
905
|
-
this is コラム「test」.
|
|
906
|
-
EOS
|
|
907
|
-
|
|
908
|
-
assert_equal expected, column_helper(review)
|
|
909
|
-
end
|
|
910
|
-
|
|
911
|
-
def test_texequation_with_caption
|
|
912
|
-
src = <<-EOS
|
|
913
|
-
@<eq>{emc2}
|
|
914
|
-
|
|
915
|
-
//texequation[emc2][The Equivalence of Mass @<i>{and} Energy]{
|
|
916
|
-
e=mc^2
|
|
917
|
-
//}
|
|
918
|
-
EOS
|
|
919
|
-
expected = <<-EOS
|
|
920
|
-
式1.1
|
|
921
|
-
|
|
922
|
-
式1.1 The Equivalence of Mass and Energy
|
|
923
|
-
e=mc^2
|
|
924
|
-
|
|
925
|
-
EOS
|
|
926
|
-
actual = compile_block(src)
|
|
927
|
-
assert_equal expected, actual
|
|
928
|
-
|
|
929
|
-
@config['caption_position']['equation'] = 'bottom'
|
|
930
|
-
expected = <<-EOS
|
|
931
|
-
式1.1
|
|
932
|
-
|
|
933
|
-
e=mc^2
|
|
934
|
-
式1.1 The Equivalence of Mass and Energy
|
|
935
|
-
|
|
936
|
-
EOS
|
|
937
|
-
actual = compile_block(src)
|
|
938
|
-
assert_equal expected, actual
|
|
939
|
-
end
|
|
940
|
-
|
|
941
|
-
def test_nest_error_open
|
|
942
|
-
src = <<-EOS
|
|
943
|
-
//endchild
|
|
944
|
-
EOS
|
|
945
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
946
|
-
assert_equal ":1: //endchild is shown, but any opened //beginchild doesn't exist", e.message
|
|
947
|
-
end
|
|
948
|
-
|
|
949
|
-
def test_nest_error_close1
|
|
950
|
-
src = <<-EOS
|
|
951
|
-
//beginchild
|
|
952
|
-
EOS
|
|
953
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
954
|
-
assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
|
955
|
-
end
|
|
956
|
-
|
|
957
|
-
def test_nest_error_close2
|
|
958
|
-
src = <<-EOS
|
|
959
|
-
* foo
|
|
960
|
-
|
|
961
|
-
//beginchild
|
|
962
|
-
|
|
963
|
-
1. foo
|
|
964
|
-
|
|
965
|
-
//beginchild
|
|
966
|
-
|
|
967
|
-
: foo
|
|
968
|
-
|
|
969
|
-
//beginchild
|
|
970
|
-
EOS
|
|
971
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
972
|
-
assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
|
|
973
|
-
end
|
|
974
|
-
|
|
975
|
-
def test_nest_error_close3
|
|
976
|
-
src = <<-EOS
|
|
977
|
-
* foo
|
|
978
|
-
|
|
979
|
-
//beginchild
|
|
980
|
-
|
|
981
|
-
1. foo
|
|
982
|
-
|
|
983
|
-
//beginchild
|
|
984
|
-
|
|
985
|
-
: foo
|
|
986
|
-
|
|
987
|
-
//beginchild
|
|
988
|
-
|
|
989
|
-
//endchild
|
|
990
|
-
EOS
|
|
991
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
992
|
-
assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
|
|
993
|
-
end
|
|
994
|
-
|
|
995
|
-
def test_nest_ul
|
|
996
|
-
src = <<-EOS
|
|
997
|
-
* UL1
|
|
998
|
-
|
|
999
|
-
//beginchild
|
|
1000
|
-
|
|
1001
|
-
1. UL1-OL1
|
|
1002
|
-
2. UL1-OL2
|
|
1003
|
-
|
|
1004
|
-
* UL1-UL1
|
|
1005
|
-
* UL1-UL2
|
|
1006
|
-
|
|
1007
|
-
: UL1-DL1
|
|
1008
|
-
UL1-DD1
|
|
1009
|
-
: UL1-DL2
|
|
1010
|
-
UL1-DD2
|
|
1011
|
-
|
|
1012
|
-
//endchild
|
|
1013
|
-
|
|
1014
|
-
* UL2
|
|
1015
|
-
|
|
1016
|
-
//beginchild
|
|
1017
|
-
|
|
1018
|
-
UL2-PARA
|
|
1019
|
-
|
|
1020
|
-
//endchild
|
|
1021
|
-
EOS
|
|
1022
|
-
|
|
1023
|
-
expected = <<-EOS
|
|
1024
|
-
UL1
|
|
1025
|
-
|
|
1026
|
-
1 UL1-OL1
|
|
1027
|
-
2 UL1-OL2
|
|
1028
|
-
|
|
1029
|
-
UL1-UL1
|
|
1030
|
-
UL1-UL2
|
|
1031
|
-
|
|
1032
|
-
UL1-DL1
|
|
1033
|
-
UL1-DD1
|
|
1034
|
-
UL1-DL2
|
|
1035
|
-
UL1-DD2
|
|
1036
|
-
|
|
1037
|
-
UL2
|
|
1038
|
-
UL2-PARA
|
|
1039
|
-
EOS
|
|
1040
|
-
|
|
1041
|
-
actual = compile_block(src)
|
|
1042
|
-
assert_equal expected, actual
|
|
1043
|
-
end
|
|
1044
|
-
|
|
1045
|
-
def test_nest_ol
|
|
1046
|
-
src = <<-EOS
|
|
1047
|
-
1. OL1
|
|
1048
|
-
|
|
1049
|
-
//beginchild
|
|
1050
|
-
|
|
1051
|
-
1. OL1-OL1
|
|
1052
|
-
2. OL1-OL2
|
|
1053
|
-
|
|
1054
|
-
* OL1-UL1
|
|
1055
|
-
* OL1-UL2
|
|
1056
|
-
|
|
1057
|
-
: OL1-DL1
|
|
1058
|
-
OL1-DD1
|
|
1059
|
-
: OL1-DL2
|
|
1060
|
-
OL1-DD2
|
|
1061
|
-
|
|
1062
|
-
//endchild
|
|
1063
|
-
|
|
1064
|
-
2. OL2
|
|
1065
|
-
|
|
1066
|
-
//beginchild
|
|
1067
|
-
|
|
1068
|
-
OL2-PARA
|
|
1069
|
-
|
|
1070
|
-
//endchild
|
|
1071
|
-
EOS
|
|
1072
|
-
|
|
1073
|
-
expected = <<-EOS
|
|
1074
|
-
1 OL1
|
|
1075
|
-
|
|
1076
|
-
1 OL1-OL1
|
|
1077
|
-
2 OL1-OL2
|
|
1078
|
-
|
|
1079
|
-
OL1-UL1
|
|
1080
|
-
OL1-UL2
|
|
1081
|
-
|
|
1082
|
-
OL1-DL1
|
|
1083
|
-
OL1-DD1
|
|
1084
|
-
OL1-DL2
|
|
1085
|
-
OL1-DD2
|
|
1086
|
-
|
|
1087
|
-
2 OL2
|
|
1088
|
-
OL2-PARA
|
|
1089
|
-
EOS
|
|
1090
|
-
|
|
1091
|
-
actual = compile_block(src)
|
|
1092
|
-
assert_equal expected, actual
|
|
1093
|
-
end
|
|
1094
|
-
|
|
1095
|
-
def test_nest_dl
|
|
1096
|
-
src = <<-EOS
|
|
1097
|
-
: DL1
|
|
1098
|
-
|
|
1099
|
-
//beginchild
|
|
1100
|
-
|
|
1101
|
-
1. DL1-OL1
|
|
1102
|
-
2. DL1-OL2
|
|
1103
|
-
|
|
1104
|
-
* DL1-UL1
|
|
1105
|
-
* DL1-UL2
|
|
1106
|
-
|
|
1107
|
-
: DL1-DL1
|
|
1108
|
-
DL1-DD1
|
|
1109
|
-
: DL1-DL2
|
|
1110
|
-
DL1-DD2
|
|
1111
|
-
|
|
1112
|
-
//endchild
|
|
1113
|
-
|
|
1114
|
-
: DL2
|
|
1115
|
-
DD2
|
|
1116
|
-
|
|
1117
|
-
//beginchild
|
|
1118
|
-
|
|
1119
|
-
* DD2-UL1
|
|
1120
|
-
* DD2-UL2
|
|
1121
|
-
|
|
1122
|
-
DD2-PARA
|
|
1123
|
-
|
|
1124
|
-
//endchild
|
|
1125
|
-
EOS
|
|
1126
|
-
|
|
1127
|
-
expected = <<-EOS
|
|
1128
|
-
DL1
|
|
1129
|
-
|
|
1130
|
-
1 DL1-OL1
|
|
1131
|
-
2 DL1-OL2
|
|
1132
|
-
|
|
1133
|
-
DL1-UL1
|
|
1134
|
-
DL1-UL2
|
|
1135
|
-
|
|
1136
|
-
DL1-DL1
|
|
1137
|
-
DL1-DD1
|
|
1138
|
-
DL1-DL2
|
|
1139
|
-
DL1-DD2
|
|
1140
|
-
|
|
1141
|
-
DL2
|
|
1142
|
-
DD2
|
|
1143
|
-
|
|
1144
|
-
DD2-UL1
|
|
1145
|
-
DD2-UL2
|
|
1146
|
-
|
|
1147
|
-
DD2-PARA
|
|
1148
|
-
EOS
|
|
1149
|
-
|
|
1150
|
-
actual = compile_block(src)
|
|
1151
|
-
assert_equal expected, actual
|
|
1152
|
-
end
|
|
1153
|
-
|
|
1154
|
-
def test_nest_multi
|
|
1155
|
-
src = <<-EOS
|
|
1156
|
-
1. OL1
|
|
1157
|
-
|
|
1158
|
-
//beginchild
|
|
1159
|
-
|
|
1160
|
-
1. OL1-OL1
|
|
1161
|
-
|
|
1162
|
-
//beginchild
|
|
1163
|
-
|
|
1164
|
-
* OL1-OL1-UL1
|
|
1165
|
-
|
|
1166
|
-
OL1-OL1-PARA
|
|
1167
|
-
|
|
1168
|
-
//endchild
|
|
1169
|
-
|
|
1170
|
-
2. OL1-OL2
|
|
1171
|
-
|
|
1172
|
-
* OL1-UL1
|
|
1173
|
-
|
|
1174
|
-
//beginchild
|
|
1175
|
-
|
|
1176
|
-
: OL1-UL1-DL1
|
|
1177
|
-
OL1-UL1-DD1
|
|
1178
|
-
|
|
1179
|
-
OL1-UL1-PARA
|
|
1180
|
-
|
|
1181
|
-
//endchild
|
|
1182
|
-
|
|
1183
|
-
* OL1-UL2
|
|
1184
|
-
|
|
1185
|
-
//endchild
|
|
1186
|
-
EOS
|
|
1187
|
-
expected = <<-EOS
|
|
1188
|
-
1 OL1
|
|
1189
|
-
|
|
1190
|
-
1 OL1-OL1
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
OL1-OL1-UL1
|
|
1194
|
-
|
|
1195
|
-
OL1-OL1-PARA
|
|
1196
|
-
|
|
1197
|
-
2 OL1-OL2
|
|
1198
|
-
|
|
1199
|
-
OL1-UL1
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
OL1-UL1-DL1
|
|
1203
|
-
OL1-UL1-DD1
|
|
1204
|
-
|
|
1205
|
-
OL1-UL1-PARA
|
|
1206
|
-
|
|
1207
|
-
OL1-UL2
|
|
1208
|
-
|
|
1209
|
-
EOS
|
|
1210
|
-
|
|
1211
|
-
actual = compile_block(src)
|
|
1212
|
-
assert_equal expected, actual
|
|
1213
|
-
end
|
|
1214
|
-
end
|