review 3.1.0 → 5.0.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 +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +161 -34
- data/.travis.yml +16 -15
- data/Dockerfile +21 -5
- data/NEWS.ja.md +394 -0
- data/NEWS.md +395 -1
- data/README.md +10 -7
- data/appveyor.yml +1 -3
- data/bin/review-catalog-converter +5 -5
- data/bin/review-check +10 -12
- data/bin/review-checkdep +2 -2
- data/bin/review-compile +17 -23
- data/bin/review-epubmaker +3 -35
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +2 -89
- data/bin/review-preproc +13 -13
- data/bin/review-validate +4 -4
- data/bin/review-vol +4 -78
- data/doc/config.yml.sample +47 -12
- data/doc/config.yml.sample-simple +3 -2
- data/doc/format.ja.md +120 -17
- data/doc/format.md +119 -27
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- data/doc/quickstart.ja.md +45 -25
- data/doc/quickstart.md +37 -16
- data/lib/epubmaker/content.rb +3 -2
- data/lib/epubmaker/epubcommon.rb +34 -27
- data/lib/epubmaker/epubv2.rb +5 -6
- data/lib/epubmaker/epubv3.rb +21 -18
- data/lib/epubmaker/producer.rb +2 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +91 -96
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +155 -0
- data/lib/review/book/chapter.rb +48 -29
- data/lib/review/book/index.rb +46 -240
- data/lib/review/book/index/item.rb +46 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +45 -10
- data/lib/review/book/volume.rb +4 -5
- data/lib/review/builder.rb +172 -56
- data/lib/review/catalog.rb +14 -17
- data/lib/review/compiler.rb +219 -121
- data/lib/review/configure.rb +39 -7
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +43 -5
- data/lib/review/epubmaker.rb +69 -27
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +112 -101
- data/lib/review/htmlutils.rb +9 -13
- data/lib/review/i18n.rb +3 -3
- data/lib/review/idgxmlbuilder.rb +202 -78
- data/lib/review/idgxmlmaker.rb +186 -0
- data/lib/review/index_builder.rb +653 -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 +129 -46
- data/lib/review/latexbuilder.rb +255 -92
- 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 +35 -5
- data/lib/review/markdownbuilder.rb +50 -38
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +60 -57
- data/lib/review/plaintextbuilder.rb +154 -87
- data/lib/review/preprocessor.rb +20 -42
- data/lib/review/rstbuilder.rb +57 -38
- data/lib/review/sec_counter.rb +13 -0
- data/lib/review/textmaker.rb +23 -15
- data/lib/review/textutils.rb +76 -2
- data/lib/review/tocprinter.rb +230 -102
- data/lib/review/topbuilder.rb +139 -60
- data/lib/review/update.rb +24 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +98 -0
- data/lib/review/webmaker.rb +20 -24
- 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/Gemfile +1 -1
- 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 +39 -25
- data/templates/latex/layout.tex.erb +1 -0
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +161 -50
- data/templates/latex/review-jlreq/review-jlreq.cls +21 -22
- data/templates/latex/review-jlreq/review-style.sty +4 -1
- data/templates/latex/review-jsbook/README.md +46 -5
- data/templates/latex/review-jsbook/review-base.sty +123 -35
- data/templates/latex/review-jsbook/review-jsbook.cls +10 -4
- 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 +3 -3
- data/test/assets/test_template.tex +19 -7
- data/test/assets/test_template_backmatter.tex +19 -7
- data/test/book_test_helper.rb +11 -5
- data/test/test_book.rb +124 -79
- data/test/test_book_chapter.rb +97 -54
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +38 -13
- data/test/test_catalog.rb +24 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +2 -2
- data/test/test_epubmaker.rb +8 -0
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +18 -7
- data/test/test_htmlbuilder.rb +1491 -205
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +37 -37
- data/test/test_idgxmlbuilder.rb +744 -42
- data/test/test_idgxmlmaker_cmd.rb +46 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_index.rb +94 -44
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +1784 -161
- data/test/test_latexbuilder_v2.rb +671 -102
- data/test/test_logger.rb +17 -4
- data/test/test_makerhelper.rb +2 -14
- data/test/test_markdownbuilder.rb +137 -16
- data/test/test_md2inaobuilder.rb +32 -9
- data/test/test_pdfmaker.rb +30 -12
- data/test/test_pdfmaker_cmd.rb +100 -6
- data/test/test_plaintextbuilder.rb +791 -30
- data/test/test_preprocessor.rb +2 -16
- data/test/test_review_ext.rb +2 -1
- data/test/test_rstbuilder.rb +274 -27
- data/test/test_sec_counter.rb +156 -0
- data/test/test_textmaker_cmd.rb +54 -0
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +724 -34
- data/test/test_update.rb +20 -11
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_yamlloader.rb +13 -0
- data/vendor/gentombow/LICENSE +1 -1
- data/vendor/gentombow/Makefile +0 -1
- data/vendor/gentombow/bounddvi-en.pdf +0 -0
- data/vendor/gentombow/bounddvi-en.tex +1 -0
- data/vendor/gentombow/bounddvi.pdf +0 -0
- data/vendor/gentombow/bounddvi.sty +30 -7
- data/vendor/gentombow/bounddvi.tex +1 -0
- data/vendor/gentombow/create_archive.sh +1 -0
- data/vendor/gentombow/gentombow-ja.pdf +0 -0
- data/vendor/gentombow/gentombow-ja.tex +9 -0
- data/vendor/gentombow/gentombow.pdf +0 -0
- data/vendor/gentombow/gentombow.sty +32 -10
- data/vendor/gentombow/gentombow.tex +8 -0
- data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
- data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +74 -31
- data/vendor/jsclasses/jis/jsbook.cls +74 -31
- data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +4 -16
- data/vendor/jsclasses/jis/jspf.cls +73 -30
- data/vendor/jsclasses/jis/jsreport.cls +74 -31
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +74 -31
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +4 -17
- data/vendor/jsclasses/jis/okuverb.ins +9 -0
- data/vendor/jsclasses/jis/okuverb.sty +1 -13
- data/vendor/jsclasses/jis/winjis.sty +23 -19
- data/vendor/jsclasses/jsarticle.cls +74 -31
- data/vendor/jsclasses/jsbook.cls +74 -31
- data/vendor/jsclasses/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +4 -16
- data/vendor/jsclasses/jspf.cls +73 -30
- data/vendor/jsclasses/jsreport.cls +74 -31
- data/vendor/jsclasses/jsverb.ins +9 -0
- data/vendor/jsclasses/jsverb.pdf +0 -0
- data/vendor/jsclasses/jsverb.sty +1 -13
- data/vendor/jsclasses/kiyou.cls +74 -31
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +4 -17
- data/vendor/jsclasses/okuverb.ins +9 -0
- data/vendor/jsclasses/okuverb.pdf +0 -0
- data/vendor/jsclasses/okuverb.sty +1 -13
- data/vendor/jsclasses/tests/relfont.tex +10 -0
- data/vendor/jsclasses/winjis.sty +23 -19
- metadata +65 -12
- data/.rubocop_todo.yml +0 -7
- data/lib/review/book/compilable.rb +0 -173
- 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_converter.rb
CHANGED
data/test/test_epub3maker.rb
CHANGED
@@ -631,7 +631,7 @@ EOT
|
|
631
631
|
</body>
|
632
632
|
</html>
|
633
633
|
EOT
|
634
|
-
File.
|
634
|
+
File.write(path, html)
|
635
635
|
assert_equal ['mathml'], epubmaker.detect_properties(path)
|
636
636
|
end
|
637
637
|
end
|
@@ -656,7 +656,7 @@ EOT
|
|
656
656
|
</body>
|
657
657
|
</html>
|
658
658
|
EOT
|
659
|
-
File.
|
659
|
+
File.write(path, html)
|
660
660
|
assert_equal ['mathml'], epubmaker.detect_properties(path)
|
661
661
|
end
|
662
662
|
end
|
data/test/test_epubmaker.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'epubmaker'
|
3
|
+
require 'review/epubmaker'
|
3
4
|
|
4
5
|
class EPUBMakerTest < Test::Unit::TestCase
|
5
6
|
include EPUBMaker
|
@@ -818,4 +819,11 @@ EOT
|
|
818
819
|
EOT
|
819
820
|
assert_equal expect, @output.string
|
820
821
|
end
|
822
|
+
|
823
|
+
def test_epub_unsafe_id
|
824
|
+
content = Content.new({ 'file' => 'sample.png' })
|
825
|
+
assert_equal 'sample-png', content.id
|
826
|
+
content = Content.new({ 'file' => 'sample-&()-=+@:,漢字.png' })
|
827
|
+
assert_equal 'sample-_25_26_25_28_25_29-_25_3D_25_2B_25_40_25_3A_25_2C_25_E6_25_BC_25_A2_25_E5_25_AD_25_97-png', content.id
|
828
|
+
end
|
821
829
|
end
|
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)
|
@@ -31,11 +39,13 @@ end
|
|
31
39
|
|
32
40
|
def compile_block_default(text)
|
33
41
|
@chapter.content = text
|
42
|
+
@chapter.execute_indexer(force: true)
|
34
43
|
@compiler.compile(@chapter)
|
35
44
|
end
|
36
45
|
|
37
46
|
def compile_block_html(text)
|
38
47
|
@chapter.content = text
|
48
|
+
@chapter.execute_indexer(force: true)
|
39
49
|
matched = @compiler.compile(@chapter).match(Regexp.new(%Q(<body>\n(.+)</body>), Regexp::MULTILINE))
|
40
50
|
if matched && matched.size > 1
|
41
51
|
matched[1]
|
@@ -46,5 +56,6 @@ end
|
|
46
56
|
|
47
57
|
def compile_block_idgxml(text)
|
48
58
|
@chapter.content = text
|
59
|
+
@chapter.execute_indexer(force: true)
|
49
60
|
@compiler.compile(@chapter).gsub(Regexp.new(%Q(.*<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">), Regexp::MULTILINE), '').gsub("</doc>\n", '')
|
50
61
|
end
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -61,7 +61,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
61
61
|
Dir.mktmpdir do |dir|
|
62
62
|
Dir.chdir(dir) do
|
63
63
|
file = File.join(dir, 'locale.yml')
|
64
|
-
File.
|
64
|
+
File.write(file, "locale: ja\nappendix: 付録%pR")
|
65
65
|
I18n.setup('ja')
|
66
66
|
@chapter.instance_eval do
|
67
67
|
def on_appendix?
|
@@ -82,7 +82,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
82
82
|
Dir.mktmpdir do |dir|
|
83
83
|
Dir.chdir(dir) do
|
84
84
|
file = File.join(dir, 'locale.yml')
|
85
|
-
File.
|
85
|
+
File.write(file, "locale: ja\nappendix: 付録%pA")
|
86
86
|
I18n.setup('ja')
|
87
87
|
@chapter.instance_eval do
|
88
88
|
def on_appendix?
|
@@ -106,8 +106,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def test_headline_level1_with_tricky_id
|
109
|
-
actual = compile_block("={123
|
110
|
-
assert_equal %Q(<h1 id="
|
109
|
+
actual = compile_block("={123あ_} this is test.\n")
|
110
|
+
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
|
111
111
|
end
|
112
112
|
|
113
113
|
def test_headline_level1_with_inlinetag
|
@@ -137,8 +137,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def test_label_with_tricky_id
|
140
|
-
actual = compile_block("//label[123
|
141
|
-
assert_equal %Q(<a id="
|
140
|
+
actual = compile_block("//label[123あ_]\n")
|
141
|
+
assert_equal %Q(<a id="id_123_E3_81_82__"></a>\n), actual
|
142
142
|
end
|
143
143
|
|
144
144
|
def test_href
|
@@ -191,7 +191,15 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
191
191
|
|
192
192
|
def test_inline_in_table
|
193
193
|
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
194
|
-
|
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
|
195
203
|
end
|
196
204
|
|
197
205
|
def test_inline_br
|
@@ -236,10 +244,21 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
236
244
|
|
237
245
|
def test_inline_hd_chap
|
238
246
|
def @chapter.headline_index
|
239
|
-
|
240
|
-
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
|
241
251
|
end
|
242
252
|
|
253
|
+
@config['secnolevel'] = 2
|
254
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
255
|
+
assert_equal 'test <a href="-.html#h1-1-1">「te_st」</a> test2', actual
|
256
|
+
|
257
|
+
@config['secnolevel'] = 3
|
258
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
259
|
+
assert_equal 'test <a href="-.html#h1-1-1">「1.1.1 te_st」</a> test2', actual
|
260
|
+
|
261
|
+
@config['chapterlink'] = nil
|
243
262
|
@config['secnolevel'] = 2
|
244
263
|
actual = compile_inline('test @<hd>{chap1|test} test2')
|
245
264
|
assert_equal 'test 「te_st」 test2', actual
|
@@ -253,7 +272,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
253
272
|
Dir.mktmpdir do |dir|
|
254
273
|
Dir.chdir(dir) do
|
255
274
|
file = File.join(dir, 'locale.yml')
|
256
|
-
File.
|
275
|
+
File.write(file, "locale: ja\nappendix: 付録%pR")
|
257
276
|
I18n.setup('ja')
|
258
277
|
@chapter.instance_eval do
|
259
278
|
def on_appendix?
|
@@ -262,10 +281,16 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
262
281
|
end
|
263
282
|
|
264
283
|
def @chapter.headline_index
|
265
|
-
|
266
|
-
Book::HeadlineIndex.new(
|
284
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
285
|
+
idx = Book::HeadlineIndex.new(self)
|
286
|
+
idx.add_item(item)
|
287
|
+
idx
|
267
288
|
end
|
268
289
|
|
290
|
+
actual = compile_inline('test @<hd>{test} test2')
|
291
|
+
assert_equal 'test <a href="-.html#hI-1">「I.1 te_st」</a> test2', actual
|
292
|
+
|
293
|
+
@config['chapterlink'] = nil
|
269
294
|
actual = compile_inline('test @<hd>{test} test2')
|
270
295
|
assert_equal 'test 「I.1 te_st」 test2', actual
|
271
296
|
end
|
@@ -276,7 +301,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
276
301
|
Dir.mktmpdir do |dir|
|
277
302
|
Dir.chdir(dir) do
|
278
303
|
file = File.join(dir, 'locale.yml')
|
279
|
-
File.
|
304
|
+
File.write(file, "locale: ja\nappendix: 付録%pA")
|
280
305
|
I18n.setup('ja')
|
281
306
|
@chapter.instance_eval do
|
282
307
|
def on_appendix?
|
@@ -285,10 +310,16 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
285
310
|
end
|
286
311
|
|
287
312
|
def @chapter.headline_index
|
288
|
-
|
289
|
-
Book::HeadlineIndex.new(
|
313
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
314
|
+
idx = Book::HeadlineIndex.new(self)
|
315
|
+
idx.add_item(item)
|
316
|
+
idx
|
290
317
|
end
|
291
318
|
|
319
|
+
actual = compile_inline('test @<hd>{test} test2')
|
320
|
+
assert_equal 'test <a href="-.html#hA-1">「A.1 te_st」</a> test2', actual
|
321
|
+
|
322
|
+
@config['chapterlink'] = nil
|
292
323
|
actual = compile_inline('test @<hd>{test} test2')
|
293
324
|
assert_equal 'test 「A.1 te_st」 test2', actual
|
294
325
|
end
|
@@ -335,36 +366,51 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
335
366
|
|
336
367
|
def test_inline_img
|
337
368
|
def @chapter.image(_id)
|
338
|
-
item = Book::
|
369
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
339
370
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
340
371
|
item
|
341
372
|
end
|
342
373
|
|
343
|
-
actual = compile_block
|
374
|
+
actual = compile_block("@<img>{sampleimg}\n")
|
375
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
376
|
+
assert_equal expected, actual
|
377
|
+
|
378
|
+
@config['chapterlink'] = nil
|
379
|
+
actual = compile_block("@<img>{sampleimg}\n")
|
344
380
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
345
381
|
assert_equal expected, actual
|
346
382
|
end
|
347
383
|
|
348
384
|
def test_inline_imgref
|
349
385
|
def @chapter.image(_id)
|
350
|
-
item = Book::
|
386
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
351
387
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
352
388
|
item
|
353
389
|
end
|
354
390
|
|
355
|
-
actual = compile_block
|
391
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
392
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span>「sample photo」</p>\n)
|
393
|
+
assert_equal expected, actual
|
394
|
+
|
395
|
+
@config['chapterlink'] = nil
|
396
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
356
397
|
expected = %Q(<p><span class="imgref">図1.1</span>「sample photo」</p>\n)
|
357
398
|
assert_equal expected, actual
|
358
399
|
end
|
359
400
|
|
360
401
|
def test_inline_imgref2
|
361
402
|
def @chapter.image(_id)
|
362
|
-
item = Book::
|
403
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
363
404
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
364
405
|
item
|
365
406
|
end
|
366
407
|
|
367
|
-
actual = compile_block
|
408
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
409
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
410
|
+
assert_equal expected, actual
|
411
|
+
|
412
|
+
@config['chapterlink'] = nil
|
413
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
368
414
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
369
415
|
assert_equal expected, actual
|
370
416
|
end
|
@@ -375,20 +421,24 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
375
421
|
file1 = File.join(dir, 'images', 'img1.png')
|
376
422
|
filet1 = File.join(dir, 'images', 'tbl1.png')
|
377
423
|
file2 = File.join(dir, 'images', 'img2.png')
|
424
|
+
file3 = File.join(dir, 'images', 'icon3.png')
|
378
425
|
re1 = File.join(dir, 'sample1.re')
|
379
426
|
cat = File.join(dir, 'catalog.yml')
|
380
427
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
381
|
-
File.
|
382
|
-
File.
|
383
|
-
File.
|
384
|
-
File.
|
385
|
-
File.
|
428
|
+
File.write(file1, '')
|
429
|
+
File.write(filet1, '')
|
430
|
+
File.write(file2, '')
|
431
|
+
File.write(file3, '')
|
432
|
+
File.write(cat, "CHAPS:\n - sample1.re\n")
|
433
|
+
File.write(re1, <<-EOF)
|
386
434
|
= test
|
387
435
|
|
388
436
|
tbl1 is @<table>{tbl1}.
|
389
437
|
|
390
438
|
img2 is @<img>{img2}.
|
391
439
|
|
440
|
+
icon3 is @<icon>{icon3}.
|
441
|
+
|
392
442
|
//image[img1][image 1]{
|
393
443
|
//}
|
394
444
|
|
@@ -403,8 +453,37 @@ EOF
|
|
403
453
|
|
404
454
|
expected = <<-EOS
|
405
455
|
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
456
|
+
<p>tbl1 is <span class="tableref"><a href="./-.html#tbl1">表1.1</a></span>.</p>
|
457
|
+
<p>img2 is <span class="imgref"><a href="./-.html#img2">図1.2</a></span>.</p>
|
458
|
+
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
459
|
+
<div id="img1" class="image">
|
460
|
+
<img src="images/img1.png" alt="image 1" />
|
461
|
+
<p class="caption">
|
462
|
+
図1.1: image 1
|
463
|
+
</p>
|
464
|
+
</div>
|
465
|
+
<div id="tbl1" class="imgtable image">
|
466
|
+
<p class="caption">表1.1: table 1</p>
|
467
|
+
<img src="images/tbl1.png" alt="table 1" />
|
468
|
+
</div>
|
469
|
+
<div id="img2" class="image">
|
470
|
+
<img src="images/img2.png" alt="image 2" />
|
471
|
+
<p class="caption">
|
472
|
+
図1.2: image 2
|
473
|
+
</p>
|
474
|
+
</div>
|
475
|
+
EOS
|
476
|
+
|
477
|
+
assert_equal expected, actual
|
478
|
+
|
479
|
+
@config['chapterlink'] = nil
|
480
|
+
actual = compile_block(content)
|
481
|
+
|
482
|
+
expected = <<-EOS
|
483
|
+
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
406
484
|
<p>tbl1 is <span class="tableref">表1.1</span>.</p>
|
407
485
|
<p>img2 is <span class="imgref">図1.2</span>.</p>
|
486
|
+
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
408
487
|
<div id="img1" class="image">
|
409
488
|
<img src="images/img1.png" alt="image 1" />
|
410
489
|
<p class="caption">
|
@@ -430,189 +509,443 @@ EOS
|
|
430
509
|
|
431
510
|
def test_quote
|
432
511
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
433
|
-
|
512
|
+
expected = <<-EOS
|
513
|
+
<blockquote><p>foobar</p>
|
514
|
+
<p>buz</p></blockquote>
|
515
|
+
EOS
|
516
|
+
assert_equal expected, actual
|
517
|
+
|
518
|
+
@book.config['join_lines_by_lang'] = true
|
519
|
+
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
520
|
+
expected = <<-EOS
|
521
|
+
<blockquote><p>foo bar</p>
|
522
|
+
<p>buz</p></blockquote>
|
523
|
+
EOS
|
524
|
+
assert_equal expected, actual
|
434
525
|
end
|
435
526
|
|
436
527
|
def test_memo
|
437
528
|
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
438
|
-
|
529
|
+
expected = <<-EOS
|
530
|
+
<div class="memo">
|
531
|
+
<p class="caption">this is <b>test</b><&>_</p>
|
532
|
+
<p>test1</p>
|
533
|
+
<p>test<i>2</i></p>
|
534
|
+
</div>
|
535
|
+
EOS
|
536
|
+
assert_equal expected, actual
|
439
537
|
end
|
440
538
|
|
441
539
|
def test_blankline
|
442
540
|
actual = compile_block("//blankline\nfoo\n")
|
443
|
-
|
541
|
+
expected = <<-EOS
|
542
|
+
<p><br /></p>
|
543
|
+
<p>foo</p>
|
544
|
+
EOS
|
545
|
+
assert_equal expected, actual
|
444
546
|
end
|
445
547
|
|
446
548
|
def test_noindent
|
447
549
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
448
|
-
|
550
|
+
expected = <<-EOS
|
551
|
+
<p class="noindent">foobar</p>
|
552
|
+
<p>foo2bar2</p>
|
553
|
+
EOS
|
554
|
+
assert_equal expected, actual
|
555
|
+
|
556
|
+
@book.config['join_lines_by_lang'] = true
|
557
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
558
|
+
expected = <<-EOS
|
559
|
+
<p class="noindent">foo bar</p>
|
560
|
+
<p>foo2 bar2</p>
|
561
|
+
EOS
|
562
|
+
assert_equal expected, actual
|
449
563
|
end
|
450
564
|
|
451
565
|
def test_flushright
|
452
566
|
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
453
|
-
|
567
|
+
expected = <<-EOS
|
568
|
+
<p class="flushright">foobar</p>
|
569
|
+
<p class="flushright">buz</p>
|
570
|
+
EOS
|
571
|
+
assert_equal expected, actual
|
572
|
+
|
573
|
+
@book.config['join_lines_by_lang'] = true
|
574
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
575
|
+
expected = <<-EOS
|
576
|
+
<p class="flushright">foo bar</p>
|
577
|
+
<p class="flushright">buz</p>
|
578
|
+
EOS
|
579
|
+
assert_equal expected, actual
|
454
580
|
end
|
455
581
|
|
456
582
|
def test_centering
|
457
583
|
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
458
|
-
|
584
|
+
expected = <<-EOS
|
585
|
+
<p class="center">foobar</p>
|
586
|
+
<p class="center">buz</p>
|
587
|
+
EOS
|
588
|
+
assert_equal expected, actual
|
589
|
+
|
590
|
+
@book.config['join_lines_by_lang'] = true
|
591
|
+
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
592
|
+
expected = <<-EOS
|
593
|
+
<p class="center">foo bar</p>
|
594
|
+
<p class="center">buz</p>
|
595
|
+
EOS
|
596
|
+
assert_equal expected, actual
|
459
597
|
end
|
460
598
|
|
461
599
|
def test_image
|
462
600
|
def @chapter.image(_id)
|
463
|
-
item = Book::
|
601
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
464
602
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
465
603
|
item
|
466
604
|
end
|
467
605
|
|
468
606
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
469
|
-
|
607
|
+
expected = <<-EOS
|
608
|
+
<div id="sampleimg" class="image">
|
609
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
610
|
+
<p class="caption">
|
611
|
+
図1.1: sample photo
|
612
|
+
</p>
|
613
|
+
</div>
|
614
|
+
EOS
|
615
|
+
assert_equal expected, actual
|
616
|
+
|
617
|
+
@config['caption_position']['image'] = 'top'
|
618
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
619
|
+
expected = <<-EOS
|
620
|
+
<div id="sampleimg" class="image">
|
621
|
+
<p class="caption">
|
622
|
+
図1.1: sample photo
|
623
|
+
</p>
|
624
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
625
|
+
</div>
|
626
|
+
EOS
|
627
|
+
assert_equal expected, actual
|
470
628
|
end
|
471
629
|
|
472
630
|
def test_image_with_metric
|
473
631
|
def @chapter.image(_id)
|
474
|
-
item = Book::
|
632
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
475
633
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
476
634
|
item
|
477
635
|
end
|
478
636
|
|
479
637
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
480
|
-
|
638
|
+
expected = <<-EOS
|
639
|
+
<div id="sampleimg" class="image">
|
640
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
|
641
|
+
<p class="caption">
|
642
|
+
図1.1: sample photo
|
643
|
+
</p>
|
644
|
+
</div>
|
645
|
+
EOS
|
646
|
+
assert_equal expected, actual
|
481
647
|
end
|
482
648
|
|
483
649
|
def test_image_with_metric2
|
484
650
|
def @chapter.image(_id)
|
485
|
-
item = Book::
|
651
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
486
652
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
487
653
|
item
|
488
654
|
end
|
489
655
|
|
490
656
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
491
|
-
|
657
|
+
expected = <<-EOS
|
658
|
+
<div id="sampleimg" class="image">
|
659
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
|
660
|
+
<p class="caption">
|
661
|
+
図1.1: sample photo
|
662
|
+
</p>
|
663
|
+
</div>
|
664
|
+
EOS
|
665
|
+
assert_equal expected, actual
|
492
666
|
end
|
493
667
|
|
494
|
-
def
|
668
|
+
def test_image_with_tricky_id_kana
|
495
669
|
def @chapter.image(_id)
|
496
|
-
item = Book::
|
497
|
-
item.instance_eval { @path = './images/
|
670
|
+
item = Book::Index::Item.new('123あいう', 1)
|
671
|
+
item.instance_eval { @path = './images/123あいう.png' }
|
498
672
|
item
|
499
673
|
end
|
500
|
-
|
501
|
-
actual = compile_block("//image[123
|
502
|
-
|
674
|
+
@chapter.instance_eval { @name = 'ch01' }
|
675
|
+
actual = compile_block("//image[123あいう][sample photo]{\n//}\nimg: @<img>{123あいう}\n")
|
676
|
+
expected = <<-EOS
|
677
|
+
<div id="id_123_E3_81_82_E3_81_84_E3_81_86" class="image">
|
678
|
+
<img src="images/123あいう.png" alt="sample photo" />
|
679
|
+
<p class="caption">
|
680
|
+
図1.1: sample photo
|
681
|
+
</p>
|
682
|
+
</div>
|
683
|
+
<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>
|
684
|
+
EOS
|
685
|
+
assert_equal expected, actual
|
503
686
|
end
|
504
687
|
|
505
688
|
def test_indepimage
|
506
689
|
def @chapter.image(_id)
|
507
|
-
item = Book::
|
690
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
508
691
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
509
692
|
item
|
510
693
|
end
|
511
694
|
|
512
695
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
513
|
-
|
696
|
+
expected = <<-EOS
|
697
|
+
<div id="sampleimg" class="image">
|
698
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
699
|
+
<p class="caption">
|
700
|
+
図: sample photo
|
701
|
+
</p>
|
702
|
+
</div>
|
703
|
+
EOS
|
704
|
+
assert_equal expected, actual
|
705
|
+
|
706
|
+
@config['caption_position']['image'] = 'top'
|
707
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
708
|
+
expected = <<-EOS
|
709
|
+
<div id="sampleimg" class="image">
|
710
|
+
<p class="caption">
|
711
|
+
図: sample photo
|
712
|
+
</p>
|
713
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
714
|
+
</div>
|
715
|
+
EOS
|
716
|
+
assert_equal expected, actual
|
514
717
|
end
|
515
718
|
|
516
719
|
def test_indepimage_without_caption
|
517
720
|
def @chapter.image(_id)
|
518
|
-
item = Book::
|
721
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
519
722
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
520
723
|
item
|
521
724
|
end
|
522
725
|
|
523
726
|
actual = compile_block("//indepimage[sampleimg]\n")
|
524
|
-
|
727
|
+
expected = <<-EOS
|
728
|
+
<div id="sampleimg" class="image">
|
729
|
+
<img src="images/chap1-sampleimg.png" alt="" />
|
730
|
+
</div>
|
731
|
+
EOS
|
732
|
+
assert_equal expected, actual
|
525
733
|
end
|
526
734
|
|
527
735
|
def test_indepimage_with_metric
|
528
736
|
def @chapter.image(_id)
|
529
|
-
item = Book::
|
737
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
530
738
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
531
739
|
item
|
532
740
|
end
|
533
741
|
|
534
742
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
535
|
-
|
743
|
+
expected = <<-EOS
|
744
|
+
<div id="sampleimg" class="image">
|
745
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
|
746
|
+
<p class="caption">
|
747
|
+
図: sample photo
|
748
|
+
</p>
|
749
|
+
</div>
|
750
|
+
EOS
|
751
|
+
assert_equal expected, actual
|
536
752
|
end
|
537
753
|
|
538
754
|
def test_indepimage_with_metric2
|
539
755
|
def @chapter.image(_id)
|
540
|
-
item = Book::
|
756
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
541
757
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
542
758
|
item
|
543
759
|
end
|
544
760
|
|
545
761
|
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
|
546
|
-
|
762
|
+
expected = <<-EOS
|
763
|
+
<div id="sampleimg" class="image">
|
764
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
|
765
|
+
<p class="caption">
|
766
|
+
図: sample photo
|
767
|
+
</p>
|
768
|
+
</div>
|
769
|
+
EOS
|
770
|
+
assert_equal expected, actual
|
547
771
|
end
|
548
772
|
|
549
773
|
def test_indepimage_without_caption_but_with_metric
|
550
774
|
def @chapter.image(_id)
|
551
|
-
item = Book::
|
775
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
552
776
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
553
777
|
item
|
554
778
|
end
|
555
779
|
|
556
780
|
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
557
|
-
|
781
|
+
expected = <<-EOS
|
782
|
+
<div id="sampleimg" class="image">
|
783
|
+
<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />
|
784
|
+
</div>
|
785
|
+
EOS
|
786
|
+
assert_equal expected, actual
|
558
787
|
end
|
559
788
|
|
560
789
|
def test_dlist
|
561
|
-
actual = compile_block(": foo\n foo.\n bar.\n")
|
562
|
-
|
790
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
791
|
+
expected = <<-EOS
|
792
|
+
<dl>
|
793
|
+
<dt>foo</dt>
|
794
|
+
<dd>foo.bar.</dd>
|
795
|
+
</dl>
|
796
|
+
EOS
|
797
|
+
assert_equal expected, actual
|
798
|
+
|
799
|
+
@book.config['join_lines_by_lang'] = true
|
800
|
+
actual = compile_block(" : foo\n foo.\n bar.\n")
|
801
|
+
expected = <<-EOS
|
802
|
+
<dl>
|
803
|
+
<dt>foo</dt>
|
804
|
+
<dd>foo. bar.</dd>
|
805
|
+
</dl>
|
806
|
+
EOS
|
807
|
+
assert_equal expected, actual
|
563
808
|
end
|
564
809
|
|
565
810
|
def test_dlist_with_bracket
|
566
|
-
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
567
|
-
|
811
|
+
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
812
|
+
expected = <<-EOS
|
813
|
+
<dl>
|
814
|
+
<dt>foo[bar]</dt>
|
815
|
+
<dd>foo.bar.</dd>
|
816
|
+
</dl>
|
817
|
+
EOS
|
818
|
+
assert_equal expected, actual
|
819
|
+
|
820
|
+
@book.config['join_lines_by_lang'] = true
|
821
|
+
actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
|
822
|
+
expected = <<-EOS
|
823
|
+
<dl>
|
824
|
+
<dt>foo[bar]</dt>
|
825
|
+
<dd>foo. bar.</dd>
|
826
|
+
</dl>
|
827
|
+
EOS
|
828
|
+
assert_equal expected, actual
|
568
829
|
end
|
569
830
|
|
570
831
|
def test_dlist_with_comment
|
571
|
-
source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
|
832
|
+
source = " : title\n body\n\#@ comment\n\#@ comment\n : title2\n body2\n"
|
572
833
|
actual = compile_block(source)
|
573
|
-
|
834
|
+
expected = <<-EOS
|
835
|
+
<dl>
|
836
|
+
<dt>title</dt>
|
837
|
+
<dd>body</dd>
|
838
|
+
<dt>title2</dt>
|
839
|
+
<dd>body2</dd>
|
840
|
+
</dl>
|
841
|
+
EOS
|
842
|
+
assert_equal expected, actual
|
574
843
|
end
|
575
844
|
|
576
845
|
def test_dlist_beforeulol
|
577
846
|
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")
|
578
|
-
|
847
|
+
expected = <<-EOS
|
848
|
+
<dl>
|
849
|
+
<dt>foo</dt>
|
850
|
+
<dd>foo.</dd>
|
851
|
+
</dl>
|
852
|
+
<p>para</p>
|
853
|
+
<dl>
|
854
|
+
<dt>foo</dt>
|
855
|
+
<dd>foo.</dd>
|
856
|
+
</dl>
|
857
|
+
<ol>
|
858
|
+
<li>bar</li>
|
859
|
+
</ol>
|
860
|
+
<dl>
|
861
|
+
<dt>foo</dt>
|
862
|
+
<dd>foo.</dd>
|
863
|
+
</dl>
|
864
|
+
<ul>
|
865
|
+
<li>bar</li>
|
866
|
+
</ul>
|
867
|
+
EOS
|
868
|
+
assert_equal expected, actual
|
869
|
+
end
|
870
|
+
|
871
|
+
def test_dt_inline
|
872
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
873
|
+
|
874
|
+
expected = <<-EOS
|
875
|
+
<div class="footnote" epub:type="footnote" id="fn-bar"><p class="footnote">[*1] bar</p></div>
|
876
|
+
<dl>
|
877
|
+
<dt>foo<a id="fnb-bar" href="#fn-bar" class="noteref" epub:type="noteref">*1</a>[]<>&<span class="equation">\\alpha[]</span></dt>
|
878
|
+
<dd></dd>
|
879
|
+
</dl>
|
880
|
+
EOS
|
881
|
+
assert_equal expected, actual
|
579
882
|
end
|
580
883
|
|
581
884
|
def test_list
|
582
885
|
def @chapter.list(_id)
|
583
|
-
Book::
|
886
|
+
Book::Index::Item.new('samplelist', 1)
|
584
887
|
end
|
585
888
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
586
|
-
|
889
|
+
expected = <<-EOS
|
890
|
+
<div id="samplelist" class="caption-code">
|
891
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
892
|
+
<pre class="list">test1
|
893
|
+
test1.5
|
894
|
+
|
895
|
+
test<i>2</i>
|
896
|
+
</pre>
|
897
|
+
</div>
|
898
|
+
EOS
|
899
|
+
assert_equal expected, actual
|
900
|
+
|
901
|
+
@config['caption_position']['list'] = 'bottom'
|
902
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
903
|
+
expected = <<-EOS
|
904
|
+
<div id="samplelist" class="caption-code">
|
905
|
+
<pre class="list">test1
|
906
|
+
test1.5
|
907
|
+
|
908
|
+
test<i>2</i>
|
909
|
+
</pre>
|
910
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
911
|
+
</div>
|
912
|
+
EOS
|
913
|
+
assert_equal expected, actual
|
587
914
|
end
|
588
915
|
|
589
916
|
def test_inline_list
|
590
917
|
def @chapter.list(_id)
|
591
|
-
Book::
|
918
|
+
Book::Index::Item.new('samplelist', 1)
|
592
919
|
end
|
593
|
-
actual = compile_block("@<list>{
|
920
|
+
actual = compile_block("@<list>{samplelist}\n")
|
921
|
+
assert_equal %Q(<p><span class="listref"><a href="./-.html#samplelist">リスト1.1</a></span></p>\n), actual
|
922
|
+
|
923
|
+
@config['chapterlink'] = nil
|
924
|
+
actual = compile_block("@<list>{samplelist}\n")
|
594
925
|
assert_equal %Q(<p><span class="listref">リスト1.1</span></p>\n), actual
|
595
926
|
end
|
596
927
|
|
597
928
|
def test_inline_list_href
|
598
|
-
book = ReVIEW::Book::Base.
|
929
|
+
book = ReVIEW::Book::Base.new
|
599
930
|
book.config['chapterlink'] = true
|
600
931
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
601
|
-
io1 = StringIO.new("//list[sampletest]{\nfoo\n//}\n")
|
932
|
+
io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
|
602
933
|
io2 = StringIO.new("= BAR\n")
|
603
934
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
604
935
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
605
|
-
book.parts = [ReVIEW::Book::Part.new(
|
936
|
+
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
606
937
|
builder = ReVIEW::HTMLBuilder.new
|
607
938
|
comp = ReVIEW::Compiler.new(builder)
|
608
939
|
builder.bind(comp, chap2, nil)
|
940
|
+
|
941
|
+
chap1.generate_indexes
|
609
942
|
actual = builder.inline_list('ch1|sampletest')
|
610
943
|
assert_equal %Q(<span class="listref"><a href="./ch1.html#sampletest">リスト1.1</a></span>), actual
|
611
944
|
end
|
612
945
|
|
613
946
|
def test_list_pygments
|
614
947
|
def @chapter.list(_id)
|
615
|
-
Book::
|
948
|
+
Book::Index::Item.new('samplelist', 1)
|
616
949
|
end
|
617
950
|
begin
|
618
951
|
require 'pygments'
|
@@ -639,7 +972,7 @@ test<i>2</i>
|
|
639
972
|
|
640
973
|
def test_list_pygments_lang
|
641
974
|
def @chapter.list(_id)
|
642
|
-
Book::
|
975
|
+
Book::Index::Item.new('samplelist', 1)
|
643
976
|
end
|
644
977
|
begin
|
645
978
|
require 'pygments'
|
@@ -667,7 +1000,7 @@ EOS
|
|
667
1000
|
|
668
1001
|
def test_list_pygments_nulllang
|
669
1002
|
def @chapter.list(_id)
|
670
|
-
Book::
|
1003
|
+
Book::Index::Item.new('samplelist', 1)
|
671
1004
|
end
|
672
1005
|
begin
|
673
1006
|
require 'pygments'
|
@@ -700,13 +1033,23 @@ end
|
|
700
1033
|
return true
|
701
1034
|
end
|
702
1035
|
def @chapter.list(_id)
|
703
|
-
Book::
|
1036
|
+
Book::Index::Item.new('samplelist', 1)
|
704
1037
|
end
|
705
1038
|
@book.config['highlight'] = {}
|
706
1039
|
@book.config['highlight']['html'] = 'rouge'
|
707
1040
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
708
1041
|
|
709
|
-
|
1042
|
+
expected = <<-EOS
|
1043
|
+
<div id="samplelist" class="caption-code">
|
1044
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1045
|
+
<pre class="list highlight">test1
|
1046
|
+
test1.5
|
1047
|
+
|
1048
|
+
test<i>2</i>
|
1049
|
+
</pre>
|
1050
|
+
</div>
|
1051
|
+
EOS
|
1052
|
+
assert_equal expected, actual
|
710
1053
|
end
|
711
1054
|
|
712
1055
|
def test_list_rouge_lang
|
@@ -717,7 +1060,7 @@ end
|
|
717
1060
|
return true
|
718
1061
|
end
|
719
1062
|
def @chapter.list(_id)
|
720
|
-
Book::
|
1063
|
+
Book::Index::Item.new('samplelist', 1)
|
721
1064
|
end
|
722
1065
|
@book.config['highlight'] = {}
|
723
1066
|
@book.config['highlight']['html'] = 'rouge'
|
@@ -745,18 +1088,29 @@ EOS
|
|
745
1088
|
return true
|
746
1089
|
end
|
747
1090
|
def @chapter.list(_id)
|
748
|
-
Book::
|
1091
|
+
Book::Index::Item.new('samplelist', 1)
|
749
1092
|
end
|
750
1093
|
@book.config['highlight'] = {}
|
751
1094
|
@book.config['highlight']['html'] = 'rouge'
|
752
1095
|
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")
|
753
1096
|
|
754
|
-
|
1097
|
+
expected = <<-EOS
|
1098
|
+
<div id="samplelist" class="caption-code">
|
1099
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1100
|
+
<pre class="list highlight">def foo(a1, a2=:test)
|
1101
|
+
(1..3).times{|i| a.include?(:foo)}
|
1102
|
+
return true
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
</pre>
|
1106
|
+
</div>
|
1107
|
+
EOS
|
1108
|
+
assert_equal expected, actual
|
755
1109
|
end
|
756
1110
|
|
757
1111
|
def test_listnum
|
758
1112
|
def @chapter.list(_id)
|
759
|
-
Book::
|
1113
|
+
Book::Index::Item.new('samplelist', 1)
|
760
1114
|
end
|
761
1115
|
|
762
1116
|
@book.config['highlight'] = false
|
@@ -778,6 +1132,29 @@ EOS
|
|
778
1132
|
4: end
|
779
1133
|
</pre>
|
780
1134
|
</div>
|
1135
|
+
EOS
|
1136
|
+
|
1137
|
+
assert_equal expected, actual
|
1138
|
+
|
1139
|
+
@config['caption_position']['list'] = 'bottom'
|
1140
|
+
actual = compile_block(<<-EOS)
|
1141
|
+
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
1142
|
+
def foo(a1, a2=:test)
|
1143
|
+
(1..3).times{|i| a.include?(:foo)}
|
1144
|
+
return true
|
1145
|
+
end
|
1146
|
+
//}
|
1147
|
+
EOS
|
1148
|
+
|
1149
|
+
expected = <<-EOS
|
1150
|
+
<div id="samplelist" class="code">
|
1151
|
+
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
|
1152
|
+
2: (1..3).times{|i| a.include?(:foo)}
|
1153
|
+
3: return true
|
1154
|
+
4: end
|
1155
|
+
</pre>
|
1156
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1157
|
+
</div>
|
781
1158
|
EOS
|
782
1159
|
|
783
1160
|
assert_equal expected, actual
|
@@ -785,7 +1162,7 @@ EOS
|
|
785
1162
|
|
786
1163
|
def test_listnum_linenum
|
787
1164
|
def @chapter.list(_id)
|
788
|
-
Book::
|
1165
|
+
Book::Index::Item.new('samplelist', 1)
|
789
1166
|
end
|
790
1167
|
|
791
1168
|
@book.config['highlight'] = false
|
@@ -815,7 +1192,7 @@ EOS
|
|
815
1192
|
|
816
1193
|
def test_listnum_pygments_lang
|
817
1194
|
def @chapter.list(_id)
|
818
|
-
Book::
|
1195
|
+
Book::Index::Item.new('samplelist', 1)
|
819
1196
|
end
|
820
1197
|
begin
|
821
1198
|
require 'pygments'
|
@@ -842,7 +1219,7 @@ EOS
|
|
842
1219
|
|
843
1220
|
def test_listnum_pygments_lang_linenum
|
844
1221
|
def @chapter.list(_id)
|
845
|
-
Book::
|
1222
|
+
Book::Index::Item.new('samplelist', 1)
|
846
1223
|
end
|
847
1224
|
begin
|
848
1225
|
require 'pygments'
|
@@ -870,7 +1247,7 @@ EOS
|
|
870
1247
|
|
871
1248
|
def test_listnum_pygments_lang_without_lang
|
872
1249
|
def @chapter.list(_id)
|
873
|
-
Book::
|
1250
|
+
Book::Index::Item.new('samplelist', 1)
|
874
1251
|
end
|
875
1252
|
begin
|
876
1253
|
require 'pygments'
|
@@ -904,7 +1281,7 @@ EOS
|
|
904
1281
|
return true
|
905
1282
|
end
|
906
1283
|
def @chapter.list(_id)
|
907
|
-
Book::
|
1284
|
+
Book::Index::Item.new('samplelist', 1)
|
908
1285
|
end
|
909
1286
|
@book.config['highlight'] = {}
|
910
1287
|
@book.config['highlight']['html'] = 'rouge'
|
@@ -938,7 +1315,7 @@ EOS
|
|
938
1315
|
return true
|
939
1316
|
end
|
940
1317
|
def @chapter.list(_id)
|
941
|
-
Book::
|
1318
|
+
Book::Index::Item.new('samplelist', 1)
|
942
1319
|
end
|
943
1320
|
@book.config['highlight'] = {}
|
944
1321
|
@book.config['highlight']['html'] = 'rouge'
|
@@ -964,15 +1341,100 @@ EOB
|
|
964
1341
|
assert_equal expected, actual
|
965
1342
|
end
|
966
1343
|
|
967
|
-
def
|
968
|
-
actual = compile_block("//
|
969
|
-
|
970
|
-
|
1344
|
+
def test_source
|
1345
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1346
|
+
expected = <<-EOS
|
1347
|
+
<div class="source-code">
|
1348
|
+
<p class="caption">foo/bar/test.rb</p>
|
1349
|
+
<pre class="source">foo
|
1350
|
+
bar
|
971
1351
|
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
1352
|
+
buz
|
1353
|
+
</pre>
|
1354
|
+
</div>
|
1355
|
+
EOS
|
1356
|
+
assert_equal expected, actual
|
1357
|
+
|
1358
|
+
@config['caption_position']['list'] = 'bottom'
|
1359
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1360
|
+
expected = <<-EOS
|
1361
|
+
<div class="source-code">
|
1362
|
+
<pre class="source">foo
|
1363
|
+
bar
|
1364
|
+
|
1365
|
+
buz
|
1366
|
+
</pre>
|
1367
|
+
<p class="caption">foo/bar/test.rb</p>
|
1368
|
+
</div>
|
1369
|
+
EOS
|
1370
|
+
assert_equal expected, actual
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
def test_source_empty_caption
|
1374
|
+
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
1375
|
+
expected = <<-EOS
|
1376
|
+
<div class="source-code">
|
1377
|
+
<pre class="source">foo
|
1378
|
+
bar
|
1379
|
+
|
1380
|
+
buz
|
1381
|
+
</pre>
|
1382
|
+
</div>
|
1383
|
+
EOS
|
1384
|
+
assert_equal expected, actual
|
1385
|
+
end
|
1386
|
+
|
1387
|
+
def test_box
|
1388
|
+
actual = compile_block("//box{\nfoo\nbar\n//}\n")
|
1389
|
+
expected = <<-EOS
|
1390
|
+
<div class="syntax">
|
1391
|
+
<pre class="syntax">foo
|
1392
|
+
bar
|
1393
|
+
</pre>
|
1394
|
+
</div>
|
1395
|
+
EOS
|
1396
|
+
assert_equal expected, actual
|
1397
|
+
|
1398
|
+
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1399
|
+
expected = <<-EOS
|
1400
|
+
<div class="syntax">
|
1401
|
+
<p class="caption">FOO</p>
|
1402
|
+
<pre class="syntax">foo
|
1403
|
+
bar
|
1404
|
+
</pre>
|
1405
|
+
</div>
|
1406
|
+
EOS
|
1407
|
+
assert_equal expected, actual
|
1408
|
+
|
1409
|
+
@config['caption_position']['list'] = 'bottom'
|
1410
|
+
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1411
|
+
expected = <<-EOS
|
1412
|
+
<div class="syntax">
|
1413
|
+
<pre class="syntax">foo
|
1414
|
+
bar
|
1415
|
+
</pre>
|
1416
|
+
<p class="caption">FOO</p>
|
1417
|
+
</div>
|
1418
|
+
EOS
|
1419
|
+
assert_equal expected, actual
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
def test_emlist
|
1423
|
+
actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
|
1424
|
+
expected = <<-EOS
|
1425
|
+
<div class="emlist-code">
|
1426
|
+
<pre class="emlist">lineA
|
1427
|
+
lineB
|
1428
|
+
</pre>
|
1429
|
+
</div>
|
1430
|
+
EOS
|
1431
|
+
assert_equal expected, actual
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
def test_emlist_pygments_lang
|
1435
|
+
begin
|
1436
|
+
require 'pygments'
|
1437
|
+
rescue LoadError
|
976
1438
|
$stderr.puts 'skip test_emlist_pygments_lang (cannot find pygments.rb)'
|
977
1439
|
return true
|
978
1440
|
end
|
@@ -990,12 +1452,40 @@ EOB
|
|
990
1452
|
|
991
1453
|
def test_emlist_caption
|
992
1454
|
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
993
|
-
|
1455
|
+
expected = <<-EOS
|
1456
|
+
<div class="emlist-code">
|
1457
|
+
<p class="caption">cap1</p>
|
1458
|
+
<pre class="emlist">lineA
|
1459
|
+
lineB
|
1460
|
+
</pre>
|
1461
|
+
</div>
|
1462
|
+
EOS
|
1463
|
+
assert_equal expected, actual
|
1464
|
+
|
1465
|
+
@config['caption_position']['list'] = 'bottom'
|
1466
|
+
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
1467
|
+
expected = <<-EOS
|
1468
|
+
<div class="emlist-code">
|
1469
|
+
<pre class="emlist">lineA
|
1470
|
+
lineB
|
1471
|
+
</pre>
|
1472
|
+
<p class="caption">cap1</p>
|
1473
|
+
</div>
|
1474
|
+
EOS
|
1475
|
+
assert_equal expected, actual
|
994
1476
|
end
|
995
1477
|
|
996
1478
|
def test_emlist_with_tab
|
997
1479
|
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
998
|
-
|
1480
|
+
expected = <<-EOS
|
1481
|
+
<div class="emlist-code">
|
1482
|
+
<pre class="emlist"> lineA
|
1483
|
+
lineB
|
1484
|
+
lineC
|
1485
|
+
</pre>
|
1486
|
+
</div>
|
1487
|
+
EOS
|
1488
|
+
assert_equal expected, actual
|
999
1489
|
end
|
1000
1490
|
|
1001
1491
|
def test_emlistnum
|
@@ -1021,6 +1511,18 @@ EOS
|
|
1021
1511
|
2: lineB
|
1022
1512
|
</pre>
|
1023
1513
|
</div>
|
1514
|
+
EOS
|
1515
|
+
assert_equal expected, actual
|
1516
|
+
|
1517
|
+
@config['caption_position']['list'] = 'bottom'
|
1518
|
+
actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
1519
|
+
expected = <<-EOS
|
1520
|
+
<div class="emlistnum-code">
|
1521
|
+
<pre class="emlist language-text"> 1: lineA
|
1522
|
+
2: lineB
|
1523
|
+
</pre>
|
1524
|
+
<p class="caption">cap</p>
|
1525
|
+
</div>
|
1024
1526
|
EOS
|
1025
1527
|
assert_equal expected, actual
|
1026
1528
|
end
|
@@ -1042,12 +1544,27 @@ EOS
|
|
1042
1544
|
def test_emlist_with_4tab
|
1043
1545
|
@config['tabwidth'] = 4
|
1044
1546
|
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
1045
|
-
|
1547
|
+
expected = <<-EOS
|
1548
|
+
<div class="emlist-code">
|
1549
|
+
<pre class="emlist"> lineA
|
1550
|
+
lineB
|
1551
|
+
lineC
|
1552
|
+
</pre>
|
1553
|
+
</div>
|
1554
|
+
EOS
|
1555
|
+
assert_equal expected, actual
|
1046
1556
|
end
|
1047
1557
|
|
1048
1558
|
def test_cmd
|
1049
1559
|
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
1050
|
-
|
1560
|
+
expected = <<-EOS
|
1561
|
+
<div class="cmd-code">
|
1562
|
+
<pre class="cmd">lineA
|
1563
|
+
lineB
|
1564
|
+
</pre>
|
1565
|
+
</div>
|
1566
|
+
EOS
|
1567
|
+
assert_equal expected, actual
|
1051
1568
|
end
|
1052
1569
|
|
1053
1570
|
def test_cmd_pygments
|
@@ -1059,12 +1576,39 @@ EOS
|
|
1059
1576
|
@book.config['highlight'] = {}
|
1060
1577
|
@book.config['highlight']['html'] = 'pygments'
|
1061
1578
|
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
1062
|
-
|
1579
|
+
expected = <<-EOS
|
1580
|
+
<div class="cmd-code">
|
1581
|
+
<pre class="cmd"><span style="color: #888888">lineA</span>
|
1582
|
+
<span style="color: #888888">lineB</span>
|
1583
|
+
</pre>
|
1584
|
+
</div>
|
1585
|
+
EOS
|
1586
|
+
assert_equal expected, actual
|
1063
1587
|
end
|
1064
1588
|
|
1065
1589
|
def test_cmd_caption
|
1066
1590
|
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1067
|
-
|
1591
|
+
expected = <<-EOS
|
1592
|
+
<div class="cmd-code">
|
1593
|
+
<p class="caption">cap1</p>
|
1594
|
+
<pre class="cmd">lineA
|
1595
|
+
lineB
|
1596
|
+
</pre>
|
1597
|
+
</div>
|
1598
|
+
EOS
|
1599
|
+
assert_equal expected, actual
|
1600
|
+
|
1601
|
+
@config['caption_position']['list'] = 'bottom'
|
1602
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1603
|
+
expected = <<-EOS
|
1604
|
+
<div class="cmd-code">
|
1605
|
+
<pre class="cmd">lineA
|
1606
|
+
lineB
|
1607
|
+
</pre>
|
1608
|
+
<p class="caption">cap1</p>
|
1609
|
+
</div>
|
1610
|
+
EOS
|
1611
|
+
assert_equal expected, actual
|
1068
1612
|
end
|
1069
1613
|
|
1070
1614
|
def test_texequation
|
@@ -1124,7 +1668,7 @@ EOS
|
|
1124
1668
|
|
1125
1669
|
def test_bib
|
1126
1670
|
def @chapter.bibpaper(_id)
|
1127
|
-
Book::
|
1671
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1128
1672
|
end
|
1129
1673
|
|
1130
1674
|
assert_equal %Q(<a href="bib.html#bib-samplebib">[1]</a>), compile_inline('@<bib>{samplebib}')
|
@@ -1132,7 +1676,7 @@ EOS
|
|
1132
1676
|
|
1133
1677
|
def test_bib_noramlized
|
1134
1678
|
def @chapter.bibpaper(_id)
|
1135
|
-
Book::
|
1679
|
+
Book::Index::Item.new('sampleb=ib', 1, 'sample bib')
|
1136
1680
|
end
|
1137
1681
|
|
1138
1682
|
assert_equal %Q(<a href="bib.html#bib-id_sample_3Dbib">[1]</a>), compile_inline('@<bib>{sample=bib}')
|
@@ -1140,7 +1684,7 @@ EOS
|
|
1140
1684
|
|
1141
1685
|
def test_bib_htmlext
|
1142
1686
|
def @chapter.bibpaper(_id)
|
1143
|
-
Book::
|
1687
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1144
1688
|
end
|
1145
1689
|
|
1146
1690
|
@config['htmlext'] = 'xhtml'
|
@@ -1149,29 +1693,71 @@ EOS
|
|
1149
1693
|
|
1150
1694
|
def test_bibpaper
|
1151
1695
|
def @chapter.bibpaper(_id)
|
1152
|
-
Book::
|
1696
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1153
1697
|
end
|
1154
1698
|
|
1155
1699
|
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1156
|
-
|
1700
|
+
expected = <<-EOS
|
1701
|
+
<div class="bibpaper">
|
1702
|
+
<a id="bib-samplebib">[1]</a> sample bib <b>bold</b>
|
1703
|
+
<p>ab</p></div>
|
1704
|
+
EOS
|
1705
|
+
assert_equal expected, actual
|
1706
|
+
|
1707
|
+
@book.config['join_lines_by_lang'] = true
|
1708
|
+
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1709
|
+
expected = <<-EOS
|
1710
|
+
<div class="bibpaper">
|
1711
|
+
<a id="bib-samplebib">[1]</a> sample bib <b>bold</b>
|
1712
|
+
<p>a b</p></div>
|
1713
|
+
EOS
|
1714
|
+
assert_equal expected, actual
|
1157
1715
|
end
|
1158
1716
|
|
1159
1717
|
def test_bibpaper_normalized
|
1160
1718
|
def @chapter.bibpaper(_id)
|
1161
|
-
Book::
|
1719
|
+
Book::Index::Item.new('sample=bib', 1, 'sample bib')
|
1162
1720
|
end
|
1163
1721
|
|
1164
1722
|
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1165
|
-
|
1723
|
+
expected = <<-EOS
|
1724
|
+
<div class="bibpaper">
|
1725
|
+
<a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>
|
1726
|
+
<p>ab</p></div>
|
1727
|
+
EOS
|
1728
|
+
assert_equal expected, actual
|
1729
|
+
|
1730
|
+
@book.config['join_lines_by_lang'] = true
|
1731
|
+
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
1732
|
+
expected = <<-EOS
|
1733
|
+
<div class="bibpaper">
|
1734
|
+
<a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>
|
1735
|
+
<p>a b</p></div>
|
1736
|
+
EOS
|
1737
|
+
assert_equal expected, actual
|
1166
1738
|
end
|
1167
1739
|
|
1168
1740
|
def test_bibpaper_with_anchor
|
1169
1741
|
def @chapter.bibpaper(_id)
|
1170
|
-
Book::
|
1742
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
1171
1743
|
end
|
1172
1744
|
|
1173
1745
|
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
1174
|
-
|
1746
|
+
expected = <<-EOS
|
1747
|
+
<div class="bibpaper">
|
1748
|
+
<a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>
|
1749
|
+
<p>ab</p></div>
|
1750
|
+
EOS
|
1751
|
+
assert_equal expected, actual
|
1752
|
+
|
1753
|
+
@book.config['join_lines_by_lang'] = true
|
1754
|
+
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
1755
|
+
expected = <<-EOS
|
1756
|
+
<div class="bibpaper">
|
1757
|
+
<a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>
|
1758
|
+
<p>a b</p></div>
|
1759
|
+
EOS
|
1760
|
+
assert_equal expected, actual
|
1175
1761
|
end
|
1176
1762
|
|
1177
1763
|
def column_helper(review)
|
@@ -1256,6 +1842,20 @@ EOS
|
|
1256
1842
|
<p>inside column</p>
|
1257
1843
|
</div>
|
1258
1844
|
|
1845
|
+
<h3><a id="h1-0-1"></a>next level</h3>
|
1846
|
+
<p>this is <a href="-.html#column-1" class="columnref">コラム「test」</a>.</p>
|
1847
|
+
EOS
|
1848
|
+
|
1849
|
+
assert_equal expected, column_helper(review)
|
1850
|
+
|
1851
|
+
@config['chapterlink'] = nil
|
1852
|
+
expected = <<-EOS
|
1853
|
+
<div class="column">
|
1854
|
+
|
1855
|
+
<h3 id="foo"><a id="column-1"></a>test</h3>
|
1856
|
+
<p>inside column</p>
|
1857
|
+
</div>
|
1858
|
+
|
1259
1859
|
<h3><a id="h1-0-1"></a>next level</h3>
|
1260
1860
|
<p>this is コラム「test」.</p>
|
1261
1861
|
EOS
|
@@ -1265,10 +1865,17 @@ EOS
|
|
1265
1865
|
|
1266
1866
|
def test_column_in_aother_chapter_ref
|
1267
1867
|
def @chapter.column_index
|
1268
|
-
|
1269
|
-
Book::ColumnIndex.new
|
1868
|
+
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
1869
|
+
idx = Book::ColumnIndex.new
|
1870
|
+
idx.add_item(item)
|
1871
|
+
idx
|
1270
1872
|
end
|
1271
1873
|
|
1874
|
+
actual = compile_inline('test @<column>{chap1|column} test2')
|
1875
|
+
expected = 'test <a href="-.html#column-1" class="columnref">コラム「column_cap」</a> test2'
|
1876
|
+
assert_equal expected, actual
|
1877
|
+
|
1878
|
+
@config['chapterlink'] = nil
|
1272
1879
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
1273
1880
|
expected = 'test コラム「column_cap」 test2'
|
1274
1881
|
assert_equal expected, actual
|
@@ -1279,7 +1886,12 @@ EOS
|
|
1279
1886
|
* AAA
|
1280
1887
|
* BBB
|
1281
1888
|
EOS
|
1282
|
-
expected =
|
1889
|
+
expected = <<-EOS
|
1890
|
+
<ul>
|
1891
|
+
<li>AAA</li>
|
1892
|
+
<li>BBB</li>
|
1893
|
+
</ul>
|
1894
|
+
EOS
|
1283
1895
|
actual = compile_block(src)
|
1284
1896
|
assert_equal expected, actual
|
1285
1897
|
end
|
@@ -1291,7 +1903,22 @@ EOS
|
|
1291
1903
|
* BBB
|
1292
1904
|
-BB
|
1293
1905
|
EOS
|
1294
|
-
expected =
|
1906
|
+
expected = <<-EOS
|
1907
|
+
<ul>
|
1908
|
+
<li>AAA-AA</li>
|
1909
|
+
<li>BBB-BB</li>
|
1910
|
+
</ul>
|
1911
|
+
EOS
|
1912
|
+
actual = compile_block(src)
|
1913
|
+
assert_equal expected, actual
|
1914
|
+
|
1915
|
+
@book.config['join_lines_by_lang'] = true
|
1916
|
+
expected = <<-EOS
|
1917
|
+
<ul>
|
1918
|
+
<li>AAA -AA</li>
|
1919
|
+
<li>BBB -BB</li>
|
1920
|
+
</ul>
|
1921
|
+
EOS
|
1295
1922
|
actual = compile_block(src)
|
1296
1923
|
assert_equal expected, actual
|
1297
1924
|
end
|
@@ -1342,25 +1969,10 @@ EOS
|
|
1342
1969
|
src = <<-EOS
|
1343
1970
|
** AAA
|
1344
1971
|
* AA
|
1345
|
-
* BBB
|
1346
|
-
** BB
|
1347
1972
|
EOS
|
1348
1973
|
|
1349
|
-
|
1350
|
-
|
1351
|
-
<li><ul>
|
1352
|
-
<li>AAA</li>
|
1353
|
-
</ul>
|
1354
|
-
</li>
|
1355
|
-
<li>AA</li>
|
1356
|
-
<li>BBB<ul>
|
1357
|
-
<li>BB</li>
|
1358
|
-
</ul>
|
1359
|
-
</li>
|
1360
|
-
</ul>
|
1361
|
-
EOS
|
1362
|
-
actual = compile_block(src)
|
1363
|
-
assert_equal expected, actual
|
1974
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1975
|
+
assert_equal ':1: error: too many *.', e.message
|
1364
1976
|
end
|
1365
1977
|
|
1366
1978
|
def test_ul_nest4
|
@@ -1391,37 +2003,6 @@ EOS
|
|
1391
2003
|
assert_equal expected, actual
|
1392
2004
|
end
|
1393
2005
|
|
1394
|
-
def test_ul_nest5
|
1395
|
-
src = <<-EOS
|
1396
|
-
* A
|
1397
|
-
** AA
|
1398
|
-
**** AAAA
|
1399
|
-
* B
|
1400
|
-
** BB
|
1401
|
-
EOS
|
1402
|
-
|
1403
|
-
expected = <<-EOS
|
1404
|
-
<ul>
|
1405
|
-
<li>A<ul>
|
1406
|
-
<li>AA<ul>
|
1407
|
-
<li><ul>
|
1408
|
-
<li>AAAA</li>
|
1409
|
-
</ul>
|
1410
|
-
</li>
|
1411
|
-
</ul>
|
1412
|
-
</li>
|
1413
|
-
</ul>
|
1414
|
-
</li>
|
1415
|
-
<li>B<ul>
|
1416
|
-
<li>BB</li>
|
1417
|
-
</ul>
|
1418
|
-
</li>
|
1419
|
-
</ul>
|
1420
|
-
EOS
|
1421
|
-
actual = compile_block(src)
|
1422
|
-
assert_equal expected, actual
|
1423
|
-
end
|
1424
|
-
|
1425
2006
|
def test_ol
|
1426
2007
|
src = <<-EOS
|
1427
2008
|
3. AAA
|
@@ -1592,8 +2173,6 @@ EOS
|
|
1592
2173
|
end
|
1593
2174
|
|
1594
2175
|
def test_footnote
|
1595
|
-
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
|
1596
|
-
@chapter.instance_eval { @footnote_index = fn }
|
1597
2176
|
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
1598
2177
|
expected = <<-'EOS'
|
1599
2178
|
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote">[*1] bar\a\$buz</p></div>
|
@@ -1618,58 +2197,69 @@ EOS
|
|
1618
2197
|
end
|
1619
2198
|
|
1620
2199
|
def test_footnote_with_tricky_id
|
1621
|
-
|
1622
|
-
@chapter.instance_eval { @footnote_index = fn }
|
1623
|
-
actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
|
2200
|
+
actual = compile_block("//footnote[123あ_;][bar\\a\\$buz]\n")
|
1624
2201
|
expected = <<-'EOS'
|
1625
|
-
<div class="footnote" epub:type="footnote" id="fn-
|
2202
|
+
<div class="footnote" epub:type="footnote" id="fn-id_123_E3_81_82___3B"><p class="footnote">[*1] bar\a\$buz</p></div>
|
1626
2203
|
EOS
|
1627
2204
|
assert_equal expected, actual
|
1628
2205
|
end
|
1629
2206
|
|
1630
2207
|
def test_inline_fn
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
comp = ReVIEW::Compiler.new(builder)
|
1638
|
-
builder.bind(comp, chap1, nil)
|
1639
|
-
fn = builder.inline_fn('foo')
|
1640
|
-
assert_equal '<a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a>', fn
|
2208
|
+
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2209
|
+
expected = <<-EOS
|
2210
|
+
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2211
|
+
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a></p>
|
2212
|
+
EOS
|
2213
|
+
assert_equal expected, fn
|
1641
2214
|
I18n.set('html_footnote_refmark', '+%s')
|
1642
|
-
fn =
|
1643
|
-
|
2215
|
+
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2216
|
+
expected = <<-EOS
|
2217
|
+
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2218
|
+
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">+1</a></p>
|
2219
|
+
EOS
|
2220
|
+
assert_equal expected, fn
|
1644
2221
|
end
|
1645
2222
|
|
1646
2223
|
def test_inline_hd
|
1647
|
-
book = ReVIEW::Book::Base.
|
2224
|
+
book = ReVIEW::Book::Base.new
|
1648
2225
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
1649
2226
|
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
1650
2227
|
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
1651
2228
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
1652
2229
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
1653
|
-
book.parts = [ReVIEW::Book::Part.new(
|
2230
|
+
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
1654
2231
|
builder = ReVIEW::HTMLBuilder.new
|
1655
2232
|
comp = ReVIEW::Compiler.new(builder)
|
1656
2233
|
builder.bind(comp, chap2, nil)
|
2234
|
+
|
2235
|
+
chap1.generate_indexes
|
2236
|
+
chap2.generate_indexes
|
2237
|
+
hd = builder.inline_hd('ch1|test1-1')
|
2238
|
+
assert_equal '<a href="ch1.html#h1-1">「1.1 test1-1」</a>', hd
|
2239
|
+
|
2240
|
+
builder.instance_eval { @book.config['chapterlink'] = nil }
|
1657
2241
|
hd = builder.inline_hd('ch1|test1-1')
|
1658
2242
|
assert_equal '「1.1 test1-1」', hd
|
1659
2243
|
end
|
1660
2244
|
|
1661
2245
|
def test_inline_hd_for_part
|
1662
|
-
book = ReVIEW::Book::Base.
|
2246
|
+
book = ReVIEW::Book::Base.new
|
1663
2247
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
1664
2248
|
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
1665
2249
|
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
1666
2250
|
io_p1 = StringIO.new("= part1\n\nfoo\n\n== part1-1\n\nbar\n\n== part1-2\n\nbar\n\n")
|
1667
2251
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
1668
2252
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
1669
|
-
book.parts = [ReVIEW::Book::Part.new(
|
2253
|
+
book.parts = [ReVIEW::Book::Part.new(book, 1, [chap1, chap2], 'part1.re', io_p1)]
|
1670
2254
|
builder = ReVIEW::HTMLBuilder.new
|
1671
2255
|
comp = ReVIEW::Compiler.new(builder)
|
1672
2256
|
builder.bind(comp, chap2, nil)
|
2257
|
+
book.generate_indexes
|
2258
|
+
|
2259
|
+
hd = builder.inline_hd('part1|part1-1')
|
2260
|
+
assert_equal '<a href="part1.html#h1-1">「1.1 part1-1」</a>', hd
|
2261
|
+
|
2262
|
+
builder.instance_eval { @book.config['chapterlink'] = nil }
|
1673
2263
|
hd = builder.inline_hd('part1|part1-1')
|
1674
2264
|
assert_equal '「1.1 part1-1」', hd
|
1675
2265
|
end
|
@@ -1680,77 +2270,453 @@ EOS
|
|
1680
2270
|
location = Location.new(nil, nil)
|
1681
2271
|
@builder.bind(@compiler, chap1, location)
|
1682
2272
|
hd = @builder.inline_hd('foo')
|
2273
|
+
assert_equal '<a href="-.html#h1-1">「1.1 foo」</a>', hd
|
2274
|
+
|
2275
|
+
@config['chapterlink'] = nil
|
2276
|
+
hd = @builder.inline_hd('foo')
|
1683
2277
|
assert_equal '「1.1 foo」', hd
|
2278
|
+
|
1684
2279
|
hd = @builder.inline_hd('bar')
|
1685
2280
|
assert_equal '「1.2 bar」', hd
|
1686
2281
|
end
|
1687
2282
|
|
1688
2283
|
def test_table
|
1689
2284
|
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1690
|
-
|
1691
|
-
|
2285
|
+
expected = <<-EOS
|
2286
|
+
<div class="table">
|
2287
|
+
<table>
|
2288
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2289
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2290
|
+
</table>
|
2291
|
+
</div>
|
2292
|
+
EOS
|
2293
|
+
assert_equal expected, actual
|
2294
|
+
|
2295
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2296
|
+
expected = <<-EOS
|
2297
|
+
<div id="foo" class="table">
|
2298
|
+
<p class="caption">表1.1: FOO</p>
|
2299
|
+
<table>
|
2300
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2301
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2302
|
+
</table>
|
2303
|
+
</div>
|
2304
|
+
EOS
|
2305
|
+
assert_equal expected, actual
|
2306
|
+
|
2307
|
+
@config['caption_position']['table'] = 'bottom'
|
2308
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2309
|
+
expected = <<-EOS
|
2310
|
+
<div id="foo" class="table">
|
2311
|
+
<table>
|
2312
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2313
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2314
|
+
</table>
|
2315
|
+
<p class="caption">表1.1: FOO</p>
|
2316
|
+
</div>
|
2317
|
+
EOS
|
2318
|
+
assert_equal expected, actual
|
2319
|
+
end
|
2320
|
+
|
2321
|
+
def test_empty_table
|
2322
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
2323
|
+
assert_equal ':2: error: no rows in the table', e.message
|
2324
|
+
|
2325
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
2326
|
+
assert_equal ':3: error: no rows in the table', e.message
|
1692
2327
|
end
|
1693
2328
|
|
1694
2329
|
def test_inline_table
|
1695
2330
|
def @chapter.table(_id)
|
1696
|
-
Book::
|
2331
|
+
Book::Index::Item.new('sampletable', 1)
|
1697
2332
|
end
|
1698
2333
|
actual = compile_block("@<table>{sampletest}\n")
|
2334
|
+
assert_equal %Q(<p><span class="tableref"><a href="./-.html#sampletest">表1.1</a></span></p>\n), actual
|
2335
|
+
|
2336
|
+
@config['chapterlink'] = nil
|
2337
|
+
actual = compile_block("@<table>{sampletest}\n")
|
1699
2338
|
assert_equal %Q(<p><span class="tableref">表1.1</span></p>\n), actual
|
1700
2339
|
end
|
1701
2340
|
|
1702
2341
|
def test_emtable
|
1703
2342
|
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
2343
|
+
expected = <<-EOS
|
2344
|
+
<div class="table">
|
2345
|
+
<p class="caption">foo</p>
|
2346
|
+
<table>
|
2347
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2348
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2349
|
+
</table>
|
2350
|
+
</div>
|
2351
|
+
<div class="table">
|
2352
|
+
<table>
|
2353
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2354
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2355
|
+
</table>
|
2356
|
+
</div>
|
2357
|
+
EOS
|
2358
|
+
assert_equal expected, actual
|
1707
2359
|
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
2360
|
+
@config['caption_position']['table'] = 'bottom'
|
2361
|
+
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2362
|
+
expected = <<-EOS
|
2363
|
+
<div class="table">
|
2364
|
+
<table>
|
2365
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2366
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2367
|
+
</table>
|
2368
|
+
<p class="caption">foo</p>
|
2369
|
+
</div>
|
2370
|
+
<div class="table">
|
2371
|
+
<table>
|
2372
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2373
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2374
|
+
</table>
|
2375
|
+
</div>
|
2376
|
+
EOS
|
2377
|
+
assert_equal expected, actual
|
2378
|
+
end
|
2379
|
+
|
2380
|
+
def test_imgtable
|
2381
|
+
def @chapter.image(_id)
|
2382
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
|
2383
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1712
2384
|
item
|
1713
2385
|
end
|
1714
2386
|
|
1715
2387
|
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
1716
|
-
expected =
|
2388
|
+
expected = <<-EOS
|
2389
|
+
<div id="sampleimg" class="imgtable image">
|
2390
|
+
<p class="caption">表1.1: test for imgtable</p>
|
2391
|
+
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2392
|
+
</div>
|
2393
|
+
EOS
|
2394
|
+
assert_equal expected, actual
|
2395
|
+
|
2396
|
+
@config['caption_position']['table'] = 'bottom'
|
2397
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
2398
|
+
expected = <<-EOS
|
2399
|
+
<div id="sampleimg" class="imgtable image">
|
2400
|
+
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2401
|
+
<p class="caption">表1.1: test for imgtable</p>
|
2402
|
+
</div>
|
2403
|
+
EOS
|
2404
|
+
assert_equal expected, actual
|
2405
|
+
end
|
2406
|
+
|
2407
|
+
def test_table_row_separator
|
2408
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
2409
|
+
expected = <<-EOS
|
2410
|
+
<div class="table">
|
2411
|
+
<table>
|
2412
|
+
<tr><th>1</th><th>2</th><th>3 4| 5</th></tr>
|
2413
|
+
<tr><td>a b</td><td>c d |e</td><td></td></tr>
|
2414
|
+
</table>
|
2415
|
+
</div>
|
2416
|
+
EOS
|
2417
|
+
actual = compile_block(src)
|
2418
|
+
assert_equal expected, actual
|
2419
|
+
|
2420
|
+
@config['table_row_separator'] = 'singletab'
|
2421
|
+
actual = compile_block(src)
|
2422
|
+
expected = <<-EOS
|
2423
|
+
<div class="table">
|
2424
|
+
<table>
|
2425
|
+
<tr><th>1</th><th>2</th><th></th><th>3 4| 5</th></tr>
|
2426
|
+
<tr><td>a b</td><td>c d |e</td><td></td><td></td></tr>
|
2427
|
+
</table>
|
2428
|
+
</div>
|
2429
|
+
EOS
|
2430
|
+
assert_equal expected, actual
|
2431
|
+
|
2432
|
+
@config['table_row_separator'] = 'spaces'
|
2433
|
+
actual = compile_block(src)
|
2434
|
+
expected = <<-EOS
|
2435
|
+
<div class="table">
|
2436
|
+
<table>
|
2437
|
+
<tr><th>1</th><th>2</th><th>3</th><th>4|</th><th>5</th></tr>
|
2438
|
+
<tr><td>a</td><td>b</td><td>c</td><td>d</td><td>|e</td></tr>
|
2439
|
+
</table>
|
2440
|
+
</div>
|
2441
|
+
EOS
|
2442
|
+
assert_equal expected, actual
|
2443
|
+
|
2444
|
+
@config['table_row_separator'] = 'verticalbar'
|
2445
|
+
actual = compile_block(src)
|
2446
|
+
expected = <<-EOS
|
2447
|
+
<div class="table">
|
2448
|
+
<table>
|
2449
|
+
<tr><th>1 2 3 4</th><th>5</th></tr>
|
2450
|
+
<tr><td>a b c d</td><td>e</td></tr>
|
2451
|
+
</table>
|
2452
|
+
</div>
|
2453
|
+
EOS
|
1717
2454
|
assert_equal expected, actual
|
1718
2455
|
end
|
1719
2456
|
|
1720
2457
|
def test_major_blocks
|
1721
2458
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
1722
|
-
expected =
|
2459
|
+
expected = <<-EOS
|
2460
|
+
<div class="note">
|
2461
|
+
<p>A</p>
|
2462
|
+
<p>B</p>
|
2463
|
+
</div>
|
2464
|
+
<div class="note">
|
2465
|
+
<p class="caption">caption</p>
|
2466
|
+
<p>A</p>
|
2467
|
+
</div>
|
2468
|
+
EOS
|
1723
2469
|
assert_equal expected, actual
|
1724
2470
|
|
1725
2471
|
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
1726
|
-
expected =
|
2472
|
+
expected = <<-EOS
|
2473
|
+
<div class="memo">
|
2474
|
+
<p>A</p>
|
2475
|
+
<p>B</p>
|
2476
|
+
</div>
|
2477
|
+
<div class="memo">
|
2478
|
+
<p class="caption">caption</p>
|
2479
|
+
<p>A</p>
|
2480
|
+
</div>
|
2481
|
+
EOS
|
1727
2482
|
assert_equal expected, actual
|
1728
2483
|
|
1729
2484
|
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
1730
|
-
expected =
|
2485
|
+
expected = <<-EOS
|
2486
|
+
<div class="info">
|
2487
|
+
<p>A</p>
|
2488
|
+
<p>B</p>
|
2489
|
+
</div>
|
2490
|
+
<div class="info">
|
2491
|
+
<p class="caption">caption</p>
|
2492
|
+
<p>A</p>
|
2493
|
+
</div>
|
2494
|
+
EOS
|
1731
2495
|
assert_equal expected, actual
|
1732
2496
|
|
1733
2497
|
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
1734
|
-
expected =
|
2498
|
+
expected = <<-EOS
|
2499
|
+
<div class="important">
|
2500
|
+
<p>A</p>
|
2501
|
+
<p>B</p>
|
2502
|
+
</div>
|
2503
|
+
<div class="important">
|
2504
|
+
<p class="caption">caption</p>
|
2505
|
+
<p>A</p>
|
2506
|
+
</div>
|
2507
|
+
EOS
|
1735
2508
|
assert_equal expected, actual
|
1736
2509
|
|
1737
2510
|
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
1738
|
-
expected =
|
2511
|
+
expected = <<-EOS
|
2512
|
+
<div class="caution">
|
2513
|
+
<p>A</p>
|
2514
|
+
<p>B</p>
|
2515
|
+
</div>
|
2516
|
+
<div class="caution">
|
2517
|
+
<p class="caption">caption</p>
|
2518
|
+
<p>A</p>
|
2519
|
+
</div>
|
2520
|
+
EOS
|
1739
2521
|
assert_equal expected, actual
|
1740
2522
|
|
1741
2523
|
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
1742
|
-
expected =
|
2524
|
+
expected = <<-EOS
|
2525
|
+
<div class="notice">
|
2526
|
+
<p>A</p>
|
2527
|
+
<p>B</p>
|
2528
|
+
</div>
|
2529
|
+
<div class="notice">
|
2530
|
+
<p class="caption">caption</p>
|
2531
|
+
<p>A</p>
|
2532
|
+
</div>
|
2533
|
+
EOS
|
1743
2534
|
assert_equal expected, actual
|
1744
2535
|
|
1745
2536
|
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
1746
|
-
expected =
|
2537
|
+
expected = <<-EOS
|
2538
|
+
<div class="warning">
|
2539
|
+
<p>A</p>
|
2540
|
+
<p>B</p>
|
2541
|
+
</div>
|
2542
|
+
<div class="warning">
|
2543
|
+
<p class="caption">caption</p>
|
2544
|
+
<p>A</p>
|
2545
|
+
</div>
|
2546
|
+
EOS
|
1747
2547
|
assert_equal expected, actual
|
1748
2548
|
|
1749
2549
|
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
1750
|
-
expected =
|
2550
|
+
expected = <<-EOS
|
2551
|
+
<div class="tip">
|
2552
|
+
<p>A</p>
|
2553
|
+
<p>B</p>
|
2554
|
+
</div>
|
2555
|
+
<div class="tip">
|
2556
|
+
<p class="caption">caption</p>
|
2557
|
+
<p>A</p>
|
2558
|
+
</div>
|
2559
|
+
EOS
|
1751
2560
|
assert_equal expected, actual
|
1752
2561
|
end
|
1753
2562
|
|
2563
|
+
def test_minicolumn_blocks
|
2564
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2565
|
+
src = <<-EOS
|
2566
|
+
//#{type}[#{type}1]{
|
2567
|
+
|
2568
|
+
//}
|
2569
|
+
|
2570
|
+
//#{type}[#{type}2]{
|
2571
|
+
//}
|
2572
|
+
EOS
|
2573
|
+
|
2574
|
+
expected = <<-EOS
|
2575
|
+
<div class="#{type}">
|
2576
|
+
<p class="caption">#{type}1</p>
|
2577
|
+
</div>
|
2578
|
+
<div class="#{type}">
|
2579
|
+
<p class="caption">#{type}2</p>
|
2580
|
+
</div>
|
2581
|
+
EOS
|
2582
|
+
assert_equal expected, compile_block(src)
|
2583
|
+
|
2584
|
+
src = <<-EOS
|
2585
|
+
//#{type}[#{type}2]{
|
2586
|
+
|
2587
|
+
//}
|
2588
|
+
|
2589
|
+
//#{type}[#{type}3]{
|
2590
|
+
|
2591
|
+
//}
|
2592
|
+
|
2593
|
+
//#{type}[#{type}4]{
|
2594
|
+
|
2595
|
+
//}
|
2596
|
+
|
2597
|
+
//#{type}[#{type}5]{
|
2598
|
+
|
2599
|
+
//}
|
2600
|
+
|
2601
|
+
//#{type}[#{type}6]{
|
2602
|
+
|
2603
|
+
//}
|
2604
|
+
EOS
|
2605
|
+
|
2606
|
+
expected = <<-EOS
|
2607
|
+
<div class="#{type}">
|
2608
|
+
<p class="caption">#{type}2</p>
|
2609
|
+
</div>
|
2610
|
+
<div class="#{type}">
|
2611
|
+
<p class="caption">#{type}3</p>
|
2612
|
+
</div>
|
2613
|
+
<div class="#{type}">
|
2614
|
+
<p class="caption">#{type}4</p>
|
2615
|
+
</div>
|
2616
|
+
<div class="#{type}">
|
2617
|
+
<p class="caption">#{type}5</p>
|
2618
|
+
</div>
|
2619
|
+
<div class="#{type}">
|
2620
|
+
<p class="caption">#{type}6</p>
|
2621
|
+
</div>
|
2622
|
+
EOS
|
2623
|
+
assert_equal expected, compile_block(src)
|
2624
|
+
|
2625
|
+
src = <<-EOS
|
2626
|
+
//#{type}{
|
2627
|
+
|
2628
|
+
* A
|
2629
|
+
|
2630
|
+
1. B
|
2631
|
+
|
2632
|
+
//}
|
2633
|
+
|
2634
|
+
//#{type}[OMITEND1]{
|
2635
|
+
|
2636
|
+
//emlist{
|
2637
|
+
LIST
|
2638
|
+
//}
|
2639
|
+
|
2640
|
+
//}
|
2641
|
+
|
2642
|
+
//#{type}[OMITEND2]{
|
2643
|
+
//}
|
2644
|
+
EOS
|
2645
|
+
|
2646
|
+
expected = <<-EOS
|
2647
|
+
<div class="#{type}">
|
2648
|
+
<ul>
|
2649
|
+
<li>A</li>
|
2650
|
+
</ul>
|
2651
|
+
<ol>
|
2652
|
+
<li>B</li>
|
2653
|
+
</ol>
|
2654
|
+
</div>
|
2655
|
+
<div class="#{type}">
|
2656
|
+
<p class="caption">OMITEND1</p>
|
2657
|
+
<div class="emlist-code">
|
2658
|
+
<pre class="emlist">LIST
|
2659
|
+
</pre>
|
2660
|
+
</div>
|
2661
|
+
</div>
|
2662
|
+
<div class="#{type}">
|
2663
|
+
<p class="caption">OMITEND2</p>
|
2664
|
+
</div>
|
2665
|
+
EOS
|
2666
|
+
assert_equal expected, compile_block(src)
|
2667
|
+
end
|
2668
|
+
end
|
2669
|
+
|
2670
|
+
def test_minicolumn_blocks_nest_error1
|
2671
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2672
|
+
@builder.doc_status.clear
|
2673
|
+
src = <<-EOS
|
2674
|
+
//#{type}{
|
2675
|
+
|
2676
|
+
//#{type}{
|
2677
|
+
//}
|
2678
|
+
|
2679
|
+
//}
|
2680
|
+
EOS
|
2681
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2682
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2683
|
+
end
|
2684
|
+
end
|
2685
|
+
|
2686
|
+
def test_minicolumn_blocks_nest_error2
|
2687
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2688
|
+
@builder.doc_status.clear
|
2689
|
+
src = <<-EOS
|
2690
|
+
//#{type}{
|
2691
|
+
|
2692
|
+
//#{type}{
|
2693
|
+
|
2694
|
+
//}
|
2695
|
+
|
2696
|
+
//}
|
2697
|
+
EOS
|
2698
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2699
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2700
|
+
end
|
2701
|
+
end
|
2702
|
+
|
2703
|
+
def test_minicolumn_blocks_nest_error3
|
2704
|
+
%w[memo tip info warning important caution notice].each do |type|
|
2705
|
+
@builder.doc_status.clear
|
2706
|
+
src = <<-EOS
|
2707
|
+
//#{type}{
|
2708
|
+
|
2709
|
+
//note{
|
2710
|
+
|
2711
|
+
//}
|
2712
|
+
|
2713
|
+
//}
|
2714
|
+
EOS
|
2715
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2716
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2717
|
+
end
|
2718
|
+
end
|
2719
|
+
|
1754
2720
|
def test_comment
|
1755
2721
|
actual = compile_block('//comment[コメント]')
|
1756
2722
|
assert_equal '', actual
|
@@ -1793,23 +2759,23 @@ EOB
|
|
1793
2759
|
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
1794
2760
|
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
1795
2761
|
assert_equal %Q(<p>foo bar"\\<>_@<b>{BAZ} <b>bar"\\<>_@<b>{BAZ}</b> [missing word: N]</p>\n), actual
|
1796
|
-
assert_match(/WARN
|
2762
|
+
assert_match(/WARN --: :1: word not bound: N/, io.string)
|
1797
2763
|
end
|
1798
2764
|
end
|
1799
2765
|
|
1800
2766
|
def test_inline_unknown
|
1801
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2767
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1802
2768
|
assert_equal ':1: error: unknown image: n', e.message
|
1803
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2769
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1804
2770
|
assert_equal ':1: error: unknown footnote: n', e.message
|
1805
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2771
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1806
2772
|
assert_equal ':1: error: unknown headline: n', e.message
|
1807
2773
|
%w[list table column].each do |name|
|
1808
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2774
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1809
2775
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
1810
2776
|
end
|
1811
2777
|
%w[chap chapref title].each do |name|
|
1812
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2778
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1813
2779
|
assert_equal ':1: error: key not found: "n"', e.message
|
1814
2780
|
end
|
1815
2781
|
end
|
@@ -1839,6 +2805,20 @@ e=mc^2
|
|
1839
2805
|
//}
|
1840
2806
|
EOS
|
1841
2807
|
expected = <<-EOS
|
2808
|
+
<p><span class="eqref"><a href="./-.html#emc2">式1.1</a></span></p>
|
2809
|
+
<div id="emc2" class="caption-equation">
|
2810
|
+
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2811
|
+
<div class="equation">
|
2812
|
+
<pre>e=mc^2
|
2813
|
+
</pre>
|
2814
|
+
</div>
|
2815
|
+
</div>
|
2816
|
+
EOS
|
2817
|
+
actual = compile_block(src)
|
2818
|
+
assert_equal expected, actual
|
2819
|
+
|
2820
|
+
@config['chapterlink'] = nil
|
2821
|
+
expected = <<-EOS
|
1842
2822
|
<p><span class="eqref">式1.1</span></p>
|
1843
2823
|
<div id="emc2" class="caption-equation">
|
1844
2824
|
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
@@ -1850,5 +2830,311 @@ EOS
|
|
1850
2830
|
EOS
|
1851
2831
|
actual = compile_block(src)
|
1852
2832
|
assert_equal expected, actual
|
2833
|
+
|
2834
|
+
@config['caption_position']['equation'] = 'bottom'
|
2835
|
+
expected = <<-EOS
|
2836
|
+
<p><span class="eqref">式1.1</span></p>
|
2837
|
+
<div id="emc2" class="caption-equation">
|
2838
|
+
<div class="equation">
|
2839
|
+
<pre>e=mc^2
|
2840
|
+
</pre>
|
2841
|
+
</div>
|
2842
|
+
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2843
|
+
</div>
|
2844
|
+
EOS
|
2845
|
+
actual = compile_block(src)
|
2846
|
+
assert_equal expected, actual
|
2847
|
+
end
|
2848
|
+
|
2849
|
+
def test_nest_error_close1
|
2850
|
+
src = <<-EOS
|
2851
|
+
//beginchild
|
2852
|
+
EOS
|
2853
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2854
|
+
assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
2855
|
+
end
|
2856
|
+
|
2857
|
+
def test_nest_error_close2
|
2858
|
+
src = <<-EOS
|
2859
|
+
* foo
|
2860
|
+
|
2861
|
+
//beginchild
|
2862
|
+
|
2863
|
+
1. foo
|
2864
|
+
|
2865
|
+
//beginchild
|
2866
|
+
|
2867
|
+
: foo
|
2868
|
+
|
2869
|
+
//beginchild
|
2870
|
+
EOS
|
2871
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2872
|
+
assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
|
2873
|
+
end
|
2874
|
+
|
2875
|
+
def test_nest_error_close3
|
2876
|
+
src = <<-EOS
|
2877
|
+
* foo
|
2878
|
+
|
2879
|
+
//beginchild
|
2880
|
+
|
2881
|
+
1. foo
|
2882
|
+
|
2883
|
+
//beginchild
|
2884
|
+
|
2885
|
+
: foo
|
2886
|
+
|
2887
|
+
//beginchild
|
2888
|
+
|
2889
|
+
//endchild
|
2890
|
+
EOS
|
2891
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2892
|
+
assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
|
2893
|
+
end
|
2894
|
+
|
2895
|
+
def test_nest_ul
|
2896
|
+
src = <<-EOS
|
2897
|
+
* UL1
|
2898
|
+
|
2899
|
+
//beginchild
|
2900
|
+
|
2901
|
+
1. UL1-OL1
|
2902
|
+
2. UL1-OL2
|
2903
|
+
|
2904
|
+
* UL1-UL1
|
2905
|
+
* UL1-UL2
|
2906
|
+
|
2907
|
+
: UL1-DL1
|
2908
|
+
UL1-DD1
|
2909
|
+
: UL1-DL2
|
2910
|
+
UL1-DD2
|
2911
|
+
|
2912
|
+
//endchild
|
2913
|
+
|
2914
|
+
* UL2
|
2915
|
+
|
2916
|
+
//beginchild
|
2917
|
+
|
2918
|
+
UL2-PARA
|
2919
|
+
|
2920
|
+
//endchild
|
2921
|
+
EOS
|
2922
|
+
|
2923
|
+
expected = <<-EOS
|
2924
|
+
<ul>
|
2925
|
+
<li>UL1
|
2926
|
+
<ol>
|
2927
|
+
<li>UL1-OL1</li>
|
2928
|
+
<li>UL1-OL2</li>
|
2929
|
+
</ol>
|
2930
|
+
<ul>
|
2931
|
+
<li>UL1-UL1</li>
|
2932
|
+
<li>UL1-UL2</li>
|
2933
|
+
</ul>
|
2934
|
+
<dl>
|
2935
|
+
<dt>UL1-DL1</dt>
|
2936
|
+
<dd>UL1-DD1</dd>
|
2937
|
+
<dt>UL1-DL2</dt>
|
2938
|
+
<dd>UL1-DD2</dd>
|
2939
|
+
</dl>
|
2940
|
+
</li>
|
2941
|
+
|
2942
|
+
<li>UL2
|
2943
|
+
<p>UL2-PARA</p>
|
2944
|
+
</li>
|
2945
|
+
</ul>
|
2946
|
+
EOS
|
2947
|
+
|
2948
|
+
actual = compile_block(src)
|
2949
|
+
assert_equal expected, actual
|
2950
|
+
end
|
2951
|
+
|
2952
|
+
def test_nest_ol
|
2953
|
+
src = <<-EOS
|
2954
|
+
1. OL1
|
2955
|
+
|
2956
|
+
//beginchild
|
2957
|
+
|
2958
|
+
1. OL1-OL1
|
2959
|
+
2. OL1-OL2
|
2960
|
+
|
2961
|
+
* OL1-UL1
|
2962
|
+
* OL1-UL2
|
2963
|
+
|
2964
|
+
: OL1-DL1
|
2965
|
+
OL1-DD1
|
2966
|
+
: OL1-DL2
|
2967
|
+
OL1-DD2
|
2968
|
+
|
2969
|
+
//endchild
|
2970
|
+
|
2971
|
+
2. OL2
|
2972
|
+
|
2973
|
+
//beginchild
|
2974
|
+
|
2975
|
+
OL2-PARA
|
2976
|
+
|
2977
|
+
//endchild
|
2978
|
+
EOS
|
2979
|
+
|
2980
|
+
expected = <<-EOS
|
2981
|
+
<ol>
|
2982
|
+
<li>OL1
|
2983
|
+
<ol>
|
2984
|
+
<li>OL1-OL1</li>
|
2985
|
+
<li>OL1-OL2</li>
|
2986
|
+
</ol>
|
2987
|
+
<ul>
|
2988
|
+
<li>OL1-UL1</li>
|
2989
|
+
<li>OL1-UL2</li>
|
2990
|
+
</ul>
|
2991
|
+
<dl>
|
2992
|
+
<dt>OL1-DL1</dt>
|
2993
|
+
<dd>OL1-DD1</dd>
|
2994
|
+
<dt>OL1-DL2</dt>
|
2995
|
+
<dd>OL1-DD2</dd>
|
2996
|
+
</dl>
|
2997
|
+
</li>
|
2998
|
+
|
2999
|
+
<li>OL2
|
3000
|
+
<p>OL2-PARA</p>
|
3001
|
+
</li>
|
3002
|
+
</ol>
|
3003
|
+
EOS
|
3004
|
+
|
3005
|
+
actual = compile_block(src)
|
3006
|
+
assert_equal expected, actual
|
3007
|
+
end
|
3008
|
+
|
3009
|
+
def test_nest_dl
|
3010
|
+
src = <<-EOS
|
3011
|
+
: DL1
|
3012
|
+
|
3013
|
+
//beginchild
|
3014
|
+
|
3015
|
+
1. DL1-OL1
|
3016
|
+
2. DL1-OL2
|
3017
|
+
|
3018
|
+
* DL1-UL1
|
3019
|
+
* DL1-UL2
|
3020
|
+
|
3021
|
+
: DL1-DL1
|
3022
|
+
DL1-DD1
|
3023
|
+
: DL1-DL2
|
3024
|
+
DL1-DD2
|
3025
|
+
|
3026
|
+
//endchild
|
3027
|
+
|
3028
|
+
: DL2
|
3029
|
+
DD2
|
3030
|
+
|
3031
|
+
//beginchild
|
3032
|
+
|
3033
|
+
* DD2-UL1
|
3034
|
+
* DD2-UL2
|
3035
|
+
|
3036
|
+
DD2-PARA
|
3037
|
+
|
3038
|
+
//endchild
|
3039
|
+
EOS
|
3040
|
+
|
3041
|
+
expected = <<-EOS
|
3042
|
+
<dl>
|
3043
|
+
<dt>DL1</dt>
|
3044
|
+
<dd>
|
3045
|
+
<ol>
|
3046
|
+
<li>DL1-OL1</li>
|
3047
|
+
<li>DL1-OL2</li>
|
3048
|
+
</ol>
|
3049
|
+
<ul>
|
3050
|
+
<li>DL1-UL1</li>
|
3051
|
+
<li>DL1-UL2</li>
|
3052
|
+
</ul>
|
3053
|
+
<dl>
|
3054
|
+
<dt>DL1-DL1</dt>
|
3055
|
+
<dd>DL1-DD1</dd>
|
3056
|
+
<dt>DL1-DL2</dt>
|
3057
|
+
<dd>DL1-DD2</dd>
|
3058
|
+
</dl>
|
3059
|
+
</dd>
|
3060
|
+
|
3061
|
+
<dt>DL2</dt>
|
3062
|
+
<dd>DD2
|
3063
|
+
<ul>
|
3064
|
+
<li>DD2-UL1</li>
|
3065
|
+
<li>DD2-UL2</li>
|
3066
|
+
</ul>
|
3067
|
+
<p>DD2-PARA</p>
|
3068
|
+
</dd>
|
3069
|
+
</dl>
|
3070
|
+
EOS
|
3071
|
+
|
3072
|
+
actual = compile_block(src)
|
3073
|
+
assert_equal expected, actual
|
3074
|
+
end
|
3075
|
+
|
3076
|
+
def test_nest_multi
|
3077
|
+
src = <<-EOS
|
3078
|
+
1. OL1
|
3079
|
+
|
3080
|
+
//beginchild
|
3081
|
+
|
3082
|
+
1. OL1-OL1
|
3083
|
+
|
3084
|
+
//beginchild
|
3085
|
+
|
3086
|
+
* OL1-OL1-UL1
|
3087
|
+
|
3088
|
+
OL1-OL1-PARA
|
3089
|
+
|
3090
|
+
//endchild
|
3091
|
+
|
3092
|
+
2. OL1-OL2
|
3093
|
+
|
3094
|
+
* OL1-UL1
|
3095
|
+
|
3096
|
+
//beginchild
|
3097
|
+
|
3098
|
+
: OL1-UL1-DL1
|
3099
|
+
OL1-UL1-DD1
|
3100
|
+
|
3101
|
+
OL1-UL1-PARA
|
3102
|
+
|
3103
|
+
//endchild
|
3104
|
+
|
3105
|
+
* OL1-UL2
|
3106
|
+
|
3107
|
+
//endchild
|
3108
|
+
EOS
|
3109
|
+
expected = <<-EOS
|
3110
|
+
<ol>
|
3111
|
+
<li>OL1
|
3112
|
+
<ol>
|
3113
|
+
<li>OL1-OL1
|
3114
|
+
<ul>
|
3115
|
+
<li>OL1-OL1-UL1</li>
|
3116
|
+
</ul>
|
3117
|
+
<p>OL1-OL1-PARA</p>
|
3118
|
+
</li>
|
3119
|
+
|
3120
|
+
<li>OL1-OL2</li>
|
3121
|
+
</ol>
|
3122
|
+
<ul>
|
3123
|
+
<li>OL1-UL1
|
3124
|
+
<dl>
|
3125
|
+
<dt>OL1-UL1-DL1</dt>
|
3126
|
+
<dd>OL1-UL1-DD1</dd>
|
3127
|
+
</dl>
|
3128
|
+
<p>OL1-UL1-PARA</p>
|
3129
|
+
</li>
|
3130
|
+
|
3131
|
+
<li>OL1-UL2</li>
|
3132
|
+
</ul>
|
3133
|
+
</li>
|
3134
|
+
</ol>
|
3135
|
+
EOS
|
3136
|
+
|
3137
|
+
actual = compile_block(src)
|
3138
|
+
assert_equal expected, actual
|
1853
3139
|
end
|
1854
3140
|
end
|