review 5.6.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 +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_htmlbuilder.rb
DELETED
@@ -1,3315 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'book_test_helper'
|
3
|
-
require 'review'
|
4
|
-
|
5
|
-
class HTMLBuidlerTest < Test::Unit::TestCase
|
6
|
-
include ReVIEW
|
7
|
-
include BookTestHelper
|
8
|
-
|
9
|
-
def setup
|
10
|
-
ReVIEW::I18n.setup
|
11
|
-
@config = ReVIEW::Configure.values
|
12
|
-
@config['secnolevel'] = 2
|
13
|
-
@config['stylesheet'] = nil
|
14
|
-
@config['htmlext'] = 'html'
|
15
|
-
@config['epubmaker'] = {}
|
16
|
-
@book = Book::Base.new('.')
|
17
|
-
@book.config = @config
|
18
|
-
img_math = ReVIEW::ImgMath.new(@config)
|
19
|
-
@log_io = StringIO.new
|
20
|
-
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
21
|
-
@builder = HTMLBuilder.new(img_math: img_math)
|
22
|
-
@compiler = ReVIEW::Compiler.new(@builder)
|
23
|
-
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
24
|
-
location = Location.new(nil, nil)
|
25
|
-
@builder.bind(@compiler, @chapter, location)
|
26
|
-
I18n.setup('ja')
|
27
|
-
@skip_pygments = true # temporary suppress pygments test
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_xmlns_ops_prefix_epub3
|
31
|
-
assert_equal 'epub', @builder.xmlns_ops_prefix
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_xmlns_ops_prefix_epub2
|
35
|
-
@book.config['epubversion'] = 2
|
36
|
-
assert_equal 'ops', @builder.xmlns_ops_prefix
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_headline_level1
|
40
|
-
actual = compile_block("={test} this is test.\n")
|
41
|
-
assert_equal %Q(<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n), actual
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_headline_level1_postdef
|
45
|
-
@chapter.instance_eval do
|
46
|
-
def on_appendix?
|
47
|
-
true
|
48
|
-
end
|
49
|
-
end
|
50
|
-
actual = compile_block("={test} this is test.\n")
|
51
|
-
assert_equal %Q(<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n), actual
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_headline_level2_postdef
|
55
|
-
@chapter.instance_eval do
|
56
|
-
def on_appendix?
|
57
|
-
true
|
58
|
-
end
|
59
|
-
end
|
60
|
-
actual = compile_block("=={test} this is test.\n")
|
61
|
-
assert_equal %Q(\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n), actual
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_headline_postdef_roman
|
65
|
-
Dir.mktmpdir do |dir|
|
66
|
-
Dir.chdir(dir) do
|
67
|
-
file = File.join(dir, 'locale.yml')
|
68
|
-
File.write(file, "locale: ja\nappendix: 付録%pR")
|
69
|
-
I18n.setup('ja')
|
70
|
-
@chapter.instance_eval do
|
71
|
-
def on_appendix?
|
72
|
-
true
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
actual = compile_block("={test} this is test.\n")
|
77
|
-
assert_equal %Q(<h1 id="test"><a id="hI"></a><span class="secno">付録I </span>this is test.</h1>\n), actual
|
78
|
-
|
79
|
-
actual = compile_block("=={test} this is test.\n")
|
80
|
-
assert_equal %Q(\n<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n), actual
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_headline_postdef_alpha
|
86
|
-
Dir.mktmpdir do |dir|
|
87
|
-
Dir.chdir(dir) do
|
88
|
-
file = File.join(dir, 'locale.yml')
|
89
|
-
File.write(file, "locale: ja\nappendix: 付録%pA")
|
90
|
-
I18n.setup('ja')
|
91
|
-
@chapter.instance_eval do
|
92
|
-
def on_appendix?
|
93
|
-
true
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
actual = compile_block("={test} this is test.\n")
|
98
|
-
assert_equal %Q(<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n), actual
|
99
|
-
|
100
|
-
actual = compile_block("=={test} this is test.\n")
|
101
|
-
assert_equal %Q(\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n), actual
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_headline_level1_without_secno
|
107
|
-
@book.config['secnolevel'] = 0
|
108
|
-
actual = compile_block("={test} this is test.\n")
|
109
|
-
assert_equal %Q(<h1 id="test"><a id="h1"></a>this is test.</h1>\n), actual
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_headline_level1_with_tricky_id
|
113
|
-
actual = compile_block("={123あ_} this is test.\n")
|
114
|
-
assert_equal %Q(<h1 id="id_123_E3_81_82__"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n), actual
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_headline_level1_with_inlinetag
|
118
|
-
actual = compile_block(%Q(={test} this @<b>{is} test.<&">\n))
|
119
|
-
assert_equal %Q(<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this <b>is</b> test.<&"></h1>\n), actual
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_headline_level2
|
123
|
-
actual = compile_block("=={test} this is test.\n")
|
124
|
-
assert_equal %Q(\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n), actual
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_headline_level3
|
128
|
-
actual = compile_block("==={test} this is test.\n")
|
129
|
-
assert_equal %Q(\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n), actual
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_headline_level3_with_secno
|
133
|
-
@book.config['secnolevel'] = 3
|
134
|
-
actual = compile_block("==={test} this is test.\n")
|
135
|
-
assert_equal %Q(\n<h3 id="test"><a id="h1-0-1"></a><span class="secno">1.0.1 </span>this is test.</h3>\n), actual
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_headline_sections
|
139
|
-
@book.config['epubmaker']['use_section'] = true
|
140
|
-
actual = compile_block("= H1\n== H2\n== H2-2\n")
|
141
|
-
expected = <<-EOS
|
142
|
-
<section class="level1"><h1><a id="h1"></a><span class="secno">第1章 </span>H1</h1>
|
143
|
-
<section class="level2">
|
144
|
-
<h2><a id="h1-1"></a><span class="secno">1.1 </span>H2</h2>
|
145
|
-
</section>
|
146
|
-
<section class="level2">
|
147
|
-
<h2><a id="h1-2"></a><span class="secno">1.2 </span>H2-2</h2>
|
148
|
-
</section>
|
149
|
-
</section>
|
150
|
-
EOS
|
151
|
-
assert_equal expected, actual
|
152
|
-
|
153
|
-
actual = compile_block("= H1\n== H2\n==== H4\n== H2-2\n")
|
154
|
-
expected = <<-EOS
|
155
|
-
<section class="level1"><h1><a id="h1"></a><span class="secno">第1章 </span>H1</h1>
|
156
|
-
<section class="level2">
|
157
|
-
<h2><a id="h1-1"></a><span class="secno">1.1 </span>H2</h2>
|
158
|
-
<section class="level4">
|
159
|
-
<h4><a id="h1-1-0-1"></a>H4</h4>
|
160
|
-
</section>
|
161
|
-
</section>
|
162
|
-
<section class="level2">
|
163
|
-
<h2><a id="h1-2"></a><span class="secno">1.2 </span>H2-2</h2>
|
164
|
-
</section>
|
165
|
-
</section>
|
166
|
-
EOS
|
167
|
-
assert_equal expected, actual
|
168
|
-
|
169
|
-
actual = compile_block("===== H5\n= H1\n")
|
170
|
-
expected = <<-EOS
|
171
|
-
<section class="level5">
|
172
|
-
<h5><a id="h1-0-0-0-1"></a>H5</h5>
|
173
|
-
</section>
|
174
|
-
<section class="level1"><h1><a id="h1"></a><span class="secno">第1章 </span>H1</h1>
|
175
|
-
</section>
|
176
|
-
EOS
|
177
|
-
assert_equal expected, actual
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_label
|
181
|
-
actual = compile_block("//label[label_test]\n")
|
182
|
-
assert_equal %Q(<a id="label_test"></a>\n), actual
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_label_with_tricky_id
|
186
|
-
actual = compile_block("//label[123あ_]\n")
|
187
|
-
assert_equal %Q(<a id="id_123_E3_81_82__"></a>\n), actual
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_href
|
191
|
-
actual = compile_inline('@<href>{http://github.com,GitHub}')
|
192
|
-
assert_equal %Q(<a href="http://github.com" class="link">GitHub</a>), actual
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_href_without_label
|
196
|
-
actual = compile_inline('@<href>{http://github.com}')
|
197
|
-
assert_equal %Q(<a href="http://github.com" class="link">http://github.com</a>), actual
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_inline_href
|
201
|
-
actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
|
202
|
-
assert_equal %Q(<a href="http://github.com" class="link">Git,Hub</a>), actual
|
203
|
-
|
204
|
-
@book.config['epubmaker'] ||= {}
|
205
|
-
@book.config['epubmaker']['externallink'] = false
|
206
|
-
actual = compile_inline('@<href>{http://github.com&q=1,Git\\,Hub}')
|
207
|
-
assert_equal %Q(<a href="http://github.com&q=1" class="link">Git,Hub</a>), actual
|
208
|
-
|
209
|
-
actual = compile_inline('@<href>{http://github.com&q=1}')
|
210
|
-
assert_equal %Q(<a href="http://github.com&q=1" class="link">http://github.com&q=1</a>), actual
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_inline_href_epubmaker
|
214
|
-
@book.config.maker = 'epubmaker'
|
215
|
-
actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
|
216
|
-
assert_equal %Q(<a href="http://github.com" class="link">Git,Hub</a>), actual
|
217
|
-
|
218
|
-
@book.config['epubmaker'] ||= {}
|
219
|
-
@book.config['epubmaker']['externallink'] = false
|
220
|
-
actual = compile_inline('@<href>{http://github.com&q=1,Git\\,Hub}')
|
221
|
-
assert_equal 'Git,Hub(http://github.com&q=1)', actual
|
222
|
-
|
223
|
-
actual = compile_inline('@<href>{http://github.com&q=1}')
|
224
|
-
assert_equal 'http://github.com&q=1', actual
|
225
|
-
|
226
|
-
@book.config['epubmaker']['externallink'] = true
|
227
|
-
actual = compile_inline('@<href>{http://github.com&q=1,Git\\,Hub}')
|
228
|
-
assert_equal %Q(<a href="http://github.com&q=1" class="link">Git,Hub</a>), actual
|
229
|
-
actual = compile_inline('@<href>{http://github.com&q=1}')
|
230
|
-
assert_equal %Q(<a href="http://github.com&q=1" class="link">http://github.com&q=1</a>), actual
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_inline_raw
|
234
|
-
actual = compile_inline('@<raw>{@<tt>{inline\\}}')
|
235
|
-
assert_equal '@<tt>{inline}', actual
|
236
|
-
end
|
237
|
-
|
238
|
-
def test_inline_in_table
|
239
|
-
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
240
|
-
expected = <<-EOS
|
241
|
-
<div class="table">
|
242
|
-
<table>
|
243
|
-
<tr><th><b>1</b></th><th><i>2</i></th></tr>
|
244
|
-
<tr><td><b>3</b></td><td><i>4</i><>&</td></tr>
|
245
|
-
</table>
|
246
|
-
</div>
|
247
|
-
EOS
|
248
|
-
assert_equal expected, actual
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_inline_br
|
252
|
-
actual = compile_inline('@<br>{}')
|
253
|
-
assert_equal '<br />', actual
|
254
|
-
end
|
255
|
-
|
256
|
-
def test_inline_i
|
257
|
-
actual = compile_inline('test @<i>{inline test} test2')
|
258
|
-
assert_equal 'test <i>inline test</i> test2', actual
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_inline_i_and_escape
|
262
|
-
actual = compile_inline('test @<i>{inline<&;\\ test} test2')
|
263
|
-
assert_equal 'test <i>inline<&;\\ test</i> test2', actual
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_inline_b
|
267
|
-
actual = compile_inline('test @<b>{inline test} test2')
|
268
|
-
assert_equal 'test <b>inline test</b> test2', actual
|
269
|
-
end
|
270
|
-
|
271
|
-
def test_inline_b_and_escape
|
272
|
-
actual = compile_inline('test @<b>{inline<&;\\ test} test2')
|
273
|
-
assert_equal 'test <b>inline<&;\\ test</b> test2', actual
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_inline_tt
|
277
|
-
actual = compile_inline('test @<tt>{inline test} test2')
|
278
|
-
assert_equal %Q(test <code class="tt">inline test</code> test2), actual
|
279
|
-
end
|
280
|
-
|
281
|
-
def test_inline_tti
|
282
|
-
actual = compile_inline('test @<tti>{inline test} test2')
|
283
|
-
assert_equal %Q(test <code class="tt"><i>inline test</i></code> test2), actual
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_inline_ttb
|
287
|
-
actual = compile_inline('test @<ttb>{inline test} test2')
|
288
|
-
assert_equal %Q(test <code class="tt"><b>inline test</b></code> test2), actual
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_inline_hd_chap
|
292
|
-
def @chapter.headline_index
|
293
|
-
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
294
|
-
idx = Book::HeadlineIndex.new(self)
|
295
|
-
idx.add_item(item)
|
296
|
-
idx
|
297
|
-
end
|
298
|
-
|
299
|
-
@config['secnolevel'] = 2
|
300
|
-
actual = compile_inline('test @<hd>{chap1|test} test2')
|
301
|
-
assert_equal 'test <a href="-.html#h1-1-1">「te_st」</a> test2', actual
|
302
|
-
|
303
|
-
@config['secnolevel'] = 3
|
304
|
-
actual = compile_inline('test @<hd>{chap1|test} test2')
|
305
|
-
assert_equal 'test <a href="-.html#h1-1-1">「1.1.1 te_st」</a> test2', actual
|
306
|
-
|
307
|
-
@config['chapterlink'] = nil
|
308
|
-
@config['secnolevel'] = 2
|
309
|
-
actual = compile_inline('test @<hd>{chap1|test} test2')
|
310
|
-
assert_equal 'test 「te_st」 test2', actual
|
311
|
-
|
312
|
-
@config['secnolevel'] = 3
|
313
|
-
actual = compile_inline('test @<hd>{chap1|test} test2')
|
314
|
-
assert_equal 'test 「1.1.1 te_st」 test2', actual
|
315
|
-
end
|
316
|
-
|
317
|
-
def test_inline_hd_chap_postdef_roman
|
318
|
-
Dir.mktmpdir do |dir|
|
319
|
-
Dir.chdir(dir) do
|
320
|
-
file = File.join(dir, 'locale.yml')
|
321
|
-
File.write(file, "locale: ja\nappendix: 付録%pR")
|
322
|
-
I18n.setup('ja')
|
323
|
-
@chapter.instance_eval do
|
324
|
-
def on_appendix?
|
325
|
-
true
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
def @chapter.headline_index
|
330
|
-
item = Book::Index::Item.new('test', [1], 'te_st')
|
331
|
-
idx = Book::HeadlineIndex.new(self)
|
332
|
-
idx.add_item(item)
|
333
|
-
idx
|
334
|
-
end
|
335
|
-
|
336
|
-
actual = compile_inline('test @<hd>{test} test2')
|
337
|
-
assert_equal 'test <a href="-.html#hI-1">「I.1 te_st」</a> test2', actual
|
338
|
-
|
339
|
-
@config['chapterlink'] = nil
|
340
|
-
actual = compile_inline('test @<hd>{test} test2')
|
341
|
-
assert_equal 'test 「I.1 te_st」 test2', actual
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
def test_inline_hd_chap_postdef_alpha
|
347
|
-
Dir.mktmpdir do |dir|
|
348
|
-
Dir.chdir(dir) do
|
349
|
-
file = File.join(dir, 'locale.yml')
|
350
|
-
File.write(file, "locale: ja\nappendix: 付録%pA")
|
351
|
-
I18n.setup('ja')
|
352
|
-
@chapter.instance_eval do
|
353
|
-
def on_appendix?
|
354
|
-
true
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
def @chapter.headline_index
|
359
|
-
item = Book::Index::Item.new('test', [1], 'te_st')
|
360
|
-
idx = Book::HeadlineIndex.new(self)
|
361
|
-
idx.add_item(item)
|
362
|
-
idx
|
363
|
-
end
|
364
|
-
|
365
|
-
actual = compile_inline('test @<hd>{test} test2')
|
366
|
-
assert_equal 'test <a href="-.html#hA-1">「A.1 te_st」</a> test2', actual
|
367
|
-
|
368
|
-
@config['chapterlink'] = nil
|
369
|
-
actual = compile_inline('test @<hd>{test} test2')
|
370
|
-
assert_equal 'test 「A.1 te_st」 test2', actual
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
def test_inline_sec
|
376
|
-
def @chapter.headline_index
|
377
|
-
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st<>')
|
378
|
-
idx = Book::HeadlineIndex.new(self)
|
379
|
-
idx.add_item(item)
|
380
|
-
idx
|
381
|
-
end
|
382
|
-
|
383
|
-
@config['secnolevel'] = 3
|
384
|
-
actual = compile_inline('test @<secref>{test}')
|
385
|
-
assert_equal 'test <a href="-.html#h1-1-1">「1.1.1 te_st<>」</a>', actual
|
386
|
-
actual = compile_inline('test @<sectitle>{test}')
|
387
|
-
assert_equal 'test <a href="-.html#h1-1-1">te_st<></a>', actual
|
388
|
-
actual = compile_inline('test @<sec>{test}')
|
389
|
-
assert_equal 'test <a href="-.html#h1-1-1">1.1.1</a>', actual
|
390
|
-
|
391
|
-
@config['secnolevel'] = 2
|
392
|
-
actual = compile_inline('test @<secref>{test}')
|
393
|
-
assert_equal 'test <a href="-.html#h1-1-1">「te_st<>」</a>', actual
|
394
|
-
actual = compile_inline('test @<sectitle>{test}')
|
395
|
-
assert_equal 'test <a href="-.html#h1-1-1">te_st<></a>', actual
|
396
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block('test @<sec>{test}') }
|
397
|
-
assert_match(/the target headline doesn't have a number/, @log_io.string)
|
398
|
-
|
399
|
-
@config['chapterlink'] = nil
|
400
|
-
@config['secnolevel'] = 3
|
401
|
-
actual = compile_inline('test @<secref>{test}')
|
402
|
-
assert_equal 'test 「1.1.1 te_st<>」', actual
|
403
|
-
actual = compile_inline('test @<sectitle>{test}')
|
404
|
-
assert_equal 'test te_st<>', actual
|
405
|
-
actual = compile_inline('test @<sec>{test}')
|
406
|
-
assert_equal 'test 1.1.1', actual
|
407
|
-
end
|
408
|
-
|
409
|
-
def test_inline_uchar
|
410
|
-
actual = compile_inline('test @<uchar>{2460} test2')
|
411
|
-
assert_equal 'test ① test2', actual
|
412
|
-
end
|
413
|
-
|
414
|
-
def test_inline_balloon
|
415
|
-
actual = compile_inline('test @<balloon>{①}')
|
416
|
-
assert_equal %Q(test <span class="balloon">①</span>), actual
|
417
|
-
end
|
418
|
-
|
419
|
-
def test_inline_ruby
|
420
|
-
actual = compile_inline('@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。')
|
421
|
-
assert_equal '<ruby>粗雑<rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby>繊細<rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。', actual
|
422
|
-
|
423
|
-
actual = compile_inline('@<ruby>{ 粗雑 , クルード }と思われているなら@<ruby>{ 繊細 ,テクニカル }にやり、繊細と思われているなら粗雑にやる。')
|
424
|
-
assert_equal '<ruby>粗雑<rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby>繊細<rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。', actual
|
425
|
-
end
|
426
|
-
|
427
|
-
def test_inline_ruby_comma
|
428
|
-
actual = compile_inline('@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}')
|
429
|
-
assert_equal '<ruby>foo, bar, buz<rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>', actual
|
430
|
-
end
|
431
|
-
|
432
|
-
def test_inline_ref
|
433
|
-
actual = compile_inline('@<ref>{外部参照<>&}')
|
434
|
-
assert_equal %Q(<a target='外部参照<>&'>「●● 外部参照<>&」</a>), actual
|
435
|
-
end
|
436
|
-
|
437
|
-
def test_inline_mathml
|
438
|
-
begin
|
439
|
-
require 'math_ml'
|
440
|
-
require 'math_ml/symbol/character_reference'
|
441
|
-
rescue LoadError
|
442
|
-
return true
|
443
|
-
end
|
444
|
-
@config['math_format'] = 'mathml'
|
445
|
-
actual = compile_inline('@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}')
|
446
|
-
assert_equal %Q(<span class="equation"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span>), actual
|
447
|
-
end
|
448
|
-
|
449
|
-
def test_inline_mathjax
|
450
|
-
@config['math_format'] = 'mathjax'
|
451
|
-
actual = compile_inline('@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}')
|
452
|
-
assert_equal %Q(<span class="equation">\\( \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a} \\)</span>), actual
|
453
|
-
|
454
|
-
content = <<-EOF
|
455
|
-
//texequation{
|
456
|
-
\\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}
|
457
|
-
//}
|
458
|
-
EOF
|
459
|
-
actual = compile_block(content)
|
460
|
-
expected = %Q(<div class="equation">\n$$\\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$$\n</div>\n)
|
461
|
-
assert_equal expected, actual
|
462
|
-
end
|
463
|
-
|
464
|
-
def test_inline_img
|
465
|
-
def @chapter.image(_id)
|
466
|
-
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
467
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
468
|
-
item
|
469
|
-
end
|
470
|
-
|
471
|
-
actual = compile_block("@<img>{sampleimg}\n")
|
472
|
-
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
473
|
-
assert_equal expected, actual
|
474
|
-
|
475
|
-
@config['chapterlink'] = nil
|
476
|
-
actual = compile_block("@<img>{sampleimg}\n")
|
477
|
-
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
478
|
-
assert_equal expected, actual
|
479
|
-
end
|
480
|
-
|
481
|
-
def test_inline_imgref
|
482
|
-
def @chapter.image(_id)
|
483
|
-
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
484
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
485
|
-
item
|
486
|
-
end
|
487
|
-
|
488
|
-
actual = compile_block("@<imgref>{sampleimg}\n")
|
489
|
-
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span>「sample photo」</p>\n)
|
490
|
-
assert_equal expected, actual
|
491
|
-
|
492
|
-
@config['chapterlink'] = nil
|
493
|
-
actual = compile_block("@<imgref>{sampleimg}\n")
|
494
|
-
expected = %Q(<p><span class="imgref">図1.1</span>「sample photo」</p>\n)
|
495
|
-
assert_equal expected, actual
|
496
|
-
end
|
497
|
-
|
498
|
-
def test_inline_imgref2
|
499
|
-
def @chapter.image(_id)
|
500
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
501
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
502
|
-
item
|
503
|
-
end
|
504
|
-
|
505
|
-
actual = compile_block("@<imgref>{sampleimg}\n")
|
506
|
-
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
507
|
-
assert_equal expected, actual
|
508
|
-
|
509
|
-
@config['chapterlink'] = nil
|
510
|
-
actual = compile_block("@<imgref>{sampleimg}\n")
|
511
|
-
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
512
|
-
assert_equal expected, actual
|
513
|
-
end
|
514
|
-
|
515
|
-
def test_inline_imgref3
|
516
|
-
Dir.mktmpdir do |dir|
|
517
|
-
Dir.chdir(dir) do
|
518
|
-
file1 = File.join(dir, 'images', 'img1.png')
|
519
|
-
filet1 = File.join(dir, 'images', 'tbl1.png')
|
520
|
-
file2 = File.join(dir, 'images', 'img2.png')
|
521
|
-
file3 = File.join(dir, 'images', 'icon3.png')
|
522
|
-
re1 = File.join(dir, 'sample1.re')
|
523
|
-
cat = File.join(dir, 'catalog.yml')
|
524
|
-
FileUtils.mkdir_p(File.join(dir, 'images'))
|
525
|
-
File.write(file1, '')
|
526
|
-
File.write(filet1, '')
|
527
|
-
File.write(file2, '')
|
528
|
-
File.write(file3, '')
|
529
|
-
File.write(cat, "CHAPS:\n - sample1.re\n")
|
530
|
-
File.write(re1, <<-EOF)
|
531
|
-
= test
|
532
|
-
|
533
|
-
tbl1 is @<table>{tbl1}.
|
534
|
-
|
535
|
-
img2 is @<img>{img2}.
|
536
|
-
|
537
|
-
icon3 is @<icon>{icon3}.
|
538
|
-
|
539
|
-
//image[img1][image 1]{
|
540
|
-
//}
|
541
|
-
|
542
|
-
//imgtable[tbl1][table 1]{
|
543
|
-
//}
|
544
|
-
|
545
|
-
//image[img2][image 2]{
|
546
|
-
//}
|
547
|
-
EOF
|
548
|
-
content = File.read(re1)
|
549
|
-
actual = compile_block(content)
|
550
|
-
|
551
|
-
expected = <<-EOS
|
552
|
-
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
553
|
-
<p>tbl1 is <span class="tableref"><a href="./-.html#tbl1">表1.1</a></span>.</p>
|
554
|
-
<p>img2 is <span class="imgref"><a href="./-.html#img2">図1.2</a></span>.</p>
|
555
|
-
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
556
|
-
<div id="img1" class="image">
|
557
|
-
<img src="images/img1.png" alt="image 1" />
|
558
|
-
<p class="caption">
|
559
|
-
図1.1: image 1
|
560
|
-
</p>
|
561
|
-
</div>
|
562
|
-
<div id="tbl1" class="imgtable image">
|
563
|
-
<p class="caption">表1.1: table 1</p>
|
564
|
-
<img src="images/tbl1.png" alt="table 1" />
|
565
|
-
</div>
|
566
|
-
<div id="img2" class="image">
|
567
|
-
<img src="images/img2.png" alt="image 2" />
|
568
|
-
<p class="caption">
|
569
|
-
図1.2: image 2
|
570
|
-
</p>
|
571
|
-
</div>
|
572
|
-
EOS
|
573
|
-
|
574
|
-
assert_equal expected, actual
|
575
|
-
|
576
|
-
@config['chapterlink'] = nil
|
577
|
-
actual = compile_block(content)
|
578
|
-
|
579
|
-
expected = <<-EOS
|
580
|
-
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
581
|
-
<p>tbl1 is <span class="tableref">表1.1</span>.</p>
|
582
|
-
<p>img2 is <span class="imgref">図1.2</span>.</p>
|
583
|
-
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
584
|
-
<div id="img1" class="image">
|
585
|
-
<img src="images/img1.png" alt="image 1" />
|
586
|
-
<p class="caption">
|
587
|
-
図1.1: image 1
|
588
|
-
</p>
|
589
|
-
</div>
|
590
|
-
<div id="tbl1" class="imgtable image">
|
591
|
-
<p class="caption">表1.1: table 1</p>
|
592
|
-
<img src="images/tbl1.png" alt="table 1" />
|
593
|
-
</div>
|
594
|
-
<div id="img2" class="image">
|
595
|
-
<img src="images/img2.png" alt="image 2" />
|
596
|
-
<p class="caption">
|
597
|
-
図1.2: image 2
|
598
|
-
</p>
|
599
|
-
</div>
|
600
|
-
EOS
|
601
|
-
|
602
|
-
assert_equal expected, actual
|
603
|
-
end
|
604
|
-
end
|
605
|
-
end
|
606
|
-
|
607
|
-
def test_quote
|
608
|
-
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
609
|
-
expected = <<-EOS
|
610
|
-
<blockquote><p>foobar</p>
|
611
|
-
<p>buz</p></blockquote>
|
612
|
-
EOS
|
613
|
-
assert_equal expected, actual
|
614
|
-
|
615
|
-
@book.config['join_lines_by_lang'] = true
|
616
|
-
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
617
|
-
expected = <<-EOS
|
618
|
-
<blockquote><p>foo bar</p>
|
619
|
-
<p>buz</p></blockquote>
|
620
|
-
EOS
|
621
|
-
assert_equal expected, actual
|
622
|
-
end
|
623
|
-
|
624
|
-
def test_memo
|
625
|
-
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
626
|
-
expected = <<-EOS
|
627
|
-
<div class="memo">
|
628
|
-
<p class="caption">this is <b>test</b><&>_</p>
|
629
|
-
<p>test1</p>
|
630
|
-
<p>test<i>2</i></p>
|
631
|
-
</div>
|
632
|
-
EOS
|
633
|
-
assert_equal expected, actual
|
634
|
-
end
|
635
|
-
|
636
|
-
def test_blankline
|
637
|
-
actual = compile_block("//blankline\nfoo\n")
|
638
|
-
expected = <<-EOS
|
639
|
-
<p><br /></p>
|
640
|
-
<p>foo</p>
|
641
|
-
EOS
|
642
|
-
assert_equal expected, actual
|
643
|
-
end
|
644
|
-
|
645
|
-
def test_noindent
|
646
|
-
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
647
|
-
expected = <<-EOS
|
648
|
-
<p class="noindent">foobar</p>
|
649
|
-
<p>foo2bar2</p>
|
650
|
-
EOS
|
651
|
-
assert_equal expected, actual
|
652
|
-
|
653
|
-
@book.config['join_lines_by_lang'] = true
|
654
|
-
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
655
|
-
expected = <<-EOS
|
656
|
-
<p class="noindent">foo bar</p>
|
657
|
-
<p>foo2 bar2</p>
|
658
|
-
EOS
|
659
|
-
assert_equal expected, actual
|
660
|
-
end
|
661
|
-
|
662
|
-
def test_flushright
|
663
|
-
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
664
|
-
expected = <<-EOS
|
665
|
-
<p class="flushright">foobar</p>
|
666
|
-
<p class="flushright">buz</p>
|
667
|
-
EOS
|
668
|
-
assert_equal expected, actual
|
669
|
-
|
670
|
-
@book.config['join_lines_by_lang'] = true
|
671
|
-
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
672
|
-
expected = <<-EOS
|
673
|
-
<p class="flushright">foo bar</p>
|
674
|
-
<p class="flushright">buz</p>
|
675
|
-
EOS
|
676
|
-
assert_equal expected, actual
|
677
|
-
end
|
678
|
-
|
679
|
-
def test_centering
|
680
|
-
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
681
|
-
expected = <<-EOS
|
682
|
-
<p class="center">foobar</p>
|
683
|
-
<p class="center">buz</p>
|
684
|
-
EOS
|
685
|
-
assert_equal expected, actual
|
686
|
-
|
687
|
-
@book.config['join_lines_by_lang'] = true
|
688
|
-
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
689
|
-
expected = <<-EOS
|
690
|
-
<p class="center">foo bar</p>
|
691
|
-
<p class="center">buz</p>
|
692
|
-
EOS
|
693
|
-
assert_equal expected, actual
|
694
|
-
end
|
695
|
-
|
696
|
-
def test_image
|
697
|
-
def @chapter.image(_id)
|
698
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
699
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
700
|
-
item
|
701
|
-
end
|
702
|
-
|
703
|
-
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
704
|
-
expected = <<-EOS
|
705
|
-
<div id="sampleimg" class="image">
|
706
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
707
|
-
<p class="caption">
|
708
|
-
図1.1: sample photo
|
709
|
-
</p>
|
710
|
-
</div>
|
711
|
-
EOS
|
712
|
-
assert_equal expected, actual
|
713
|
-
|
714
|
-
actual = compile_block("//image[sampleimg][]{\n//}\n")
|
715
|
-
expected = <<-EOS
|
716
|
-
<div id="sampleimg" class="image">
|
717
|
-
<img src="images/chap1-sampleimg.png" alt="" />
|
718
|
-
<p class="caption">
|
719
|
-
図1.1:
|
720
|
-
</p>
|
721
|
-
</div>
|
722
|
-
EOS
|
723
|
-
assert_equal expected, actual
|
724
|
-
|
725
|
-
actual = compile_block("//image[sampleimg][][]{\n//}\n")
|
726
|
-
assert_equal expected, actual
|
727
|
-
|
728
|
-
@config['caption_position']['image'] = 'top'
|
729
|
-
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
730
|
-
expected = <<-EOS
|
731
|
-
<div id="sampleimg" class="image">
|
732
|
-
<p class="caption">
|
733
|
-
図1.1: sample photo
|
734
|
-
</p>
|
735
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
736
|
-
</div>
|
737
|
-
EOS
|
738
|
-
assert_equal expected, actual
|
739
|
-
end
|
740
|
-
|
741
|
-
def test_image_with_metric
|
742
|
-
def @chapter.image(_id)
|
743
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
744
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
745
|
-
item
|
746
|
-
end
|
747
|
-
|
748
|
-
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
749
|
-
expected = <<-EOS
|
750
|
-
<div id="sampleimg" class="image">
|
751
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
|
752
|
-
<p class="caption">
|
753
|
-
図1.1: sample photo
|
754
|
-
</p>
|
755
|
-
</div>
|
756
|
-
EOS
|
757
|
-
assert_equal expected, actual
|
758
|
-
end
|
759
|
-
|
760
|
-
def test_image_with_metric2
|
761
|
-
def @chapter.image(_id)
|
762
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
763
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
764
|
-
item
|
765
|
-
end
|
766
|
-
|
767
|
-
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
768
|
-
expected = <<-EOS
|
769
|
-
<div id="sampleimg" class="image">
|
770
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
|
771
|
-
<p class="caption">
|
772
|
-
図1.1: sample photo
|
773
|
-
</p>
|
774
|
-
</div>
|
775
|
-
EOS
|
776
|
-
assert_equal expected, actual
|
777
|
-
end
|
778
|
-
|
779
|
-
def test_image_with_tricky_id_kana
|
780
|
-
def @chapter.image(_id)
|
781
|
-
item = Book::Index::Item.new('123あいう', 1)
|
782
|
-
item.instance_eval { @path = './images/123あいう.png' }
|
783
|
-
item
|
784
|
-
end
|
785
|
-
@chapter.instance_eval { @name = 'ch01' }
|
786
|
-
actual = compile_block("//image[123あいう][sample photo]{\n//}\nimg: @<img>{123あいう}\n")
|
787
|
-
expected = <<-EOS
|
788
|
-
<div id="id_123_E3_81_82_E3_81_84_E3_81_86" class="image">
|
789
|
-
<img src="images/123あいう.png" alt="sample photo" />
|
790
|
-
<p class="caption">
|
791
|
-
図1.1: sample photo
|
792
|
-
</p>
|
793
|
-
</div>
|
794
|
-
<p>img: <span class="imgref"><a href="./ch01.html#id_123_E3_81_82_E3_81_84_E3_81_86">図1.1</a></span></p>
|
795
|
-
EOS
|
796
|
-
assert_equal expected, actual
|
797
|
-
end
|
798
|
-
|
799
|
-
def test_indepimage
|
800
|
-
def @chapter.image(_id)
|
801
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
802
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
803
|
-
item
|
804
|
-
end
|
805
|
-
|
806
|
-
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
807
|
-
expected = <<-EOS
|
808
|
-
<div id="sampleimg" class="image">
|
809
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
810
|
-
<p class="caption">
|
811
|
-
図: sample photo
|
812
|
-
</p>
|
813
|
-
</div>
|
814
|
-
EOS
|
815
|
-
assert_equal expected, actual
|
816
|
-
|
817
|
-
@config['caption_position']['image'] = 'top'
|
818
|
-
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
819
|
-
expected = <<-EOS
|
820
|
-
<div id="sampleimg" class="image">
|
821
|
-
<p class="caption">
|
822
|
-
図: sample photo
|
823
|
-
</p>
|
824
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
825
|
-
</div>
|
826
|
-
EOS
|
827
|
-
assert_equal expected, actual
|
828
|
-
end
|
829
|
-
|
830
|
-
def test_indepimage_without_caption
|
831
|
-
def @chapter.image(_id)
|
832
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
833
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
834
|
-
item
|
835
|
-
end
|
836
|
-
|
837
|
-
actual = compile_block("//indepimage[sampleimg]\n")
|
838
|
-
expected = <<-EOS
|
839
|
-
<div id="sampleimg" class="image">
|
840
|
-
<img src="images/chap1-sampleimg.png" alt="" />
|
841
|
-
</div>
|
842
|
-
EOS
|
843
|
-
assert_equal expected, actual
|
844
|
-
|
845
|
-
actual = compile_block("//indepimage[sampleimg][]\n")
|
846
|
-
assert_equal expected, actual
|
847
|
-
|
848
|
-
actual = compile_block("//indepimage[sampleimg][][]\n")
|
849
|
-
assert_equal expected, actual
|
850
|
-
end
|
851
|
-
|
852
|
-
def test_indepimage_with_metric
|
853
|
-
def @chapter.image(_id)
|
854
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
855
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
856
|
-
item
|
857
|
-
end
|
858
|
-
|
859
|
-
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
860
|
-
expected = <<-EOS
|
861
|
-
<div id="sampleimg" class="image">
|
862
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
|
863
|
-
<p class="caption">
|
864
|
-
図: sample photo
|
865
|
-
</p>
|
866
|
-
</div>
|
867
|
-
EOS
|
868
|
-
assert_equal expected, actual
|
869
|
-
end
|
870
|
-
|
871
|
-
def test_indepimage_with_metric2
|
872
|
-
def @chapter.image(_id)
|
873
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
874
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
875
|
-
item
|
876
|
-
end
|
877
|
-
|
878
|
-
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
|
879
|
-
expected = <<-EOS
|
880
|
-
<div id="sampleimg" class="image">
|
881
|
-
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
|
882
|
-
<p class="caption">
|
883
|
-
図: sample photo
|
884
|
-
</p>
|
885
|
-
</div>
|
886
|
-
EOS
|
887
|
-
assert_equal expected, actual
|
888
|
-
end
|
889
|
-
|
890
|
-
def test_indepimage_without_caption_but_with_metric
|
891
|
-
def @chapter.image(_id)
|
892
|
-
item = Book::Index::Item.new('sampleimg', 1)
|
893
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
894
|
-
item
|
895
|
-
end
|
896
|
-
|
897
|
-
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
898
|
-
expected = <<-EOS
|
899
|
-
<div id="sampleimg" class="image">
|
900
|
-
<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />
|
901
|
-
</div>
|
902
|
-
EOS
|
903
|
-
assert_equal expected, actual
|
904
|
-
end
|
905
|
-
|
906
|
-
def test_dlist
|
907
|
-
actual = compile_block(" : foo\n foo.\n bar.\n")
|
908
|
-
expected = <<-EOS
|
909
|
-
<dl>
|
910
|
-
<dt>foo</dt>
|
911
|
-
<dd>foo.bar.</dd>
|
912
|
-
</dl>
|
913
|
-
EOS
|
914
|
-
assert_equal expected, actual
|
915
|
-
|
916
|
-
@book.config['join_lines_by_lang'] = true
|
917
|
-
actual = compile_block(" : foo\n foo.\n bar.\n")
|
918
|
-
expected = <<-EOS
|
919
|
-
<dl>
|
920
|
-
<dt>foo</dt>
|
921
|
-
<dd>foo. bar.</dd>
|
922
|
-
</dl>
|
923
|
-
EOS
|
924
|
-
assert_equal expected, actual
|
925
|
-
end
|
926
|
-
|
927
|
-
def test_dlist_with_bracket
|
928
|
-
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
929
|
-
expected = <<-EOS
|
930
|
-
<dl>
|
931
|
-
<dt>foo[bar]</dt>
|
932
|
-
<dd>foo.bar.</dd>
|
933
|
-
</dl>
|
934
|
-
EOS
|
935
|
-
assert_equal expected, actual
|
936
|
-
|
937
|
-
@book.config['join_lines_by_lang'] = true
|
938
|
-
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
939
|
-
expected = <<-EOS
|
940
|
-
<dl>
|
941
|
-
<dt>foo[bar]</dt>
|
942
|
-
<dd>foo. bar.</dd>
|
943
|
-
</dl>
|
944
|
-
EOS
|
945
|
-
assert_equal expected, actual
|
946
|
-
end
|
947
|
-
|
948
|
-
def test_dlist_with_comment
|
949
|
-
source = " : title\n body\n\#@ comment\n\#@ comment\n : title2\n body2\n"
|
950
|
-
actual = compile_block(source)
|
951
|
-
expected = <<-EOS
|
952
|
-
<dl>
|
953
|
-
<dt>title</dt>
|
954
|
-
<dd>body</dd>
|
955
|
-
<dt>title2</dt>
|
956
|
-
<dd>body2</dd>
|
957
|
-
</dl>
|
958
|
-
EOS
|
959
|
-
assert_equal expected, actual
|
960
|
-
end
|
961
|
-
|
962
|
-
def test_dlist_beforeulol
|
963
|
-
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")
|
964
|
-
expected = <<-EOS
|
965
|
-
<dl>
|
966
|
-
<dt>foo</dt>
|
967
|
-
<dd>foo.</dd>
|
968
|
-
</dl>
|
969
|
-
<p>para</p>
|
970
|
-
<dl>
|
971
|
-
<dt>foo</dt>
|
972
|
-
<dd>foo.</dd>
|
973
|
-
</dl>
|
974
|
-
<ol>
|
975
|
-
<li>bar</li>
|
976
|
-
</ol>
|
977
|
-
<dl>
|
978
|
-
<dt>foo</dt>
|
979
|
-
<dd>foo.</dd>
|
980
|
-
</dl>
|
981
|
-
<ul>
|
982
|
-
<li>bar</li>
|
983
|
-
</ul>
|
984
|
-
EOS
|
985
|
-
assert_equal expected, actual
|
986
|
-
end
|
987
|
-
|
988
|
-
def test_dt_inline
|
989
|
-
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
990
|
-
|
991
|
-
expected = <<-EOS
|
992
|
-
<div class="footnote" epub:type="footnote" id="fn-bar"><p class="footnote">[*1] bar</p></div>
|
993
|
-
<dl>
|
994
|
-
<dt>foo<a id="fnb-bar" href="#fn-bar" class="noteref" epub:type="noteref">*1</a>[]<>&<span class="equation">\\alpha[]</span></dt>
|
995
|
-
<dd></dd>
|
996
|
-
</dl>
|
997
|
-
EOS
|
998
|
-
assert_equal expected, actual
|
999
|
-
end
|
1000
|
-
|
1001
|
-
def test_list
|
1002
|
-
def @chapter.list(_id)
|
1003
|
-
Book::Index::Item.new('samplelist', 1)
|
1004
|
-
end
|
1005
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
1006
|
-
expected = <<-EOS
|
1007
|
-
<div id="samplelist" class="caption-code">
|
1008
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1009
|
-
<pre class="list">test1
|
1010
|
-
test1.5
|
1011
|
-
|
1012
|
-
test<i>2</i>
|
1013
|
-
</pre>
|
1014
|
-
</div>
|
1015
|
-
EOS
|
1016
|
-
assert_equal expected, actual
|
1017
|
-
|
1018
|
-
@config['caption_position']['list'] = 'bottom'
|
1019
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
1020
|
-
expected = <<-EOS
|
1021
|
-
<div id="samplelist" class="caption-code">
|
1022
|
-
<pre class="list">test1
|
1023
|
-
test1.5
|
1024
|
-
|
1025
|
-
test<i>2</i>
|
1026
|
-
</pre>
|
1027
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1028
|
-
</div>
|
1029
|
-
EOS
|
1030
|
-
assert_equal expected, actual
|
1031
|
-
end
|
1032
|
-
|
1033
|
-
def test_inline_list
|
1034
|
-
def @chapter.list(_id)
|
1035
|
-
Book::Index::Item.new('samplelist', 1)
|
1036
|
-
end
|
1037
|
-
actual = compile_block("@<list>{samplelist}\n")
|
1038
|
-
assert_equal %Q(<p><span class="listref"><a href="./-.html#samplelist">リスト1.1</a></span></p>\n), actual
|
1039
|
-
|
1040
|
-
@config['chapterlink'] = nil
|
1041
|
-
actual = compile_block("@<list>{samplelist}\n")
|
1042
|
-
assert_equal %Q(<p><span class="listref">リスト1.1</span></p>\n), actual
|
1043
|
-
end
|
1044
|
-
|
1045
|
-
def test_inline_list_href
|
1046
|
-
book = ReVIEW::Book::Base.new
|
1047
|
-
book.config['chapterlink'] = true
|
1048
|
-
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
1049
|
-
io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
|
1050
|
-
io2 = StringIO.new("= BAR\n")
|
1051
|
-
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
1052
|
-
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
1053
|
-
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
1054
|
-
builder = ReVIEW::HTMLBuilder.new
|
1055
|
-
comp = ReVIEW::Compiler.new(builder)
|
1056
|
-
builder.bind(comp, chap2, nil)
|
1057
|
-
|
1058
|
-
chap1.generate_indexes
|
1059
|
-
actual = builder.inline_list('ch1|sampletest')
|
1060
|
-
assert_equal %Q(<span class="listref"><a href="./ch1.html#sampletest">リスト1.1</a></span>), actual
|
1061
|
-
end
|
1062
|
-
|
1063
|
-
def test_list_pygments
|
1064
|
-
return true if @skip_pygments
|
1065
|
-
|
1066
|
-
def @chapter.list(_id)
|
1067
|
-
Book::Index::Item.new('samplelist', 1)
|
1068
|
-
end
|
1069
|
-
begin
|
1070
|
-
require 'pygments'
|
1071
|
-
rescue LoadError
|
1072
|
-
$stderr.puts 'skip test_list_pygments_lang (cannot find pygments.rb)'
|
1073
|
-
return true
|
1074
|
-
end
|
1075
|
-
@book.config['highlight'] = {}
|
1076
|
-
@book.config['highlight']['html'] = 'pygments'
|
1077
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
1078
|
-
|
1079
|
-
expected = <<-EOS
|
1080
|
-
<div id="samplelist" class="caption-code">
|
1081
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1082
|
-
<pre class="list highlight">test1
|
1083
|
-
test1.5
|
1084
|
-
|
1085
|
-
test<i>2</i>
|
1086
|
-
</pre>
|
1087
|
-
</div>
|
1088
|
-
EOS
|
1089
|
-
assert_equal expected, actual
|
1090
|
-
end
|
1091
|
-
|
1092
|
-
def test_list_pygments_lang
|
1093
|
-
return true if @skip_pygments
|
1094
|
-
|
1095
|
-
def @chapter.list(_id)
|
1096
|
-
Book::Index::Item.new('samplelist', 1)
|
1097
|
-
end
|
1098
|
-
begin
|
1099
|
-
require 'pygments'
|
1100
|
-
rescue LoadError
|
1101
|
-
$stderr.puts 'skip test_list_pygments_lang (cannot find pygments.rb)'
|
1102
|
-
return true
|
1103
|
-
end
|
1104
|
-
@book.config['highlight'] = {}
|
1105
|
-
@book.config['highlight']['html'] = 'pygments'
|
1106
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1107
|
-
|
1108
|
-
expected = <<-EOS
|
1109
|
-
<div id="samplelist" class="caption-code">
|
1110
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1111
|
-
<pre class="list language-ruby highlight"><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">foo</span>(a1, a2<span style="color: #666666">=</span><span style="color: #19177C">:test</span>)
|
1112
|
-
(<span style="color: #666666">1..3</span>)<span style="color: #666666">.</span>times{<span style="color: #666666">\|</span>i<span style="color: #666666">|</span> a<span style="color: #666666">.</span>include?(<span style="color: #19177C">:foo</span>)}
|
1113
|
-
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">true</span>
|
1114
|
-
<span style="color: #008000; font-weight: bold">end</span>
|
1115
|
-
</pre>
|
1116
|
-
</div>
|
1117
|
-
EOS
|
1118
|
-
|
1119
|
-
assert_equal expected, actual
|
1120
|
-
end
|
1121
|
-
|
1122
|
-
def test_list_pygments_nulllang
|
1123
|
-
return true if @skip_pygments
|
1124
|
-
|
1125
|
-
def @chapter.list(_id)
|
1126
|
-
Book::Index::Item.new('samplelist', 1)
|
1127
|
-
end
|
1128
|
-
begin
|
1129
|
-
require 'pygments'
|
1130
|
-
rescue LoadError
|
1131
|
-
$stderr.puts 'skip test_list_pygments_nulllang (cannot find pygments.rb)'
|
1132
|
-
return true
|
1133
|
-
end
|
1134
|
-
@book.config['highlight'] = {}
|
1135
|
-
@book.config['highlight']['html'] = 'pygments'
|
1136
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1137
|
-
|
1138
|
-
expected = <<-EOS
|
1139
|
-
<div id="samplelist" class="caption-code">
|
1140
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1141
|
-
<pre class="list highlight">def foo(a1, a2=:test)
|
1142
|
-
(1..3).times{|i| a.include?(:foo)}
|
1143
|
-
return true
|
1144
|
-
end
|
1145
|
-
</pre>
|
1146
|
-
</div>
|
1147
|
-
EOS
|
1148
|
-
assert_equal expected, actual
|
1149
|
-
end
|
1150
|
-
|
1151
|
-
def test_list_rouge
|
1152
|
-
begin
|
1153
|
-
require 'rouge'
|
1154
|
-
rescue LoadError
|
1155
|
-
$stderr.puts 'skip test_list_rouge (cannot find Rouge)'
|
1156
|
-
return true
|
1157
|
-
end
|
1158
|
-
def @chapter.list(_id)
|
1159
|
-
Book::Index::Item.new('samplelist', 1)
|
1160
|
-
end
|
1161
|
-
@book.config['highlight'] = {}
|
1162
|
-
@book.config['highlight']['html'] = 'rouge'
|
1163
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
1164
|
-
|
1165
|
-
expected = <<-EOS
|
1166
|
-
<div id="samplelist" class="caption-code">
|
1167
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1168
|
-
<pre class="list highlight">test1
|
1169
|
-
test1.5
|
1170
|
-
|
1171
|
-
test<i>2</i>
|
1172
|
-
</pre>
|
1173
|
-
</div>
|
1174
|
-
EOS
|
1175
|
-
assert_equal expected, actual
|
1176
|
-
end
|
1177
|
-
|
1178
|
-
def test_list_rouge_lang
|
1179
|
-
begin
|
1180
|
-
require 'rouge'
|
1181
|
-
rescue LoadError
|
1182
|
-
$stderr.puts 'skip test_list_rouge_lang (cannot find Rouge)'
|
1183
|
-
return true
|
1184
|
-
end
|
1185
|
-
def @chapter.list(_id)
|
1186
|
-
Book::Index::Item.new('samplelist', 1)
|
1187
|
-
end
|
1188
|
-
@book.config['highlight'] = {}
|
1189
|
-
@book.config['highlight']['html'] = 'rouge'
|
1190
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1191
|
-
|
1192
|
-
expected = <<-EOS
|
1193
|
-
<div id="samplelist" class="caption-code">
|
1194
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1195
|
-
<pre class="list language-ruby highlight"><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a2</span><span class="o">=</span><span class="ss">:test</span><span class="p">)</span>
|
1196
|
-
<span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">3</span><span class="p">).</span><span class="nf">times</span><span class="p">{</span><span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="n">a</span><span class="p">.</span><span class="nf">include?</span><span class="p">(</span><span class="ss">:foo</span><span class="p">)}</span>
|
1197
|
-
<span class="k">return</span> <span class="kp">true</span>
|
1198
|
-
<span class="k">end</span>
|
1199
|
-
|
1200
|
-
</pre>
|
1201
|
-
</div>
|
1202
|
-
EOS
|
1203
|
-
assert_equal expected, actual
|
1204
|
-
end
|
1205
|
-
|
1206
|
-
def test_list_rouge_nulllang
|
1207
|
-
begin
|
1208
|
-
require 'rouge'
|
1209
|
-
rescue LoadError
|
1210
|
-
$stderr.puts 'skip test_list_rouge_nulllang (cannot find Rouge)'
|
1211
|
-
return true
|
1212
|
-
end
|
1213
|
-
def @chapter.list(_id)
|
1214
|
-
Book::Index::Item.new('samplelist', 1)
|
1215
|
-
end
|
1216
|
-
@book.config['highlight'] = {}
|
1217
|
-
@book.config['highlight']['html'] = 'rouge'
|
1218
|
-
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1219
|
-
|
1220
|
-
expected = <<-EOS
|
1221
|
-
<div id="samplelist" class="caption-code">
|
1222
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1223
|
-
<pre class="list highlight">def foo(a1, a2=:test)
|
1224
|
-
(1..3).times{|i| a.include?(:foo)}
|
1225
|
-
return true
|
1226
|
-
end
|
1227
|
-
|
1228
|
-
</pre>
|
1229
|
-
</div>
|
1230
|
-
EOS
|
1231
|
-
assert_equal expected, actual
|
1232
|
-
end
|
1233
|
-
|
1234
|
-
def test_listnum
|
1235
|
-
def @chapter.list(_id)
|
1236
|
-
Book::Index::Item.new('samplelist', 1)
|
1237
|
-
end
|
1238
|
-
|
1239
|
-
@book.config['highlight'] = false
|
1240
|
-
actual = compile_block(<<-EOS)
|
1241
|
-
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
1242
|
-
def foo(a1, a2=:test)
|
1243
|
-
(1..3).times{|i| a.include?(:foo)}
|
1244
|
-
return true
|
1245
|
-
end
|
1246
|
-
//}
|
1247
|
-
EOS
|
1248
|
-
|
1249
|
-
expected = <<-EOS
|
1250
|
-
<div id="samplelist" class="code">
|
1251
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1252
|
-
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
|
1253
|
-
2: (1..3).times{|i| a.include?(:foo)}
|
1254
|
-
3: return true
|
1255
|
-
4: end
|
1256
|
-
</pre>
|
1257
|
-
</div>
|
1258
|
-
EOS
|
1259
|
-
|
1260
|
-
assert_equal expected, actual
|
1261
|
-
|
1262
|
-
@config['caption_position']['list'] = 'bottom'
|
1263
|
-
actual = compile_block(<<-EOS)
|
1264
|
-
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
1265
|
-
def foo(a1, a2=:test)
|
1266
|
-
(1..3).times{|i| a.include?(:foo)}
|
1267
|
-
return true
|
1268
|
-
end
|
1269
|
-
//}
|
1270
|
-
EOS
|
1271
|
-
|
1272
|
-
expected = <<-EOS
|
1273
|
-
<div id="samplelist" class="code">
|
1274
|
-
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
|
1275
|
-
2: (1..3).times{|i| a.include?(:foo)}
|
1276
|
-
3: return true
|
1277
|
-
4: end
|
1278
|
-
</pre>
|
1279
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1280
|
-
</div>
|
1281
|
-
EOS
|
1282
|
-
|
1283
|
-
assert_equal expected, actual
|
1284
|
-
end
|
1285
|
-
|
1286
|
-
def test_listnum_linenum
|
1287
|
-
def @chapter.list(_id)
|
1288
|
-
Book::Index::Item.new('samplelist', 1)
|
1289
|
-
end
|
1290
|
-
|
1291
|
-
@book.config['highlight'] = false
|
1292
|
-
actual = compile_block(<<-EOS)
|
1293
|
-
//firstlinenum[100]
|
1294
|
-
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
1295
|
-
def foo(a1, a2=:test)
|
1296
|
-
(1..3).times{|i| a.include?(:foo)}
|
1297
|
-
return true
|
1298
|
-
end
|
1299
|
-
//}
|
1300
|
-
EOS
|
1301
|
-
|
1302
|
-
expected = <<-EOS
|
1303
|
-
<div id="samplelist" class="code">
|
1304
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1305
|
-
<pre class="list language-ruby">100: def foo(a1, a2=:test)
|
1306
|
-
101: (1..3).times{|i| a.include?(:foo)}
|
1307
|
-
102: return true
|
1308
|
-
103: end
|
1309
|
-
</pre>
|
1310
|
-
</div>
|
1311
|
-
EOS
|
1312
|
-
|
1313
|
-
assert_equal expected, actual
|
1314
|
-
end
|
1315
|
-
|
1316
|
-
def test_listnum_pygments_lang
|
1317
|
-
return true if @skip_pygments
|
1318
|
-
|
1319
|
-
def @chapter.list(_id)
|
1320
|
-
Book::Index::Item.new('samplelist', 1)
|
1321
|
-
end
|
1322
|
-
begin
|
1323
|
-
require 'pygments'
|
1324
|
-
rescue LoadError
|
1325
|
-
$stderr.puts 'skip test_listnum_pygments_lang (cannot find pygments.rb)'
|
1326
|
-
return true
|
1327
|
-
end
|
1328
|
-
@book.config['highlight'] = {}
|
1329
|
-
@book.config['highlight']['html'] = 'pygments'
|
1330
|
-
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1331
|
-
|
1332
|
-
expected = <<-EOS
|
1333
|
-
<div id="samplelist" class="code">
|
1334
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1335
|
-
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">1 </span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">foo</span>(a1, a2<span style="color: #666666">=</span><span style="color: #19177C">:test</span>)
|
1336
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </span> (<span style="color: #666666">1..3</span>)<span style="color: #666666">.</span>times{<span style="color: #666666">|</span>i<span style="color: #666666">|</span> a<span style="color: #666666">.</span>include?(<span style="color: #19177C">:foo</span>)}
|
1337
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">3 </span> <span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">true</span>
|
1338
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">4 </span><span style="color: #008000; font-weight: bold">end</span>
|
1339
|
-
</pre></div>
|
1340
|
-
</div>
|
1341
|
-
EOS
|
1342
|
-
assert_equal expected, actual
|
1343
|
-
end
|
1344
|
-
|
1345
|
-
def test_listnum_pygments_lang_linenum
|
1346
|
-
return true if @skip_pygments
|
1347
|
-
|
1348
|
-
def @chapter.list(_id)
|
1349
|
-
Book::Index::Item.new('samplelist', 1)
|
1350
|
-
end
|
1351
|
-
begin
|
1352
|
-
require 'pygments'
|
1353
|
-
rescue LoadError
|
1354
|
-
$stderr.puts 'skip test_listnum_pygments_lang (cannot find pygments.rb)'
|
1355
|
-
return true
|
1356
|
-
end
|
1357
|
-
@book.config['highlight'] = {}
|
1358
|
-
@book.config['highlight']['html'] = 'pygments'
|
1359
|
-
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1360
|
-
|
1361
|
-
expected = <<-EOS
|
1362
|
-
<div id="samplelist" class="code">
|
1363
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1364
|
-
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">100 </span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">foo</span>(a1, a2<span style="color: #666666">=</span><span style="color: #19177C">:test</span>)
|
1365
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">101 </span> (<span style="color: #666666">1..3</span>)<span style="color: #666666">.</span>times{<span style="color: #666666">|</span>i<span style="color: #666666">|</span> a<span style="color: #666666">.</span>include?(<span style="color: #19177C">:foo</span>)}
|
1366
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">102 </span> <span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">true</span>
|
1367
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">103 </span><span style="color: #008000; font-weight: bold">end</span>
|
1368
|
-
</pre></div>
|
1369
|
-
</div>
|
1370
|
-
EOS
|
1371
|
-
|
1372
|
-
assert_equal expected, actual
|
1373
|
-
end
|
1374
|
-
|
1375
|
-
def test_listnum_pygments_lang_without_lang
|
1376
|
-
return true if @skip_pygments
|
1377
|
-
|
1378
|
-
def @chapter.list(_id)
|
1379
|
-
Book::Index::Item.new('samplelist', 1)
|
1380
|
-
end
|
1381
|
-
begin
|
1382
|
-
require 'pygments'
|
1383
|
-
rescue LoadError
|
1384
|
-
$stderr.puts 'skip test_listnum_pygments_lang (cannot find pygments.rb)'
|
1385
|
-
return true
|
1386
|
-
end
|
1387
|
-
@book.config['highlight'] = {}
|
1388
|
-
@book.config['highlight']['html'] = 'pygments'
|
1389
|
-
@book.config['highlight']['lang'] = 'ruby'
|
1390
|
-
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1391
|
-
|
1392
|
-
expected = <<-EOS
|
1393
|
-
<div id="samplelist" class="code">
|
1394
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1395
|
-
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">1 </span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">foo</span>(a1, a2<span style="color: #666666">=</span><span style="color: #19177C">:test</span>)
|
1396
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </span> (<span style="color: #666666">1..3</span>)<span style="color: #666666">.</span>times{<span style="color: #666666">|</span>i<span style="color: #666666">|</span> a<span style="color: #666666">.</span>include?(<span style="color: #19177C">:foo</span>)}
|
1397
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">3 </span> <span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">true</span>
|
1398
|
-
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">4 </span><span style="color: #008000; font-weight: bold">end</span>
|
1399
|
-
</pre></div>
|
1400
|
-
</div>
|
1401
|
-
EOS
|
1402
|
-
assert_equal expected, actual
|
1403
|
-
end
|
1404
|
-
|
1405
|
-
def test_listnum_rouge_lang
|
1406
|
-
begin
|
1407
|
-
require 'rouge'
|
1408
|
-
rescue LoadError
|
1409
|
-
$stderr.puts 'skip test_listnum_rouge_lang (cannot find Rouge)'
|
1410
|
-
return true
|
1411
|
-
end
|
1412
|
-
def @chapter.list(_id)
|
1413
|
-
Book::Index::Item.new('samplelist', 1)
|
1414
|
-
end
|
1415
|
-
@book.config['highlight'] = {}
|
1416
|
-
@book.config['highlight']['html'] = 'rouge'
|
1417
|
-
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1418
|
-
|
1419
|
-
expected = <<-EOS
|
1420
|
-
<div id="samplelist" class="code">
|
1421
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1422
|
-
<table class="highlight rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
|
1423
|
-
2
|
1424
|
-
3
|
1425
|
-
4
|
1426
|
-
5
|
1427
|
-
</pre></td><td class="rouge-code"><pre><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a2</span><span class="o">=</span><span class="ss">:test</span><span class="p">)</span>
|
1428
|
-
<span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">3</span><span class="p">).</span><span class="nf">times</span><span class="p">{</span><span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="n">a</span><span class="p">.</span><span class="nf">include?</span><span class="p">(</span><span class="ss">:foo</span><span class="p">)}</span>
|
1429
|
-
<span class="k">return</span> <span class="kp">true</span>
|
1430
|
-
<span class="k">end</span>
|
1431
|
-
|
1432
|
-
</pre></td></tr></tbody></table>
|
1433
|
-
</div>
|
1434
|
-
EOS
|
1435
|
-
|
1436
|
-
assert_equal expected, actual
|
1437
|
-
end
|
1438
|
-
|
1439
|
-
def test_listnum_rouge_lang_linenum
|
1440
|
-
begin
|
1441
|
-
require 'rouge'
|
1442
|
-
rescue LoadError
|
1443
|
-
$stderr.puts 'skip test_listnum_rouge_lang_linenum (cannot find Rouge)'
|
1444
|
-
return true
|
1445
|
-
end
|
1446
|
-
def @chapter.list(_id)
|
1447
|
-
Book::Index::Item.new('samplelist', 1)
|
1448
|
-
end
|
1449
|
-
@book.config['highlight'] = {}
|
1450
|
-
@book.config['highlight']['html'] = 'rouge'
|
1451
|
-
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
1452
|
-
|
1453
|
-
expected = <<-EOB
|
1454
|
-
<div id="samplelist" class="code">
|
1455
|
-
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1456
|
-
<table class="highlight rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">100
|
1457
|
-
101
|
1458
|
-
102
|
1459
|
-
103
|
1460
|
-
104
|
1461
|
-
</pre></td><td class="rouge-code"><pre><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a2</span><span class="o">=</span><span class="ss">:test</span><span class="p">)</span>
|
1462
|
-
<span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">3</span><span class="p">).</span><span class="nf">times</span><span class="p">{</span><span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="n">a</span><span class="p">.</span><span class="nf">include?</span><span class="p">(</span><span class="ss">:foo</span><span class="p">)}</span>
|
1463
|
-
<span class="k">return</span> <span class="kp">true</span>
|
1464
|
-
<span class="k">end</span>
|
1465
|
-
|
1466
|
-
</pre></td></tr></tbody></table>
|
1467
|
-
</div>
|
1468
|
-
EOB
|
1469
|
-
|
1470
|
-
assert_equal expected, actual
|
1471
|
-
end
|
1472
|
-
|
1473
|
-
def test_source
|
1474
|
-
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1475
|
-
expected = <<-EOS
|
1476
|
-
<div class="source-code">
|
1477
|
-
<p class="caption">foo/bar/test.rb</p>
|
1478
|
-
<pre class="source">foo
|
1479
|
-
bar
|
1480
|
-
|
1481
|
-
buz
|
1482
|
-
</pre>
|
1483
|
-
</div>
|
1484
|
-
EOS
|
1485
|
-
assert_equal expected, actual
|
1486
|
-
|
1487
|
-
@config['caption_position']['list'] = 'bottom'
|
1488
|
-
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1489
|
-
expected = <<-EOS
|
1490
|
-
<div class="source-code">
|
1491
|
-
<pre class="source">foo
|
1492
|
-
bar
|
1493
|
-
|
1494
|
-
buz
|
1495
|
-
</pre>
|
1496
|
-
<p class="caption">foo/bar/test.rb</p>
|
1497
|
-
</div>
|
1498
|
-
EOS
|
1499
|
-
assert_equal expected, actual
|
1500
|
-
end
|
1501
|
-
|
1502
|
-
def test_source_empty_caption
|
1503
|
-
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
1504
|
-
expected = <<-EOS
|
1505
|
-
<div class="source-code">
|
1506
|
-
<pre class="source">foo
|
1507
|
-
bar
|
1508
|
-
|
1509
|
-
buz
|
1510
|
-
</pre>
|
1511
|
-
</div>
|
1512
|
-
EOS
|
1513
|
-
assert_equal expected, actual
|
1514
|
-
end
|
1515
|
-
|
1516
|
-
def test_box
|
1517
|
-
actual = compile_block("//box{\nfoo\nbar\n//}\n")
|
1518
|
-
expected = <<-EOS
|
1519
|
-
<div class="syntax">
|
1520
|
-
<pre class="syntax">foo
|
1521
|
-
bar
|
1522
|
-
</pre>
|
1523
|
-
</div>
|
1524
|
-
EOS
|
1525
|
-
assert_equal expected, actual
|
1526
|
-
|
1527
|
-
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1528
|
-
expected = <<-EOS
|
1529
|
-
<div class="syntax">
|
1530
|
-
<p class="caption">FOO</p>
|
1531
|
-
<pre class="syntax">foo
|
1532
|
-
bar
|
1533
|
-
</pre>
|
1534
|
-
</div>
|
1535
|
-
EOS
|
1536
|
-
assert_equal expected, actual
|
1537
|
-
|
1538
|
-
@config['caption_position']['list'] = 'bottom'
|
1539
|
-
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1540
|
-
expected = <<-EOS
|
1541
|
-
<div class="syntax">
|
1542
|
-
<pre class="syntax">foo
|
1543
|
-
bar
|
1544
|
-
</pre>
|
1545
|
-
<p class="caption">FOO</p>
|
1546
|
-
</div>
|
1547
|
-
EOS
|
1548
|
-
assert_equal expected, actual
|
1549
|
-
end
|
1550
|
-
|
1551
|
-
def test_emlist
|
1552
|
-
actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
|
1553
|
-
expected = <<-EOS
|
1554
|
-
<div class="emlist-code">
|
1555
|
-
<pre class="emlist">lineA
|
1556
|
-
lineB
|
1557
|
-
</pre>
|
1558
|
-
</div>
|
1559
|
-
EOS
|
1560
|
-
assert_equal expected, actual
|
1561
|
-
end
|
1562
|
-
|
1563
|
-
def test_emlist_pygments_lang
|
1564
|
-
return true if @skip_pygments
|
1565
|
-
|
1566
|
-
begin
|
1567
|
-
require 'pygments'
|
1568
|
-
rescue LoadError
|
1569
|
-
$stderr.puts 'skip test_emlist_pygments_lang (cannot find pygments.rb)'
|
1570
|
-
return true
|
1571
|
-
end
|
1572
|
-
@book.config['highlight'] = {}
|
1573
|
-
@book.config['highlight']['html'] = 'pygments'
|
1574
|
-
actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
1575
|
-
expected = <<-EOS
|
1576
|
-
<div class="emlist-code">
|
1577
|
-
<pre class="emlist language-sql highlight"><span style="color: #008000; font-weight: bold">SELECT</span> <span style="color: #008000; font-weight: bold">COUNT</span>(<span style="color: #666666">*</span>) <span style="color: #008000; font-weight: bold">FROM</span> tests <span style="color: #008000; font-weight: bold">WHERE</span> tests.<span style="color: #008000; font-weight: bold">no</span> <span style="color: #666666">></span> <span style="color: #666666">10</span> <span style="color: #008000; font-weight: bold">AND</span> test.name <span style="color: #008000; font-weight: bold">LIKE</span> <span style="color: #BA2121">'ABC%'</span>
|
1578
|
-
</pre>
|
1579
|
-
</div>
|
1580
|
-
EOS
|
1581
|
-
assert_equal expected, actual
|
1582
|
-
end
|
1583
|
-
|
1584
|
-
def test_emlist_caption
|
1585
|
-
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
1586
|
-
expected = <<-EOS
|
1587
|
-
<div class="emlist-code">
|
1588
|
-
<p class="caption">cap1</p>
|
1589
|
-
<pre class="emlist">lineA
|
1590
|
-
lineB
|
1591
|
-
</pre>
|
1592
|
-
</div>
|
1593
|
-
EOS
|
1594
|
-
assert_equal expected, actual
|
1595
|
-
|
1596
|
-
@config['caption_position']['list'] = 'bottom'
|
1597
|
-
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
1598
|
-
expected = <<-EOS
|
1599
|
-
<div class="emlist-code">
|
1600
|
-
<pre class="emlist">lineA
|
1601
|
-
lineB
|
1602
|
-
</pre>
|
1603
|
-
<p class="caption">cap1</p>
|
1604
|
-
</div>
|
1605
|
-
EOS
|
1606
|
-
assert_equal expected, actual
|
1607
|
-
end
|
1608
|
-
|
1609
|
-
def test_emlist_with_tab
|
1610
|
-
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
1611
|
-
expected = <<-EOS
|
1612
|
-
<div class="emlist-code">
|
1613
|
-
<pre class="emlist"> lineA
|
1614
|
-
lineB
|
1615
|
-
lineC
|
1616
|
-
</pre>
|
1617
|
-
</div>
|
1618
|
-
EOS
|
1619
|
-
assert_equal expected, actual
|
1620
|
-
end
|
1621
|
-
|
1622
|
-
def test_emlistnum
|
1623
|
-
@book.config['highlight'] = false
|
1624
|
-
actual = compile_block("//emlistnum{\nlineA\nlineB\n//}\n")
|
1625
|
-
expected = <<-EOS
|
1626
|
-
<div class="emlistnum-code">
|
1627
|
-
<pre class="emlist"> 1: lineA
|
1628
|
-
2: lineB
|
1629
|
-
</pre>
|
1630
|
-
</div>
|
1631
|
-
EOS
|
1632
|
-
assert_equal expected, actual
|
1633
|
-
end
|
1634
|
-
|
1635
|
-
def test_emlistnum_lang
|
1636
|
-
@book.config['highlight'] = false
|
1637
|
-
actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
1638
|
-
expected = <<-EOS
|
1639
|
-
<div class="emlistnum-code">
|
1640
|
-
<p class="caption">cap</p>
|
1641
|
-
<pre class="emlist language-text"> 1: lineA
|
1642
|
-
2: lineB
|
1643
|
-
</pre>
|
1644
|
-
</div>
|
1645
|
-
EOS
|
1646
|
-
assert_equal expected, actual
|
1647
|
-
|
1648
|
-
@config['caption_position']['list'] = 'bottom'
|
1649
|
-
actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
1650
|
-
expected = <<-EOS
|
1651
|
-
<div class="emlistnum-code">
|
1652
|
-
<pre class="emlist language-text"> 1: lineA
|
1653
|
-
2: lineB
|
1654
|
-
</pre>
|
1655
|
-
<p class="caption">cap</p>
|
1656
|
-
</div>
|
1657
|
-
EOS
|
1658
|
-
assert_equal expected, actual
|
1659
|
-
end
|
1660
|
-
|
1661
|
-
def test_emlistnum_lang_linenum
|
1662
|
-
@book.config['highlight'] = false
|
1663
|
-
actual = compile_block("//firstlinenum[1000]\n//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
1664
|
-
expected = <<-EOS
|
1665
|
-
<div class="emlistnum-code">
|
1666
|
-
<p class="caption">cap</p>
|
1667
|
-
<pre class="emlist language-text">1000: lineA
|
1668
|
-
1001: lineB
|
1669
|
-
</pre>
|
1670
|
-
</div>
|
1671
|
-
EOS
|
1672
|
-
assert_equal expected, actual
|
1673
|
-
end
|
1674
|
-
|
1675
|
-
def test_emlist_with_4tab
|
1676
|
-
@config['tabwidth'] = 4
|
1677
|
-
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
1678
|
-
expected = <<-EOS
|
1679
|
-
<div class="emlist-code">
|
1680
|
-
<pre class="emlist"> lineA
|
1681
|
-
lineB
|
1682
|
-
lineC
|
1683
|
-
</pre>
|
1684
|
-
</div>
|
1685
|
-
EOS
|
1686
|
-
assert_equal expected, actual
|
1687
|
-
end
|
1688
|
-
|
1689
|
-
def test_cmd
|
1690
|
-
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
1691
|
-
expected = <<-EOS
|
1692
|
-
<div class="cmd-code">
|
1693
|
-
<pre class="cmd">lineA
|
1694
|
-
lineB
|
1695
|
-
</pre>
|
1696
|
-
</div>
|
1697
|
-
EOS
|
1698
|
-
assert_equal expected, actual
|
1699
|
-
end
|
1700
|
-
|
1701
|
-
def test_cmd_pygments
|
1702
|
-
return true if @skip_pygments
|
1703
|
-
|
1704
|
-
begin
|
1705
|
-
require 'pygments'
|
1706
|
-
rescue LoadError
|
1707
|
-
return true
|
1708
|
-
end
|
1709
|
-
@book.config['highlight'] = {}
|
1710
|
-
@book.config['highlight']['html'] = 'pygments'
|
1711
|
-
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
1712
|
-
expected = <<-EOS
|
1713
|
-
<div class="cmd-code">
|
1714
|
-
<pre class="cmd"><span style="color: #888888">lineA</span>
|
1715
|
-
<span style="color: #888888">lineB</span>
|
1716
|
-
</pre>
|
1717
|
-
</div>
|
1718
|
-
EOS
|
1719
|
-
assert_equal expected, actual
|
1720
|
-
end
|
1721
|
-
|
1722
|
-
def test_cmd_caption
|
1723
|
-
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1724
|
-
expected = <<-EOS
|
1725
|
-
<div class="cmd-code">
|
1726
|
-
<p class="caption">cap1</p>
|
1727
|
-
<pre class="cmd">lineA
|
1728
|
-
lineB
|
1729
|
-
</pre>
|
1730
|
-
</div>
|
1731
|
-
EOS
|
1732
|
-
assert_equal expected, actual
|
1733
|
-
|
1734
|
-
@config['caption_position']['list'] = 'bottom'
|
1735
|
-
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1736
|
-
expected = <<-EOS
|
1737
|
-
<div class="cmd-code">
|
1738
|
-
<pre class="cmd">lineA
|
1739
|
-
lineB
|
1740
|
-
</pre>
|
1741
|
-
<p class="caption">cap1</p>
|
1742
|
-
</div>
|
1743
|
-
EOS
|
1744
|
-
assert_equal expected, actual
|
1745
|
-
end
|
1746
|
-
|
1747
|
-
def test_texequation
|
1748
|
-
return true if /mswin|mingw|cygwin/.match?(RUBY_PLATFORM)
|
1749
|
-
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1750
|
-
|
1751
|
-
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1752
|
-
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P} q\n//}\n") do |dir, book, _files|
|
1753
|
-
@book = book
|
1754
|
-
@book.config = @config
|
1755
|
-
@config['math_format'] = 'imgmath'
|
1756
|
-
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1757
|
-
location = Location.new(nil, nil)
|
1758
|
-
img_math = ReVIEW::ImgMath.new(@config)
|
1759
|
-
@builder = HTMLBuilder.new(img_math: img_math)
|
1760
|
-
@builder.bind(@compiler, @chapter, location)
|
1761
|
-
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1762
|
-
expected = <<-EOB
|
1763
|
-
<div class=\"equation\">
|
1764
|
-
<img src=\"images/_review_math/_gen_XXX.png\" class=\"math_gen_84291054a12d278ea05694c20fbbc8e974ec66fc13be801c01dca764faeecccb\" alt="p \\land \\bm{P} q" />
|
1765
|
-
</div>
|
1766
|
-
EOB
|
1767
|
-
tmpio = $stderr
|
1768
|
-
$stderr = StringIO.new
|
1769
|
-
begin
|
1770
|
-
result = compile_block("//texequation{\np \\land \\bm{P} q\n//}\n")
|
1771
|
-
ensure
|
1772
|
-
$stderr = tmpio
|
1773
|
-
end
|
1774
|
-
actual = result.gsub(/_gen_[0-9a-f]+\.png/, '_gen_XXX.png')
|
1775
|
-
assert_equal expected, actual
|
1776
|
-
end
|
1777
|
-
end
|
1778
|
-
|
1779
|
-
def test_texequation_fail
|
1780
|
-
# Re:VIEW 3 never fail on defer mode. This test is only for Re:VIEW 2.
|
1781
|
-
return true if /mswin|mingw|cygwin/.match?(RUBY_PLATFORM)
|
1782
|
-
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1783
|
-
|
1784
|
-
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1785
|
-
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P}} q\n//}\n") do |dir, book, _files|
|
1786
|
-
@book = book
|
1787
|
-
@book.config = @config
|
1788
|
-
@config['review_version'] = 2
|
1789
|
-
@config['math_format'] = 'imgmath'
|
1790
|
-
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1791
|
-
location = Location.new(nil, nil)
|
1792
|
-
img_math = ReVIEW::ImgMath.new(@config)
|
1793
|
-
@builder = HTMLBuilder.new(img_math: img_math)
|
1794
|
-
@builder.bind(@compiler, @chapter, location)
|
1795
|
-
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1796
|
-
tmpio = $stderr
|
1797
|
-
$stderr = StringIO.new
|
1798
|
-
begin
|
1799
|
-
assert_raise(ReVIEW::ApplicationError) do
|
1800
|
-
_result = compile_block("//texequation{\np \\land \\bm{P}} q\n//}\n")
|
1801
|
-
end
|
1802
|
-
ensure
|
1803
|
-
$stderr = tmpio
|
1804
|
-
end
|
1805
|
-
end
|
1806
|
-
end
|
1807
|
-
|
1808
|
-
def test_bib
|
1809
|
-
def @chapter.bibpaper(_id)
|
1810
|
-
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1811
|
-
end
|
1812
|
-
|
1813
|
-
assert_equal %Q(<a href="bib.html#bib-samplebib">[1]</a>), compile_inline('@<bib>{samplebib}')
|
1814
|
-
end
|
1815
|
-
|
1816
|
-
def test_bib_noramlized
|
1817
|
-
def @chapter.bibpaper(_id)
|
1818
|
-
Book::Index::Item.new('sampleb=ib', 1, 'sample bib')
|
1819
|
-
end
|
1820
|
-
|
1821
|
-
assert_equal %Q(<a href="bib.html#bib-id_sample_3Dbib">[1]</a>), compile_inline('@<bib>{sample=bib}')
|
1822
|
-
end
|
1823
|
-
|
1824
|
-
def test_bib_htmlext
|
1825
|
-
def @chapter.bibpaper(_id)
|
1826
|
-
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1827
|
-
end
|
1828
|
-
|
1829
|
-
@config['htmlext'] = 'xhtml'
|
1830
|
-
assert_equal %Q(<a href="bib.xhtml#bib-samplebib">[1]</a>), compile_inline('@<bib>{samplebib}')
|
1831
|
-
end
|
1832
|
-
|
1833
|
-
def test_bibpaper
|
1834
|
-
def @chapter.bibpaper(_id)
|
1835
|
-
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1836
|
-
end
|
1837
|
-
|
1838
|
-
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1839
|
-
expected = <<-EOS
|
1840
|
-
<div class="bibpaper">
|
1841
|
-
<a id="bib-samplebib">[1]</a> sample bib <b>bold</b>
|
1842
|
-
<p>ab</p></div>
|
1843
|
-
EOS
|
1844
|
-
assert_equal expected, actual
|
1845
|
-
|
1846
|
-
@book.config['join_lines_by_lang'] = true
|
1847
|
-
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1848
|
-
expected = <<-EOS
|
1849
|
-
<div class="bibpaper">
|
1850
|
-
<a id="bib-samplebib">[1]</a> sample bib <b>bold</b>
|
1851
|
-
<p>a b</p></div>
|
1852
|
-
EOS
|
1853
|
-
assert_equal expected, actual
|
1854
|
-
end
|
1855
|
-
|
1856
|
-
def test_bibpaper_normalized
|
1857
|
-
def @chapter.bibpaper(_id)
|
1858
|
-
Book::Index::Item.new('sample=bib', 1, 'sample bib')
|
1859
|
-
end
|
1860
|
-
|
1861
|
-
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1862
|
-
expected = <<-EOS
|
1863
|
-
<div class="bibpaper">
|
1864
|
-
<a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>
|
1865
|
-
<p>ab</p></div>
|
1866
|
-
EOS
|
1867
|
-
assert_equal expected, actual
|
1868
|
-
|
1869
|
-
@book.config['join_lines_by_lang'] = true
|
1870
|
-
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1871
|
-
expected = <<-EOS
|
1872
|
-
<div class="bibpaper">
|
1873
|
-
<a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>
|
1874
|
-
<p>a b</p></div>
|
1875
|
-
EOS
|
1876
|
-
assert_equal expected, actual
|
1877
|
-
end
|
1878
|
-
|
1879
|
-
def test_bibpaper_with_anchor
|
1880
|
-
def @chapter.bibpaper(_id)
|
1881
|
-
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1882
|
-
end
|
1883
|
-
|
1884
|
-
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
1885
|
-
expected = <<-EOS
|
1886
|
-
<div class="bibpaper">
|
1887
|
-
<a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>
|
1888
|
-
<p>ab</p></div>
|
1889
|
-
EOS
|
1890
|
-
assert_equal expected, actual
|
1891
|
-
|
1892
|
-
@book.config['join_lines_by_lang'] = true
|
1893
|
-
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
1894
|
-
expected = <<-EOS
|
1895
|
-
<div class="bibpaper">
|
1896
|
-
<a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>
|
1897
|
-
<p>a b</p></div>
|
1898
|
-
EOS
|
1899
|
-
assert_equal expected, actual
|
1900
|
-
end
|
1901
|
-
|
1902
|
-
def column_helper(review)
|
1903
|
-
compile_block(review)
|
1904
|
-
end
|
1905
|
-
|
1906
|
-
def test_column_1
|
1907
|
-
review = <<-EOS
|
1908
|
-
===[column] prev column
|
1909
|
-
|
1910
|
-
inside prev column
|
1911
|
-
|
1912
|
-
===[column] test
|
1913
|
-
|
1914
|
-
inside column
|
1915
|
-
|
1916
|
-
===[/column]
|
1917
|
-
EOS
|
1918
|
-
expected = <<-EOS
|
1919
|
-
<div class="column">
|
1920
|
-
|
1921
|
-
<h3><a id="column-1"></a>prev column</h3>
|
1922
|
-
<p>inside prev column</p>
|
1923
|
-
</div>
|
1924
|
-
<div class="column">
|
1925
|
-
|
1926
|
-
<h3><a id="column-2"></a>test</h3>
|
1927
|
-
<p>inside column</p>
|
1928
|
-
</div>
|
1929
|
-
EOS
|
1930
|
-
assert_equal expected, column_helper(review)
|
1931
|
-
end
|
1932
|
-
|
1933
|
-
def test_column_2
|
1934
|
-
review = <<-EOS
|
1935
|
-
===[column] test
|
1936
|
-
|
1937
|
-
inside column
|
1938
|
-
|
1939
|
-
=== next level
|
1940
|
-
EOS
|
1941
|
-
expected = <<-EOS
|
1942
|
-
<div class="column">
|
1943
|
-
|
1944
|
-
<h3><a id="column-1"></a>test</h3>
|
1945
|
-
<p>inside column</p>
|
1946
|
-
</div>
|
1947
|
-
|
1948
|
-
<h3><a id="h1-0-1"></a>next level</h3>
|
1949
|
-
EOS
|
1950
|
-
|
1951
|
-
assert_equal expected, column_helper(review)
|
1952
|
-
end
|
1953
|
-
|
1954
|
-
def test_column_3
|
1955
|
-
review = <<-EOS
|
1956
|
-
===[column] test
|
1957
|
-
|
1958
|
-
inside column
|
1959
|
-
|
1960
|
-
===[/column_dummy]
|
1961
|
-
EOS
|
1962
|
-
assert_raise(ReVIEW::ApplicationError) do
|
1963
|
-
column_helper(review)
|
1964
|
-
end
|
1965
|
-
end
|
1966
|
-
|
1967
|
-
def test_column_ref
|
1968
|
-
review = <<-EOS
|
1969
|
-
===[column]{foo} test
|
1970
|
-
|
1971
|
-
inside column
|
1972
|
-
|
1973
|
-
=== next level
|
1974
|
-
|
1975
|
-
this is @<column>{foo}.
|
1976
|
-
EOS
|
1977
|
-
expected = <<-EOS
|
1978
|
-
<div class="column">
|
1979
|
-
|
1980
|
-
<h3 id="foo"><a id="column-1"></a>test</h3>
|
1981
|
-
<p>inside column</p>
|
1982
|
-
</div>
|
1983
|
-
|
1984
|
-
<h3><a id="h1-0-1"></a>next level</h3>
|
1985
|
-
<p>this is <a href="-.html#column-1" class="columnref">コラム「test」</a>.</p>
|
1986
|
-
EOS
|
1987
|
-
|
1988
|
-
assert_equal expected, column_helper(review)
|
1989
|
-
|
1990
|
-
@config['chapterlink'] = nil
|
1991
|
-
expected = <<-EOS
|
1992
|
-
<div class="column">
|
1993
|
-
|
1994
|
-
<h3 id="foo"><a id="column-1"></a>test</h3>
|
1995
|
-
<p>inside column</p>
|
1996
|
-
</div>
|
1997
|
-
|
1998
|
-
<h3><a id="h1-0-1"></a>next level</h3>
|
1999
|
-
<p>this is コラム「test」.</p>
|
2000
|
-
EOS
|
2001
|
-
|
2002
|
-
assert_equal expected, column_helper(review)
|
2003
|
-
end
|
2004
|
-
|
2005
|
-
def test_column_in_aother_chapter_ref
|
2006
|
-
def @chapter.column_index
|
2007
|
-
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
2008
|
-
idx = Book::ColumnIndex.new
|
2009
|
-
idx.add_item(item)
|
2010
|
-
idx
|
2011
|
-
end
|
2012
|
-
|
2013
|
-
actual = compile_inline('test @<column>{chap1|column} test2')
|
2014
|
-
expected = 'test <a href="-.html#column-1" class="columnref">コラム「column_cap」</a> test2'
|
2015
|
-
assert_equal expected, actual
|
2016
|
-
|
2017
|
-
@config['chapterlink'] = nil
|
2018
|
-
actual = compile_inline('test @<column>{chap1|column} test2')
|
2019
|
-
expected = 'test コラム「column_cap」 test2'
|
2020
|
-
assert_equal expected, actual
|
2021
|
-
end
|
2022
|
-
|
2023
|
-
def test_ul
|
2024
|
-
src = <<-EOS
|
2025
|
-
* AAA
|
2026
|
-
* BBB
|
2027
|
-
EOS
|
2028
|
-
expected = <<-EOS
|
2029
|
-
<ul>
|
2030
|
-
<li>AAA</li>
|
2031
|
-
<li>BBB</li>
|
2032
|
-
</ul>
|
2033
|
-
EOS
|
2034
|
-
actual = compile_block(src)
|
2035
|
-
assert_equal expected, actual
|
2036
|
-
end
|
2037
|
-
|
2038
|
-
def test_ul_cont
|
2039
|
-
src = <<-EOS
|
2040
|
-
* AAA
|
2041
|
-
-AA
|
2042
|
-
* BBB
|
2043
|
-
-BB
|
2044
|
-
EOS
|
2045
|
-
expected = <<-EOS
|
2046
|
-
<ul>
|
2047
|
-
<li>AAA-AA</li>
|
2048
|
-
<li>BBB-BB</li>
|
2049
|
-
</ul>
|
2050
|
-
EOS
|
2051
|
-
actual = compile_block(src)
|
2052
|
-
assert_equal expected, actual
|
2053
|
-
|
2054
|
-
@book.config['join_lines_by_lang'] = true
|
2055
|
-
expected = <<-EOS
|
2056
|
-
<ul>
|
2057
|
-
<li>AAA -AA</li>
|
2058
|
-
<li>BBB -BB</li>
|
2059
|
-
</ul>
|
2060
|
-
EOS
|
2061
|
-
actual = compile_block(src)
|
2062
|
-
assert_equal expected, actual
|
2063
|
-
end
|
2064
|
-
|
2065
|
-
def test_ul_nest1
|
2066
|
-
src = <<-EOS
|
2067
|
-
* AAA
|
2068
|
-
** AA
|
2069
|
-
EOS
|
2070
|
-
|
2071
|
-
expected = <<-EOS
|
2072
|
-
<ul>
|
2073
|
-
<li>AAA<ul>
|
2074
|
-
<li>AA</li>
|
2075
|
-
</ul>
|
2076
|
-
</li>
|
2077
|
-
</ul>
|
2078
|
-
EOS
|
2079
|
-
actual = compile_block(src)
|
2080
|
-
assert_equal expected, actual
|
2081
|
-
end
|
2082
|
-
|
2083
|
-
def test_ul_nest2
|
2084
|
-
src = <<-EOS
|
2085
|
-
* AAA
|
2086
|
-
** AA
|
2087
|
-
* BBB
|
2088
|
-
** BB
|
2089
|
-
EOS
|
2090
|
-
|
2091
|
-
expected = <<-EOS
|
2092
|
-
<ul>
|
2093
|
-
<li>AAA<ul>
|
2094
|
-
<li>AA</li>
|
2095
|
-
</ul>
|
2096
|
-
</li>
|
2097
|
-
<li>BBB<ul>
|
2098
|
-
<li>BB</li>
|
2099
|
-
</ul>
|
2100
|
-
</li>
|
2101
|
-
</ul>
|
2102
|
-
EOS
|
2103
|
-
actual = compile_block(src)
|
2104
|
-
assert_equal expected, actual
|
2105
|
-
end
|
2106
|
-
|
2107
|
-
def test_ul_nest3
|
2108
|
-
src = <<-EOS
|
2109
|
-
** AAA
|
2110
|
-
* AA
|
2111
|
-
EOS
|
2112
|
-
|
2113
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2114
|
-
assert_match(/too many \*\./, @log_io.string)
|
2115
|
-
end
|
2116
|
-
|
2117
|
-
def test_ul_nest4
|
2118
|
-
src = <<-EOS
|
2119
|
-
* A
|
2120
|
-
** AA
|
2121
|
-
*** AAA
|
2122
|
-
* B
|
2123
|
-
** BB
|
2124
|
-
EOS
|
2125
|
-
|
2126
|
-
expected = <<-EOS
|
2127
|
-
<ul>
|
2128
|
-
<li>A<ul>
|
2129
|
-
<li>AA<ul>
|
2130
|
-
<li>AAA</li>
|
2131
|
-
</ul>
|
2132
|
-
</li>
|
2133
|
-
</ul>
|
2134
|
-
</li>
|
2135
|
-
<li>B<ul>
|
2136
|
-
<li>BB</li>
|
2137
|
-
</ul>
|
2138
|
-
</li>
|
2139
|
-
</ul>
|
2140
|
-
EOS
|
2141
|
-
actual = compile_block(src)
|
2142
|
-
assert_equal expected, actual
|
2143
|
-
end
|
2144
|
-
|
2145
|
-
def test_ol
|
2146
|
-
src = <<-EOS
|
2147
|
-
3. AAA
|
2148
|
-
3. BBB
|
2149
|
-
EOS
|
2150
|
-
|
2151
|
-
expected = <<-EOS
|
2152
|
-
<ol>
|
2153
|
-
<li>AAA</li>
|
2154
|
-
<li>BBB</li>
|
2155
|
-
</ol>
|
2156
|
-
EOS
|
2157
|
-
actual = compile_block(src)
|
2158
|
-
assert_equal expected, actual
|
2159
|
-
end
|
2160
|
-
|
2161
|
-
def test_inline_raw0
|
2162
|
-
assert_equal 'normal', compile_inline('@<raw>{normal}')
|
2163
|
-
end
|
2164
|
-
|
2165
|
-
def test_inline_raw1
|
2166
|
-
assert_equal 'body', compile_inline('@<raw>{|html|body}')
|
2167
|
-
end
|
2168
|
-
|
2169
|
-
def test_inline_raw2
|
2170
|
-
assert_equal 'body', compile_inline('@<raw>{|html, latex|body}')
|
2171
|
-
end
|
2172
|
-
|
2173
|
-
def test_inline_raw3
|
2174
|
-
assert_equal '', compile_inline('@<raw>{|idgxml, latex|body}')
|
2175
|
-
end
|
2176
|
-
|
2177
|
-
def test_inline_raw4
|
2178
|
-
assert_equal '|html body', compile_inline('@<raw>{|html body}')
|
2179
|
-
end
|
2180
|
-
|
2181
|
-
def test_inline_raw5
|
2182
|
-
assert_equal "nor\nmal", compile_inline('@<raw>{|html|nor\\nmal}')
|
2183
|
-
end
|
2184
|
-
|
2185
|
-
def test_inline_embed0
|
2186
|
-
assert_equal 'normal', compile_inline('@<embed>{normal}')
|
2187
|
-
end
|
2188
|
-
|
2189
|
-
def test_inline_embed1
|
2190
|
-
assert_equal 'body', compile_inline('@<embed>{|html|body}')
|
2191
|
-
end
|
2192
|
-
|
2193
|
-
def test_inline_embed3
|
2194
|
-
assert_equal '', compile_inline('@<embed>{|idgxml, latex|body}')
|
2195
|
-
end
|
2196
|
-
|
2197
|
-
def test_inline_embed5
|
2198
|
-
assert_equal 'nor\\nmal', compile_inline('@<embed>{|html|nor\\nmal}')
|
2199
|
-
end
|
2200
|
-
|
2201
|
-
def test_inline_embed_math1
|
2202
|
-
assert_equal '\[ \frac{\partial f}{\partial x} =x^2+xy \]', compile_inline('@<embed>{\[ \frac{\partial f\}{\partial x\} =x^2+xy \]}')
|
2203
|
-
end
|
2204
|
-
|
2205
|
-
def test_inline_embed_math1a
|
2206
|
-
assert_equal '\[ \frac{\partial f}{\partial x} =x^2+xy \]', compile_inline('@<embed>{\\[ \\frac{\\partial f\}{\\partial x\} =x^2+xy \\]}')
|
2207
|
-
end
|
2208
|
-
|
2209
|
-
def test_inline_embed_math1b
|
2210
|
-
assert_equal '\[ \frac{\partial f}{\partial x} =x^2+xy \]', compile_inline('@<embed>{\\\\[ \\\\frac{\\\\partial f\}{\\\\partial x\} =x^2+xy \\\\]}')
|
2211
|
-
end
|
2212
|
-
|
2213
|
-
def test_inline_embed_math1c
|
2214
|
-
assert_equal '\\[ \\frac{}{} \\]',
|
2215
|
-
compile_inline('@<embed>{\[ \\frac{\}{\} \\]}')
|
2216
|
-
end
|
2217
|
-
|
2218
|
-
def test_inline_embed_n1
|
2219
|
-
assert_equal '\\n', compile_inline('@<embed>{\\n}')
|
2220
|
-
end
|
2221
|
-
|
2222
|
-
def test_inline_embed_n2
|
2223
|
-
assert_equal '\\n', compile_inline('@<embed>{\\\\n}')
|
2224
|
-
end
|
2225
|
-
|
2226
|
-
def test_inline_embed_brace_right0
|
2227
|
-
assert_equal '}', compile_inline('@<embed>{\\}}')
|
2228
|
-
end
|
2229
|
-
|
2230
|
-
def test_inline_embed_brace_right1
|
2231
|
-
assert_equal '\\}', compile_inline('@<embed>{\\\\}}')
|
2232
|
-
end
|
2233
|
-
|
2234
|
-
def test_inline_embed_brace_right2
|
2235
|
-
assert_equal '\\}', compile_inline('@<embed>{\\\\\\}}')
|
2236
|
-
end
|
2237
|
-
|
2238
|
-
def test_inline_embed_brace_right3
|
2239
|
-
assert_equal '\\\\}', compile_inline('@<embed>{\\\\\\\\}}')
|
2240
|
-
end
|
2241
|
-
|
2242
|
-
def test_block_raw0
|
2243
|
-
actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
|
2244
|
-
expected = %Q(<>!"\n& )
|
2245
|
-
assert_equal expected, actual
|
2246
|
-
end
|
2247
|
-
|
2248
|
-
def test_block_raw1
|
2249
|
-
actual = compile_block(%Q(//raw[|html|<>!"\\n& ]\n))
|
2250
|
-
expected = %Q(<>!"\n& )
|
2251
|
-
assert_equal expected, actual
|
2252
|
-
end
|
2253
|
-
|
2254
|
-
def test_block_raw2
|
2255
|
-
actual = compile_block(%Q(//raw[|html, latex|<>!"\\n& ]\n))
|
2256
|
-
expected = %Q(<>!"\n& )
|
2257
|
-
assert_equal expected, actual
|
2258
|
-
end
|
2259
|
-
|
2260
|
-
def test_block_raw3
|
2261
|
-
actual = compile_block(%Q(//raw[|latex, idgxml|<>!"\\n& ]\n))
|
2262
|
-
expected = ''
|
2263
|
-
assert_equal expected, actual
|
2264
|
-
end
|
2265
|
-
|
2266
|
-
def test_block_raw4
|
2267
|
-
actual = compile_block(%Q(//raw[|html <>!"\\n& ]\n))
|
2268
|
-
expected = %Q(|html <>!"\n& )
|
2269
|
-
assert_equal expected, actual
|
2270
|
-
end
|
2271
|
-
|
2272
|
-
def test_embed0
|
2273
|
-
lines = '//embed{' + "\n" +
|
2274
|
-
%Q( <>!"\\\\n& ) + "\n" +
|
2275
|
-
'//}' + "\n"
|
2276
|
-
actual = compile_block(lines)
|
2277
|
-
expected = %Q( <>!"\\\\n& ) + "\n"
|
2278
|
-
assert_equal expected, actual
|
2279
|
-
end
|
2280
|
-
|
2281
|
-
def test_embed1
|
2282
|
-
actual = compile_block("//embed[|html|]{\n" +
|
2283
|
-
%Q(<>!"\\\\n& \n) +
|
2284
|
-
"//}\n")
|
2285
|
-
expected = %Q(<>!"\\\\n& \n)
|
2286
|
-
assert_equal expected, actual
|
2287
|
-
end
|
2288
|
-
|
2289
|
-
def test_embed2
|
2290
|
-
actual = compile_block("//embed[html, latex]{\n" +
|
2291
|
-
%Q(<>!"\\\\n& \n) +
|
2292
|
-
"//}\n")
|
2293
|
-
expected = %Q(<>!"\\\\n& \n)
|
2294
|
-
assert_equal expected, actual
|
2295
|
-
end
|
2296
|
-
|
2297
|
-
def test_embed2a
|
2298
|
-
actual = compile_block("//embed[|html, latex|]{\n" +
|
2299
|
-
%Q(<>!"\\\\n& \n) +
|
2300
|
-
"//}\n")
|
2301
|
-
expected = %Q(<>!"\\\\n& \n)
|
2302
|
-
assert_equal expected, actual
|
2303
|
-
end
|
2304
|
-
|
2305
|
-
def test_embed2b
|
2306
|
-
actual = compile_block("//embed[html, latex]{\n" +
|
2307
|
-
'#@# comments are not ignored in //embed block' + "\n" +
|
2308
|
-
%Q(<>!"\\\\n& \n) +
|
2309
|
-
"//}\n")
|
2310
|
-
expected = '#@# comments are not ignored in //embed block' + "\n" + %Q(<>!"\\\\n& \n)
|
2311
|
-
assert_equal expected, actual
|
2312
|
-
end
|
2313
|
-
|
2314
|
-
def test_footnote
|
2315
|
-
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
2316
|
-
expected = <<-'EOS'
|
2317
|
-
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote">[*1] bar\a\$buz</p></div>
|
2318
|
-
EOS
|
2319
|
-
assert_equal expected, actual
|
2320
|
-
|
2321
|
-
@book.config['epubmaker'] ||= {}
|
2322
|
-
@book.config['epubmaker']['back_footnote'] = true
|
2323
|
-
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
2324
|
-
expected = <<-'EOS'
|
2325
|
-
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote"><a href="#fnb-foo">⏎</a>[*1] bar\a\$buz</p></div>
|
2326
|
-
EOS
|
2327
|
-
assert_equal expected, actual
|
2328
|
-
|
2329
|
-
I18n.set('html_footnote_textmark', '+%s:')
|
2330
|
-
I18n.set('html_footnote_backmark', '←')
|
2331
|
-
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
2332
|
-
expected = <<-'EOS'
|
2333
|
-
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote"><a href="#fnb-foo">←</a>+1:bar\a\$buz</p></div>
|
2334
|
-
EOS
|
2335
|
-
assert_equal expected, actual
|
2336
|
-
end
|
2337
|
-
|
2338
|
-
def test_footnote_with_tricky_id
|
2339
|
-
actual = compile_block("//footnote[123あ_;][bar\\a\\$buz]\n")
|
2340
|
-
expected = <<-'EOS'
|
2341
|
-
<div class="footnote" epub:type="footnote" id="fn-id_123_E3_81_82___3B"><p class="footnote">[*1] bar\a\$buz</p></div>
|
2342
|
-
EOS
|
2343
|
-
assert_equal expected, actual
|
2344
|
-
end
|
2345
|
-
|
2346
|
-
def test_inline_fn
|
2347
|
-
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2348
|
-
expected = <<-EOS
|
2349
|
-
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2350
|
-
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a></p>
|
2351
|
-
EOS
|
2352
|
-
assert_equal expected, fn
|
2353
|
-
I18n.set('html_footnote_refmark', '+%s')
|
2354
|
-
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2355
|
-
expected = <<-EOS
|
2356
|
-
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2357
|
-
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">+1</a></p>
|
2358
|
-
EOS
|
2359
|
-
assert_equal expected, fn
|
2360
|
-
end
|
2361
|
-
|
2362
|
-
def test_endnote
|
2363
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
2364
|
-
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
2365
|
-
|
2366
|
-
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
2367
|
-
expected = <<-'EOS'
|
2368
|
-
<p><a id="endnoteb-foo" href="#endnote-foo" class="noteref" epub:type="noteref">(1)</a></p>
|
2369
|
-
<div class="endnotes">
|
2370
|
-
<div class="endnote" id="endnote-foo"><p class="endnote">(1) bar</p></div>
|
2371
|
-
</div>
|
2372
|
-
EOS
|
2373
|
-
assert_equal expected, actual
|
2374
|
-
|
2375
|
-
@book.config['epubmaker'] ||= {}
|
2376
|
-
@book.config['epubmaker']['back_footnote'] = true
|
2377
|
-
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
2378
|
-
expected = <<-'EOS'
|
2379
|
-
<p><a id="endnoteb-foo" href="#endnote-foo" class="noteref" epub:type="noteref">(1)</a></p>
|
2380
|
-
<div class="endnotes">
|
2381
|
-
<div class="endnote" id="endnote-foo"><p class="endnote"><a href="#endnoteb-foo">⏎</a>(1) bar</p></div>
|
2382
|
-
</div>
|
2383
|
-
EOS
|
2384
|
-
assert_equal expected, actual
|
2385
|
-
|
2386
|
-
I18n.set('html_endnote_textmark', '+%s:')
|
2387
|
-
I18n.set('html_endnote_refmark', '+%s:')
|
2388
|
-
I18n.set('html_footnote_backmark', '←')
|
2389
|
-
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
2390
|
-
expected = <<-'EOS'
|
2391
|
-
<p><a id="endnoteb-foo" href="#endnote-foo" class="noteref" epub:type="noteref">+1:</a></p>
|
2392
|
-
<div class="endnotes">
|
2393
|
-
<div class="endnote" id="endnote-foo"><p class="endnote"><a href="#endnoteb-foo">←</a>+1:bar</p></div>
|
2394
|
-
</div>
|
2395
|
-
EOS
|
2396
|
-
assert_equal expected, actual
|
2397
|
-
end
|
2398
|
-
|
2399
|
-
def test_inline_hd
|
2400
|
-
book = ReVIEW::Book::Base.new
|
2401
|
-
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
2402
|
-
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
2403
|
-
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
2404
|
-
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
2405
|
-
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
2406
|
-
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
2407
|
-
builder = ReVIEW::HTMLBuilder.new
|
2408
|
-
comp = ReVIEW::Compiler.new(builder)
|
2409
|
-
builder.bind(comp, chap2, nil)
|
2410
|
-
|
2411
|
-
chap1.generate_indexes
|
2412
|
-
chap2.generate_indexes
|
2413
|
-
hd = builder.inline_hd('ch1|test1-1')
|
2414
|
-
assert_equal '<a href="ch1.html#h1-1">「1.1 test1-1」</a>', hd
|
2415
|
-
|
2416
|
-
builder.instance_eval { @book.config['chapterlink'] = nil }
|
2417
|
-
hd = builder.inline_hd('ch1|test1-1')
|
2418
|
-
assert_equal '「1.1 test1-1」', hd
|
2419
|
-
end
|
2420
|
-
|
2421
|
-
def test_inline_hd_for_part
|
2422
|
-
book = ReVIEW::Book::Base.new
|
2423
|
-
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
2424
|
-
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
2425
|
-
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
2426
|
-
io_p1 = StringIO.new("= part1\n\nfoo\n\n== part1-1\n\nbar\n\n== part1-2\n\nbar\n\n")
|
2427
|
-
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
2428
|
-
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
2429
|
-
book.parts = [ReVIEW::Book::Part.new(book, 1, [chap1, chap2], 'part1.re', io_p1)]
|
2430
|
-
builder = ReVIEW::HTMLBuilder.new
|
2431
|
-
comp = ReVIEW::Compiler.new(builder)
|
2432
|
-
builder.bind(comp, chap2, nil)
|
2433
|
-
book.generate_indexes
|
2434
|
-
|
2435
|
-
hd = builder.inline_hd('part1|part1-1')
|
2436
|
-
assert_equal '<a href="part1.html#h1-1">「1.1 part1-1」</a>', hd
|
2437
|
-
|
2438
|
-
builder.instance_eval { @book.config['chapterlink'] = nil }
|
2439
|
-
hd = builder.inline_hd('part1|part1-1')
|
2440
|
-
assert_equal '「1.1 part1-1」', hd
|
2441
|
-
end
|
2442
|
-
|
2443
|
-
def test_inline_hd_with_block
|
2444
|
-
io1 = StringIO.new("= test1\n=={foo} foo\n//emlist{\n======\nbar\n======\n}\n//}\n=={bar} bar")
|
2445
|
-
chap1 = Book::Chapter.new(@book, 1, '-', nil, io1)
|
2446
|
-
location = Location.new(nil, nil)
|
2447
|
-
@builder.bind(@compiler, chap1, location)
|
2448
|
-
hd = @builder.inline_hd('foo')
|
2449
|
-
assert_equal '<a href="-.html#h1-1">「1.1 foo」</a>', hd
|
2450
|
-
|
2451
|
-
@config['chapterlink'] = nil
|
2452
|
-
hd = @builder.inline_hd('foo')
|
2453
|
-
assert_equal '「1.1 foo」', hd
|
2454
|
-
|
2455
|
-
hd = @builder.inline_hd('bar')
|
2456
|
-
assert_equal '「1.2 bar」', hd
|
2457
|
-
end
|
2458
|
-
|
2459
|
-
def test_table
|
2460
|
-
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2461
|
-
expected = <<-EOS
|
2462
|
-
<div class="table">
|
2463
|
-
<table>
|
2464
|
-
<tr><th>aaa</th><th>bbb</th></tr>
|
2465
|
-
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2466
|
-
</table>
|
2467
|
-
</div>
|
2468
|
-
EOS
|
2469
|
-
assert_equal expected, actual
|
2470
|
-
|
2471
|
-
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2472
|
-
expected = <<-EOS
|
2473
|
-
<div id="foo" class="table">
|
2474
|
-
<p class="caption">表1.1: FOO</p>
|
2475
|
-
<table>
|
2476
|
-
<tr><th>aaa</th><th>bbb</th></tr>
|
2477
|
-
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2478
|
-
</table>
|
2479
|
-
</div>
|
2480
|
-
EOS
|
2481
|
-
assert_equal expected, actual
|
2482
|
-
|
2483
|
-
@config['caption_position']['table'] = 'bottom'
|
2484
|
-
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2485
|
-
expected = <<-EOS
|
2486
|
-
<div id="foo" class="table">
|
2487
|
-
<table>
|
2488
|
-
<tr><th>aaa</th><th>bbb</th></tr>
|
2489
|
-
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2490
|
-
</table>
|
2491
|
-
<p class="caption">表1.1: FOO</p>
|
2492
|
-
</div>
|
2493
|
-
EOS
|
2494
|
-
assert_equal expected, actual
|
2495
|
-
end
|
2496
|
-
|
2497
|
-
def test_empty_table
|
2498
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
2499
|
-
assert_equal 'no rows in the table', e.message
|
2500
|
-
|
2501
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
2502
|
-
assert_equal 'no rows in the table', e.message
|
2503
|
-
end
|
2504
|
-
|
2505
|
-
def test_inline_table
|
2506
|
-
def @chapter.table(_id)
|
2507
|
-
Book::Index::Item.new('sampletable', 1)
|
2508
|
-
end
|
2509
|
-
actual = compile_block("@<table>{sampletest}\n")
|
2510
|
-
assert_equal %Q(<p><span class="tableref"><a href="./-.html#sampletest">表1.1</a></span></p>\n), actual
|
2511
|
-
|
2512
|
-
@config['chapterlink'] = nil
|
2513
|
-
actual = compile_block("@<table>{sampletest}\n")
|
2514
|
-
assert_equal %Q(<p><span class="tableref">表1.1</span></p>\n), actual
|
2515
|
-
end
|
2516
|
-
|
2517
|
-
def test_emtable
|
2518
|
-
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2519
|
-
expected = <<-EOS
|
2520
|
-
<div class="table">
|
2521
|
-
<p class="caption">foo</p>
|
2522
|
-
<table>
|
2523
|
-
<tr><th>aaa</th><th>bbb</th></tr>
|
2524
|
-
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2525
|
-
</table>
|
2526
|
-
</div>
|
2527
|
-
<div class="table">
|
2528
|
-
<table>
|
2529
|
-
<tr><th>aaa</th><th>bbb</th></tr>
|
2530
|
-
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2531
|
-
</table>
|
2532
|
-
</div>
|
2533
|
-
EOS
|
2534
|
-
assert_equal expected, actual
|
2535
|
-
|
2536
|
-
@config['caption_position']['table'] = 'bottom'
|
2537
|
-
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2538
|
-
expected = <<-EOS
|
2539
|
-
<div class="table">
|
2540
|
-
<table>
|
2541
|
-
<tr><th>aaa</th><th>bbb</th></tr>
|
2542
|
-
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2543
|
-
</table>
|
2544
|
-
<p class="caption">foo</p>
|
2545
|
-
</div>
|
2546
|
-
<div class="table">
|
2547
|
-
<table>
|
2548
|
-
<tr><th>aaa</th><th>bbb</th></tr>
|
2549
|
-
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2550
|
-
</table>
|
2551
|
-
</div>
|
2552
|
-
EOS
|
2553
|
-
assert_equal expected, actual
|
2554
|
-
end
|
2555
|
-
|
2556
|
-
def test_imgtable
|
2557
|
-
def @chapter.image(_id)
|
2558
|
-
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
|
2559
|
-
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
2560
|
-
item
|
2561
|
-
end
|
2562
|
-
|
2563
|
-
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
2564
|
-
expected = <<-EOS
|
2565
|
-
<div id="sampleimg" class="imgtable image">
|
2566
|
-
<p class="caption">表1.1: test for imgtable</p>
|
2567
|
-
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2568
|
-
</div>
|
2569
|
-
EOS
|
2570
|
-
assert_equal expected, actual
|
2571
|
-
|
2572
|
-
@config['caption_position']['table'] = 'bottom'
|
2573
|
-
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
2574
|
-
expected = <<-EOS
|
2575
|
-
<div id="sampleimg" class="imgtable image">
|
2576
|
-
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2577
|
-
<p class="caption">表1.1: test for imgtable</p>
|
2578
|
-
</div>
|
2579
|
-
EOS
|
2580
|
-
assert_equal expected, actual
|
2581
|
-
end
|
2582
|
-
|
2583
|
-
def test_table_row_separator
|
2584
|
-
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
2585
|
-
expected = <<-EOS
|
2586
|
-
<div class="table">
|
2587
|
-
<table>
|
2588
|
-
<tr><th>1</th><th>2</th><th>3 4| 5</th></tr>
|
2589
|
-
<tr><td>a b</td><td>c d |e</td><td></td></tr>
|
2590
|
-
</table>
|
2591
|
-
</div>
|
2592
|
-
EOS
|
2593
|
-
actual = compile_block(src)
|
2594
|
-
assert_equal expected, actual
|
2595
|
-
|
2596
|
-
@config['table_row_separator'] = 'singletab'
|
2597
|
-
actual = compile_block(src)
|
2598
|
-
expected = <<-EOS
|
2599
|
-
<div class="table">
|
2600
|
-
<table>
|
2601
|
-
<tr><th>1</th><th>2</th><th></th><th>3 4| 5</th></tr>
|
2602
|
-
<tr><td>a b</td><td>c d |e</td><td></td><td></td></tr>
|
2603
|
-
</table>
|
2604
|
-
</div>
|
2605
|
-
EOS
|
2606
|
-
assert_equal expected, actual
|
2607
|
-
|
2608
|
-
@config['table_row_separator'] = 'spaces'
|
2609
|
-
actual = compile_block(src)
|
2610
|
-
expected = <<-EOS
|
2611
|
-
<div class="table">
|
2612
|
-
<table>
|
2613
|
-
<tr><th>1</th><th>2</th><th>3</th><th>4|</th><th>5</th></tr>
|
2614
|
-
<tr><td>a</td><td>b</td><td>c</td><td>d</td><td>|e</td></tr>
|
2615
|
-
</table>
|
2616
|
-
</div>
|
2617
|
-
EOS
|
2618
|
-
assert_equal expected, actual
|
2619
|
-
|
2620
|
-
@config['table_row_separator'] = 'verticalbar'
|
2621
|
-
actual = compile_block(src)
|
2622
|
-
expected = <<-EOS
|
2623
|
-
<div class="table">
|
2624
|
-
<table>
|
2625
|
-
<tr><th>1 2 3 4</th><th>5</th></tr>
|
2626
|
-
<tr><td>a b c d</td><td>e</td></tr>
|
2627
|
-
</table>
|
2628
|
-
</div>
|
2629
|
-
EOS
|
2630
|
-
assert_equal expected, actual
|
2631
|
-
end
|
2632
|
-
|
2633
|
-
def test_major_blocks
|
2634
|
-
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
2635
|
-
expected = <<-EOS
|
2636
|
-
<div class="note">
|
2637
|
-
<p>A</p>
|
2638
|
-
<p>B</p>
|
2639
|
-
</div>
|
2640
|
-
<div class="note">
|
2641
|
-
<p class="caption">caption</p>
|
2642
|
-
<p>A</p>
|
2643
|
-
</div>
|
2644
|
-
EOS
|
2645
|
-
assert_equal expected, actual
|
2646
|
-
|
2647
|
-
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
2648
|
-
expected = <<-EOS
|
2649
|
-
<div class="memo">
|
2650
|
-
<p>A</p>
|
2651
|
-
<p>B</p>
|
2652
|
-
</div>
|
2653
|
-
<div class="memo">
|
2654
|
-
<p class="caption">caption</p>
|
2655
|
-
<p>A</p>
|
2656
|
-
</div>
|
2657
|
-
EOS
|
2658
|
-
assert_equal expected, actual
|
2659
|
-
|
2660
|
-
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
2661
|
-
expected = <<-EOS
|
2662
|
-
<div class="info">
|
2663
|
-
<p>A</p>
|
2664
|
-
<p>B</p>
|
2665
|
-
</div>
|
2666
|
-
<div class="info">
|
2667
|
-
<p class="caption">caption</p>
|
2668
|
-
<p>A</p>
|
2669
|
-
</div>
|
2670
|
-
EOS
|
2671
|
-
assert_equal expected, actual
|
2672
|
-
|
2673
|
-
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
2674
|
-
expected = <<-EOS
|
2675
|
-
<div class="important">
|
2676
|
-
<p>A</p>
|
2677
|
-
<p>B</p>
|
2678
|
-
</div>
|
2679
|
-
<div class="important">
|
2680
|
-
<p class="caption">caption</p>
|
2681
|
-
<p>A</p>
|
2682
|
-
</div>
|
2683
|
-
EOS
|
2684
|
-
assert_equal expected, actual
|
2685
|
-
|
2686
|
-
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
2687
|
-
expected = <<-EOS
|
2688
|
-
<div class="caution">
|
2689
|
-
<p>A</p>
|
2690
|
-
<p>B</p>
|
2691
|
-
</div>
|
2692
|
-
<div class="caution">
|
2693
|
-
<p class="caption">caption</p>
|
2694
|
-
<p>A</p>
|
2695
|
-
</div>
|
2696
|
-
EOS
|
2697
|
-
assert_equal expected, actual
|
2698
|
-
|
2699
|
-
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
2700
|
-
expected = <<-EOS
|
2701
|
-
<div class="notice">
|
2702
|
-
<p>A</p>
|
2703
|
-
<p>B</p>
|
2704
|
-
</div>
|
2705
|
-
<div class="notice">
|
2706
|
-
<p class="caption">caption</p>
|
2707
|
-
<p>A</p>
|
2708
|
-
</div>
|
2709
|
-
EOS
|
2710
|
-
assert_equal expected, actual
|
2711
|
-
|
2712
|
-
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
2713
|
-
expected = <<-EOS
|
2714
|
-
<div class="warning">
|
2715
|
-
<p>A</p>
|
2716
|
-
<p>B</p>
|
2717
|
-
</div>
|
2718
|
-
<div class="warning">
|
2719
|
-
<p class="caption">caption</p>
|
2720
|
-
<p>A</p>
|
2721
|
-
</div>
|
2722
|
-
EOS
|
2723
|
-
assert_equal expected, actual
|
2724
|
-
|
2725
|
-
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
2726
|
-
expected = <<-EOS
|
2727
|
-
<div class="tip">
|
2728
|
-
<p>A</p>
|
2729
|
-
<p>B</p>
|
2730
|
-
</div>
|
2731
|
-
<div class="tip">
|
2732
|
-
<p class="caption">caption</p>
|
2733
|
-
<p>A</p>
|
2734
|
-
</div>
|
2735
|
-
EOS
|
2736
|
-
assert_equal expected, actual
|
2737
|
-
end
|
2738
|
-
|
2739
|
-
def test_minicolumn_blocks
|
2740
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
2741
|
-
src = <<-EOS
|
2742
|
-
//#{type}[#{type}1]{
|
2743
|
-
|
2744
|
-
//}
|
2745
|
-
|
2746
|
-
//#{type}[#{type}2]{
|
2747
|
-
//}
|
2748
|
-
EOS
|
2749
|
-
|
2750
|
-
expected = <<-EOS
|
2751
|
-
<div class="#{type}">
|
2752
|
-
<p class="caption">#{type}1</p>
|
2753
|
-
</div>
|
2754
|
-
<div class="#{type}">
|
2755
|
-
<p class="caption">#{type}2</p>
|
2756
|
-
</div>
|
2757
|
-
EOS
|
2758
|
-
assert_equal expected, compile_block(src)
|
2759
|
-
|
2760
|
-
src = <<-EOS
|
2761
|
-
//#{type}[#{type}2]{
|
2762
|
-
|
2763
|
-
//}
|
2764
|
-
|
2765
|
-
//#{type}[#{type}3]{
|
2766
|
-
|
2767
|
-
//}
|
2768
|
-
|
2769
|
-
//#{type}[#{type}4]{
|
2770
|
-
|
2771
|
-
//}
|
2772
|
-
|
2773
|
-
//#{type}[#{type}5]{
|
2774
|
-
|
2775
|
-
//}
|
2776
|
-
|
2777
|
-
//#{type}[#{type}6]{
|
2778
|
-
|
2779
|
-
//}
|
2780
|
-
EOS
|
2781
|
-
|
2782
|
-
expected = <<-EOS
|
2783
|
-
<div class="#{type}">
|
2784
|
-
<p class="caption">#{type}2</p>
|
2785
|
-
</div>
|
2786
|
-
<div class="#{type}">
|
2787
|
-
<p class="caption">#{type}3</p>
|
2788
|
-
</div>
|
2789
|
-
<div class="#{type}">
|
2790
|
-
<p class="caption">#{type}4</p>
|
2791
|
-
</div>
|
2792
|
-
<div class="#{type}">
|
2793
|
-
<p class="caption">#{type}5</p>
|
2794
|
-
</div>
|
2795
|
-
<div class="#{type}">
|
2796
|
-
<p class="caption">#{type}6</p>
|
2797
|
-
</div>
|
2798
|
-
EOS
|
2799
|
-
assert_equal expected, compile_block(src)
|
2800
|
-
|
2801
|
-
src = <<-EOS
|
2802
|
-
//#{type}{
|
2803
|
-
|
2804
|
-
* A
|
2805
|
-
|
2806
|
-
1. B
|
2807
|
-
|
2808
|
-
//}
|
2809
|
-
|
2810
|
-
//#{type}[OMITEND1]{
|
2811
|
-
|
2812
|
-
//emlist{
|
2813
|
-
LIST
|
2814
|
-
//}
|
2815
|
-
|
2816
|
-
//}
|
2817
|
-
|
2818
|
-
//#{type}[OMITEND2]{
|
2819
|
-
//}
|
2820
|
-
EOS
|
2821
|
-
|
2822
|
-
expected = <<-EOS
|
2823
|
-
<div class="#{type}">
|
2824
|
-
<ul>
|
2825
|
-
<li>A</li>
|
2826
|
-
</ul>
|
2827
|
-
<ol>
|
2828
|
-
<li>B</li>
|
2829
|
-
</ol>
|
2830
|
-
</div>
|
2831
|
-
<div class="#{type}">
|
2832
|
-
<p class="caption">OMITEND1</p>
|
2833
|
-
<div class="emlist-code">
|
2834
|
-
<pre class="emlist">LIST
|
2835
|
-
</pre>
|
2836
|
-
</div>
|
2837
|
-
</div>
|
2838
|
-
<div class="#{type}">
|
2839
|
-
<p class="caption">OMITEND2</p>
|
2840
|
-
</div>
|
2841
|
-
EOS
|
2842
|
-
assert_equal expected, compile_block(src)
|
2843
|
-
end
|
2844
|
-
end
|
2845
|
-
|
2846
|
-
def test_minicolumn_blocks_nest_error1
|
2847
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
2848
|
-
@builder.doc_status.clear
|
2849
|
-
src = <<-EOS
|
2850
|
-
//#{type}{
|
2851
|
-
|
2852
|
-
//#{type}{
|
2853
|
-
//}
|
2854
|
-
|
2855
|
-
//}
|
2856
|
-
EOS
|
2857
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2858
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2859
|
-
end
|
2860
|
-
end
|
2861
|
-
|
2862
|
-
def test_minicolumn_blocks_nest_error2
|
2863
|
-
%w[note memo tip info warning important caution notice].each do |type|
|
2864
|
-
@builder.doc_status.clear
|
2865
|
-
src = <<-EOS
|
2866
|
-
//#{type}{
|
2867
|
-
|
2868
|
-
//#{type}{
|
2869
|
-
|
2870
|
-
//}
|
2871
|
-
|
2872
|
-
//}
|
2873
|
-
EOS
|
2874
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2875
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2876
|
-
end
|
2877
|
-
end
|
2878
|
-
|
2879
|
-
def test_minicolumn_blocks_nest_error3
|
2880
|
-
%w[memo tip info warning important caution notice].each do |type|
|
2881
|
-
@builder.doc_status.clear
|
2882
|
-
src = <<-EOS
|
2883
|
-
//#{type}{
|
2884
|
-
|
2885
|
-
//note{
|
2886
|
-
|
2887
|
-
//}
|
2888
|
-
|
2889
|
-
//}
|
2890
|
-
EOS
|
2891
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2892
|
-
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2893
|
-
end
|
2894
|
-
end
|
2895
|
-
|
2896
|
-
def test_comment
|
2897
|
-
actual = compile_block('//comment[コメント]')
|
2898
|
-
assert_equal '', actual
|
2899
|
-
end
|
2900
|
-
|
2901
|
-
def test_comment_for_draft
|
2902
|
-
@config['draft'] = true
|
2903
|
-
actual = compile_block('//comment[コメント<]')
|
2904
|
-
assert_equal %Q(<div class="draft-comment">コメント<</div>\n), actual
|
2905
|
-
actual = compile_block("//comment{\nA<>\nB&\n//}")
|
2906
|
-
assert_equal %Q(<div class="draft-comment">A<><br />B&</div>\n), actual
|
2907
|
-
end
|
2908
|
-
|
2909
|
-
def test_inline_comment
|
2910
|
-
actual = compile_inline('test @<comment>{コメント} test2')
|
2911
|
-
assert_equal 'test test2', actual
|
2912
|
-
end
|
2913
|
-
|
2914
|
-
def test_inline_comment_for_draft
|
2915
|
-
@config['draft'] = true
|
2916
|
-
actual = compile_inline('test @<comment>{コメント} test2')
|
2917
|
-
assert_equal %Q(test <span class="draft-comment">コメント</span> test2), actual
|
2918
|
-
end
|
2919
|
-
|
2920
|
-
def test_inline_fence
|
2921
|
-
actual = compile_inline('test @<code>|@<code>{$サンプル$}|')
|
2922
|
-
assert_equal 'test <code class="inline-code tt">@<code>{$サンプル$}</code>', actual
|
2923
|
-
end
|
2924
|
-
|
2925
|
-
def test_inline_w
|
2926
|
-
Dir.mktmpdir do |dir|
|
2927
|
-
File.write(File.join(dir, 'words.csv'), <<EOB
|
2928
|
-
"F","foo"
|
2929
|
-
"B","bar""\\<>_@<b>{BAZ}"
|
2930
|
-
EOB
|
2931
|
-
)
|
2932
|
-
@book.config['words_file'] = File.join(dir, 'words.csv')
|
2933
|
-
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
2934
|
-
assert_equal %Q(<p>foo bar"\\<>_@<b>{BAZ} <b>bar"\\<>_@<b>{BAZ}</b> [missing word: N]</p>\n), actual
|
2935
|
-
assert_match(/WARN --: :1: word not bound: N/, @log_io.string)
|
2936
|
-
end
|
2937
|
-
end
|
2938
|
-
|
2939
|
-
def test_inline_unknown
|
2940
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
2941
|
-
assert_match(/unknown image: n/, @log_io.string)
|
2942
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
2943
|
-
assert_match(/unknown footnote: n/, @log_io.string)
|
2944
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<endnote>{n}\n") }
|
2945
|
-
assert_match(/unknown endnote: n/, @log_io.string)
|
2946
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
2947
|
-
assert_match(/unknown headline: n/, @log_io.string)
|
2948
|
-
%w[list table column].each do |name|
|
2949
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2950
|
-
assert_match(/unknown #{name}: n/, @log_io.string)
|
2951
|
-
end
|
2952
|
-
%w[chap chapref title].each do |name|
|
2953
|
-
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2954
|
-
assert_match(/key not found: "n"/, @log_io.string)
|
2955
|
-
end
|
2956
|
-
end
|
2957
|
-
|
2958
|
-
def test_texequation_plain
|
2959
|
-
src = <<-EOS
|
2960
|
-
//texequation{
|
2961
|
-
e=mc^2
|
2962
|
-
//}
|
2963
|
-
EOS
|
2964
|
-
expected = <<-EOS
|
2965
|
-
<div class="equation">
|
2966
|
-
<pre>e=mc^2
|
2967
|
-
</pre>
|
2968
|
-
</div>
|
2969
|
-
EOS
|
2970
|
-
actual = compile_block(src)
|
2971
|
-
assert_equal expected, actual
|
2972
|
-
end
|
2973
|
-
|
2974
|
-
def test_texequation_with_caption
|
2975
|
-
src = <<-EOS
|
2976
|
-
@<eq>{emc2}
|
2977
|
-
|
2978
|
-
//texequation[emc2][The Equivalence of Mass @<i>{and} Energy]{
|
2979
|
-
e=mc^2
|
2980
|
-
//}
|
2981
|
-
EOS
|
2982
|
-
expected = <<-EOS
|
2983
|
-
<p><span class="eqref"><a href="./-.html#emc2">式1.1</a></span></p>
|
2984
|
-
<div id="emc2" class="caption-equation">
|
2985
|
-
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2986
|
-
<div class="equation">
|
2987
|
-
<pre>e=mc^2
|
2988
|
-
</pre>
|
2989
|
-
</div>
|
2990
|
-
</div>
|
2991
|
-
EOS
|
2992
|
-
actual = compile_block(src)
|
2993
|
-
assert_equal expected, actual
|
2994
|
-
|
2995
|
-
@config['chapterlink'] = nil
|
2996
|
-
expected = <<-EOS
|
2997
|
-
<p><span class="eqref">式1.1</span></p>
|
2998
|
-
<div id="emc2" class="caption-equation">
|
2999
|
-
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
3000
|
-
<div class="equation">
|
3001
|
-
<pre>e=mc^2
|
3002
|
-
</pre>
|
3003
|
-
</div>
|
3004
|
-
</div>
|
3005
|
-
EOS
|
3006
|
-
actual = compile_block(src)
|
3007
|
-
assert_equal expected, actual
|
3008
|
-
|
3009
|
-
@config['caption_position']['equation'] = 'bottom'
|
3010
|
-
expected = <<-EOS
|
3011
|
-
<p><span class="eqref">式1.1</span></p>
|
3012
|
-
<div id="emc2" class="caption-equation">
|
3013
|
-
<div class="equation">
|
3014
|
-
<pre>e=mc^2
|
3015
|
-
</pre>
|
3016
|
-
</div>
|
3017
|
-
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
3018
|
-
</div>
|
3019
|
-
EOS
|
3020
|
-
actual = compile_block(src)
|
3021
|
-
assert_equal expected, actual
|
3022
|
-
end
|
3023
|
-
|
3024
|
-
def test_nest_error_close1
|
3025
|
-
src = <<-EOS
|
3026
|
-
//beginchild
|
3027
|
-
EOS
|
3028
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
3029
|
-
assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
3030
|
-
end
|
3031
|
-
|
3032
|
-
def test_nest_error_close2
|
3033
|
-
src = <<-EOS
|
3034
|
-
* foo
|
3035
|
-
|
3036
|
-
//beginchild
|
3037
|
-
|
3038
|
-
1. foo
|
3039
|
-
|
3040
|
-
//beginchild
|
3041
|
-
|
3042
|
-
: foo
|
3043
|
-
|
3044
|
-
//beginchild
|
3045
|
-
EOS
|
3046
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
3047
|
-
assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
|
3048
|
-
end
|
3049
|
-
|
3050
|
-
def test_nest_error_close3
|
3051
|
-
src = <<-EOS
|
3052
|
-
* foo
|
3053
|
-
|
3054
|
-
//beginchild
|
3055
|
-
|
3056
|
-
1. foo
|
3057
|
-
|
3058
|
-
//beginchild
|
3059
|
-
|
3060
|
-
: foo
|
3061
|
-
|
3062
|
-
//beginchild
|
3063
|
-
|
3064
|
-
//endchild
|
3065
|
-
EOS
|
3066
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
3067
|
-
assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
|
3068
|
-
end
|
3069
|
-
|
3070
|
-
def test_nest_ul
|
3071
|
-
src = <<-EOS
|
3072
|
-
* UL1
|
3073
|
-
|
3074
|
-
//beginchild
|
3075
|
-
|
3076
|
-
1. UL1-OL1
|
3077
|
-
2. UL1-OL2
|
3078
|
-
|
3079
|
-
* UL1-UL1
|
3080
|
-
* UL1-UL2
|
3081
|
-
|
3082
|
-
: UL1-DL1
|
3083
|
-
UL1-DD1
|
3084
|
-
: UL1-DL2
|
3085
|
-
UL1-DD2
|
3086
|
-
|
3087
|
-
//endchild
|
3088
|
-
|
3089
|
-
* UL2
|
3090
|
-
|
3091
|
-
//beginchild
|
3092
|
-
|
3093
|
-
UL2-PARA
|
3094
|
-
|
3095
|
-
//endchild
|
3096
|
-
EOS
|
3097
|
-
|
3098
|
-
expected = <<-EOS
|
3099
|
-
<ul>
|
3100
|
-
<li>UL1
|
3101
|
-
<ol>
|
3102
|
-
<li>UL1-OL1</li>
|
3103
|
-
<li>UL1-OL2</li>
|
3104
|
-
</ol>
|
3105
|
-
<ul>
|
3106
|
-
<li>UL1-UL1</li>
|
3107
|
-
<li>UL1-UL2</li>
|
3108
|
-
</ul>
|
3109
|
-
<dl>
|
3110
|
-
<dt>UL1-DL1</dt>
|
3111
|
-
<dd>UL1-DD1</dd>
|
3112
|
-
<dt>UL1-DL2</dt>
|
3113
|
-
<dd>UL1-DD2</dd>
|
3114
|
-
</dl>
|
3115
|
-
</li>
|
3116
|
-
|
3117
|
-
<li>UL2
|
3118
|
-
<p>UL2-PARA</p>
|
3119
|
-
</li>
|
3120
|
-
</ul>
|
3121
|
-
EOS
|
3122
|
-
|
3123
|
-
actual = compile_block(src)
|
3124
|
-
assert_equal expected, actual
|
3125
|
-
end
|
3126
|
-
|
3127
|
-
def test_nest_ol
|
3128
|
-
src = <<-EOS
|
3129
|
-
1. OL1
|
3130
|
-
|
3131
|
-
//beginchild
|
3132
|
-
|
3133
|
-
1. OL1-OL1
|
3134
|
-
2. OL1-OL2
|
3135
|
-
|
3136
|
-
* OL1-UL1
|
3137
|
-
* OL1-UL2
|
3138
|
-
|
3139
|
-
: OL1-DL1
|
3140
|
-
OL1-DD1
|
3141
|
-
: OL1-DL2
|
3142
|
-
OL1-DD2
|
3143
|
-
|
3144
|
-
//endchild
|
3145
|
-
|
3146
|
-
2. OL2
|
3147
|
-
|
3148
|
-
//beginchild
|
3149
|
-
|
3150
|
-
OL2-PARA
|
3151
|
-
|
3152
|
-
//endchild
|
3153
|
-
EOS
|
3154
|
-
|
3155
|
-
expected = <<-EOS
|
3156
|
-
<ol>
|
3157
|
-
<li>OL1
|
3158
|
-
<ol>
|
3159
|
-
<li>OL1-OL1</li>
|
3160
|
-
<li>OL1-OL2</li>
|
3161
|
-
</ol>
|
3162
|
-
<ul>
|
3163
|
-
<li>OL1-UL1</li>
|
3164
|
-
<li>OL1-UL2</li>
|
3165
|
-
</ul>
|
3166
|
-
<dl>
|
3167
|
-
<dt>OL1-DL1</dt>
|
3168
|
-
<dd>OL1-DD1</dd>
|
3169
|
-
<dt>OL1-DL2</dt>
|
3170
|
-
<dd>OL1-DD2</dd>
|
3171
|
-
</dl>
|
3172
|
-
</li>
|
3173
|
-
|
3174
|
-
<li>OL2
|
3175
|
-
<p>OL2-PARA</p>
|
3176
|
-
</li>
|
3177
|
-
</ol>
|
3178
|
-
EOS
|
3179
|
-
|
3180
|
-
actual = compile_block(src)
|
3181
|
-
assert_equal expected, actual
|
3182
|
-
end
|
3183
|
-
|
3184
|
-
def test_nest_dl
|
3185
|
-
src = <<-EOS
|
3186
|
-
: DL1
|
3187
|
-
|
3188
|
-
//beginchild
|
3189
|
-
|
3190
|
-
1. DL1-OL1
|
3191
|
-
2. DL1-OL2
|
3192
|
-
|
3193
|
-
* DL1-UL1
|
3194
|
-
* DL1-UL2
|
3195
|
-
|
3196
|
-
: DL1-DL1
|
3197
|
-
DL1-DD1
|
3198
|
-
: DL1-DL2
|
3199
|
-
DL1-DD2
|
3200
|
-
|
3201
|
-
//endchild
|
3202
|
-
|
3203
|
-
: DL2
|
3204
|
-
DD2
|
3205
|
-
|
3206
|
-
//beginchild
|
3207
|
-
|
3208
|
-
* DD2-UL1
|
3209
|
-
* DD2-UL2
|
3210
|
-
|
3211
|
-
DD2-PARA
|
3212
|
-
|
3213
|
-
//endchild
|
3214
|
-
EOS
|
3215
|
-
|
3216
|
-
expected = <<-EOS
|
3217
|
-
<dl>
|
3218
|
-
<dt>DL1</dt>
|
3219
|
-
<dd>
|
3220
|
-
<ol>
|
3221
|
-
<li>DL1-OL1</li>
|
3222
|
-
<li>DL1-OL2</li>
|
3223
|
-
</ol>
|
3224
|
-
<ul>
|
3225
|
-
<li>DL1-UL1</li>
|
3226
|
-
<li>DL1-UL2</li>
|
3227
|
-
</ul>
|
3228
|
-
<dl>
|
3229
|
-
<dt>DL1-DL1</dt>
|
3230
|
-
<dd>DL1-DD1</dd>
|
3231
|
-
<dt>DL1-DL2</dt>
|
3232
|
-
<dd>DL1-DD2</dd>
|
3233
|
-
</dl>
|
3234
|
-
</dd>
|
3235
|
-
|
3236
|
-
<dt>DL2</dt>
|
3237
|
-
<dd>DD2
|
3238
|
-
<ul>
|
3239
|
-
<li>DD2-UL1</li>
|
3240
|
-
<li>DD2-UL2</li>
|
3241
|
-
</ul>
|
3242
|
-
<p>DD2-PARA</p>
|
3243
|
-
</dd>
|
3244
|
-
</dl>
|
3245
|
-
EOS
|
3246
|
-
|
3247
|
-
actual = compile_block(src)
|
3248
|
-
assert_equal expected, actual
|
3249
|
-
end
|
3250
|
-
|
3251
|
-
def test_nest_multi
|
3252
|
-
src = <<-EOS
|
3253
|
-
1. OL1
|
3254
|
-
|
3255
|
-
//beginchild
|
3256
|
-
|
3257
|
-
1. OL1-OL1
|
3258
|
-
|
3259
|
-
//beginchild
|
3260
|
-
|
3261
|
-
* OL1-OL1-UL1
|
3262
|
-
|
3263
|
-
OL1-OL1-PARA
|
3264
|
-
|
3265
|
-
//endchild
|
3266
|
-
|
3267
|
-
2. OL1-OL2
|
3268
|
-
|
3269
|
-
* OL1-UL1
|
3270
|
-
|
3271
|
-
//beginchild
|
3272
|
-
|
3273
|
-
: OL1-UL1-DL1
|
3274
|
-
OL1-UL1-DD1
|
3275
|
-
|
3276
|
-
OL1-UL1-PARA
|
3277
|
-
|
3278
|
-
//endchild
|
3279
|
-
|
3280
|
-
* OL1-UL2
|
3281
|
-
|
3282
|
-
//endchild
|
3283
|
-
EOS
|
3284
|
-
expected = <<-EOS
|
3285
|
-
<ol>
|
3286
|
-
<li>OL1
|
3287
|
-
<ol>
|
3288
|
-
<li>OL1-OL1
|
3289
|
-
<ul>
|
3290
|
-
<li>OL1-OL1-UL1</li>
|
3291
|
-
</ul>
|
3292
|
-
<p>OL1-OL1-PARA</p>
|
3293
|
-
</li>
|
3294
|
-
|
3295
|
-
<li>OL1-OL2</li>
|
3296
|
-
</ol>
|
3297
|
-
<ul>
|
3298
|
-
<li>OL1-UL1
|
3299
|
-
<dl>
|
3300
|
-
<dt>OL1-UL1-DL1</dt>
|
3301
|
-
<dd>OL1-UL1-DD1</dd>
|
3302
|
-
</dl>
|
3303
|
-
<p>OL1-UL1-PARA</p>
|
3304
|
-
</li>
|
3305
|
-
|
3306
|
-
<li>OL1-UL2</li>
|
3307
|
-
</ul>
|
3308
|
-
</li>
|
3309
|
-
</ol>
|
3310
|
-
EOS
|
3311
|
-
|
3312
|
-
actual = compile_block(src)
|
3313
|
-
assert_equal expected, actual
|
3314
|
-
end
|
3315
|
-
end
|