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
data/test/test_htmlutils.rb
CHANGED
@@ -17,18 +17,6 @@ class HTMLUtilsTest < Test::Unit::TestCase
|
|
17
17
|
assert_equal '&', unescape('&amp;')
|
18
18
|
end
|
19
19
|
|
20
|
-
def test_escape_html_ex
|
21
|
-
keys = ESC.keys
|
22
|
-
ESC['.'] = 'X'
|
23
|
-
ESC.each_pair do |ch, ref|
|
24
|
-
if keys.include?(ch)
|
25
|
-
assert_equal ref, escape(ch)
|
26
|
-
else
|
27
|
-
assert_equal ch, escape(ch)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
20
|
def test_strip_html
|
33
21
|
assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
|
34
22
|
end
|
data/test/test_i18n.rb
CHANGED
@@ -9,7 +9,7 @@ class I18nTest < Test::Unit::TestCase
|
|
9
9
|
Dir.mktmpdir do |dir|
|
10
10
|
Dir.chdir(dir) do
|
11
11
|
file = File.join(dir, 'locale.yml')
|
12
|
-
File.
|
12
|
+
File.write(file, %Q(locale: ja\nfoo: "bar"\n))
|
13
13
|
I18n.setup
|
14
14
|
assert_equal 'bar', I18n.t('foo')
|
15
15
|
end
|
@@ -20,7 +20,7 @@ class I18nTest < Test::Unit::TestCase
|
|
20
20
|
Dir.mktmpdir do |dir|
|
21
21
|
Dir.chdir(dir) do
|
22
22
|
file = File.join(dir, 'locale.yaml')
|
23
|
-
File.
|
23
|
+
File.write(file, %Q(locale: ja\nfoo: "bar"\n))
|
24
24
|
assert_raise ReVIEW::ConfigError do
|
25
25
|
I18n.setup
|
26
26
|
end
|
@@ -32,7 +32,7 @@ class I18nTest < Test::Unit::TestCase
|
|
32
32
|
Dir.mktmpdir do |dir|
|
33
33
|
Dir.chdir(dir) do
|
34
34
|
file = File.join(dir, 'foo.yml')
|
35
|
-
File.
|
35
|
+
File.write(file, %Q(locale: ja\nfoo: "bar"\n))
|
36
36
|
I18n.setup('ja', 'foo.yml')
|
37
37
|
assert_equal 'bar', I18n.t('foo')
|
38
38
|
end
|
@@ -43,7 +43,7 @@ class I18nTest < Test::Unit::TestCase
|
|
43
43
|
Dir.mktmpdir do |dir|
|
44
44
|
Dir.chdir(dir) do
|
45
45
|
file = File.join(dir, 'foo.yml')
|
46
|
-
File.
|
46
|
+
File.write(file, %Q(locale: ja\nfoo: "bar"\n))
|
47
47
|
i18n = ReVIEW::I18n.new('ja')
|
48
48
|
i18n.update_localefile(File.join(Dir.pwd, 'foo.yml'))
|
49
49
|
assert_equal 'bar', i18n.t('foo')
|
@@ -55,7 +55,7 @@ class I18nTest < Test::Unit::TestCase
|
|
55
55
|
Dir.mktmpdir do |dir|
|
56
56
|
Dir.chdir(dir) do
|
57
57
|
file = File.join(dir, 'foo.yml')
|
58
|
-
File.
|
58
|
+
File.write(file, %Q(locale: ja\nfoo: "bar"\n))
|
59
59
|
I18n.setup('ja', 'foo.yml')
|
60
60
|
assert_equal 'bar', I18n.t('foo')
|
61
61
|
end
|
@@ -66,7 +66,7 @@ class I18nTest < Test::Unit::TestCase
|
|
66
66
|
Dir.mktmpdir do |dir|
|
67
67
|
Dir.chdir(dir) do
|
68
68
|
file = File.join(dir, 'locale.yml')
|
69
|
-
File.
|
69
|
+
File.write(file, %Q(ja:\n foo: "bar"\nen:\n foo: "buz"\n))
|
70
70
|
I18n.setup
|
71
71
|
assert_equal 'bar', I18n.t('foo')
|
72
72
|
assert_equal '図', I18n.t('image')
|
@@ -81,7 +81,7 @@ class I18nTest < Test::Unit::TestCase
|
|
81
81
|
Dir.mktmpdir do |dir|
|
82
82
|
Dir.chdir(dir) do
|
83
83
|
file = File.join(dir, 'locale.yml')
|
84
|
-
File.
|
84
|
+
File.write(file, %Q(local: ja\nfoo: "bar"\n))
|
85
85
|
assert_raises(ReVIEW::KeyError) do
|
86
86
|
I18n.setup
|
87
87
|
end
|
@@ -93,59 +93,59 @@ class I18nTest < Test::Unit::TestCase
|
|
93
93
|
Dir.mktmpdir do |dir|
|
94
94
|
Dir.chdir(dir) do
|
95
95
|
file = File.join(dir, 'locale.yml')
|
96
|
-
File.
|
96
|
+
File.write(file, "locale: ja\nchapter: 第%pa章")
|
97
97
|
I18n.setup('ja')
|
98
98
|
assert_equal '第a章', I18n.t('chapter', 1)
|
99
99
|
|
100
|
-
File.
|
100
|
+
File.write(file, "locale: ja\nchapter: 第%pA章")
|
101
101
|
I18n.setup('ja')
|
102
102
|
assert_equal '第B章', I18n.t('chapter', 2)
|
103
103
|
|
104
|
-
File.
|
104
|
+
File.write(file, "locale: ja\nchapter: 第%pAW章")
|
105
105
|
I18n.setup('ja')
|
106
106
|
assert_equal '第B章', I18n.t('chapter', 2)
|
107
107
|
|
108
|
-
File.
|
108
|
+
File.write(file, "locale: ja\nchapter: 第%paW章")
|
109
109
|
I18n.setup('ja')
|
110
110
|
assert_equal '第b章', I18n.t('chapter', 2)
|
111
111
|
|
112
|
-
File.
|
112
|
+
File.write(file, "locale: ja\nchapter: 第%pR章")
|
113
113
|
I18n.setup('ja')
|
114
114
|
assert_equal '第I章', I18n.t('chapter', 1)
|
115
115
|
|
116
|
-
File.
|
116
|
+
File.write(file, "locale: ja\nchapter: 第%pr章")
|
117
117
|
I18n.setup('ja')
|
118
118
|
assert_equal '第ii章', I18n.t('chapter', 2)
|
119
119
|
|
120
|
-
File.
|
120
|
+
File.write(file, "locale: ja\nchapter: 第%pRW章")
|
121
121
|
I18n.setup('ja')
|
122
122
|
assert_equal '第Ⅻ章', I18n.t('chapter', 12)
|
123
123
|
|
124
|
-
File.
|
124
|
+
File.write(file, "locale: ja\nchapter: 第%pJ章")
|
125
125
|
I18n.setup('ja')
|
126
126
|
assert_equal '第二十七章', I18n.t('chapter', 27)
|
127
127
|
|
128
|
-
File.
|
128
|
+
File.write(file, "locale: ja\nchapter: 第%pdW章")
|
129
129
|
I18n.setup('ja')
|
130
130
|
assert_equal '第1章', I18n.t('chapter', 1)
|
131
131
|
|
132
|
-
File.
|
132
|
+
File.write(file, "locale: ja\nchapter: 第%pdW章")
|
133
133
|
I18n.setup('ja')
|
134
134
|
assert_equal '第27章', I18n.t('chapter', 27)
|
135
135
|
|
136
|
-
File.
|
136
|
+
File.write(file, "locale: ja\nchapter: 第%pDW章")
|
137
137
|
I18n.setup('ja')
|
138
138
|
assert_equal '第1章', I18n.t('chapter', 1)
|
139
139
|
|
140
|
-
File.
|
140
|
+
File.write(file, "locale: ja\nchapter: 第%pDW章")
|
141
141
|
I18n.setup('ja')
|
142
142
|
assert_equal '第27章', I18n.t('chapter', 27)
|
143
143
|
|
144
|
-
File.
|
144
|
+
File.write(file, "locale: ja\npart: Part %pRW")
|
145
145
|
I18n.setup('ja')
|
146
146
|
assert_equal 'Part 0', I18n.t('part', 0)
|
147
147
|
|
148
|
-
File.
|
148
|
+
File.write(file, "locale: ja\npart: 第%pJ部")
|
149
149
|
I18n.setup('ja')
|
150
150
|
assert_equal '第一部', I18n.t('part', 1)
|
151
151
|
end
|
@@ -157,23 +157,23 @@ class I18nTest < Test::Unit::TestCase
|
|
157
157
|
Dir.chdir(dir) do
|
158
158
|
file = File.join(dir, 'locale.yml')
|
159
159
|
|
160
|
-
File.
|
160
|
+
File.write(file, %Q(locale: ja\nformat_number_header: "%s-%pA:"))
|
161
161
|
I18n.setup('ja')
|
162
162
|
assert_equal '1-B:', I18n.t('format_number_header', [1, 2])
|
163
163
|
|
164
|
-
File.
|
164
|
+
File.write(file, %Q(locale: ja\nformat_number_header: "%s.%pa:"))
|
165
165
|
I18n.setup('ja')
|
166
166
|
assert_equal '2.c:', I18n.t('format_number_header', [2, 3])
|
167
167
|
|
168
|
-
File.
|
168
|
+
File.write(file, %Q(locale: ja\nformat_number_header: "%pA,%pAW:"))
|
169
169
|
I18n.setup('ja')
|
170
170
|
assert_equal 'C,D:', I18n.t('format_number_header', [3, 4])
|
171
171
|
|
172
|
-
File.
|
172
|
+
File.write(file, %Q(locale: ja\nformat_number_header: "%pJ・%pJ:"))
|
173
173
|
I18n.setup('ja')
|
174
174
|
assert_equal '十二・二十六:', I18n.t('format_number_header', [12, 26])
|
175
175
|
|
176
|
-
File.
|
176
|
+
File.write(file, %Q(locale: ja\nformat_number_header: "%pdW―%pdW:"))
|
177
177
|
I18n.setup('ja')
|
178
178
|
assert_equal '3―12:', I18n.t('format_number_header', [3, 12])
|
179
179
|
end
|
@@ -185,11 +185,11 @@ class I18nTest < Test::Unit::TestCase
|
|
185
185
|
Dir.chdir(dir) do
|
186
186
|
file = File.join(dir, 'locale.yml')
|
187
187
|
|
188
|
-
File.
|
188
|
+
File.write(file, %Q(locale: ja\nformat_number_header: "%2$d"))
|
189
189
|
I18n.setup('ja')
|
190
190
|
assert_equal '10', I18n.t('format_number_header', [1, 10])
|
191
191
|
|
192
|
-
File.
|
192
|
+
File.write(file, %Q(locale: ja\nformat_number_header: "%2$d-%1$d"))
|
193
193
|
I18n.setup('ja')
|
194
194
|
# ERROR: returns raw format
|
195
195
|
assert_equal '%2$d-%1$d', I18n.t('format_number_header', [1])
|
@@ -215,7 +215,7 @@ class I18nTest < Test::Unit::TestCase
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def test_en
|
218
|
-
I18n.setup
|
218
|
+
I18n.setup('en')
|
219
219
|
assert_equal 'Figure ', I18n.t('image')
|
220
220
|
assert_equal 'Table ', I18n.t('table')
|
221
221
|
assert_equal 'Chapter 1', I18n.t('chapter', 1)
|
@@ -223,7 +223,7 @@ class I18nTest < Test::Unit::TestCase
|
|
223
223
|
end
|
224
224
|
|
225
225
|
def test_nil
|
226
|
-
I18n.setup
|
226
|
+
I18n.setup('nil')
|
227
227
|
assert_equal 'image', I18n.t('image')
|
228
228
|
assert_equal 'table', I18n.t('table')
|
229
229
|
assert_equal 'etc', I18n.t('etc')
|
@@ -236,13 +236,13 @@ class I18nTest < Test::Unit::TestCase
|
|
236
236
|
end
|
237
237
|
|
238
238
|
def _setup_htmlbuilder
|
239
|
-
I18n.setup
|
239
|
+
I18n.setup('en')
|
240
240
|
@builder = HTMLBuilder.new
|
241
|
-
@config = ReVIEW::Configure
|
242
|
-
'secnolevel' => 2, # for IDGXMLBuilder, HTMLBuilder
|
243
|
-
|
244
|
-
|
245
|
-
|
241
|
+
@config = ReVIEW::Configure.values.merge(
|
242
|
+
{ 'secnolevel' => 2, # for IDGXMLBuilder, HTMLBuilder
|
243
|
+
'stylesheet' => nil, # for HTMLBuilder
|
244
|
+
'ext' => '.re' }
|
245
|
+
)
|
246
246
|
@book = Book::Base.new('.')
|
247
247
|
@book.config = @config
|
248
248
|
@compiler = ReVIEW::Compiler.new(@builder)
|
@@ -295,6 +295,6 @@ class I18nTest < Test::Unit::TestCase
|
|
295
295
|
end
|
296
296
|
|
297
297
|
def teardown
|
298
|
-
I18n.setup
|
298
|
+
I18n.setup('ja')
|
299
299
|
end
|
300
300
|
end
|
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -100,6 +100,27 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
100
100
|
assert_equal %Q(<table><tbody><tr><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i><>&</tr></tbody></table>), actual
|
101
101
|
end
|
102
102
|
|
103
|
+
def test_table
|
104
|
+
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
105
|
+
expected = <<-EOS.chomp
|
106
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">aaa</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">bbb</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ccc</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ddd<>&</td></tbody></table>
|
107
|
+
EOS
|
108
|
+
assert_equal expected, actual
|
109
|
+
|
110
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
111
|
+
expected = <<-EOS.chomp
|
112
|
+
<table><caption>表1.1 FOO</caption><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">aaa</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">bbb</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ccc</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ddd<>&</td></tbody></table>
|
113
|
+
EOS
|
114
|
+
assert_equal expected, actual
|
115
|
+
|
116
|
+
@config['caption_position']['table'] = 'bottom'
|
117
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
118
|
+
expected = <<-EOS.chomp
|
119
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">aaa</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">bbb</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ccc</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ddd<>&</td></tbody><caption>表1.1 FOO</caption></table>
|
120
|
+
EOS
|
121
|
+
assert_equal expected, actual
|
122
|
+
end
|
123
|
+
|
103
124
|
def test_customize_cellwidth
|
104
125
|
actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
105
126
|
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="8.503">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">C</td></tbody></table>), actual
|
@@ -133,9 +154,51 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
133
154
|
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.458">A</td></tbody></table>), actual
|
134
155
|
end
|
135
156
|
|
157
|
+
def test_empty_table
|
158
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
159
|
+
assert_equal ':2: error: no rows in the table', e.message
|
160
|
+
|
161
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
162
|
+
assert_equal ':3: error: no rows in the table', e.message
|
163
|
+
end
|
164
|
+
|
136
165
|
def test_emtable
|
137
166
|
actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
|
138
167
|
assert_equal %Q(<table><caption>foo</caption><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>), actual
|
168
|
+
|
169
|
+
@config['caption_position']['table'] = 'bottom'
|
170
|
+
actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
|
171
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody><caption>foo</caption></table><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>), actual
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_table_row_separator
|
175
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
176
|
+
expected = <<-EOS.chomp
|
177
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="3"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">c d |e</td></tbody></table>
|
178
|
+
EOS
|
179
|
+
actual = compile_block(src)
|
180
|
+
assert_equal expected, actual
|
181
|
+
|
182
|
+
@config['table_row_separator'] = 'singletab'
|
183
|
+
actual = compile_block(src)
|
184
|
+
expected = <<-EOS.chomp
|
185
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="4"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086"></td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">c d |e</td></tbody></table>
|
186
|
+
EOS
|
187
|
+
assert_equal expected, actual
|
188
|
+
|
189
|
+
@config['table_row_separator'] = 'spaces'
|
190
|
+
actual = compile_block(src)
|
191
|
+
expected = <<-EOS.chomp
|
192
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="5"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">3</td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">4|</td><td xyh="5,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">a</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">b</td><td xyh="3,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">c</td><td xyh="4,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">d</td><td xyh="5,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">|e</td></tbody></table>
|
193
|
+
EOS
|
194
|
+
assert_equal expected, actual
|
195
|
+
|
196
|
+
@config['table_row_separator'] = 'verticalbar'
|
197
|
+
actual = compile_block(src)
|
198
|
+
expected = <<-EOS.chomp
|
199
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">1 2 3 4</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">a b c d</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">e</td></tbody></table>
|
200
|
+
EOS
|
201
|
+
assert_equal expected, actual
|
139
202
|
end
|
140
203
|
|
141
204
|
def test_inline_br
|
@@ -188,19 +251,40 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
188
251
|
assert_equal %Q(<dl><dt>foo</dt><dd>foo.</dd></dl><p>para</p><dl><dt>foo</dt><dd>foo.</dd></dl><ol><li aid:pstyle="ol-item" olnum="1" num="1">bar</li></ol><dl><dt>foo</dt><dd>foo.</dd></dl><ul><li aid:pstyle="ul-item">bar</li></ul>), actual
|
189
252
|
end
|
190
253
|
|
254
|
+
def test_dt_inline
|
255
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
256
|
+
|
257
|
+
expected = <<-EOS.chomp
|
258
|
+
<dl><dt>foo<footnote>bar</footnote>[]<>&<replace idref="texinline-1"><pre>\\alpha[]</pre></replace></dt><dd></dd></dl>
|
259
|
+
EOS
|
260
|
+
assert_equal expected, actual
|
261
|
+
end
|
262
|
+
|
191
263
|
def test_paragraph
|
192
264
|
actual = compile_block("foo\nbar\n")
|
193
265
|
assert_equal '<p>foobar</p>', actual
|
266
|
+
|
267
|
+
@book.config['join_lines_by_lang'] = true
|
268
|
+
actual = compile_block("foo\nbar\n")
|
269
|
+
assert_equal '<p>foo bar</p>', actual
|
194
270
|
end
|
195
271
|
|
196
272
|
def test_tabbed_paragraph
|
197
273
|
actual = compile_block("\tfoo\nbar\n")
|
198
274
|
assert_equal %Q(<p inlist="1">foobar</p>), actual
|
275
|
+
|
276
|
+
@book.config['join_lines_by_lang'] = true
|
277
|
+
actual = compile_block("\tfoo\nbar\n")
|
278
|
+
assert_equal %Q(<p inlist="1">foo bar</p>), actual
|
199
279
|
end
|
200
280
|
|
201
281
|
def test_quote
|
202
282
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
203
283
|
assert_equal '<quote><p>foobar</p><p>buz</p></quote>', actual
|
284
|
+
|
285
|
+
@book.config['join_lines_by_lang'] = true
|
286
|
+
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
287
|
+
assert_equal '<quote><p>foo bar</p><p>buz</p></quote>', actual
|
204
288
|
end
|
205
289
|
|
206
290
|
def test_major_blocks
|
@@ -238,107 +322,495 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
238
322
|
assert_equal expected, actual
|
239
323
|
end
|
240
324
|
|
325
|
+
def test_minicolumn_blocks
|
326
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
327
|
+
src = <<-EOS
|
328
|
+
//#{type}[#{type}1]{
|
329
|
+
|
330
|
+
//}
|
331
|
+
|
332
|
+
//#{type}[#{type}2]{
|
333
|
+
//}
|
334
|
+
EOS
|
335
|
+
|
336
|
+
if type == 'notice' # exception pattern
|
337
|
+
expected = <<-EOS.chomp
|
338
|
+
<#{type}-t><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}-t>
|
339
|
+
EOS
|
340
|
+
else
|
341
|
+
expected = <<-EOS.chomp
|
342
|
+
<#{type}><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}>
|
343
|
+
EOS
|
344
|
+
end
|
345
|
+
assert_equal expected, compile_block(src)
|
346
|
+
|
347
|
+
src = <<-EOS
|
348
|
+
//#{type}[#{type}2]{
|
349
|
+
|
350
|
+
//}
|
351
|
+
|
352
|
+
//#{type}[#{type}3]{
|
353
|
+
|
354
|
+
//}
|
355
|
+
|
356
|
+
//#{type}[#{type}4]{
|
357
|
+
|
358
|
+
//}
|
359
|
+
|
360
|
+
//#{type}[#{type}5]{
|
361
|
+
|
362
|
+
//}
|
363
|
+
|
364
|
+
//#{type}[#{type}6]{
|
365
|
+
|
366
|
+
//}
|
367
|
+
EOS
|
368
|
+
|
369
|
+
if type == 'notice' # exception pattern
|
370
|
+
expected = <<-EOS.chomp
|
371
|
+
<#{type}-t><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}3</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}4</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}5</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}6</title></#{type}-t>
|
372
|
+
EOS
|
373
|
+
else
|
374
|
+
expected = <<-EOS.chomp
|
375
|
+
<#{type}><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}3</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}4</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}5</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}6</title></#{type}>
|
376
|
+
EOS
|
377
|
+
end
|
378
|
+
assert_equal expected, compile_block(src)
|
379
|
+
|
380
|
+
src = <<-EOS
|
381
|
+
//#{type}{
|
382
|
+
|
383
|
+
* A
|
384
|
+
|
385
|
+
1. B
|
386
|
+
|
387
|
+
//}
|
388
|
+
|
389
|
+
//#{type}[OMITEND1]{
|
390
|
+
|
391
|
+
//emlist{
|
392
|
+
LIST
|
393
|
+
//}
|
394
|
+
|
395
|
+
//}
|
396
|
+
//#{type}[OMITEND2]{
|
397
|
+
//}
|
398
|
+
EOS
|
399
|
+
|
400
|
+
if type == 'notice' # exception pattern
|
401
|
+
expected = <<-EOS.chomp
|
402
|
+
<#{type}><ul><li aid:pstyle="ul-item">A</li></ul><ol><li aid:pstyle="ol-item" olnum="1" num="1">B</li></ol></#{type}><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND1</title><list type='emlist'><pre>LIST
|
403
|
+
</pre></list></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}-t>
|
404
|
+
EOS
|
405
|
+
else
|
406
|
+
expected = <<-EOS.chomp
|
407
|
+
<#{type}><ul><li aid:pstyle="ul-item">A</li></ul><ol><li aid:pstyle="ol-item" olnum="1" num="1">B</li></ol></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND1</title><list type='emlist'><pre>LIST
|
408
|
+
</pre></list></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}>
|
409
|
+
EOS
|
410
|
+
end
|
411
|
+
assert_equal expected, compile_block(src)
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_minicolumn_blocks_nest_error1
|
416
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
417
|
+
@builder.doc_status.clear
|
418
|
+
src = <<-EOS
|
419
|
+
//#{type}{
|
420
|
+
|
421
|
+
//#{type}{
|
422
|
+
//}
|
423
|
+
|
424
|
+
//}
|
425
|
+
EOS
|
426
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
427
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
def test_minicolumn_blocks_nest_error2
|
432
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
433
|
+
@builder.doc_status.clear
|
434
|
+
src = <<-EOS
|
435
|
+
//#{type}{
|
436
|
+
|
437
|
+
//#{type}{
|
438
|
+
|
439
|
+
//}
|
440
|
+
|
441
|
+
//}
|
442
|
+
EOS
|
443
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
444
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
def test_minicolumn_blocks_nest_error3
|
449
|
+
%w[memo tip info warning important caution notice].each do |type|
|
450
|
+
@builder.doc_status.clear
|
451
|
+
src = <<-EOS
|
452
|
+
//#{type}{
|
453
|
+
|
454
|
+
//note{
|
455
|
+
//}
|
456
|
+
|
457
|
+
//}
|
458
|
+
EOS
|
459
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
460
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
241
464
|
def test_term
|
242
465
|
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
243
466
|
assert_equal '<term><p>test1test1.5</p><p>test<i>2</i></p></term>', actual
|
467
|
+
|
468
|
+
@book.config['join_lines_by_lang'] = true
|
469
|
+
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
470
|
+
assert_equal '<term><p>test1 test1.5</p><p>test<i>2</i></p></term>', actual
|
244
471
|
end
|
245
472
|
|
246
473
|
def test_point
|
247
474
|
actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
248
475
|
assert_equal %Q(<point-t><title aid:pstyle='point-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></point-t>), actual
|
476
|
+
|
477
|
+
@book.config['join_lines_by_lang'] = true
|
478
|
+
actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
479
|
+
assert_equal %Q(<point-t><title aid:pstyle='point-title'>this is <b>test</b><&>_</title><p>test1 test1.5</p><p>test<i>2</i></p></point-t>), actual
|
249
480
|
end
|
250
481
|
|
251
482
|
def test_point_without_caption
|
252
483
|
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
253
484
|
assert_equal '<point><p>test1test1.5</p><p>test<i>2</i></p></point>', actual
|
485
|
+
|
486
|
+
@book.config['join_lines_by_lang'] = true
|
487
|
+
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
488
|
+
assert_equal '<point><p>test1 test1.5</p><p>test<i>2</i></p></point>', actual
|
254
489
|
end
|
255
490
|
|
256
491
|
def test_emlist
|
257
492
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
258
493
|
assert_equal %Q(<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>), actual
|
494
|
+
|
495
|
+
@config['caption_position']['list'] = 'bottom'
|
496
|
+
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
497
|
+
assert_equal %Q(<list type='emlist'><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption></list>), actual
|
259
498
|
end
|
260
499
|
|
261
500
|
def test_emlistnum
|
262
501
|
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
263
502
|
assert_equal %Q(<list type='emlistnum'><caption aid:pstyle='emlistnum-title'>this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre></list>), actual
|
503
|
+
|
504
|
+
@config['caption_position']['list'] = 'bottom'
|
505
|
+
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
506
|
+
assert_equal %Q(<list type='emlistnum'><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre><caption aid:pstyle='emlistnum-title'>this is <b>test</b><&>_</caption></list>), actual
|
264
507
|
end
|
265
508
|
|
266
509
|
def test_emlist_listinfo
|
267
510
|
@config['listinfo'] = true
|
268
511
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
269
|
-
|
512
|
+
expected = <<-EOS.chomp
|
513
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1
|
514
|
+
</listinfo><listinfo line="2">test1.5
|
515
|
+
</listinfo><listinfo line="3">
|
516
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
517
|
+
</listinfo></pre></list>
|
518
|
+
EOS
|
519
|
+
assert_equal expected, actual
|
270
520
|
end
|
271
521
|
|
272
522
|
def test_emlist_with_tab
|
273
523
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
274
|
-
|
524
|
+
expected = <<-EOS.chomp
|
525
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1
|
526
|
+
test1.5
|
527
|
+
|
528
|
+
test<i>2</i>
|
529
|
+
</pre></list>
|
530
|
+
EOS
|
531
|
+
assert_equal expected, actual
|
275
532
|
end
|
276
533
|
|
277
534
|
def test_emlist_with_4tab
|
278
535
|
@config['tabwidth'] = 4
|
279
536
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
280
|
-
|
537
|
+
expected = <<-EOS.chomp
|
538
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1
|
539
|
+
test1.5
|
540
|
+
|
541
|
+
test<i>2</i>
|
542
|
+
</pre></list>
|
543
|
+
EOS
|
544
|
+
assert_equal expected, actual
|
281
545
|
end
|
282
546
|
|
283
547
|
def test_list
|
284
548
|
def @chapter.list(_id)
|
285
|
-
Book::
|
549
|
+
Book::Index::Item.new('samplelist', 1)
|
286
550
|
end
|
287
551
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
288
|
-
|
552
|
+
expected = <<-EOS.chomp
|
553
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre>test1
|
554
|
+
test1.5
|
555
|
+
|
556
|
+
test<i>2</i>
|
557
|
+
</pre></codelist>
|
558
|
+
EOS
|
559
|
+
assert_equal expected, actual
|
560
|
+
|
561
|
+
@config['caption_position']['list'] = 'bottom'
|
562
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
563
|
+
expected = <<-EOS.chomp
|
564
|
+
<codelist><pre>test1
|
565
|
+
test1.5
|
566
|
+
|
567
|
+
test<i>2</i>
|
568
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
569
|
+
EOS
|
570
|
+
assert_equal expected, actual
|
289
571
|
end
|
290
572
|
|
291
573
|
def test_listnum
|
292
574
|
def @chapter.list(_id)
|
293
|
-
Book::
|
575
|
+
Book::Index::Item.new('samplelist', 1)
|
294
576
|
end
|
295
577
|
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
296
|
-
|
578
|
+
expected = <<-EOS.chomp
|
579
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1
|
580
|
+
<span type='lineno'> 2: </span>test1.5
|
581
|
+
<span type='lineno'> 3: </span>
|
582
|
+
<span type='lineno'> 4: </span>test<i>2</i>
|
583
|
+
</pre></codelist>
|
584
|
+
EOS
|
585
|
+
assert_equal expected, actual
|
586
|
+
|
587
|
+
@config['caption_position']['list'] = 'bottom'
|
588
|
+
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
589
|
+
expected = <<-EOS.chomp
|
590
|
+
<codelist><pre><span type='lineno'> 1: </span>test1
|
591
|
+
<span type='lineno'> 2: </span>test1.5
|
592
|
+
<span type='lineno'> 3: </span>
|
593
|
+
<span type='lineno'> 4: </span>test<i>2</i>
|
594
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
595
|
+
EOS
|
596
|
+
assert_equal expected, actual
|
297
597
|
end
|
298
598
|
|
299
599
|
def test_listnum_linenum
|
300
600
|
def @chapter.list(_id)
|
301
|
-
Book::
|
601
|
+
Book::Index::Item.new('samplelist', 1)
|
302
602
|
end
|
303
603
|
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
304
|
-
|
604
|
+
expected = <<-EOS.chomp
|
605
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'>100: </span>test1
|
606
|
+
<span type='lineno'>101: </span>test1.5
|
607
|
+
<span type='lineno'>102: </span>
|
608
|
+
<span type='lineno'>103: </span>test<i>2</i>
|
609
|
+
</pre></codelist>
|
610
|
+
EOS
|
611
|
+
assert_equal expected, actual
|
612
|
+
|
613
|
+
@config['caption_position']['list'] = 'bottom'
|
614
|
+
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
615
|
+
expected = <<-EOS.chomp
|
616
|
+
<codelist><pre><span type='lineno'>100: </span>test1
|
617
|
+
<span type='lineno'>101: </span>test1.5
|
618
|
+
<span type='lineno'>102: </span>
|
619
|
+
<span type='lineno'>103: </span>test<i>2</i>
|
620
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
621
|
+
EOS
|
622
|
+
assert_equal expected, actual
|
305
623
|
end
|
306
624
|
|
307
625
|
def test_list_listinfo
|
308
626
|
def @chapter.list(_id)
|
309
|
-
Book::
|
627
|
+
Book::Index::Item.new('samplelist', 1)
|
310
628
|
end
|
311
629
|
@config['listinfo'] = true
|
312
630
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
313
|
-
|
631
|
+
expected = <<-EOS.chomp
|
632
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1
|
633
|
+
</listinfo><listinfo line="2">test1.5
|
634
|
+
</listinfo><listinfo line="3">
|
635
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
636
|
+
</listinfo></pre></codelist>
|
637
|
+
EOS
|
638
|
+
assert_equal expected, actual
|
639
|
+
|
640
|
+
@config['caption_position']['list'] = 'bottom'
|
641
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
642
|
+
expected = <<-EOS.chomp
|
643
|
+
<codelist><pre><listinfo line="1" begin="1">test1
|
644
|
+
</listinfo><listinfo line="2">test1.5
|
645
|
+
</listinfo><listinfo line="3">
|
646
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
647
|
+
</listinfo></pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
648
|
+
EOS
|
649
|
+
assert_equal expected, actual
|
650
|
+
end
|
651
|
+
|
652
|
+
def test_cmd
|
653
|
+
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
654
|
+
expected = <<-EOS.chomp
|
655
|
+
<list type='cmd'><pre>lineA
|
656
|
+
lineB
|
657
|
+
</pre></list>
|
658
|
+
EOS
|
659
|
+
assert_equal expected, actual
|
660
|
+
|
661
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
662
|
+
expected = <<-EOS.chomp
|
663
|
+
<list type='cmd'><caption aid:pstyle='cmd-title'>cap1</caption><pre>lineA
|
664
|
+
lineB
|
665
|
+
</pre></list>
|
666
|
+
EOS
|
667
|
+
assert_equal expected, actual
|
668
|
+
|
669
|
+
@config['caption_position']['list'] = 'bottom'
|
670
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
671
|
+
expected = <<-EOS.chomp
|
672
|
+
<list type='cmd'><pre>lineA
|
673
|
+
lineB
|
674
|
+
</pre><caption aid:pstyle='cmd-title'>cap1</caption></list>
|
675
|
+
EOS
|
676
|
+
assert_equal expected, actual
|
677
|
+
end
|
678
|
+
|
679
|
+
def test_source
|
680
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
681
|
+
expected = <<-EOS.chomp
|
682
|
+
<source><caption>foo/bar/test.rb</caption><pre>foo
|
683
|
+
bar
|
684
|
+
|
685
|
+
buz
|
686
|
+
</pre></source>
|
687
|
+
EOS
|
688
|
+
assert_equal expected, actual
|
689
|
+
|
690
|
+
@config['caption_position']['list'] = 'bottom'
|
691
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
692
|
+
expected = <<-EOS.chomp
|
693
|
+
<source><pre>foo
|
694
|
+
bar
|
695
|
+
|
696
|
+
buz
|
697
|
+
</pre><caption>foo/bar/test.rb</caption></source>
|
698
|
+
EOS
|
699
|
+
assert_equal expected, actual
|
700
|
+
end
|
701
|
+
|
702
|
+
def test_source_empty_caption
|
703
|
+
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
704
|
+
expected = <<-EOS.chomp
|
705
|
+
<source><pre>foo
|
706
|
+
bar
|
707
|
+
|
708
|
+
buz
|
709
|
+
</pre></source>
|
710
|
+
EOS
|
711
|
+
assert_equal expected, actual
|
712
|
+
end
|
713
|
+
|
714
|
+
def test_source_nil_caption
|
715
|
+
actual = compile_block("//source{\nfoo\nbar\n\nbuz\n//}\n")
|
716
|
+
expected = <<-EOS.chomp
|
717
|
+
<source><pre>foo
|
718
|
+
bar
|
719
|
+
|
720
|
+
buz
|
721
|
+
</pre></source>
|
722
|
+
EOS
|
723
|
+
assert_equal expected, actual
|
314
724
|
end
|
315
725
|
|
316
726
|
def test_insn
|
317
727
|
@config['listinfo'] = true
|
318
728
|
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
319
|
-
|
729
|
+
expected = <<-EOS.chomp
|
730
|
+
<insn><floattitle type="insn">this is <b>test</b><&>_</floattitle><listinfo line="1" begin="1">test1
|
731
|
+
</listinfo><listinfo line="2">test1.5
|
732
|
+
</listinfo><listinfo line="3">
|
733
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
734
|
+
</listinfo></insn>
|
735
|
+
EOS
|
736
|
+
assert_equal expected, actual
|
737
|
+
|
738
|
+
@config['caption_position']['list'] = 'bottom'
|
739
|
+
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
740
|
+
expected = <<-EOS.chomp
|
741
|
+
<insn><listinfo line="1" begin="1">test1
|
742
|
+
</listinfo><listinfo line="2">test1.5
|
743
|
+
</listinfo><listinfo line="3">
|
744
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
745
|
+
</listinfo><floattitle type="insn">this is <b>test</b><&>_</floattitle></insn>
|
746
|
+
EOS
|
747
|
+
assert_equal expected, actual
|
320
748
|
end
|
321
749
|
|
322
750
|
def test_box
|
323
751
|
@config['listinfo'] = true
|
324
752
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
325
|
-
|
753
|
+
expected = <<-EOS.chomp
|
754
|
+
<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption><listinfo line="1" begin="1">test1
|
755
|
+
</listinfo><listinfo line="2">test1.5
|
756
|
+
</listinfo><listinfo line="3">
|
757
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
758
|
+
</listinfo></box>
|
759
|
+
EOS
|
760
|
+
assert_equal expected, actual
|
761
|
+
|
762
|
+
@config['caption_position']['list'] = 'bottom'
|
763
|
+
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
764
|
+
expected = <<-EOS.chomp
|
765
|
+
<box><listinfo line="1" begin="1">test1
|
766
|
+
</listinfo><listinfo line="2">test1.5
|
767
|
+
</listinfo><listinfo line="3">
|
768
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
769
|
+
</listinfo><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption></box>
|
770
|
+
EOS
|
771
|
+
assert_equal expected, actual
|
326
772
|
end
|
327
773
|
|
328
774
|
def test_box_non_listinfo
|
329
775
|
@config['listinfo'] = nil
|
330
776
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
331
|
-
|
777
|
+
expected = <<-EOS.chomp
|
778
|
+
<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption>test1
|
779
|
+
test1.5
|
780
|
+
|
781
|
+
test<i>2</i>
|
782
|
+
</box>
|
783
|
+
EOS
|
784
|
+
assert_equal expected, actual
|
785
|
+
|
786
|
+
@config['caption_position']['list'] = 'bottom'
|
787
|
+
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
788
|
+
expected = <<-EOS.chomp
|
789
|
+
<box>test1
|
790
|
+
test1.5
|
791
|
+
|
792
|
+
test<i>2</i>
|
793
|
+
<caption aid:pstyle="box-title">this is <b>test</b><&>_</caption></box>
|
794
|
+
EOS
|
795
|
+
assert_equal expected, actual
|
332
796
|
end
|
333
797
|
|
334
798
|
def test_flushright
|
335
799
|
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
336
800
|
assert_equal %Q(<p align='right'>foobar</p><p align='right'>buz</p>), actual
|
801
|
+
|
802
|
+
@book.config['join_lines_by_lang'] = true
|
803
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
804
|
+
assert_equal %Q(<p align='right'>foo bar</p><p align='right'>buz</p>), actual
|
337
805
|
end
|
338
806
|
|
339
807
|
def test_centering
|
340
808
|
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
341
809
|
assert_equal %Q(<p align='center'>foobar</p><p align='center'>buz</p>), actual
|
810
|
+
|
811
|
+
@book.config['join_lines_by_lang'] = true
|
812
|
+
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
813
|
+
assert_equal %Q(<p align='center'>foo bar</p><p align='center'>buz</p>), actual
|
342
814
|
end
|
343
815
|
|
344
816
|
def test_blankline
|
@@ -349,22 +821,30 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
349
821
|
def test_noindent
|
350
822
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
351
823
|
assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>), actual
|
824
|
+
|
825
|
+
@book.config['join_lines_by_lang'] = true
|
826
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
827
|
+
assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foo bar</p><p>foo2 bar2</p>), actual
|
352
828
|
end
|
353
829
|
|
354
830
|
def test_image
|
355
831
|
def @chapter.image(_id)
|
356
|
-
item = Book::
|
832
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
357
833
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
358
834
|
item
|
359
835
|
end
|
360
836
|
|
361
837
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
362
838
|
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>), actual
|
839
|
+
|
840
|
+
@config['caption_position']['image'] = 'top'
|
841
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
842
|
+
assert_equal %Q(<img><caption>図1.1 sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
|
363
843
|
end
|
364
844
|
|
365
845
|
def test_image_with_metric
|
366
846
|
def @chapter.image(_id)
|
367
|
-
item = Book::
|
847
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
368
848
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
369
849
|
item
|
370
850
|
end
|
@@ -375,7 +855,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
375
855
|
|
376
856
|
def test_image_with_metric2
|
377
857
|
def @chapter.image(_id)
|
378
|
-
item = Book::
|
858
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
379
859
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
380
860
|
item
|
381
861
|
end
|
@@ -386,18 +866,22 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
386
866
|
|
387
867
|
def test_indepimage
|
388
868
|
def @chapter.image(_id)
|
389
|
-
item = Book::
|
869
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
390
870
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
391
871
|
item
|
392
872
|
end
|
393
873
|
|
394
874
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
395
875
|
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>), actual
|
876
|
+
|
877
|
+
@config['caption_position']['image'] = 'top'
|
878
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
879
|
+
assert_equal %Q(<img><caption>sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
|
396
880
|
end
|
397
881
|
|
398
882
|
def test_indepimage_without_caption
|
399
883
|
def @chapter.image(_id)
|
400
|
-
item = Book::
|
884
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
401
885
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
402
886
|
item
|
403
887
|
end
|
@@ -408,7 +892,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
408
892
|
|
409
893
|
def test_indepimage_with_metric
|
410
894
|
def @chapter.image(_id)
|
411
|
-
item = Book::
|
895
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
412
896
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
413
897
|
item
|
414
898
|
end
|
@@ -419,7 +903,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
419
903
|
|
420
904
|
def test_indepimage_with_metric2
|
421
905
|
def @chapter.image(_id)
|
422
|
-
item = Book::
|
906
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
423
907
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
424
908
|
item
|
425
909
|
end
|
@@ -430,7 +914,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
430
914
|
|
431
915
|
def test_indepimage_without_caption_but_with_metric
|
432
916
|
def @chapter.image(_id)
|
433
|
-
item = Book::
|
917
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
434
918
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
435
919
|
item
|
436
920
|
end
|
@@ -500,18 +984,31 @@ inside column
|
|
500
984
|
this is @<column>{foo}.
|
501
985
|
EOS
|
502
986
|
expected = <<-EOS.chomp
|
503
|
-
<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle="h3">next level</title><?dtp level="3" section="next level"?><p>this is
|
987
|
+
<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle="h3">next level</title><?dtp level="3" section="next level"?><p>this is <link href="column-1">コラム「test」</link>.</p>
|
504
988
|
EOS
|
505
989
|
|
506
990
|
assert_equal expected, column_helper(review)
|
991
|
+
|
992
|
+
@config['chapterlink'] = nil
|
993
|
+
expected = <<-EOS.chomp
|
994
|
+
<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle="h3">next level</title><?dtp level="3" section="next level"?><p>this is コラム「test」.</p>
|
995
|
+
EOS
|
996
|
+
assert_equal expected, column_helper(review)
|
507
997
|
end
|
508
998
|
|
509
999
|
def test_column_in_aother_chapter_ref
|
510
1000
|
def @chapter.column_index
|
511
|
-
|
512
|
-
Book::ColumnIndex.new
|
1001
|
+
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
1002
|
+
idx = Book::ColumnIndex.new
|
1003
|
+
idx.add_item(item)
|
1004
|
+
idx
|
513
1005
|
end
|
514
1006
|
|
1007
|
+
actual = compile_inline('test @<column>{chap1|column} test2')
|
1008
|
+
expected = 'test <link href="column-1">コラム「column_cap」</link> test2'
|
1009
|
+
assert_equal expected, actual
|
1010
|
+
|
1011
|
+
@config['chapterlink'] = nil
|
515
1012
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
516
1013
|
expected = 'test コラム「column_cap」 test2'
|
517
1014
|
assert_equal expected, actual
|
@@ -537,9 +1034,15 @@ EOS
|
|
537
1034
|
* BBB
|
538
1035
|
-BB
|
539
1036
|
EOS
|
540
|
-
|
541
1037
|
expected = <<-EOS.chomp
|
542
1038
|
<ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
|
1039
|
+
EOS
|
1040
|
+
actual = compile_block(src)
|
1041
|
+
assert_equal expected, actual
|
1042
|
+
|
1043
|
+
@book.config['join_lines_by_lang'] = true
|
1044
|
+
expected = <<-EOS.chomp
|
1045
|
+
<ul><li aid:pstyle="ul-item">AAA -AA</li><li aid:pstyle="ul-item">BBB -BB</li></ul>
|
543
1046
|
EOS
|
544
1047
|
actual = compile_block(src)
|
545
1048
|
assert_equal expected, actual
|
@@ -577,15 +1080,10 @@ EOS
|
|
577
1080
|
src = <<-EOS
|
578
1081
|
** AAA
|
579
1082
|
* AA
|
580
|
-
* BBB
|
581
|
-
** BB
|
582
1083
|
EOS
|
583
1084
|
|
584
|
-
|
585
|
-
|
586
|
-
EOS
|
587
|
-
actual = compile_block(src)
|
588
|
-
assert_equal expected, actual
|
1085
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1086
|
+
assert_equal ':1: error: too many *.', e.message
|
589
1087
|
end
|
590
1088
|
|
591
1089
|
def test_ul_nest4
|
@@ -620,18 +1118,18 @@ EOS
|
|
620
1118
|
end
|
621
1119
|
|
622
1120
|
def test_inline_unknown
|
623
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1121
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
624
1122
|
assert_equal ':1: error: unknown image: n', e.message
|
625
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1123
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
626
1124
|
assert_equal ':1: error: unknown footnote: n', e.message
|
627
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1125
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
628
1126
|
assert_equal ':1: error: unknown headline: n', e.message
|
629
1127
|
%w[list table column].each do |name|
|
630
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1128
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
631
1129
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
632
1130
|
end
|
633
1131
|
%w[chap chapref title].each do |name|
|
634
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1132
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
635
1133
|
assert_equal ':1: error: key not found: "n"', e.message
|
636
1134
|
end
|
637
1135
|
end
|
@@ -662,24 +1160,24 @@ EOS
|
|
662
1160
|
|
663
1161
|
def test_inline_imgref
|
664
1162
|
def @chapter.image(_id)
|
665
|
-
item = Book::
|
1163
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
666
1164
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
667
1165
|
item
|
668
1166
|
end
|
669
1167
|
|
670
|
-
actual = compile_block
|
1168
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
671
1169
|
expected = %Q(<p><span type='image'>図1.1「sample photo」</span></p>)
|
672
1170
|
assert_equal expected, actual
|
673
1171
|
end
|
674
1172
|
|
675
1173
|
def test_inline_imgref2
|
676
1174
|
def @chapter.image(_id)
|
677
|
-
item = Book::
|
1175
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
678
1176
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
679
1177
|
item
|
680
1178
|
end
|
681
1179
|
|
682
|
-
actual = compile_block
|
1180
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
683
1181
|
expected = %Q(<p><span type='image'>図1.1</span></p>)
|
684
1182
|
assert_equal expected, actual
|
685
1183
|
end
|
@@ -760,5 +1258,209 @@ EOS
|
|
760
1258
|
expected = %Q(<p><span type='eq'>式1.1</span></p><equationblock><caption>式1.1 The Equivalence of Mass <i>and</i> Energy</caption><replace idref="texblock-1"><pre>e=mc^2</pre></replace></equationblock>)
|
761
1259
|
actual = compile_block(src)
|
762
1260
|
assert_equal expected, actual
|
1261
|
+
|
1262
|
+
@config['caption_position']['equation'] = 'bottom'
|
1263
|
+
expected = %Q(<p><span type='eq'>式1.1</span></p><equationblock><replace idref="texblock-1"><pre>e=mc^2</pre></replace><caption>式1.1 The Equivalence of Mass <i>and</i> Energy</caption></equationblock>)
|
1264
|
+
actual = compile_block(src)
|
1265
|
+
assert_equal expected, actual
|
1266
|
+
end
|
1267
|
+
|
1268
|
+
def test_nest_error_close1
|
1269
|
+
src = <<-EOS
|
1270
|
+
//beginchild
|
1271
|
+
EOS
|
1272
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1273
|
+
assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
1274
|
+
end
|
1275
|
+
|
1276
|
+
def test_nest_error_close2
|
1277
|
+
src = <<-EOS
|
1278
|
+
* foo
|
1279
|
+
|
1280
|
+
//beginchild
|
1281
|
+
|
1282
|
+
1. foo
|
1283
|
+
|
1284
|
+
//beginchild
|
1285
|
+
|
1286
|
+
: foo
|
1287
|
+
|
1288
|
+
//beginchild
|
1289
|
+
EOS
|
1290
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1291
|
+
assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
|
1292
|
+
end
|
1293
|
+
|
1294
|
+
def test_nest_error_close3
|
1295
|
+
src = <<-EOS
|
1296
|
+
* foo
|
1297
|
+
|
1298
|
+
//beginchild
|
1299
|
+
|
1300
|
+
1. foo
|
1301
|
+
|
1302
|
+
//beginchild
|
1303
|
+
|
1304
|
+
: foo
|
1305
|
+
|
1306
|
+
//beginchild
|
1307
|
+
|
1308
|
+
//endchild
|
1309
|
+
EOS
|
1310
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1311
|
+
assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
|
1312
|
+
end
|
1313
|
+
|
1314
|
+
def test_nest_ul
|
1315
|
+
src = <<-EOS
|
1316
|
+
* UL1
|
1317
|
+
|
1318
|
+
//beginchild
|
1319
|
+
|
1320
|
+
1. UL1-OL1
|
1321
|
+
2. UL1-OL2
|
1322
|
+
|
1323
|
+
* UL1-UL1
|
1324
|
+
* UL1-UL2
|
1325
|
+
|
1326
|
+
: UL1-DL1
|
1327
|
+
UL1-DD1
|
1328
|
+
: UL1-DL2
|
1329
|
+
UL1-DD2
|
1330
|
+
|
1331
|
+
//endchild
|
1332
|
+
|
1333
|
+
* UL2
|
1334
|
+
|
1335
|
+
//beginchild
|
1336
|
+
|
1337
|
+
UL2-PARA
|
1338
|
+
|
1339
|
+
//endchild
|
1340
|
+
EOS
|
1341
|
+
|
1342
|
+
expected = <<-EOS.chomp
|
1343
|
+
<ul><li aid:pstyle="ul-item">UL1<ol><li aid:pstyle="ol-item" olnum="1" num="1">UL1-OL1</li><li aid:pstyle="ol-item" olnum="2" num="2">UL1-OL2</li></ol><ul><li aid:pstyle="ul-item">UL1-UL1</li><li aid:pstyle="ul-item">UL1-UL2</li></ul><dl><dt>UL1-DL1</dt><dd>UL1-DD1</dd><dt>UL1-DL2</dt><dd>UL1-DD2</dd></dl></li><li aid:pstyle="ul-item">UL2<p>UL2-PARA</p></li></ul>
|
1344
|
+
EOS
|
1345
|
+
|
1346
|
+
actual = compile_block(src)
|
1347
|
+
assert_equal expected, actual
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
def test_nest_ol
|
1351
|
+
src = <<-EOS
|
1352
|
+
1. OL1
|
1353
|
+
|
1354
|
+
//beginchild
|
1355
|
+
|
1356
|
+
1. OL1-OL1
|
1357
|
+
2. OL1-OL2
|
1358
|
+
|
1359
|
+
* OL1-UL1
|
1360
|
+
* OL1-UL2
|
1361
|
+
|
1362
|
+
: OL1-DL1
|
1363
|
+
OL1-DD1
|
1364
|
+
: OL1-DL2
|
1365
|
+
OL1-DD2
|
1366
|
+
|
1367
|
+
//endchild
|
1368
|
+
|
1369
|
+
2. OL2
|
1370
|
+
|
1371
|
+
//beginchild
|
1372
|
+
|
1373
|
+
OL2-PARA
|
1374
|
+
|
1375
|
+
//endchild
|
1376
|
+
EOS
|
1377
|
+
|
1378
|
+
expected = <<-EOS.chomp
|
1379
|
+
<ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1<ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1-OL1</li><li aid:pstyle="ol-item" olnum="2" num="2">OL1-OL2</li></ol><ul><li aid:pstyle="ul-item">OL1-UL1</li><li aid:pstyle="ul-item">OL1-UL2</li></ul><dl><dt>OL1-DL1</dt><dd>OL1-DD1</dd><dt>OL1-DL2</dt><dd>OL1-DD2</dd></dl></li><li aid:pstyle="ol-item" olnum="1" num="2">OL2<p>OL2-PARA</p></li></ol>
|
1380
|
+
EOS
|
1381
|
+
|
1382
|
+
actual = compile_block(src)
|
1383
|
+
assert_equal expected, actual
|
1384
|
+
end
|
1385
|
+
|
1386
|
+
def test_nest_dl
|
1387
|
+
src = <<-EOS
|
1388
|
+
: DL1
|
1389
|
+
|
1390
|
+
//beginchild
|
1391
|
+
|
1392
|
+
1. DL1-OL1
|
1393
|
+
2. DL1-OL2
|
1394
|
+
|
1395
|
+
* DL1-UL1
|
1396
|
+
* DL1-UL2
|
1397
|
+
|
1398
|
+
: DL1-DL1
|
1399
|
+
DL1-DD1
|
1400
|
+
: DL1-DL2
|
1401
|
+
DL1-DD2
|
1402
|
+
|
1403
|
+
//endchild
|
1404
|
+
|
1405
|
+
: DL2
|
1406
|
+
DD2
|
1407
|
+
|
1408
|
+
//beginchild
|
1409
|
+
|
1410
|
+
* DD2-UL1
|
1411
|
+
* DD2-UL2
|
1412
|
+
|
1413
|
+
DD2-PARA
|
1414
|
+
|
1415
|
+
//endchild
|
1416
|
+
EOS
|
1417
|
+
|
1418
|
+
expected = <<-EOS.chomp
|
1419
|
+
<dl><dt>DL1</dt><dd><ol><li aid:pstyle="ol-item" olnum="1" num="1">DL1-OL1</li><li aid:pstyle="ol-item" olnum="2" num="2">DL1-OL2</li></ol><ul><li aid:pstyle="ul-item">DL1-UL1</li><li aid:pstyle="ul-item">DL1-UL2</li></ul><dl><dt>DL1-DL1</dt><dd>DL1-DD1</dd><dt>DL1-DL2</dt><dd>DL1-DD2</dd></dl></dd><dt>DL2</dt><dd>DD2<ul><li aid:pstyle="ul-item">DD2-UL1</li><li aid:pstyle="ul-item">DD2-UL2</li></ul><p>DD2-PARA</p></dd></dl>
|
1420
|
+
EOS
|
1421
|
+
|
1422
|
+
actual = compile_block(src)
|
1423
|
+
assert_equal expected, actual
|
1424
|
+
end
|
1425
|
+
|
1426
|
+
def test_nest_multi
|
1427
|
+
src = <<-EOS
|
1428
|
+
1. OL1
|
1429
|
+
|
1430
|
+
//beginchild
|
1431
|
+
|
1432
|
+
1. OL1-OL1
|
1433
|
+
|
1434
|
+
//beginchild
|
1435
|
+
|
1436
|
+
* OL1-OL1-UL1
|
1437
|
+
|
1438
|
+
OL1-OL1-PARA
|
1439
|
+
|
1440
|
+
//endchild
|
1441
|
+
|
1442
|
+
2. OL1-OL2
|
1443
|
+
|
1444
|
+
* OL1-UL1
|
1445
|
+
|
1446
|
+
//beginchild
|
1447
|
+
|
1448
|
+
: OL1-UL1-DL1
|
1449
|
+
OL1-UL1-DD1
|
1450
|
+
|
1451
|
+
OL1-UL1-PARA
|
1452
|
+
|
1453
|
+
//endchild
|
1454
|
+
|
1455
|
+
* OL1-UL2
|
1456
|
+
|
1457
|
+
//endchild
|
1458
|
+
EOS
|
1459
|
+
expected = <<-EOS.chomp
|
1460
|
+
<ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1<ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1-OL1<ul><li aid:pstyle="ul-item">OL1-OL1-UL1</li></ul><p>OL1-OL1-PARA</p></li><li aid:pstyle="ol-item" olnum="1" num="2">OL1-OL2</li></ol><ul><li aid:pstyle="ul-item">OL1-UL1<dl><dt>OL1-UL1-DL1</dt><dd>OL1-UL1-DD1</dd></dl><p>OL1-UL1-PARA</p></li><li aid:pstyle="ul-item">OL1-UL2</li></ul></li></ol>
|
1461
|
+
EOS
|
1462
|
+
|
1463
|
+
actual = compile_block(src)
|
1464
|
+
assert_equal expected, actual
|
763
1465
|
end
|
764
1466
|
end
|