review 3.0.0 → 4.2.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/ruby-win.yml +39 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +50 -12
- data/.travis.yml +17 -8
- data/Dockerfile +21 -5
- data/NEWS.ja.md +358 -0
- data/NEWS.md +358 -1
- data/README.md +11 -8
- data/appveyor.yml +1 -3
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -8
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +12 -12
- data/bin/review-epubmaker +3 -35
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +2 -89
- data/bin/review-preproc +14 -19
- data/bin/review-validate +3 -3
- data/bin/review-vol +4 -78
- data/doc/LICENSE +1 -1
- data/doc/config.yml.sample +46 -12
- data/doc/config.yml.sample-simple +4 -2
- data/doc/format.ja.md +37 -13
- data/doc/format.md +35 -20
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- data/doc/quickstart.ja.md +46 -26
- data/doc/quickstart.md +38 -17
- data/lib/epubmaker/epubcommon.rb +10 -5
- data/lib/epubmaker/epubv2.rb +1 -1
- data/lib/epubmaker/epubv3.rb +1 -0
- data/lib/epubmaker/producer.rb +4 -2
- data/lib/review/book.rb +1 -1
- data/lib/review/book/base.rb +38 -79
- data/lib/review/book/chapter.rb +18 -3
- data/lib/review/book/compilable.rb +6 -5
- data/lib/review/book/index.rb +69 -101
- data/lib/review/book/index/item.rb +40 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +28 -5
- data/lib/review/book/volume.rb +3 -4
- data/lib/review/builder.rb +105 -44
- data/lib/review/catalog.rb +13 -16
- data/lib/review/compiler.rb +84 -72
- data/lib/review/configure.rb +19 -8
- data/lib/review/epub2html.rb +37 -4
- data/lib/review/epubmaker.rb +62 -7
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +102 -115
- data/lib/review/htmlutils.rb +2 -3
- data/lib/review/i18n.rb +2 -2
- data/lib/review/i18n.yml +9 -0
- data/lib/review/idgxmlbuilder.rb +153 -74
- data/lib/review/idgxmlmaker.rb +191 -0
- data/lib/review/init-web/finish.html +10 -0
- data/lib/review/init-web/index.html +190 -0
- data/lib/review/init-web/review-layout-design.js +691 -0
- data/lib/review/init.rb +125 -34
- data/lib/review/latexbuilder.rb +199 -88
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/location.rb +32 -0
- data/lib/review/logger.rb +4 -8
- data/lib/review/makerhelper.rb +24 -5
- data/lib/review/markdownbuilder.rb +31 -37
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +44 -22
- data/lib/review/plaintextbuilder.rb +106 -85
- data/lib/review/preprocessor.rb +32 -41
- data/lib/review/rstbuilder.rb +33 -33
- data/lib/review/textmaker.rb +19 -3
- data/lib/review/textutils.rb +76 -2
- data/lib/review/tocprinter.rb +231 -102
- data/lib/review/topbuilder.rb +114 -61
- data/lib/review/update.rb +19 -19
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +99 -0
- data/lib/review/webmaker.rb +11 -4
- data/lib/review/webtocprinter.rb +38 -35
- data/lib/review/yamlloader.rb +26 -16
- data/review.gemspec +6 -4
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +154 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/config.yml +2 -2
- data/samples/sample-book/src/lib/tasks/review.rake +29 -14
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/ch01.re +4 -2
- data/samples/syntax-book/ch02.re +8 -16
- data/samples/syntax-book/ch03.re +3 -6
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/lib/tasks/review.rake +30 -15
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/latex/config.erb +16 -0
- data/templates/latex/layout.tex.erb +4 -0
- data/templates/latex/review-jlreq/review-base.sty +150 -61
- data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
- data/templates/latex/review-jlreq/review-style.sty +4 -1
- data/templates/latex/review-jsbook/README.md +39 -0
- data/templates/latex/review-jsbook/review-base.sty +101 -23
- data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
- data/templates/latex/review-jsbook/review-style.sty +5 -2
- data/templates/opf/epubv3.opf.erb +1 -0
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/test_template.tex +24 -3
- data/test/assets/test_template_backmatter.tex +24 -3
- data/test/test_book.rb +75 -21
- data/test/test_book_chapter.rb +4 -2
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +16 -0
- data/test/test_catalog.rb +24 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +15 -7
- data/test/test_htmlbuilder.rb +909 -159
- data/test/test_i18n.rb +25 -25
- data/test/test_idgxmlbuilder.rb +395 -38
- data/test/test_idgxmlmaker_cmd.rb +46 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_index.rb +50 -10
- data/test/test_latexbuilder.rb +1194 -106
- data/test/test_latexbuilder_v2.rb +628 -97
- data/test/test_logger.rb +14 -1
- data/test/test_makerhelper.rb +3 -3
- data/test/test_markdownbuilder.rb +134 -16
- data/test/test_md2inaobuilder.rb +32 -9
- data/test/test_pdfmaker.rb +18 -1
- data/test/test_pdfmaker_cmd.rb +100 -6
- data/test/test_plaintextbuilder.rb +371 -25
- data/test/test_preprocessor.rb +2 -16
- data/test/test_rstbuilder.rb +249 -26
- data/test/test_textmaker_cmd.rb +54 -0
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +546 -31
- data/test/test_update.rb +17 -8
- data/test/test_webtocprinter.rb +66 -34
- data/test/test_yamlloader.rb +13 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/jis/jsarticle.cls +53 -14
- data/vendor/jsclasses/jis/jsbook.cls +53 -14
- data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.sty +3 -3
- data/vendor/jsclasses/jis/jspf.cls +52 -13
- data/vendor/jsclasses/jis/jsreport.cls +53 -14
- data/vendor/jsclasses/jis/kiyou.cls +53 -14
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.sty +3 -4
- data/vendor/jsclasses/jsarticle.cls +53 -14
- data/vendor/jsclasses/jsbook.cls +53 -14
- data/vendor/jsclasses/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +3 -3
- data/vendor/jsclasses/jspf.cls +52 -13
- data/vendor/jsclasses/jsreport.cls +53 -14
- data/vendor/jsclasses/kiyou.cls +53 -14
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +3 -4
- metadata +55 -10
- data/lib/review/tocparser.rb +0 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'rbconfig'
|
6
6
|
|
7
|
-
load
|
7
|
+
load(File.expand_path('../bin/review-catalog-converter', File.dirname(__FILE__)))
|
8
8
|
|
9
9
|
class CatalogConverterCmdTest < Test::Unit::TestCase
|
10
10
|
def test_parse_chaps
|
data/test/test_epubmaker_cmd.rb
CHANGED
@@ -16,23 +16,30 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def teardown
|
19
|
-
FileUtils.rm_rf
|
20
|
-
FileUtils.rm_rf
|
19
|
+
FileUtils.rm_rf(@tmpdir1)
|
20
|
+
FileUtils.rm_rf(@tmpdir2)
|
21
21
|
ENV['RUBYLIB'] = @old_rubylib
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def common_buildepub(bookdir, configfile, targetepubfile)
|
25
25
|
if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
|
26
|
-
config = prepare_samplebook(@tmpdir1)
|
26
|
+
config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
|
27
27
|
builddir = File.join(@tmpdir1, config['bookname'] + '-epub')
|
28
28
|
assert !File.exist?(builddir)
|
29
29
|
|
30
30
|
ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
|
31
31
|
Dir.chdir(@tmpdir1) do
|
32
|
-
system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER}
|
32
|
+
system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} #{configfile} 1>/dev/null 2>/dev/null")
|
33
33
|
end
|
34
|
-
|
35
|
-
assert File.exist?(builddir)
|
34
|
+
assert File.exist?(File.join(@tmpdir1, targetepubfile))
|
36
35
|
end
|
37
36
|
end
|
37
|
+
|
38
|
+
def test_epubmaker_cmd_samplebook
|
39
|
+
common_buildepub('sample-book/src', 'config.yml', 'book.epub')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_epubmaker_cmd_syntaxbook
|
43
|
+
common_buildepub('syntax-book', 'config.yml', 'syntax-book.epub')
|
44
|
+
end
|
38
45
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
|
2
2
|
require 'test/unit'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'review/yamlloader'
|
5
|
+
require 'review/extentions'
|
4
6
|
|
5
7
|
def touch_file(path)
|
6
8
|
FileUtils.touch(path)
|
@@ -10,13 +12,19 @@ def assets_dir
|
|
10
12
|
File.join(File.dirname(__FILE__), 'assets')
|
11
13
|
end
|
12
14
|
|
13
|
-
def prepare_samplebook(srcdir)
|
14
|
-
samplebook_dir = File.expand_path(
|
15
|
-
|
16
|
-
#
|
17
|
-
|
18
|
-
FileUtils.
|
19
|
-
|
15
|
+
def prepare_samplebook(srcdir, bookdir, latextemplatedir, configfile)
|
16
|
+
samplebook_dir = File.expand_path("../samples/#{bookdir}/", File.dirname(__FILE__))
|
17
|
+
files = Dir.glob(File.join(samplebook_dir, '*'))
|
18
|
+
# ignore temporary built files
|
19
|
+
files.delete_if { |file| file =~ /.*\-(pdf|epub|text)/ || file == 'webroot' }
|
20
|
+
FileUtils.cp_r(files, srcdir)
|
21
|
+
if latextemplatedir
|
22
|
+
# copy from review-jsbook or review-jlreq
|
23
|
+
template_dir = File.expand_path("../templates/latex/#{latextemplatedir}/", File.dirname(__FILE__))
|
24
|
+
FileUtils.cp(Dir.glob(File.join(template_dir, '*')), File.join(srcdir, 'sty'))
|
25
|
+
end
|
26
|
+
loader = ReVIEW::YAMLLoader.new
|
27
|
+
loader.load_file(File.open(File.join(srcdir, configfile)))
|
20
28
|
end
|
21
29
|
|
22
30
|
def compile_inline(text)
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -13,6 +13,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
13
13
|
@config['secnolevel'] = 2
|
14
14
|
@config['stylesheet'] = nil
|
15
15
|
@config['htmlext'] = 'html'
|
16
|
+
@config['epubmaker'] = {}
|
16
17
|
@book = Book::Base.new('.')
|
17
18
|
@book.config = @config
|
18
19
|
@compiler = ReVIEW::Compiler.new(@builder)
|
@@ -60,7 +61,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
60
61
|
Dir.mktmpdir do |dir|
|
61
62
|
Dir.chdir(dir) do
|
62
63
|
file = File.join(dir, 'locale.yml')
|
63
|
-
File.open(file, 'w') { |f| f.write
|
64
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nappendix: 付録%pR" }
|
64
65
|
I18n.setup('ja')
|
65
66
|
@chapter.instance_eval do
|
66
67
|
def on_appendix?
|
@@ -81,7 +82,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
81
82
|
Dir.mktmpdir do |dir|
|
82
83
|
Dir.chdir(dir) do
|
83
84
|
file = File.join(dir, 'locale.yml')
|
84
|
-
File.open(file, 'w') { |f| f.write
|
85
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nappendix: 付録%pA" }
|
85
86
|
I18n.setup('ja')
|
86
87
|
@chapter.instance_eval do
|
87
88
|
def on_appendix?
|
@@ -190,7 +191,15 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
190
191
|
|
191
192
|
def test_inline_in_table
|
192
193
|
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
193
|
-
|
194
|
+
expected = <<-EOS
|
195
|
+
<div class="table">
|
196
|
+
<table>
|
197
|
+
<tr><th><b>1</b></th><th><i>2</i></th></tr>
|
198
|
+
<tr><td><b>3</b></td><td><i>4</i><>&</td></tr>
|
199
|
+
</table>
|
200
|
+
</div>
|
201
|
+
EOS
|
202
|
+
assert_equal expected, actual
|
194
203
|
end
|
195
204
|
|
196
205
|
def test_inline_br
|
@@ -235,8 +244,10 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
235
244
|
|
236
245
|
def test_inline_hd_chap
|
237
246
|
def @chapter.headline_index
|
238
|
-
|
239
|
-
Book::HeadlineIndex.new(
|
247
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
248
|
+
idx = Book::HeadlineIndex.new(self)
|
249
|
+
idx.add_item(item)
|
250
|
+
idx
|
240
251
|
end
|
241
252
|
|
242
253
|
@config['secnolevel'] = 2
|
@@ -252,7 +263,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
252
263
|
Dir.mktmpdir do |dir|
|
253
264
|
Dir.chdir(dir) do
|
254
265
|
file = File.join(dir, 'locale.yml')
|
255
|
-
File.open(file, 'w') { |f| f.write
|
266
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nappendix: 付録%pR" }
|
256
267
|
I18n.setup('ja')
|
257
268
|
@chapter.instance_eval do
|
258
269
|
def on_appendix?
|
@@ -261,8 +272,10 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
261
272
|
end
|
262
273
|
|
263
274
|
def @chapter.headline_index
|
264
|
-
|
265
|
-
Book::HeadlineIndex.new(
|
275
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
276
|
+
idx = Book::HeadlineIndex.new(self)
|
277
|
+
idx.add_item(item)
|
278
|
+
idx
|
266
279
|
end
|
267
280
|
|
268
281
|
actual = compile_inline('test @<hd>{test} test2')
|
@@ -275,7 +288,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
275
288
|
Dir.mktmpdir do |dir|
|
276
289
|
Dir.chdir(dir) do
|
277
290
|
file = File.join(dir, 'locale.yml')
|
278
|
-
File.open(file, 'w') { |f| f.write
|
291
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nappendix: 付録%pA" }
|
279
292
|
I18n.setup('ja')
|
280
293
|
@chapter.instance_eval do
|
281
294
|
def on_appendix?
|
@@ -284,8 +297,10 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
284
297
|
end
|
285
298
|
|
286
299
|
def @chapter.headline_index
|
287
|
-
|
288
|
-
Book::HeadlineIndex.new(
|
300
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
301
|
+
idx = Book::HeadlineIndex.new(self)
|
302
|
+
idx.add_item(item)
|
303
|
+
idx
|
289
304
|
end
|
290
305
|
|
291
306
|
actual = compile_inline('test @<hd>{test} test2')
|
@@ -334,36 +349,36 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
334
349
|
|
335
350
|
def test_inline_img
|
336
351
|
def @chapter.image(_id)
|
337
|
-
item = Book::
|
352
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
338
353
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
339
354
|
item
|
340
355
|
end
|
341
356
|
|
342
|
-
actual = compile_block
|
357
|
+
actual = compile_block("@<img>{sampleimg}\n")
|
343
358
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
344
359
|
assert_equal expected, actual
|
345
360
|
end
|
346
361
|
|
347
362
|
def test_inline_imgref
|
348
363
|
def @chapter.image(_id)
|
349
|
-
item = Book::
|
364
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
350
365
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
351
366
|
item
|
352
367
|
end
|
353
368
|
|
354
|
-
actual = compile_block
|
369
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
355
370
|
expected = %Q(<p><span class="imgref">図1.1</span>「sample photo」</p>\n)
|
356
371
|
assert_equal expected, actual
|
357
372
|
end
|
358
373
|
|
359
374
|
def test_inline_imgref2
|
360
375
|
def @chapter.image(_id)
|
361
|
-
item = Book::
|
376
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
362
377
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
363
378
|
item
|
364
379
|
end
|
365
380
|
|
366
|
-
actual = compile_block
|
381
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
367
382
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
368
383
|
assert_equal expected, actual
|
369
384
|
end
|
@@ -377,11 +392,11 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
377
392
|
re1 = File.join(dir, 'sample1.re')
|
378
393
|
cat = File.join(dir, 'catalog.yml')
|
379
394
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
380
|
-
File.open(file1, 'w') { |f| f.write
|
381
|
-
File.open(filet1, 'w') { |f| f.write
|
382
|
-
File.open(file2, 'w') { |f| f.write
|
383
|
-
File.open(cat, 'w') { |f| f.write
|
384
|
-
File.open(re1, 'w') { |f| f.write
|
395
|
+
File.open(file1, 'w') { |f| f.write '' }
|
396
|
+
File.open(filet1, 'w') { |f| f.write '' }
|
397
|
+
File.open(file2, 'w') { |f| f.write '' }
|
398
|
+
File.open(cat, 'w') { |f| f.write "CHAPS:\n - sample1.re\n" }
|
399
|
+
File.open(re1, 'w') { |f| f.write <<EOF }
|
385
400
|
= test
|
386
401
|
|
387
402
|
tbl1 is @<table>{tbl1}.
|
@@ -429,165 +444,413 @@ EOS
|
|
429
444
|
|
430
445
|
def test_quote
|
431
446
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
432
|
-
|
447
|
+
expected = <<-EOS
|
448
|
+
<blockquote><p>foobar</p>
|
449
|
+
<p>buz</p></blockquote>
|
450
|
+
EOS
|
451
|
+
assert_equal expected, actual
|
452
|
+
|
453
|
+
@book.config['join_lines_by_lang'] = true
|
454
|
+
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
455
|
+
expected = <<-EOS
|
456
|
+
<blockquote><p>foo bar</p>
|
457
|
+
<p>buz</p></blockquote>
|
458
|
+
EOS
|
459
|
+
assert_equal expected, actual
|
433
460
|
end
|
434
461
|
|
435
462
|
def test_memo
|
436
463
|
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
437
|
-
|
464
|
+
expected = <<-EOS
|
465
|
+
<div class="memo">
|
466
|
+
<p class="caption">this is <b>test</b><&>_</p>
|
467
|
+
<p>test1</p>
|
468
|
+
<p>test<i>2</i></p>
|
469
|
+
</div>
|
470
|
+
EOS
|
471
|
+
assert_equal expected, actual
|
438
472
|
end
|
439
473
|
|
440
474
|
def test_blankline
|
441
475
|
actual = compile_block("//blankline\nfoo\n")
|
442
|
-
|
476
|
+
expected = <<-EOS
|
477
|
+
<p><br /></p>
|
478
|
+
<p>foo</p>
|
479
|
+
EOS
|
480
|
+
assert_equal expected, actual
|
443
481
|
end
|
444
482
|
|
445
483
|
def test_noindent
|
446
484
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
447
|
-
|
485
|
+
expected = <<-EOS
|
486
|
+
<p class="noindent">foobar</p>
|
487
|
+
<p>foo2bar2</p>
|
488
|
+
EOS
|
489
|
+
assert_equal expected, actual
|
490
|
+
|
491
|
+
@book.config['join_lines_by_lang'] = true
|
492
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
493
|
+
expected = <<-EOS
|
494
|
+
<p class="noindent">foo bar</p>
|
495
|
+
<p>foo2 bar2</p>
|
496
|
+
EOS
|
497
|
+
assert_equal expected, actual
|
448
498
|
end
|
449
499
|
|
450
500
|
def test_flushright
|
451
501
|
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
452
|
-
|
502
|
+
expected = <<-EOS
|
503
|
+
<p class="flushright">foobar</p>
|
504
|
+
<p class="flushright">buz</p>
|
505
|
+
EOS
|
506
|
+
assert_equal expected, actual
|
507
|
+
|
508
|
+
@book.config['join_lines_by_lang'] = true
|
509
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
510
|
+
expected = <<-EOS
|
511
|
+
<p class="flushright">foo bar</p>
|
512
|
+
<p class="flushright">buz</p>
|
513
|
+
EOS
|
514
|
+
assert_equal expected, actual
|
453
515
|
end
|
454
516
|
|
455
517
|
def test_centering
|
456
518
|
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
457
|
-
|
519
|
+
expected = <<-EOS
|
520
|
+
<p class="center">foobar</p>
|
521
|
+
<p class="center">buz</p>
|
522
|
+
EOS
|
523
|
+
assert_equal expected, actual
|
524
|
+
|
525
|
+
@book.config['join_lines_by_lang'] = true
|
526
|
+
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
527
|
+
expected = <<-EOS
|
528
|
+
<p class="center">foo bar</p>
|
529
|
+
<p class="center">buz</p>
|
530
|
+
EOS
|
531
|
+
assert_equal expected, actual
|
458
532
|
end
|
459
533
|
|
460
534
|
def test_image
|
461
535
|
def @chapter.image(_id)
|
462
|
-
item = Book::
|
536
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
463
537
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
464
538
|
item
|
465
539
|
end
|
466
540
|
|
467
541
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
468
|
-
|
542
|
+
expected = <<-EOS
|
543
|
+
<div id="sampleimg" class="image">
|
544
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
545
|
+
<p class="caption">
|
546
|
+
図1.1: sample photo
|
547
|
+
</p>
|
548
|
+
</div>
|
549
|
+
EOS
|
550
|
+
assert_equal expected, actual
|
551
|
+
|
552
|
+
@config['caption_position']['image'] = 'top'
|
553
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
554
|
+
expected = <<-EOS
|
555
|
+
<div id="sampleimg" class="image">
|
556
|
+
<p class="caption">
|
557
|
+
図1.1: sample photo
|
558
|
+
</p>
|
559
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
560
|
+
</div>
|
561
|
+
EOS
|
562
|
+
assert_equal expected, actual
|
469
563
|
end
|
470
564
|
|
471
565
|
def test_image_with_metric
|
472
566
|
def @chapter.image(_id)
|
473
|
-
item = Book::
|
567
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
474
568
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
475
569
|
item
|
476
570
|
end
|
477
571
|
|
478
572
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
479
|
-
|
573
|
+
expected = <<-EOS
|
574
|
+
<div id="sampleimg" class="image">
|
575
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
|
576
|
+
<p class="caption">
|
577
|
+
図1.1: sample photo
|
578
|
+
</p>
|
579
|
+
</div>
|
580
|
+
EOS
|
581
|
+
assert_equal expected, actual
|
480
582
|
end
|
481
583
|
|
482
584
|
def test_image_with_metric2
|
483
585
|
def @chapter.image(_id)
|
484
|
-
item = Book::
|
586
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
485
587
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
486
588
|
item
|
487
589
|
end
|
488
590
|
|
489
591
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
490
|
-
|
592
|
+
expected = <<-EOS
|
593
|
+
<div id="sampleimg" class="image">
|
594
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
|
595
|
+
<p class="caption">
|
596
|
+
図1.1: sample photo
|
597
|
+
</p>
|
598
|
+
</div>
|
599
|
+
EOS
|
600
|
+
assert_equal expected, actual
|
491
601
|
end
|
492
602
|
|
493
603
|
def test_image_with_tricky_id
|
494
604
|
def @chapter.image(_id)
|
495
|
-
item = Book::
|
605
|
+
item = Book::Index::Item.new('123 あ_;', 1)
|
496
606
|
item.instance_eval { @path = './images/chap1-123 あ_;.png' }
|
497
607
|
item
|
498
608
|
end
|
499
609
|
|
500
610
|
actual = compile_block("//image[123 あ_;][sample photo]{\n//}\n")
|
501
|
-
|
611
|
+
expected = <<-EOS
|
612
|
+
<div id="id_123-_E3_81_82___3B" class="image">
|
613
|
+
<img src="images/chap1-123 あ_;.png" alt="sample photo" />
|
614
|
+
<p class="caption">
|
615
|
+
図1.1: sample photo
|
616
|
+
</p>
|
617
|
+
</div>
|
618
|
+
EOS
|
619
|
+
assert_equal expected, actual
|
502
620
|
end
|
503
621
|
|
504
622
|
def test_indepimage
|
505
623
|
def @chapter.image(_id)
|
506
|
-
item = Book::
|
624
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
507
625
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
508
626
|
item
|
509
627
|
end
|
510
628
|
|
511
629
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
512
|
-
|
630
|
+
expected = <<-EOS
|
631
|
+
<div id="sampleimg" class="image">
|
632
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
633
|
+
<p class="caption">
|
634
|
+
図: sample photo
|
635
|
+
</p>
|
636
|
+
</div>
|
637
|
+
EOS
|
638
|
+
assert_equal expected, actual
|
639
|
+
|
640
|
+
@config['caption_position']['image'] = 'top'
|
641
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
642
|
+
expected = <<-EOS
|
643
|
+
<div id="sampleimg" class="image">
|
644
|
+
<p class="caption">
|
645
|
+
図: sample photo
|
646
|
+
</p>
|
647
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
648
|
+
</div>
|
649
|
+
EOS
|
650
|
+
assert_equal expected, actual
|
513
651
|
end
|
514
652
|
|
515
653
|
def test_indepimage_without_caption
|
516
654
|
def @chapter.image(_id)
|
517
|
-
item = Book::
|
655
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
518
656
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
519
657
|
item
|
520
658
|
end
|
521
659
|
|
522
660
|
actual = compile_block("//indepimage[sampleimg]\n")
|
523
|
-
|
661
|
+
expected = <<-EOS
|
662
|
+
<div id="sampleimg" class="image">
|
663
|
+
<img src="images/chap1-sampleimg.png" alt="" />
|
664
|
+
</div>
|
665
|
+
EOS
|
666
|
+
assert_equal expected, actual
|
524
667
|
end
|
525
668
|
|
526
669
|
def test_indepimage_with_metric
|
527
670
|
def @chapter.image(_id)
|
528
|
-
item = Book::
|
671
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
529
672
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
530
673
|
item
|
531
674
|
end
|
532
675
|
|
533
676
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
534
|
-
|
677
|
+
expected = <<-EOS
|
678
|
+
<div id="sampleimg" class="image">
|
679
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
|
680
|
+
<p class="caption">
|
681
|
+
図: sample photo
|
682
|
+
</p>
|
683
|
+
</div>
|
684
|
+
EOS
|
685
|
+
assert_equal expected, actual
|
535
686
|
end
|
536
687
|
|
537
688
|
def test_indepimage_with_metric2
|
538
689
|
def @chapter.image(_id)
|
539
|
-
item = Book::
|
690
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
540
691
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
541
692
|
item
|
542
693
|
end
|
543
694
|
|
544
695
|
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
|
545
|
-
|
696
|
+
expected = <<-EOS
|
697
|
+
<div id="sampleimg" class="image">
|
698
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
|
699
|
+
<p class="caption">
|
700
|
+
図: sample photo
|
701
|
+
</p>
|
702
|
+
</div>
|
703
|
+
EOS
|
704
|
+
assert_equal expected, actual
|
546
705
|
end
|
547
706
|
|
548
707
|
def test_indepimage_without_caption_but_with_metric
|
549
708
|
def @chapter.image(_id)
|
550
|
-
item = Book::
|
709
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
551
710
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
552
711
|
item
|
553
712
|
end
|
554
713
|
|
555
714
|
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
556
|
-
|
715
|
+
expected = <<-EOS
|
716
|
+
<div id="sampleimg" class="image">
|
717
|
+
<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />
|
718
|
+
</div>
|
719
|
+
EOS
|
720
|
+
assert_equal expected, actual
|
557
721
|
end
|
558
722
|
|
559
723
|
def test_dlist
|
560
|
-
actual = compile_block(": foo\n foo.\n bar.\n")
|
561
|
-
|
724
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
725
|
+
expected = <<-EOS
|
726
|
+
<dl>
|
727
|
+
<dt>foo</dt>
|
728
|
+
<dd>foo.bar.</dd>
|
729
|
+
</dl>
|
730
|
+
EOS
|
731
|
+
assert_equal expected, actual
|
732
|
+
|
733
|
+
@book.config['join_lines_by_lang'] = true
|
734
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
735
|
+
expected = <<-EOS
|
736
|
+
<dl>
|
737
|
+
<dt>foo</dt>
|
738
|
+
<dd>foo. bar.</dd>
|
739
|
+
</dl>
|
740
|
+
EOS
|
741
|
+
assert_equal expected, actual
|
562
742
|
end
|
563
743
|
|
564
744
|
def test_dlist_with_bracket
|
565
|
-
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
566
|
-
|
745
|
+
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
746
|
+
expected = <<-EOS
|
747
|
+
<dl>
|
748
|
+
<dt>foo[bar]</dt>
|
749
|
+
<dd>foo.bar.</dd>
|
750
|
+
</dl>
|
751
|
+
EOS
|
752
|
+
assert_equal expected, actual
|
753
|
+
|
754
|
+
@book.config['join_lines_by_lang'] = true
|
755
|
+
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
756
|
+
expected = <<-EOS
|
757
|
+
<dl>
|
758
|
+
<dt>foo[bar]</dt>
|
759
|
+
<dd>foo. bar.</dd>
|
760
|
+
</dl>
|
761
|
+
EOS
|
762
|
+
assert_equal expected, actual
|
567
763
|
end
|
568
764
|
|
569
765
|
def test_dlist_with_comment
|
570
|
-
source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
|
766
|
+
source = " : title\n body\n\#@ comment\n\#@ comment\n : title2\n body2\n"
|
571
767
|
actual = compile_block(source)
|
572
|
-
|
768
|
+
expected = <<-EOS
|
769
|
+
<dl>
|
770
|
+
<dt>title</dt>
|
771
|
+
<dd>body</dd>
|
772
|
+
<dt>title2</dt>
|
773
|
+
<dd>body2</dd>
|
774
|
+
</dl>
|
775
|
+
EOS
|
776
|
+
assert_equal expected, actual
|
573
777
|
end
|
574
778
|
|
575
779
|
def test_dlist_beforeulol
|
576
780
|
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")
|
577
|
-
|
781
|
+
expected = <<-EOS
|
782
|
+
<dl>
|
783
|
+
<dt>foo</dt>
|
784
|
+
<dd>foo.</dd>
|
785
|
+
</dl>
|
786
|
+
<p>para</p>
|
787
|
+
<dl>
|
788
|
+
<dt>foo</dt>
|
789
|
+
<dd>foo.</dd>
|
790
|
+
</dl>
|
791
|
+
<ol>
|
792
|
+
<li>bar</li>
|
793
|
+
</ol>
|
794
|
+
<dl>
|
795
|
+
<dt>foo</dt>
|
796
|
+
<dd>foo.</dd>
|
797
|
+
</dl>
|
798
|
+
<ul>
|
799
|
+
<li>bar</li>
|
800
|
+
</ul>
|
801
|
+
EOS
|
802
|
+
assert_equal expected, actual
|
803
|
+
end
|
804
|
+
|
805
|
+
def test_dt_inline
|
806
|
+
fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
|
807
|
+
@chapter.instance_eval { @footnote_index = fn }
|
808
|
+
actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
809
|
+
|
810
|
+
expected = <<-EOS
|
811
|
+
<dl>
|
812
|
+
<dt>foo<a id="fnb-bar" href="#fn-bar" class="noteref" epub:type="noteref">*1</a>[]<>&<span class="equation">\\alpha[]</span></dt>
|
813
|
+
<dd></dd>
|
814
|
+
</dl>
|
815
|
+
EOS
|
816
|
+
assert_equal expected, actual
|
578
817
|
end
|
579
818
|
|
580
819
|
def test_list
|
581
820
|
def @chapter.list(_id)
|
582
|
-
Book::
|
821
|
+
Book::Index::Item.new('samplelist', 1)
|
583
822
|
end
|
584
823
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
585
|
-
|
824
|
+
expected = <<-EOS
|
825
|
+
<div id="samplelist" class="caption-code">
|
826
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
827
|
+
<pre class="list">test1
|
828
|
+
test1.5
|
829
|
+
|
830
|
+
test<i>2</i>
|
831
|
+
</pre>
|
832
|
+
</div>
|
833
|
+
EOS
|
834
|
+
assert_equal expected, actual
|
835
|
+
|
836
|
+
@config['caption_position']['list'] = 'bottom'
|
837
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
838
|
+
expected = <<-EOS
|
839
|
+
<div id="samplelist" class="caption-code">
|
840
|
+
<pre class="list">test1
|
841
|
+
test1.5
|
842
|
+
|
843
|
+
test<i>2</i>
|
844
|
+
</pre>
|
845
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
846
|
+
</div>
|
847
|
+
EOS
|
848
|
+
assert_equal expected, actual
|
586
849
|
end
|
587
850
|
|
588
851
|
def test_inline_list
|
589
852
|
def @chapter.list(_id)
|
590
|
-
Book::
|
853
|
+
Book::Index::Item.new('samplelist', 1)
|
591
854
|
end
|
592
855
|
actual = compile_block("@<list>{sampletest}\n")
|
593
856
|
assert_equal %Q(<p><span class="listref">リスト1.1</span></p>\n), actual
|
@@ -611,7 +874,7 @@ EOS
|
|
611
874
|
|
612
875
|
def test_list_pygments
|
613
876
|
def @chapter.list(_id)
|
614
|
-
Book::
|
877
|
+
Book::Index::Item.new('samplelist', 1)
|
615
878
|
end
|
616
879
|
begin
|
617
880
|
require 'pygments'
|
@@ -638,7 +901,7 @@ test<i>2</i>
|
|
638
901
|
|
639
902
|
def test_list_pygments_lang
|
640
903
|
def @chapter.list(_id)
|
641
|
-
Book::
|
904
|
+
Book::Index::Item.new('samplelist', 1)
|
642
905
|
end
|
643
906
|
begin
|
644
907
|
require 'pygments'
|
@@ -666,7 +929,7 @@ EOS
|
|
666
929
|
|
667
930
|
def test_list_pygments_nulllang
|
668
931
|
def @chapter.list(_id)
|
669
|
-
Book::
|
932
|
+
Book::Index::Item.new('samplelist', 1)
|
670
933
|
end
|
671
934
|
begin
|
672
935
|
require 'pygments'
|
@@ -699,13 +962,23 @@ end
|
|
699
962
|
return true
|
700
963
|
end
|
701
964
|
def @chapter.list(_id)
|
702
|
-
Book::
|
965
|
+
Book::Index::Item.new('samplelist', 1)
|
703
966
|
end
|
704
967
|
@book.config['highlight'] = {}
|
705
968
|
@book.config['highlight']['html'] = 'rouge'
|
706
969
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
707
970
|
|
708
|
-
|
971
|
+
expected = <<-EOS
|
972
|
+
<div id="samplelist" class="caption-code">
|
973
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
974
|
+
<pre class="list highlight">test1
|
975
|
+
test1.5
|
976
|
+
|
977
|
+
test<i>2</i>
|
978
|
+
</pre>
|
979
|
+
</div>
|
980
|
+
EOS
|
981
|
+
assert_equal expected, actual
|
709
982
|
end
|
710
983
|
|
711
984
|
def test_list_rouge_lang
|
@@ -716,7 +989,7 @@ end
|
|
716
989
|
return true
|
717
990
|
end
|
718
991
|
def @chapter.list(_id)
|
719
|
-
Book::
|
992
|
+
Book::Index::Item.new('samplelist', 1)
|
720
993
|
end
|
721
994
|
@book.config['highlight'] = {}
|
722
995
|
@book.config['highlight']['html'] = 'rouge'
|
@@ -744,18 +1017,29 @@ EOS
|
|
744
1017
|
return true
|
745
1018
|
end
|
746
1019
|
def @chapter.list(_id)
|
747
|
-
Book::
|
1020
|
+
Book::Index::Item.new('samplelist', 1)
|
748
1021
|
end
|
749
1022
|
@book.config['highlight'] = {}
|
750
1023
|
@book.config['highlight']['html'] = 'rouge'
|
751
1024
|
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")
|
752
1025
|
|
753
|
-
|
1026
|
+
expected = <<-EOS
|
1027
|
+
<div id="samplelist" class="caption-code">
|
1028
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1029
|
+
<pre class="list highlight">def foo(a1, a2=:test)
|
1030
|
+
(1..3).times{|i| a.include?(:foo)}
|
1031
|
+
return true
|
1032
|
+
end
|
1033
|
+
|
1034
|
+
</pre>
|
1035
|
+
</div>
|
1036
|
+
EOS
|
1037
|
+
assert_equal expected, actual
|
754
1038
|
end
|
755
1039
|
|
756
1040
|
def test_listnum
|
757
1041
|
def @chapter.list(_id)
|
758
|
-
Book::
|
1042
|
+
Book::Index::Item.new('samplelist', 1)
|
759
1043
|
end
|
760
1044
|
|
761
1045
|
@book.config['highlight'] = false
|
@@ -777,6 +1061,29 @@ EOS
|
|
777
1061
|
4: end
|
778
1062
|
</pre>
|
779
1063
|
</div>
|
1064
|
+
EOS
|
1065
|
+
|
1066
|
+
assert_equal expected, actual
|
1067
|
+
|
1068
|
+
@config['caption_position']['list'] = 'bottom'
|
1069
|
+
actual = compile_block(<<-EOS)
|
1070
|
+
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
1071
|
+
def foo(a1, a2=:test)
|
1072
|
+
(1..3).times{|i| a.include?(:foo)}
|
1073
|
+
return true
|
1074
|
+
end
|
1075
|
+
//}
|
1076
|
+
EOS
|
1077
|
+
|
1078
|
+
expected = <<-EOS
|
1079
|
+
<div id="samplelist" class="code">
|
1080
|
+
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
|
1081
|
+
2: (1..3).times{|i| a.include?(:foo)}
|
1082
|
+
3: return true
|
1083
|
+
4: end
|
1084
|
+
</pre>
|
1085
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1086
|
+
</div>
|
780
1087
|
EOS
|
781
1088
|
|
782
1089
|
assert_equal expected, actual
|
@@ -784,7 +1091,7 @@ EOS
|
|
784
1091
|
|
785
1092
|
def test_listnum_linenum
|
786
1093
|
def @chapter.list(_id)
|
787
|
-
Book::
|
1094
|
+
Book::Index::Item.new('samplelist', 1)
|
788
1095
|
end
|
789
1096
|
|
790
1097
|
@book.config['highlight'] = false
|
@@ -814,7 +1121,7 @@ EOS
|
|
814
1121
|
|
815
1122
|
def test_listnum_pygments_lang
|
816
1123
|
def @chapter.list(_id)
|
817
|
-
Book::
|
1124
|
+
Book::Index::Item.new('samplelist', 1)
|
818
1125
|
end
|
819
1126
|
begin
|
820
1127
|
require 'pygments'
|
@@ -841,7 +1148,7 @@ EOS
|
|
841
1148
|
|
842
1149
|
def test_listnum_pygments_lang_linenum
|
843
1150
|
def @chapter.list(_id)
|
844
|
-
Book::
|
1151
|
+
Book::Index::Item.new('samplelist', 1)
|
845
1152
|
end
|
846
1153
|
begin
|
847
1154
|
require 'pygments'
|
@@ -869,7 +1176,7 @@ EOS
|
|
869
1176
|
|
870
1177
|
def test_listnum_pygments_lang_without_lang
|
871
1178
|
def @chapter.list(_id)
|
872
|
-
Book::
|
1179
|
+
Book::Index::Item.new('samplelist', 1)
|
873
1180
|
end
|
874
1181
|
begin
|
875
1182
|
require 'pygments'
|
@@ -903,7 +1210,7 @@ EOS
|
|
903
1210
|
return true
|
904
1211
|
end
|
905
1212
|
def @chapter.list(_id)
|
906
|
-
Book::
|
1213
|
+
Book::Index::Item.new('samplelist', 1)
|
907
1214
|
end
|
908
1215
|
@book.config['highlight'] = {}
|
909
1216
|
@book.config['highlight']['html'] = 'rouge'
|
@@ -937,7 +1244,7 @@ EOS
|
|
937
1244
|
return true
|
938
1245
|
end
|
939
1246
|
def @chapter.list(_id)
|
940
|
-
Book::
|
1247
|
+
Book::Index::Item.new('samplelist', 1)
|
941
1248
|
end
|
942
1249
|
@book.config['highlight'] = {}
|
943
1250
|
@book.config['highlight']['html'] = 'rouge'
|
@@ -963,9 +1270,94 @@ EOB
|
|
963
1270
|
assert_equal expected, actual
|
964
1271
|
end
|
965
1272
|
|
1273
|
+
def test_source
|
1274
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1275
|
+
expected = <<-EOS
|
1276
|
+
<div class="source-code">
|
1277
|
+
<p class="caption">foo/bar/test.rb</p>
|
1278
|
+
<pre class="source">foo
|
1279
|
+
bar
|
1280
|
+
|
1281
|
+
buz
|
1282
|
+
</pre>
|
1283
|
+
</div>
|
1284
|
+
EOS
|
1285
|
+
assert_equal expected, actual
|
1286
|
+
|
1287
|
+
@config['caption_position']['list'] = 'bottom'
|
1288
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1289
|
+
expected = <<-EOS
|
1290
|
+
<div class="source-code">
|
1291
|
+
<pre class="source">foo
|
1292
|
+
bar
|
1293
|
+
|
1294
|
+
buz
|
1295
|
+
</pre>
|
1296
|
+
<p class="caption">foo/bar/test.rb</p>
|
1297
|
+
</div>
|
1298
|
+
EOS
|
1299
|
+
assert_equal expected, actual
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
def test_source_empty_caption
|
1303
|
+
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
1304
|
+
expected = <<-EOS
|
1305
|
+
<div class="source-code">
|
1306
|
+
<pre class="source">foo
|
1307
|
+
bar
|
1308
|
+
|
1309
|
+
buz
|
1310
|
+
</pre>
|
1311
|
+
</div>
|
1312
|
+
EOS
|
1313
|
+
assert_equal expected, actual
|
1314
|
+
end
|
1315
|
+
|
1316
|
+
def test_box
|
1317
|
+
actual = compile_block("//box{\nfoo\nbar\n//}\n")
|
1318
|
+
expected = <<-EOS
|
1319
|
+
<div class="syntax">
|
1320
|
+
<pre class="syntax">foo
|
1321
|
+
bar
|
1322
|
+
</pre>
|
1323
|
+
</div>
|
1324
|
+
EOS
|
1325
|
+
assert_equal expected, actual
|
1326
|
+
|
1327
|
+
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1328
|
+
expected = <<-EOS
|
1329
|
+
<div class="syntax">
|
1330
|
+
<p class="caption">FOO</p>
|
1331
|
+
<pre class="syntax">foo
|
1332
|
+
bar
|
1333
|
+
</pre>
|
1334
|
+
</div>
|
1335
|
+
EOS
|
1336
|
+
assert_equal expected, actual
|
1337
|
+
|
1338
|
+
@config['caption_position']['list'] = 'bottom'
|
1339
|
+
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1340
|
+
expected = <<-EOS
|
1341
|
+
<div class="syntax">
|
1342
|
+
<pre class="syntax">foo
|
1343
|
+
bar
|
1344
|
+
</pre>
|
1345
|
+
<p class="caption">FOO</p>
|
1346
|
+
</div>
|
1347
|
+
EOS
|
1348
|
+
assert_equal expected, actual
|
1349
|
+
end
|
1350
|
+
|
966
1351
|
def test_emlist
|
967
1352
|
actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
|
968
|
-
|
1353
|
+
expected = <<-EOS
|
1354
|
+
<div class="emlist-code">
|
1355
|
+
<pre class="emlist">lineA
|
1356
|
+
lineB
|
1357
|
+
</pre>
|
1358
|
+
</div>
|
1359
|
+
EOS
|
1360
|
+
assert_equal expected, actual
|
969
1361
|
end
|
970
1362
|
|
971
1363
|
def test_emlist_pygments_lang
|
@@ -989,12 +1381,40 @@ EOB
|
|
989
1381
|
|
990
1382
|
def test_emlist_caption
|
991
1383
|
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
992
|
-
|
1384
|
+
expected = <<-EOS
|
1385
|
+
<div class="emlist-code">
|
1386
|
+
<p class="caption">cap1</p>
|
1387
|
+
<pre class="emlist">lineA
|
1388
|
+
lineB
|
1389
|
+
</pre>
|
1390
|
+
</div>
|
1391
|
+
EOS
|
1392
|
+
assert_equal expected, actual
|
1393
|
+
|
1394
|
+
@config['caption_position']['list'] = 'bottom'
|
1395
|
+
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
1396
|
+
expected = <<-EOS
|
1397
|
+
<div class="emlist-code">
|
1398
|
+
<pre class="emlist">lineA
|
1399
|
+
lineB
|
1400
|
+
</pre>
|
1401
|
+
<p class="caption">cap1</p>
|
1402
|
+
</div>
|
1403
|
+
EOS
|
1404
|
+
assert_equal expected, actual
|
993
1405
|
end
|
994
1406
|
|
995
1407
|
def test_emlist_with_tab
|
996
1408
|
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
997
|
-
|
1409
|
+
expected = <<-EOS
|
1410
|
+
<div class="emlist-code">
|
1411
|
+
<pre class="emlist"> lineA
|
1412
|
+
lineB
|
1413
|
+
lineC
|
1414
|
+
</pre>
|
1415
|
+
</div>
|
1416
|
+
EOS
|
1417
|
+
assert_equal expected, actual
|
998
1418
|
end
|
999
1419
|
|
1000
1420
|
def test_emlistnum
|
@@ -1020,6 +1440,18 @@ EOS
|
|
1020
1440
|
2: lineB
|
1021
1441
|
</pre>
|
1022
1442
|
</div>
|
1443
|
+
EOS
|
1444
|
+
assert_equal expected, actual
|
1445
|
+
|
1446
|
+
@config['caption_position']['list'] = 'bottom'
|
1447
|
+
actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
1448
|
+
expected = <<-EOS
|
1449
|
+
<div class="emlistnum-code">
|
1450
|
+
<pre class="emlist language-text"> 1: lineA
|
1451
|
+
2: lineB
|
1452
|
+
</pre>
|
1453
|
+
<p class="caption">cap</p>
|
1454
|
+
</div>
|
1023
1455
|
EOS
|
1024
1456
|
assert_equal expected, actual
|
1025
1457
|
end
|
@@ -1041,12 +1473,27 @@ EOS
|
|
1041
1473
|
def test_emlist_with_4tab
|
1042
1474
|
@config['tabwidth'] = 4
|
1043
1475
|
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
1044
|
-
|
1476
|
+
expected = <<-EOS
|
1477
|
+
<div class="emlist-code">
|
1478
|
+
<pre class="emlist"> lineA
|
1479
|
+
lineB
|
1480
|
+
lineC
|
1481
|
+
</pre>
|
1482
|
+
</div>
|
1483
|
+
EOS
|
1484
|
+
assert_equal expected, actual
|
1045
1485
|
end
|
1046
1486
|
|
1047
1487
|
def test_cmd
|
1048
1488
|
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
1049
|
-
|
1489
|
+
expected = <<-EOS
|
1490
|
+
<div class="cmd-code">
|
1491
|
+
<pre class="cmd">lineA
|
1492
|
+
lineB
|
1493
|
+
</pre>
|
1494
|
+
</div>
|
1495
|
+
EOS
|
1496
|
+
assert_equal expected, actual
|
1050
1497
|
end
|
1051
1498
|
|
1052
1499
|
def test_cmd_pygments
|
@@ -1058,12 +1505,39 @@ EOS
|
|
1058
1505
|
@book.config['highlight'] = {}
|
1059
1506
|
@book.config['highlight']['html'] = 'pygments'
|
1060
1507
|
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
1061
|
-
|
1508
|
+
expected = <<-EOS
|
1509
|
+
<div class="cmd-code">
|
1510
|
+
<pre class="cmd"><span style="color: #888888">lineA</span>
|
1511
|
+
<span style="color: #888888">lineB</span>
|
1512
|
+
</pre>
|
1513
|
+
</div>
|
1514
|
+
EOS
|
1515
|
+
assert_equal expected, actual
|
1062
1516
|
end
|
1063
1517
|
|
1064
1518
|
def test_cmd_caption
|
1065
1519
|
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1066
|
-
|
1520
|
+
expected = <<-EOS
|
1521
|
+
<div class="cmd-code">
|
1522
|
+
<p class="caption">cap1</p>
|
1523
|
+
<pre class="cmd">lineA
|
1524
|
+
lineB
|
1525
|
+
</pre>
|
1526
|
+
</div>
|
1527
|
+
EOS
|
1528
|
+
assert_equal expected, actual
|
1529
|
+
|
1530
|
+
@config['caption_position']['list'] = 'bottom'
|
1531
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1532
|
+
expected = <<-EOS
|
1533
|
+
<div class="cmd-code">
|
1534
|
+
<pre class="cmd">lineA
|
1535
|
+
lineB
|
1536
|
+
</pre>
|
1537
|
+
<p class="caption">cap1</p>
|
1538
|
+
</div>
|
1539
|
+
EOS
|
1540
|
+
assert_equal expected, actual
|
1067
1541
|
end
|
1068
1542
|
|
1069
1543
|
def test_texequation
|
@@ -1123,7 +1597,7 @@ EOS
|
|
1123
1597
|
|
1124
1598
|
def test_bib
|
1125
1599
|
def @chapter.bibpaper(_id)
|
1126
|
-
Book::
|
1600
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1127
1601
|
end
|
1128
1602
|
|
1129
1603
|
assert_equal %Q(<a href="bib.html#bib-samplebib">[1]</a>), compile_inline('@<bib>{samplebib}')
|
@@ -1131,7 +1605,7 @@ EOS
|
|
1131
1605
|
|
1132
1606
|
def test_bib_noramlized
|
1133
1607
|
def @chapter.bibpaper(_id)
|
1134
|
-
Book::
|
1608
|
+
Book::Index::Item.new('sampleb=ib', 1, 'sample bib')
|
1135
1609
|
end
|
1136
1610
|
|
1137
1611
|
assert_equal %Q(<a href="bib.html#bib-id_sample_3Dbib">[1]</a>), compile_inline('@<bib>{sample=bib}')
|
@@ -1139,7 +1613,7 @@ EOS
|
|
1139
1613
|
|
1140
1614
|
def test_bib_htmlext
|
1141
1615
|
def @chapter.bibpaper(_id)
|
1142
|
-
Book::
|
1616
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1143
1617
|
end
|
1144
1618
|
|
1145
1619
|
@config['htmlext'] = 'xhtml'
|
@@ -1148,29 +1622,71 @@ EOS
|
|
1148
1622
|
|
1149
1623
|
def test_bibpaper
|
1150
1624
|
def @chapter.bibpaper(_id)
|
1151
|
-
Book::
|
1625
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1152
1626
|
end
|
1153
1627
|
|
1154
1628
|
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1155
|
-
|
1629
|
+
expected = <<-EOS
|
1630
|
+
<div class="bibpaper">
|
1631
|
+
<a id="bib-samplebib">[1]</a> sample bib <b>bold</b>
|
1632
|
+
<p>ab</p></div>
|
1633
|
+
EOS
|
1634
|
+
assert_equal expected, actual
|
1635
|
+
|
1636
|
+
@book.config['join_lines_by_lang'] = true
|
1637
|
+
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1638
|
+
expected = <<-EOS
|
1639
|
+
<div class="bibpaper">
|
1640
|
+
<a id="bib-samplebib">[1]</a> sample bib <b>bold</b>
|
1641
|
+
<p>a b</p></div>
|
1642
|
+
EOS
|
1643
|
+
assert_equal expected, actual
|
1156
1644
|
end
|
1157
1645
|
|
1158
1646
|
def test_bibpaper_normalized
|
1159
1647
|
def @chapter.bibpaper(_id)
|
1160
|
-
Book::
|
1648
|
+
Book::Index::Item.new('sample=bib', 1, 'sample bib')
|
1161
1649
|
end
|
1162
1650
|
|
1163
1651
|
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1164
|
-
|
1652
|
+
expected = <<-EOS
|
1653
|
+
<div class="bibpaper">
|
1654
|
+
<a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>
|
1655
|
+
<p>ab</p></div>
|
1656
|
+
EOS
|
1657
|
+
assert_equal expected, actual
|
1658
|
+
|
1659
|
+
@book.config['join_lines_by_lang'] = true
|
1660
|
+
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1661
|
+
expected = <<-EOS
|
1662
|
+
<div class="bibpaper">
|
1663
|
+
<a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>
|
1664
|
+
<p>a b</p></div>
|
1665
|
+
EOS
|
1666
|
+
assert_equal expected, actual
|
1165
1667
|
end
|
1166
1668
|
|
1167
1669
|
def test_bibpaper_with_anchor
|
1168
1670
|
def @chapter.bibpaper(_id)
|
1169
|
-
Book::
|
1671
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1170
1672
|
end
|
1171
1673
|
|
1172
1674
|
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
1173
|
-
|
1675
|
+
expected = <<-EOS
|
1676
|
+
<div class="bibpaper">
|
1677
|
+
<a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>
|
1678
|
+
<p>ab</p></div>
|
1679
|
+
EOS
|
1680
|
+
assert_equal expected, actual
|
1681
|
+
|
1682
|
+
@book.config['join_lines_by_lang'] = true
|
1683
|
+
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
1684
|
+
expected = <<-EOS
|
1685
|
+
<div class="bibpaper">
|
1686
|
+
<a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>
|
1687
|
+
<p>a b</p></div>
|
1688
|
+
EOS
|
1689
|
+
assert_equal expected, actual
|
1174
1690
|
end
|
1175
1691
|
|
1176
1692
|
def column_helper(review)
|
@@ -1264,8 +1780,10 @@ EOS
|
|
1264
1780
|
|
1265
1781
|
def test_column_in_aother_chapter_ref
|
1266
1782
|
def @chapter.column_index
|
1267
|
-
|
1268
|
-
Book::ColumnIndex.new
|
1783
|
+
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
1784
|
+
idx = Book::ColumnIndex.new
|
1785
|
+
idx.add_item(item)
|
1786
|
+
idx
|
1269
1787
|
end
|
1270
1788
|
|
1271
1789
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
@@ -1278,7 +1796,12 @@ EOS
|
|
1278
1796
|
* AAA
|
1279
1797
|
* BBB
|
1280
1798
|
EOS
|
1281
|
-
expected =
|
1799
|
+
expected = <<-EOS
|
1800
|
+
<ul>
|
1801
|
+
<li>AAA</li>
|
1802
|
+
<li>BBB</li>
|
1803
|
+
</ul>
|
1804
|
+
EOS
|
1282
1805
|
actual = compile_block(src)
|
1283
1806
|
assert_equal expected, actual
|
1284
1807
|
end
|
@@ -1290,7 +1813,22 @@ EOS
|
|
1290
1813
|
* BBB
|
1291
1814
|
-BB
|
1292
1815
|
EOS
|
1293
|
-
expected =
|
1816
|
+
expected = <<-EOS
|
1817
|
+
<ul>
|
1818
|
+
<li>AAA-AA</li>
|
1819
|
+
<li>BBB-BB</li>
|
1820
|
+
</ul>
|
1821
|
+
EOS
|
1822
|
+
actual = compile_block(src)
|
1823
|
+
assert_equal expected, actual
|
1824
|
+
|
1825
|
+
@book.config['join_lines_by_lang'] = true
|
1826
|
+
expected = <<-EOS
|
1827
|
+
<ul>
|
1828
|
+
<li>AAA -AA</li>
|
1829
|
+
<li>BBB -BB</li>
|
1830
|
+
</ul>
|
1831
|
+
EOS
|
1294
1832
|
actual = compile_block(src)
|
1295
1833
|
assert_equal expected, actual
|
1296
1834
|
end
|
@@ -1341,25 +1879,10 @@ EOS
|
|
1341
1879
|
src = <<-EOS
|
1342
1880
|
** AAA
|
1343
1881
|
* AA
|
1344
|
-
* BBB
|
1345
|
-
** BB
|
1346
1882
|
EOS
|
1347
1883
|
|
1348
|
-
|
1349
|
-
|
1350
|
-
<li><ul>
|
1351
|
-
<li>AAA</li>
|
1352
|
-
</ul>
|
1353
|
-
</li>
|
1354
|
-
<li>AA</li>
|
1355
|
-
<li>BBB<ul>
|
1356
|
-
<li>BB</li>
|
1357
|
-
</ul>
|
1358
|
-
</li>
|
1359
|
-
</ul>
|
1360
|
-
EOS
|
1361
|
-
actual = compile_block(src)
|
1362
|
-
assert_equal expected, actual
|
1884
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1885
|
+
assert_equal ':1: error: too many *.', e.message
|
1363
1886
|
end
|
1364
1887
|
|
1365
1888
|
def test_ul_nest4
|
@@ -1390,37 +1913,6 @@ EOS
|
|
1390
1913
|
assert_equal expected, actual
|
1391
1914
|
end
|
1392
1915
|
|
1393
|
-
def test_ul_nest5
|
1394
|
-
src = <<-EOS
|
1395
|
-
* A
|
1396
|
-
** AA
|
1397
|
-
**** AAAA
|
1398
|
-
* B
|
1399
|
-
** BB
|
1400
|
-
EOS
|
1401
|
-
|
1402
|
-
expected = <<-EOS
|
1403
|
-
<ul>
|
1404
|
-
<li>A<ul>
|
1405
|
-
<li>AA<ul>
|
1406
|
-
<li><ul>
|
1407
|
-
<li>AAAA</li>
|
1408
|
-
</ul>
|
1409
|
-
</li>
|
1410
|
-
</ul>
|
1411
|
-
</li>
|
1412
|
-
</ul>
|
1413
|
-
</li>
|
1414
|
-
<li>B<ul>
|
1415
|
-
<li>BB</li>
|
1416
|
-
</ul>
|
1417
|
-
</li>
|
1418
|
-
</ul>
|
1419
|
-
EOS
|
1420
|
-
actual = compile_block(src)
|
1421
|
-
assert_equal expected, actual
|
1422
|
-
end
|
1423
|
-
|
1424
1916
|
def test_ol
|
1425
1917
|
src = <<-EOS
|
1426
1918
|
3. AAA
|
@@ -1590,17 +2082,33 @@ EOS
|
|
1590
2082
|
assert_equal expected, actual
|
1591
2083
|
end
|
1592
2084
|
|
1593
|
-
def
|
2085
|
+
def test_footnote
|
1594
2086
|
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
|
1595
2087
|
@chapter.instance_eval { @footnote_index = fn }
|
1596
2088
|
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
1597
2089
|
expected = <<-'EOS'
|
1598
2090
|
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote">[*1] bar\a\$buz</p></div>
|
2091
|
+
EOS
|
2092
|
+
assert_equal expected, actual
|
2093
|
+
|
2094
|
+
@book.config['epubmaker'] ||= {}
|
2095
|
+
@book.config['epubmaker']['back_footnote'] = true
|
2096
|
+
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
2097
|
+
expected = <<-'EOS'
|
2098
|
+
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote"><a href="#fnb-foo">⏎</a>[*1] bar\a\$buz</p></div>
|
2099
|
+
EOS
|
2100
|
+
assert_equal expected, actual
|
2101
|
+
|
2102
|
+
I18n.set('html_footnote_textmark', '+%s:')
|
2103
|
+
I18n.set('html_footnote_backmark', '←')
|
2104
|
+
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
2105
|
+
expected = <<-'EOS'
|
2106
|
+
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote"><a href="#fnb-foo">←</a>+1:bar\a\$buz</p></div>
|
1599
2107
|
EOS
|
1600
2108
|
assert_equal expected, actual
|
1601
2109
|
end
|
1602
2110
|
|
1603
|
-
def
|
2111
|
+
def test_footnote_with_tricky_id
|
1604
2112
|
fn = Book::FootnoteIndex.parse(['//footnote[123 あ_;][bar\\a\\$buz]'])
|
1605
2113
|
@chapter.instance_eval { @footnote_index = fn }
|
1606
2114
|
actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
|
@@ -1610,6 +2118,22 @@ EOS
|
|
1610
2118
|
assert_equal expected, actual
|
1611
2119
|
end
|
1612
2120
|
|
2121
|
+
def test_inline_fn
|
2122
|
+
book = ReVIEW::Book::Base.load
|
2123
|
+
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re])
|
2124
|
+
io1 = StringIO.new("//footnote[foo][bar]\n")
|
2125
|
+
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
2126
|
+
book.parts = [ReVIEW::Book::Part.new(self, nil, [chap1])]
|
2127
|
+
builder = ReVIEW::HTMLBuilder.new
|
2128
|
+
comp = ReVIEW::Compiler.new(builder)
|
2129
|
+
builder.bind(comp, chap1, nil)
|
2130
|
+
fn = builder.inline_fn('foo')
|
2131
|
+
assert_equal '<a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a>', fn
|
2132
|
+
I18n.set('html_footnote_refmark', '+%s')
|
2133
|
+
fn = builder.inline_fn('foo')
|
2134
|
+
assert_equal '<a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">+1</a>', fn
|
2135
|
+
end
|
2136
|
+
|
1613
2137
|
def test_inline_hd
|
1614
2138
|
book = ReVIEW::Book::Base.load
|
1615
2139
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
@@ -1654,13 +2178,53 @@ EOS
|
|
1654
2178
|
|
1655
2179
|
def test_table
|
1656
2180
|
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1657
|
-
|
1658
|
-
|
2181
|
+
expected = <<-EOS
|
2182
|
+
<div class="table">
|
2183
|
+
<table>
|
2184
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2185
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2186
|
+
</table>
|
2187
|
+
</div>
|
2188
|
+
EOS
|
2189
|
+
assert_equal expected, actual
|
2190
|
+
|
2191
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2192
|
+
expected = <<-EOS
|
2193
|
+
<div id="foo" class="table">
|
2194
|
+
<p class="caption">表1.1: FOO</p>
|
2195
|
+
<table>
|
2196
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2197
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2198
|
+
</table>
|
2199
|
+
</div>
|
2200
|
+
EOS
|
2201
|
+
assert_equal expected, actual
|
2202
|
+
|
2203
|
+
@config['caption_position']['table'] = 'bottom'
|
2204
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2205
|
+
expected = <<-EOS
|
2206
|
+
<div id="foo" class="table">
|
2207
|
+
<table>
|
2208
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2209
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2210
|
+
</table>
|
2211
|
+
<p class="caption">表1.1: FOO</p>
|
2212
|
+
</div>
|
2213
|
+
EOS
|
2214
|
+
assert_equal expected, actual
|
2215
|
+
end
|
2216
|
+
|
2217
|
+
def test_empty_table
|
2218
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
|
2219
|
+
assert_equal ':2: error: no rows in the table', e.message
|
2220
|
+
|
2221
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
|
2222
|
+
assert_equal ':3: error: no rows in the table', e.message
|
1659
2223
|
end
|
1660
2224
|
|
1661
2225
|
def test_inline_table
|
1662
2226
|
def @chapter.table(_id)
|
1663
|
-
Book::
|
2227
|
+
Book::Index::Item.new('sampletable', 1)
|
1664
2228
|
end
|
1665
2229
|
actual = compile_block("@<table>{sampletest}\n")
|
1666
2230
|
assert_equal %Q(<p><span class="tableref">表1.1</span></p>\n), actual
|
@@ -1668,53 +2232,223 @@ EOS
|
|
1668
2232
|
|
1669
2233
|
def test_emtable
|
1670
2234
|
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1671
|
-
|
1672
|
-
|
2235
|
+
expected = <<-EOS
|
2236
|
+
<div class="table">
|
2237
|
+
<p class="caption">foo</p>
|
2238
|
+
<table>
|
2239
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2240
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2241
|
+
</table>
|
2242
|
+
</div>
|
2243
|
+
<div class="table">
|
2244
|
+
<table>
|
2245
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2246
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2247
|
+
</table>
|
2248
|
+
</div>
|
2249
|
+
EOS
|
2250
|
+
assert_equal expected, actual
|
2251
|
+
|
2252
|
+
@config['caption_position']['table'] = 'bottom'
|
2253
|
+
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2254
|
+
expected = <<-EOS
|
2255
|
+
<div class="table">
|
2256
|
+
<table>
|
2257
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2258
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2259
|
+
</table>
|
2260
|
+
<p class="caption">foo</p>
|
2261
|
+
</div>
|
2262
|
+
<div class="table">
|
2263
|
+
<table>
|
2264
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2265
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2266
|
+
</table>
|
2267
|
+
</div>
|
2268
|
+
EOS
|
2269
|
+
assert_equal expected, actual
|
1673
2270
|
end
|
1674
2271
|
|
1675
2272
|
def test_imgtable
|
1676
2273
|
def @chapter.image(_id)
|
1677
|
-
item = Book::
|
2274
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
|
1678
2275
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1679
2276
|
item
|
1680
2277
|
end
|
1681
2278
|
|
1682
2279
|
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
1683
|
-
expected =
|
2280
|
+
expected = <<-EOS
|
2281
|
+
<div id="sampleimg" class="imgtable image">
|
2282
|
+
<p class="caption">表1.1: test for imgtable</p>
|
2283
|
+
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2284
|
+
</div>
|
2285
|
+
EOS
|
2286
|
+
assert_equal expected, actual
|
2287
|
+
|
2288
|
+
@config['caption_position']['table'] = 'bottom'
|
2289
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
2290
|
+
expected = <<-EOS
|
2291
|
+
<div id="sampleimg" class="imgtable image">
|
2292
|
+
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2293
|
+
<p class="caption">表1.1: test for imgtable</p>
|
2294
|
+
</div>
|
2295
|
+
EOS
|
2296
|
+
assert_equal expected, actual
|
2297
|
+
end
|
2298
|
+
|
2299
|
+
def test_table_row_separator
|
2300
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
2301
|
+
expected = <<-EOS
|
2302
|
+
<div class="table">
|
2303
|
+
<table>
|
2304
|
+
<tr><th>1</th><th>2</th><th>3 4| 5</th></tr>
|
2305
|
+
<tr><td>a b</td><td>c d |e</td><td></td></tr>
|
2306
|
+
</table>
|
2307
|
+
</div>
|
2308
|
+
EOS
|
2309
|
+
actual = compile_block(src)
|
2310
|
+
assert_equal expected, actual
|
2311
|
+
|
2312
|
+
@config['table_row_separator'] = 'singletab'
|
2313
|
+
actual = compile_block(src)
|
2314
|
+
expected = <<-EOS
|
2315
|
+
<div class="table">
|
2316
|
+
<table>
|
2317
|
+
<tr><th>1</th><th>2</th><th></th><th>3 4| 5</th></tr>
|
2318
|
+
<tr><td>a b</td><td>c d |e</td><td></td><td></td></tr>
|
2319
|
+
</table>
|
2320
|
+
</div>
|
2321
|
+
EOS
|
2322
|
+
assert_equal expected, actual
|
2323
|
+
|
2324
|
+
@config['table_row_separator'] = 'spaces'
|
2325
|
+
actual = compile_block(src)
|
2326
|
+
expected = <<-EOS
|
2327
|
+
<div class="table">
|
2328
|
+
<table>
|
2329
|
+
<tr><th>1</th><th>2</th><th>3</th><th>4|</th><th>5</th></tr>
|
2330
|
+
<tr><td>a</td><td>b</td><td>c</td><td>d</td><td>|e</td></tr>
|
2331
|
+
</table>
|
2332
|
+
</div>
|
2333
|
+
EOS
|
2334
|
+
assert_equal expected, actual
|
2335
|
+
|
2336
|
+
@config['table_row_separator'] = 'verticalbar'
|
2337
|
+
actual = compile_block(src)
|
2338
|
+
expected = <<-EOS
|
2339
|
+
<div class="table">
|
2340
|
+
<table>
|
2341
|
+
<tr><th>1 2 3 4</th><th>5</th></tr>
|
2342
|
+
<tr><td>a b c d</td><td>e</td></tr>
|
2343
|
+
</table>
|
2344
|
+
</div>
|
2345
|
+
EOS
|
1684
2346
|
assert_equal expected, actual
|
1685
2347
|
end
|
1686
2348
|
|
1687
2349
|
def test_major_blocks
|
1688
2350
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
1689
|
-
expected =
|
2351
|
+
expected = <<-EOS
|
2352
|
+
<div class="note">
|
2353
|
+
<p>A</p>
|
2354
|
+
<p>B</p>
|
2355
|
+
</div>
|
2356
|
+
<div class="note">
|
2357
|
+
<p class="caption">caption</p>
|
2358
|
+
<p>A</p>
|
2359
|
+
</div>
|
2360
|
+
EOS
|
1690
2361
|
assert_equal expected, actual
|
1691
2362
|
|
1692
2363
|
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
1693
|
-
expected =
|
2364
|
+
expected = <<-EOS
|
2365
|
+
<div class="memo">
|
2366
|
+
<p>A</p>
|
2367
|
+
<p>B</p>
|
2368
|
+
</div>
|
2369
|
+
<div class="memo">
|
2370
|
+
<p class="caption">caption</p>
|
2371
|
+
<p>A</p>
|
2372
|
+
</div>
|
2373
|
+
EOS
|
1694
2374
|
assert_equal expected, actual
|
1695
2375
|
|
1696
2376
|
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
1697
|
-
expected =
|
2377
|
+
expected = <<-EOS
|
2378
|
+
<div class="info">
|
2379
|
+
<p>A</p>
|
2380
|
+
<p>B</p>
|
2381
|
+
</div>
|
2382
|
+
<div class="info">
|
2383
|
+
<p class="caption">caption</p>
|
2384
|
+
<p>A</p>
|
2385
|
+
</div>
|
2386
|
+
EOS
|
1698
2387
|
assert_equal expected, actual
|
1699
2388
|
|
1700
2389
|
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
1701
|
-
expected =
|
2390
|
+
expected = <<-EOS
|
2391
|
+
<div class="important">
|
2392
|
+
<p>A</p>
|
2393
|
+
<p>B</p>
|
2394
|
+
</div>
|
2395
|
+
<div class="important">
|
2396
|
+
<p class="caption">caption</p>
|
2397
|
+
<p>A</p>
|
2398
|
+
</div>
|
2399
|
+
EOS
|
1702
2400
|
assert_equal expected, actual
|
1703
2401
|
|
1704
2402
|
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
1705
|
-
expected =
|
2403
|
+
expected = <<-EOS
|
2404
|
+
<div class="caution">
|
2405
|
+
<p>A</p>
|
2406
|
+
<p>B</p>
|
2407
|
+
</div>
|
2408
|
+
<div class="caution">
|
2409
|
+
<p class="caption">caption</p>
|
2410
|
+
<p>A</p>
|
2411
|
+
</div>
|
2412
|
+
EOS
|
1706
2413
|
assert_equal expected, actual
|
1707
2414
|
|
1708
2415
|
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
1709
|
-
expected =
|
2416
|
+
expected = <<-EOS
|
2417
|
+
<div class="notice">
|
2418
|
+
<p>A</p>
|
2419
|
+
<p>B</p>
|
2420
|
+
</div>
|
2421
|
+
<div class="notice">
|
2422
|
+
<p class="caption">caption</p>
|
2423
|
+
<p>A</p>
|
2424
|
+
</div>
|
2425
|
+
EOS
|
1710
2426
|
assert_equal expected, actual
|
1711
2427
|
|
1712
2428
|
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
1713
|
-
expected =
|
2429
|
+
expected = <<-EOS
|
2430
|
+
<div class="warning">
|
2431
|
+
<p>A</p>
|
2432
|
+
<p>B</p>
|
2433
|
+
</div>
|
2434
|
+
<div class="warning">
|
2435
|
+
<p class="caption">caption</p>
|
2436
|
+
<p>A</p>
|
2437
|
+
</div>
|
2438
|
+
EOS
|
1714
2439
|
assert_equal expected, actual
|
1715
2440
|
|
1716
2441
|
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
1717
|
-
expected =
|
2442
|
+
expected = <<-EOS
|
2443
|
+
<div class="tip">
|
2444
|
+
<p>A</p>
|
2445
|
+
<p>B</p>
|
2446
|
+
</div>
|
2447
|
+
<div class="tip">
|
2448
|
+
<p class="caption">caption</p>
|
2449
|
+
<p>A</p>
|
2450
|
+
</div>
|
2451
|
+
EOS
|
1718
2452
|
assert_equal expected, actual
|
1719
2453
|
end
|
1720
2454
|
|
@@ -1725,8 +2459,10 @@ EOS
|
|
1725
2459
|
|
1726
2460
|
def test_comment_for_draft
|
1727
2461
|
@config['draft'] = true
|
1728
|
-
actual = compile_block('//comment[
|
1729
|
-
assert_equal %Q(<div class="draft-comment"
|
2462
|
+
actual = compile_block('//comment[コメント<]')
|
2463
|
+
assert_equal %Q(<div class="draft-comment">コメント<</div>\n), actual
|
2464
|
+
actual = compile_block("//comment{\nA<>\nB&\n//}")
|
2465
|
+
assert_equal %Q(<div class="draft-comment">A<><br />B&</div>\n), actual
|
1730
2466
|
end
|
1731
2467
|
|
1732
2468
|
def test_inline_comment
|
@@ -1758,7 +2494,7 @@ EOB
|
|
1758
2494
|
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
1759
2495
|
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
1760
2496
|
assert_equal %Q(<p>foo bar"\\<>_@<b>{BAZ} <b>bar"\\<>_@<b>{BAZ}</b> [missing word: N]</p>\n), actual
|
1761
|
-
assert_match(/WARN
|
2497
|
+
assert_match(/WARN --: :1: word not bound: N/, io.string)
|
1762
2498
|
end
|
1763
2499
|
end
|
1764
2500
|
|
@@ -1812,6 +2548,20 @@ EOS
|
|
1812
2548
|
</pre>
|
1813
2549
|
</div>
|
1814
2550
|
</div>
|
2551
|
+
EOS
|
2552
|
+
actual = compile_block(src)
|
2553
|
+
assert_equal expected, actual
|
2554
|
+
|
2555
|
+
@config['caption_position']['equation'] = 'bottom'
|
2556
|
+
expected = <<-EOS
|
2557
|
+
<p><span class="eqref">式1.1</span></p>
|
2558
|
+
<div id="emc2" class="caption-equation">
|
2559
|
+
<div class="equation">
|
2560
|
+
<pre>e=mc^2
|
2561
|
+
</pre>
|
2562
|
+
</div>
|
2563
|
+
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2564
|
+
</div>
|
1815
2565
|
EOS
|
1816
2566
|
actual = compile_block(src)
|
1817
2567
|
assert_equal expected, actual
|