review 3.0.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-win.yml +39 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +50 -12
- data/.travis.yml +17 -8
- data/Dockerfile +21 -5
- data/NEWS.ja.md +358 -0
- data/NEWS.md +358 -1
- data/README.md +11 -8
- data/appveyor.yml +1 -3
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -8
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +12 -12
- data/bin/review-epubmaker +3 -35
- data/bin/review-idgxmlmaker +16 -0
- data/bin/review-index +2 -89
- data/bin/review-preproc +14 -19
- data/bin/review-validate +3 -3
- data/bin/review-vol +4 -78
- data/doc/LICENSE +1 -1
- data/doc/config.yml.sample +46 -12
- data/doc/config.yml.sample-simple +4 -2
- data/doc/format.ja.md +37 -13
- data/doc/format.md +35 -20
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- data/doc/quickstart.ja.md +46 -26
- data/doc/quickstart.md +38 -17
- data/lib/epubmaker/epubcommon.rb +10 -5
- data/lib/epubmaker/epubv2.rb +1 -1
- data/lib/epubmaker/epubv3.rb +1 -0
- data/lib/epubmaker/producer.rb +4 -2
- data/lib/review/book.rb +1 -1
- data/lib/review/book/base.rb +38 -79
- data/lib/review/book/chapter.rb +18 -3
- data/lib/review/book/compilable.rb +6 -5
- data/lib/review/book/index.rb +69 -101
- data/lib/review/book/index/item.rb +40 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +28 -5
- data/lib/review/book/volume.rb +3 -4
- data/lib/review/builder.rb +105 -44
- data/lib/review/catalog.rb +13 -16
- data/lib/review/compiler.rb +84 -72
- data/lib/review/configure.rb +19 -8
- data/lib/review/epub2html.rb +37 -4
- data/lib/review/epubmaker.rb +62 -7
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +102 -115
- data/lib/review/htmlutils.rb +2 -3
- data/lib/review/i18n.rb +2 -2
- data/lib/review/i18n.yml +9 -0
- data/lib/review/idgxmlbuilder.rb +153 -74
- data/lib/review/idgxmlmaker.rb +191 -0
- data/lib/review/init-web/finish.html +10 -0
- data/lib/review/init-web/index.html +190 -0
- data/lib/review/init-web/review-layout-design.js +691 -0
- data/lib/review/init.rb +125 -34
- data/lib/review/latexbuilder.rb +199 -88
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/location.rb +32 -0
- data/lib/review/logger.rb +4 -8
- data/lib/review/makerhelper.rb +24 -5
- data/lib/review/markdownbuilder.rb +31 -37
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +44 -22
- data/lib/review/plaintextbuilder.rb +106 -85
- data/lib/review/preprocessor.rb +32 -41
- data/lib/review/rstbuilder.rb +33 -33
- data/lib/review/textmaker.rb +19 -3
- data/lib/review/textutils.rb +76 -2
- data/lib/review/tocprinter.rb +231 -102
- data/lib/review/topbuilder.rb +114 -61
- data/lib/review/update.rb +19 -19
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +99 -0
- data/lib/review/webmaker.rb +11 -4
- data/lib/review/webtocprinter.rb +38 -35
- data/lib/review/yamlloader.rb +26 -16
- data/review.gemspec +6 -4
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +154 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq.yml +6 -0
- data/samples/sample-book/src/config.yml +2 -2
- data/samples/sample-book/src/lib/tasks/review.rake +29 -14
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- data/samples/syntax-book/ch01.re +4 -2
- data/samples/syntax-book/ch02.re +8 -16
- data/samples/syntax-book/ch03.re +3 -6
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-jlreq.yml +5 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/lib/tasks/review.rake +30 -15
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
- data/templates/latex/config.erb +16 -0
- data/templates/latex/layout.tex.erb +4 -0
- data/templates/latex/review-jlreq/review-base.sty +150 -61
- data/templates/latex/review-jlreq/review-jlreq.cls +74 -8
- data/templates/latex/review-jlreq/review-style.sty +4 -1
- data/templates/latex/review-jsbook/README.md +39 -0
- data/templates/latex/review-jsbook/review-base.sty +101 -23
- data/templates/latex/review-jsbook/review-jsbook.cls +28 -5
- data/templates/latex/review-jsbook/review-style.sty +5 -2
- data/templates/opf/epubv3.opf.erb +1 -0
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/test_template.tex +24 -3
- data/test/assets/test_template_backmatter.tex +24 -3
- data/test/test_book.rb +75 -21
- data/test/test_book_chapter.rb +4 -2
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +16 -0
- data/test/test_catalog.rb +24 -42
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +15 -7
- data/test/test_htmlbuilder.rb +909 -159
- data/test/test_i18n.rb +25 -25
- data/test/test_idgxmlbuilder.rb +395 -38
- data/test/test_idgxmlmaker_cmd.rb +46 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_index.rb +50 -10
- data/test/test_latexbuilder.rb +1194 -106
- data/test/test_latexbuilder_v2.rb +628 -97
- data/test/test_logger.rb +14 -1
- data/test/test_makerhelper.rb +3 -3
- data/test/test_markdownbuilder.rb +134 -16
- data/test/test_md2inaobuilder.rb +32 -9
- data/test/test_pdfmaker.rb +18 -1
- data/test/test_pdfmaker_cmd.rb +100 -6
- data/test/test_plaintextbuilder.rb +371 -25
- data/test/test_preprocessor.rb +2 -16
- data/test/test_rstbuilder.rb +249 -26
- data/test/test_textmaker_cmd.rb +54 -0
- data/test/test_textutils.rb +109 -2
- data/test/test_topbuilder.rb +546 -31
- data/test/test_update.rb +17 -8
- data/test/test_webtocprinter.rb +66 -34
- data/test/test_yamlloader.rb +13 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/jis/jsarticle.cls +53 -14
- data/vendor/jsclasses/jis/jsbook.cls +53 -14
- data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.sty +3 -3
- data/vendor/jsclasses/jis/jspf.cls +52 -13
- data/vendor/jsclasses/jis/jsreport.cls +53 -14
- data/vendor/jsclasses/jis/kiyou.cls +53 -14
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.sty +3 -4
- data/vendor/jsclasses/jsarticle.cls +53 -14
- data/vendor/jsclasses/jsbook.cls +53 -14
- data/vendor/jsclasses/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +3 -3
- data/vendor/jsclasses/jspf.cls +52 -13
- data/vendor/jsclasses/jsreport.cls +53 -14
- data/vendor/jsclasses/kiyou.cls +53 -14
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +3 -4
- metadata +55 -10
- data/lib/review/tocparser.rb +0 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
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.open(file, 'w') { |f| f.write
|
12
|
+
File.open(file, 'w') { |f| f.write %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.open(file, 'w') { |f| f.write
|
23
|
+
File.open(file, 'w') { |f| f.write %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.open(file, 'w') { |f| f.write
|
35
|
+
File.open(file, 'w') { |f| f.write %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.open(file, 'w') { |f| f.write
|
46
|
+
File.open(file, 'w') { |f| f.write %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.open(file, 'w') { |f| f.write
|
58
|
+
File.open(file, 'w') { |f| f.write %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.open(file, 'w') { |f| f.write
|
69
|
+
File.open(file, 'w') { |f| f.write %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.open(file, 'w') { |f| f.write
|
84
|
+
File.open(file, 'w') { |f| f.write %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.open(file, 'w') { |f| f.write
|
96
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pa章" }
|
97
97
|
I18n.setup('ja')
|
98
98
|
assert_equal '第a章', I18n.t('chapter', 1)
|
99
99
|
|
100
|
-
File.open(file, 'w') { |f| f.write
|
100
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pA章" }
|
101
101
|
I18n.setup('ja')
|
102
102
|
assert_equal '第B章', I18n.t('chapter', 2)
|
103
103
|
|
104
|
-
File.open(file, 'w') { |f| f.write
|
104
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pAW章" }
|
105
105
|
I18n.setup('ja')
|
106
106
|
assert_equal '第B章', I18n.t('chapter', 2)
|
107
107
|
|
108
|
-
File.open(file, 'w') { |f| f.write
|
108
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%paW章" }
|
109
109
|
I18n.setup('ja')
|
110
110
|
assert_equal '第b章', I18n.t('chapter', 2)
|
111
111
|
|
112
|
-
File.open(file, 'w') { |f| f.write
|
112
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pR章" }
|
113
113
|
I18n.setup('ja')
|
114
114
|
assert_equal '第I章', I18n.t('chapter', 1)
|
115
115
|
|
116
|
-
File.open(file, 'w') { |f| f.write
|
116
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pr章" }
|
117
117
|
I18n.setup('ja')
|
118
118
|
assert_equal '第ii章', I18n.t('chapter', 2)
|
119
119
|
|
120
|
-
File.open(file, 'w') { |f| f.write
|
120
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pRW章" }
|
121
121
|
I18n.setup('ja')
|
122
122
|
assert_equal '第Ⅻ章', I18n.t('chapter', 12)
|
123
123
|
|
124
|
-
File.open(file, 'w') { |f| f.write
|
124
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pJ章" }
|
125
125
|
I18n.setup('ja')
|
126
126
|
assert_equal '第二十七章', I18n.t('chapter', 27)
|
127
127
|
|
128
|
-
File.open(file, 'w') { |f| f.write
|
128
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pdW章" }
|
129
129
|
I18n.setup('ja')
|
130
130
|
assert_equal '第1章', I18n.t('chapter', 1)
|
131
131
|
|
132
|
-
File.open(file, 'w') { |f| f.write
|
132
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pdW章" }
|
133
133
|
I18n.setup('ja')
|
134
134
|
assert_equal '第27章', I18n.t('chapter', 27)
|
135
135
|
|
136
|
-
File.open(file, 'w') { |f| f.write
|
136
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pDW章" }
|
137
137
|
I18n.setup('ja')
|
138
138
|
assert_equal '第1章', I18n.t('chapter', 1)
|
139
139
|
|
140
|
-
File.open(file, 'w') { |f| f.write
|
140
|
+
File.open(file, 'w') { |f| f.write "locale: ja\nchapter: 第%pDW章" }
|
141
141
|
I18n.setup('ja')
|
142
142
|
assert_equal '第27章', I18n.t('chapter', 27)
|
143
143
|
|
144
|
-
File.open(file, 'w') { |f| f.write
|
144
|
+
File.open(file, 'w') { |f| f.write "locale: ja\npart: Part %pRW" }
|
145
145
|
I18n.setup('ja')
|
146
146
|
assert_equal 'Part 0', I18n.t('part', 0)
|
147
147
|
|
148
|
-
File.open(file, 'w') { |f| f.write
|
148
|
+
File.open(file, 'w') { |f| f.write "locale: ja\npart: 第%pJ部" }
|
149
149
|
I18n.setup('ja')
|
150
150
|
assert_equal '第一部', I18n.t('part', 1)
|
151
151
|
end
|
@@ -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,7 +236,7 @@ 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
241
|
@config = ReVIEW::Configure[
|
242
242
|
'secnolevel' => 2, # for IDGXMLBuilder, HTMLBuilder
|
@@ -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,42 @@ 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
|
+
fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
|
256
|
+
@chapter.instance_eval { @footnote_index = fn }
|
257
|
+
actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
258
|
+
|
259
|
+
expected = <<-EOS.chomp
|
260
|
+
<dl><dt>foo<footnote>bar</footnote>[]<>&<replace idref="texinline-1"><pre>\\alpha[]</pre></replace></dt><dd></dd></dl>
|
261
|
+
EOS
|
262
|
+
assert_equal expected, actual
|
263
|
+
end
|
264
|
+
|
191
265
|
def test_paragraph
|
192
266
|
actual = compile_block("foo\nbar\n")
|
193
267
|
assert_equal '<p>foobar</p>', actual
|
268
|
+
|
269
|
+
@book.config['join_lines_by_lang'] = true
|
270
|
+
actual = compile_block("foo\nbar\n")
|
271
|
+
assert_equal '<p>foo bar</p>', actual
|
194
272
|
end
|
195
273
|
|
196
274
|
def test_tabbed_paragraph
|
197
275
|
actual = compile_block("\tfoo\nbar\n")
|
198
276
|
assert_equal %Q(<p inlist="1">foobar</p>), actual
|
277
|
+
|
278
|
+
@book.config['join_lines_by_lang'] = true
|
279
|
+
actual = compile_block("\tfoo\nbar\n")
|
280
|
+
assert_equal %Q(<p inlist="1">foo bar</p>), actual
|
199
281
|
end
|
200
282
|
|
201
283
|
def test_quote
|
202
284
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
203
285
|
assert_equal '<quote><p>foobar</p><p>buz</p></quote>', actual
|
286
|
+
|
287
|
+
@book.config['join_lines_by_lang'] = true
|
288
|
+
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
289
|
+
assert_equal '<quote><p>foo bar</p><p>buz</p></quote>', actual
|
204
290
|
end
|
205
291
|
|
206
292
|
def test_major_blocks
|
@@ -241,104 +327,353 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
241
327
|
def test_term
|
242
328
|
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
243
329
|
assert_equal '<term><p>test1test1.5</p><p>test<i>2</i></p></term>', actual
|
330
|
+
|
331
|
+
@book.config['join_lines_by_lang'] = true
|
332
|
+
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
333
|
+
assert_equal '<term><p>test1 test1.5</p><p>test<i>2</i></p></term>', actual
|
244
334
|
end
|
245
335
|
|
246
336
|
def test_point
|
247
337
|
actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
248
338
|
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
|
339
|
+
|
340
|
+
@book.config['join_lines_by_lang'] = true
|
341
|
+
actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
342
|
+
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
343
|
end
|
250
344
|
|
251
345
|
def test_point_without_caption
|
252
346
|
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
253
347
|
assert_equal '<point><p>test1test1.5</p><p>test<i>2</i></p></point>', actual
|
348
|
+
|
349
|
+
@book.config['join_lines_by_lang'] = true
|
350
|
+
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
351
|
+
assert_equal '<point><p>test1 test1.5</p><p>test<i>2</i></p></point>', actual
|
254
352
|
end
|
255
353
|
|
256
354
|
def test_emlist
|
257
355
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
258
356
|
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
|
357
|
+
|
358
|
+
@config['caption_position']['list'] = 'bottom'
|
359
|
+
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
360
|
+
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
361
|
end
|
260
362
|
|
261
363
|
def test_emlistnum
|
262
364
|
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
263
365
|
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
|
366
|
+
|
367
|
+
@config['caption_position']['list'] = 'bottom'
|
368
|
+
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
369
|
+
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
370
|
end
|
265
371
|
|
266
372
|
def test_emlist_listinfo
|
267
373
|
@config['listinfo'] = true
|
268
374
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
269
|
-
|
375
|
+
expected = <<-EOS.chomp
|
376
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1
|
377
|
+
</listinfo><listinfo line="2">test1.5
|
378
|
+
</listinfo><listinfo line="3">
|
379
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
380
|
+
</listinfo></pre></list>
|
381
|
+
EOS
|
382
|
+
assert_equal expected, actual
|
270
383
|
end
|
271
384
|
|
272
385
|
def test_emlist_with_tab
|
273
386
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
274
|
-
|
387
|
+
expected = <<-EOS.chomp
|
388
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1
|
389
|
+
test1.5
|
390
|
+
|
391
|
+
test<i>2</i>
|
392
|
+
</pre></list>
|
393
|
+
EOS
|
394
|
+
assert_equal expected, actual
|
275
395
|
end
|
276
396
|
|
277
397
|
def test_emlist_with_4tab
|
278
398
|
@config['tabwidth'] = 4
|
279
399
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
280
|
-
|
400
|
+
expected = <<-EOS.chomp
|
401
|
+
<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1
|
402
|
+
test1.5
|
403
|
+
|
404
|
+
test<i>2</i>
|
405
|
+
</pre></list>
|
406
|
+
EOS
|
407
|
+
assert_equal expected, actual
|
281
408
|
end
|
282
409
|
|
283
410
|
def test_list
|
284
411
|
def @chapter.list(_id)
|
285
|
-
Book::
|
412
|
+
Book::Index::Item.new('samplelist', 1)
|
286
413
|
end
|
287
414
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
288
|
-
|
415
|
+
expected = <<-EOS.chomp
|
416
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre>test1
|
417
|
+
test1.5
|
418
|
+
|
419
|
+
test<i>2</i>
|
420
|
+
</pre></codelist>
|
421
|
+
EOS
|
422
|
+
assert_equal expected, actual
|
423
|
+
|
424
|
+
@config['caption_position']['list'] = 'bottom'
|
425
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
426
|
+
expected = <<-EOS.chomp
|
427
|
+
<codelist><pre>test1
|
428
|
+
test1.5
|
429
|
+
|
430
|
+
test<i>2</i>
|
431
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
432
|
+
EOS
|
433
|
+
assert_equal expected, actual
|
289
434
|
end
|
290
435
|
|
291
436
|
def test_listnum
|
292
437
|
def @chapter.list(_id)
|
293
|
-
Book::
|
438
|
+
Book::Index::Item.new('samplelist', 1)
|
294
439
|
end
|
295
440
|
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
296
|
-
|
441
|
+
expected = <<-EOS.chomp
|
442
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1
|
443
|
+
<span type='lineno'> 2: </span>test1.5
|
444
|
+
<span type='lineno'> 3: </span>
|
445
|
+
<span type='lineno'> 4: </span>test<i>2</i>
|
446
|
+
</pre></codelist>
|
447
|
+
EOS
|
448
|
+
assert_equal expected, actual
|
449
|
+
|
450
|
+
@config['caption_position']['list'] = 'bottom'
|
451
|
+
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
452
|
+
expected = <<-EOS.chomp
|
453
|
+
<codelist><pre><span type='lineno'> 1: </span>test1
|
454
|
+
<span type='lineno'> 2: </span>test1.5
|
455
|
+
<span type='lineno'> 3: </span>
|
456
|
+
<span type='lineno'> 4: </span>test<i>2</i>
|
457
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
458
|
+
EOS
|
459
|
+
assert_equal expected, actual
|
297
460
|
end
|
298
461
|
|
299
462
|
def test_listnum_linenum
|
300
463
|
def @chapter.list(_id)
|
301
|
-
Book::
|
464
|
+
Book::Index::Item.new('samplelist', 1)
|
302
465
|
end
|
303
466
|
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
304
|
-
|
467
|
+
expected = <<-EOS.chomp
|
468
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'>100: </span>test1
|
469
|
+
<span type='lineno'>101: </span>test1.5
|
470
|
+
<span type='lineno'>102: </span>
|
471
|
+
<span type='lineno'>103: </span>test<i>2</i>
|
472
|
+
</pre></codelist>
|
473
|
+
EOS
|
474
|
+
assert_equal expected, actual
|
475
|
+
|
476
|
+
@config['caption_position']['list'] = 'bottom'
|
477
|
+
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
478
|
+
expected = <<-EOS.chomp
|
479
|
+
<codelist><pre><span type='lineno'>100: </span>test1
|
480
|
+
<span type='lineno'>101: </span>test1.5
|
481
|
+
<span type='lineno'>102: </span>
|
482
|
+
<span type='lineno'>103: </span>test<i>2</i>
|
483
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
484
|
+
EOS
|
485
|
+
assert_equal expected, actual
|
305
486
|
end
|
306
487
|
|
307
488
|
def test_list_listinfo
|
308
489
|
def @chapter.list(_id)
|
309
|
-
Book::
|
490
|
+
Book::Index::Item.new('samplelist', 1)
|
310
491
|
end
|
311
492
|
@config['listinfo'] = true
|
312
493
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
313
|
-
|
494
|
+
expected = <<-EOS.chomp
|
495
|
+
<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1
|
496
|
+
</listinfo><listinfo line="2">test1.5
|
497
|
+
</listinfo><listinfo line="3">
|
498
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
499
|
+
</listinfo></pre></codelist>
|
500
|
+
EOS
|
501
|
+
assert_equal expected, actual
|
502
|
+
|
503
|
+
@config['caption_position']['list'] = 'bottom'
|
504
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
505
|
+
expected = <<-EOS.chomp
|
506
|
+
<codelist><pre><listinfo line="1" begin="1">test1
|
507
|
+
</listinfo><listinfo line="2">test1.5
|
508
|
+
</listinfo><listinfo line="3">
|
509
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
510
|
+
</listinfo></pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
511
|
+
EOS
|
512
|
+
assert_equal expected, actual
|
513
|
+
end
|
514
|
+
|
515
|
+
def test_cmd
|
516
|
+
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
517
|
+
expected = <<-EOS.chomp
|
518
|
+
<list type='cmd'><pre>lineA
|
519
|
+
lineB
|
520
|
+
</pre></list>
|
521
|
+
EOS
|
522
|
+
assert_equal expected, actual
|
523
|
+
|
524
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
525
|
+
expected = <<-EOS.chomp
|
526
|
+
<list type='cmd'><caption aid:pstyle='cmd-title'>cap1</caption><pre>lineA
|
527
|
+
lineB
|
528
|
+
</pre></list>
|
529
|
+
EOS
|
530
|
+
assert_equal expected, actual
|
531
|
+
|
532
|
+
@config['caption_position']['list'] = 'bottom'
|
533
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
534
|
+
expected = <<-EOS.chomp
|
535
|
+
<list type='cmd'><pre>lineA
|
536
|
+
lineB
|
537
|
+
</pre><caption aid:pstyle='cmd-title'>cap1</caption></list>
|
538
|
+
EOS
|
539
|
+
assert_equal expected, actual
|
540
|
+
end
|
541
|
+
|
542
|
+
def test_source
|
543
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
544
|
+
expected = <<-EOS.chomp
|
545
|
+
<source><caption>foo/bar/test.rb</caption><pre>foo
|
546
|
+
bar
|
547
|
+
|
548
|
+
buz
|
549
|
+
</pre></source>
|
550
|
+
EOS
|
551
|
+
assert_equal expected, actual
|
552
|
+
|
553
|
+
@config['caption_position']['list'] = 'bottom'
|
554
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
555
|
+
expected = <<-EOS.chomp
|
556
|
+
<source><pre>foo
|
557
|
+
bar
|
558
|
+
|
559
|
+
buz
|
560
|
+
</pre><caption>foo/bar/test.rb</caption></source>
|
561
|
+
EOS
|
562
|
+
assert_equal expected, actual
|
563
|
+
end
|
564
|
+
|
565
|
+
def test_source_empty_caption
|
566
|
+
actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
|
567
|
+
expected = <<-EOS.chomp
|
568
|
+
<source><pre>foo
|
569
|
+
bar
|
570
|
+
|
571
|
+
buz
|
572
|
+
</pre></source>
|
573
|
+
EOS
|
574
|
+
assert_equal expected, actual
|
575
|
+
end
|
576
|
+
|
577
|
+
def test_source_nil_caption
|
578
|
+
actual = compile_block("//source{\nfoo\nbar\n\nbuz\n//}\n")
|
579
|
+
expected = <<-EOS.chomp
|
580
|
+
<source><pre>foo
|
581
|
+
bar
|
582
|
+
|
583
|
+
buz
|
584
|
+
</pre></source>
|
585
|
+
EOS
|
586
|
+
assert_equal expected, actual
|
314
587
|
end
|
315
588
|
|
316
589
|
def test_insn
|
317
590
|
@config['listinfo'] = true
|
318
591
|
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
319
|
-
|
592
|
+
expected = <<-EOS.chomp
|
593
|
+
<insn><floattitle type="insn">this is <b>test</b><&>_</floattitle><listinfo line="1" begin="1">test1
|
594
|
+
</listinfo><listinfo line="2">test1.5
|
595
|
+
</listinfo><listinfo line="3">
|
596
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
597
|
+
</listinfo></insn>
|
598
|
+
EOS
|
599
|
+
assert_equal expected, actual
|
600
|
+
|
601
|
+
@config['caption_position']['list'] = 'bottom'
|
602
|
+
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
603
|
+
expected = <<-EOS.chomp
|
604
|
+
<insn><listinfo line="1" begin="1">test1
|
605
|
+
</listinfo><listinfo line="2">test1.5
|
606
|
+
</listinfo><listinfo line="3">
|
607
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
608
|
+
</listinfo><floattitle type="insn">this is <b>test</b><&>_</floattitle></insn>
|
609
|
+
EOS
|
610
|
+
assert_equal expected, actual
|
320
611
|
end
|
321
612
|
|
322
613
|
def test_box
|
323
614
|
@config['listinfo'] = true
|
324
615
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
325
|
-
|
616
|
+
expected = <<-EOS.chomp
|
617
|
+
<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption><listinfo line="1" begin="1">test1
|
618
|
+
</listinfo><listinfo line="2">test1.5
|
619
|
+
</listinfo><listinfo line="3">
|
620
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
621
|
+
</listinfo></box>
|
622
|
+
EOS
|
623
|
+
assert_equal expected, actual
|
624
|
+
|
625
|
+
@config['caption_position']['list'] = 'bottom'
|
626
|
+
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
627
|
+
expected = <<-EOS.chomp
|
628
|
+
<box><listinfo line="1" begin="1">test1
|
629
|
+
</listinfo><listinfo line="2">test1.5
|
630
|
+
</listinfo><listinfo line="3">
|
631
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
632
|
+
</listinfo><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption></box>
|
633
|
+
EOS
|
634
|
+
assert_equal expected, actual
|
326
635
|
end
|
327
636
|
|
328
637
|
def test_box_non_listinfo
|
329
638
|
@config['listinfo'] = nil
|
330
639
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
331
|
-
|
640
|
+
expected = <<-EOS.chomp
|
641
|
+
<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption>test1
|
642
|
+
test1.5
|
643
|
+
|
644
|
+
test<i>2</i>
|
645
|
+
</box>
|
646
|
+
EOS
|
647
|
+
assert_equal expected, actual
|
648
|
+
|
649
|
+
@config['caption_position']['list'] = 'bottom'
|
650
|
+
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
651
|
+
expected = <<-EOS.chomp
|
652
|
+
<box>test1
|
653
|
+
test1.5
|
654
|
+
|
655
|
+
test<i>2</i>
|
656
|
+
<caption aid:pstyle="box-title">this is <b>test</b><&>_</caption></box>
|
657
|
+
EOS
|
658
|
+
assert_equal expected, actual
|
332
659
|
end
|
333
660
|
|
334
661
|
def test_flushright
|
335
662
|
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
336
663
|
assert_equal %Q(<p align='right'>foobar</p><p align='right'>buz</p>), actual
|
664
|
+
|
665
|
+
@book.config['join_lines_by_lang'] = true
|
666
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
667
|
+
assert_equal %Q(<p align='right'>foo bar</p><p align='right'>buz</p>), actual
|
337
668
|
end
|
338
669
|
|
339
670
|
def test_centering
|
340
671
|
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
341
672
|
assert_equal %Q(<p align='center'>foobar</p><p align='center'>buz</p>), actual
|
673
|
+
|
674
|
+
@book.config['join_lines_by_lang'] = true
|
675
|
+
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
676
|
+
assert_equal %Q(<p align='center'>foo bar</p><p align='center'>buz</p>), actual
|
342
677
|
end
|
343
678
|
|
344
679
|
def test_blankline
|
@@ -349,22 +684,30 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
349
684
|
def test_noindent
|
350
685
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
351
686
|
assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>), actual
|
687
|
+
|
688
|
+
@book.config['join_lines_by_lang'] = true
|
689
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
690
|
+
assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foo bar</p><p>foo2 bar2</p>), actual
|
352
691
|
end
|
353
692
|
|
354
693
|
def test_image
|
355
694
|
def @chapter.image(_id)
|
356
|
-
item = Book::
|
695
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
357
696
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
358
697
|
item
|
359
698
|
end
|
360
699
|
|
361
700
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
362
701
|
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>), actual
|
702
|
+
|
703
|
+
@config['caption_position']['image'] = 'top'
|
704
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
705
|
+
assert_equal %Q(<img><caption>図1.1 sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
|
363
706
|
end
|
364
707
|
|
365
708
|
def test_image_with_metric
|
366
709
|
def @chapter.image(_id)
|
367
|
-
item = Book::
|
710
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
368
711
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
369
712
|
item
|
370
713
|
end
|
@@ -375,7 +718,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
375
718
|
|
376
719
|
def test_image_with_metric2
|
377
720
|
def @chapter.image(_id)
|
378
|
-
item = Book::
|
721
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
379
722
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
380
723
|
item
|
381
724
|
end
|
@@ -386,18 +729,22 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
386
729
|
|
387
730
|
def test_indepimage
|
388
731
|
def @chapter.image(_id)
|
389
|
-
item = Book::
|
732
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
390
733
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
391
734
|
item
|
392
735
|
end
|
393
736
|
|
394
737
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
395
738
|
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>), actual
|
739
|
+
|
740
|
+
@config['caption_position']['image'] = 'top'
|
741
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
742
|
+
assert_equal %Q(<img><caption>sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
|
396
743
|
end
|
397
744
|
|
398
745
|
def test_indepimage_without_caption
|
399
746
|
def @chapter.image(_id)
|
400
|
-
item = Book::
|
747
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
401
748
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
402
749
|
item
|
403
750
|
end
|
@@ -408,7 +755,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
408
755
|
|
409
756
|
def test_indepimage_with_metric
|
410
757
|
def @chapter.image(_id)
|
411
|
-
item = Book::
|
758
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
412
759
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
413
760
|
item
|
414
761
|
end
|
@@ -419,7 +766,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
419
766
|
|
420
767
|
def test_indepimage_with_metric2
|
421
768
|
def @chapter.image(_id)
|
422
|
-
item = Book::
|
769
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
423
770
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
424
771
|
item
|
425
772
|
end
|
@@ -430,7 +777,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
430
777
|
|
431
778
|
def test_indepimage_without_caption_but_with_metric
|
432
779
|
def @chapter.image(_id)
|
433
|
-
item = Book::
|
780
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
434
781
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
435
782
|
item
|
436
783
|
end
|
@@ -508,8 +855,10 @@ EOS
|
|
508
855
|
|
509
856
|
def test_column_in_aother_chapter_ref
|
510
857
|
def @chapter.column_index
|
511
|
-
|
512
|
-
Book::ColumnIndex.new
|
858
|
+
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
859
|
+
idx = Book::ColumnIndex.new
|
860
|
+
idx.add_item(item)
|
861
|
+
idx
|
513
862
|
end
|
514
863
|
|
515
864
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
@@ -537,9 +886,15 @@ EOS
|
|
537
886
|
* BBB
|
538
887
|
-BB
|
539
888
|
EOS
|
540
|
-
|
541
889
|
expected = <<-EOS.chomp
|
542
890
|
<ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
|
891
|
+
EOS
|
892
|
+
actual = compile_block(src)
|
893
|
+
assert_equal expected, actual
|
894
|
+
|
895
|
+
@book.config['join_lines_by_lang'] = true
|
896
|
+
expected = <<-EOS.chomp
|
897
|
+
<ul><li aid:pstyle="ul-item">AAA -AA</li><li aid:pstyle="ul-item">BBB -BB</li></ul>
|
543
898
|
EOS
|
544
899
|
actual = compile_block(src)
|
545
900
|
assert_equal expected, actual
|
@@ -577,15 +932,10 @@ EOS
|
|
577
932
|
src = <<-EOS
|
578
933
|
** AAA
|
579
934
|
* AA
|
580
|
-
* BBB
|
581
|
-
** BB
|
582
935
|
EOS
|
583
936
|
|
584
|
-
|
585
|
-
|
586
|
-
EOS
|
587
|
-
actual = compile_block(src)
|
588
|
-
assert_equal expected, actual
|
937
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
938
|
+
assert_equal ':1: error: too many *.', e.message
|
589
939
|
end
|
590
940
|
|
591
941
|
def test_ul_nest4
|
@@ -662,24 +1012,24 @@ EOS
|
|
662
1012
|
|
663
1013
|
def test_inline_imgref
|
664
1014
|
def @chapter.image(_id)
|
665
|
-
item = Book::
|
1015
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
666
1016
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
667
1017
|
item
|
668
1018
|
end
|
669
1019
|
|
670
|
-
actual = compile_block
|
1020
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
671
1021
|
expected = %Q(<p><span type='image'>図1.1「sample photo」</span></p>)
|
672
1022
|
assert_equal expected, actual
|
673
1023
|
end
|
674
1024
|
|
675
1025
|
def test_inline_imgref2
|
676
1026
|
def @chapter.image(_id)
|
677
|
-
item = Book::
|
1027
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
678
1028
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
679
1029
|
item
|
680
1030
|
end
|
681
1031
|
|
682
|
-
actual = compile_block
|
1032
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
683
1033
|
expected = %Q(<p><span type='image'>図1.1</span></p>)
|
684
1034
|
assert_equal expected, actual
|
685
1035
|
end
|
@@ -721,8 +1071,10 @@ EOS
|
|
721
1071
|
|
722
1072
|
def test_comment_for_draft
|
723
1073
|
@config['draft'] = true
|
724
|
-
actual = compile_block('//comment[
|
725
|
-
assert_equal '<msg
|
1074
|
+
actual = compile_block('//comment[コメント<]')
|
1075
|
+
assert_equal '<msg>コメント<</msg>', actual
|
1076
|
+
actual = compile_block("//comment{\nA<>\nB&\n//}")
|
1077
|
+
assert_equal %Q(<msg>A<>\nB&</msg>), actual
|
726
1078
|
end
|
727
1079
|
|
728
1080
|
def test_inline_comment
|
@@ -758,5 +1110,10 @@ EOS
|
|
758
1110
|
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>)
|
759
1111
|
actual = compile_block(src)
|
760
1112
|
assert_equal expected, actual
|
1113
|
+
|
1114
|
+
@config['caption_position']['equation'] = 'bottom'
|
1115
|
+
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>)
|
1116
|
+
actual = compile_block(src)
|
1117
|
+
assert_equal expected, actual
|
761
1118
|
end
|
762
1119
|
end
|