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