review 4.1.0 → 5.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-tex.yml +35 -0
- data/.github/workflows/ruby-win.yml +19 -9
- data/.github/workflows/ruby.yml +7 -3
- data/.rubocop.yml +138 -34
- data/NEWS.ja.md +285 -0
- data/NEWS.md +285 -1
- data/README.md +7 -6
- data/Rakefile +7 -2
- data/bin/review +2 -4
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -12
- data/bin/review-checkdep +2 -5
- data/bin/review-compile +18 -34
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +5 -86
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +30 -38
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +4 -4
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +45 -11
- data/doc/config.yml.sample-simple +3 -3
- data/doc/format.ja.md +103 -13
- data/doc/format.md +104 -16
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +42 -0
- data/doc/pdfmaker.md +41 -0
- data/doc/quickstart.ja.md +19 -6
- data/doc/quickstart.md +18 -6
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review.rb +1 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +67 -29
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +33 -26
- data/lib/review/book/index.rb +24 -185
- data/lib/review/book/index/item.rb +7 -1
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +26 -11
- data/lib/review/book/volume.rb +5 -5
- data/lib/review/builder.rb +121 -52
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +3 -2
- data/lib/review/compiler.rb +230 -111
- data/lib/review/configure.rb +91 -7
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +124 -152
- data/lib/review/epubmaker/content.rb +113 -0
- data/lib/review/epubmaker/epubcommon.rb +372 -0
- data/lib/review/epubmaker/epubv2.rb +178 -0
- data/lib/review/epubmaker/epubv3.rb +231 -0
- data/lib/review/epubmaker/producer.rb +167 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/exception.rb +13 -0
- data/lib/review/htmlbuilder.rb +176 -89
- data/lib/review/htmlutils.rb +8 -11
- data/lib/review/i18n.rb +2 -1
- data/lib/review/idgxmlbuilder.rb +165 -75
- data/lib/review/idgxmlmaker.rb +24 -28
- data/lib/review/img_math.rb +238 -0
- data/lib/review/index_builder.rb +645 -0
- data/lib/review/init.rb +9 -17
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +193 -75
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +90 -3
- data/lib/review/makerhelper.rb +17 -188
- data/lib/review/markdownbuilder.rb +54 -4
- data/lib/review/pdfmaker.rb +76 -84
- data/lib/review/plaintextbuilder.rb +106 -22
- data/lib/review/preprocessor.rb +107 -303
- data/lib/review/preprocessor/directive.rb +35 -0
- data/lib/review/preprocessor/line.rb +34 -0
- data/lib/review/preprocessor/repository.rb +177 -0
- data/lib/review/rstbuilder.rb +27 -8
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +11 -1
- data/lib/review/textmaker.rb +27 -32
- data/lib/review/textutils.rb +3 -12
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +98 -31
- data/lib/review/update.rb +12 -13
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +40 -47
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +2 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config.yml +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +19 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/Gemfile +1 -1
- data/samples/syntax-book/ch01.re +1 -1
- data/samples/syntax-book/ch02.re +21 -6
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/html/_colophon.html.erb +23 -0
- data/templates/html/_colophon_history.html.erb +9 -0
- data/templates/html/_cover.html.erb +10 -0
- data/templates/html/_part_body.html.erb +6 -0
- data/templates/html/_titlepage.html.erb +20 -0
- data/templates/html/layout-html5.html.erb +6 -0
- data/templates/html/layout-xhtml1.html.erb +6 -0
- data/templates/latex/config.erb +35 -23
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +36 -23
- data/templates/latex/review-jlreq/review-jlreq.cls +18 -25
- data/templates/latex/review-jlreq/review-style.sty +6 -1
- data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
- data/templates/latex/review-jsbook/README.md +7 -5
- data/templates/latex/review-jsbook/review-base.sty +40 -24
- data/templates/latex/review-jsbook/review-jsbook.cls +13 -3
- data/templates/latex/review-jsbook/review-style.sty +6 -1
- data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
- data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
- data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
- data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
- data/templates/web/html/layout-html5.html.erb +9 -8
- data/templates/web/html/layout-xhtml1.html.erb +6 -0
- data/test/assets/header_listener.html +35 -0
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/syntax_book_index_detail.txt +58 -0
- data/test/assets/test_template.tex +6 -3
- data/test/assets/test_template_backmatter.tex +6 -3
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +54 -63
- data/test/test_book_chapter.rb +95 -54
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +29 -20
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +170 -126
- data/test/test_epubmaker.rb +254 -129
- data/test/test_epubmaker_cmd.rb +15 -4
- data/test/test_helper.rb +12 -5
- data/test/test_htmlbuilder.rb +926 -76
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +531 -20
- data/test/test_idgxmlmaker_cmd.rb +7 -3
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +62 -52
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +891 -20
- data/test/test_latexbuilder_v2.rb +56 -10
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +7 -7
- data/test/test_makerhelper.rb +0 -12
- data/test/test_markdownbuilder.rb +32 -0
- data/test/test_pdfmaker.rb +100 -11
- data/test/test_pdfmaker_cmd.rb +3 -3
- data/test/test_plaintextbuilder.rb +546 -32
- data/test/test_preprocessor.rb +188 -1
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +25 -1
- data/test/test_sec_counter.rb +156 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +5 -1
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +324 -20
- data/test/test_update.rb +44 -44
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_zip_exporter.rb +5 -6
- 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/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +22 -18
- data/vendor/jsclasses/jis/jsbook.cls +22 -18
- data/vendor/jsclasses/jis/jsclasses.dtx +94 -13
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +1 -13
- data/vendor/jsclasses/jis/jspf.cls +22 -18
- data/vendor/jsclasses/jis/jsreport.cls +22 -18
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +22 -18
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +1 -13
- 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 +22 -18
- data/vendor/jsclasses/jsbook.cls +22 -18
- data/vendor/jsclasses/jsclasses.dtx +94 -13
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +1 -13
- data/vendor/jsclasses/jspf.cls +22 -18
- data/vendor/jsclasses/jsreport.cls +22 -18
- 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 +22 -18
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +1 -13
- 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 +106 -22
- data/.rubocop_todo.yml +0 -7
- data/lib/epubmaker.rb +0 -23
- data/lib/epubmaker/content.rb +0 -110
- data/lib/epubmaker/epubcommon.rb +0 -441
- data/lib/epubmaker/epubv2.rb +0 -143
- data/lib/epubmaker/epubv3.rb +0 -233
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/lineinput.rb +0 -155
- data/lib/review/book/compilable.rb +0 -178
- data/lib/review/tocparser.rb +0 -275
- 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])
|
@@ -238,11 +238,11 @@ class I18nTest < Test::Unit::TestCase
|
|
238
238
|
def _setup_htmlbuilder
|
239
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)
|
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -14,6 +14,8 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
14
14
|
@config['tableopt'] = '10'
|
15
15
|
@book = Book::Base.new
|
16
16
|
@book.config = @config
|
17
|
+
@log_io = StringIO.new
|
18
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
17
19
|
@compiler = ReVIEW::Compiler.new(@builder)
|
18
20
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
19
21
|
location = Location.new(nil, nil)
|
@@ -48,6 +50,19 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
48
50
|
assert_equal %Q(<title id="test" aid:pstyle="h3">1.0.1 this is test.</title><?dtp level="3" section="1.0.1 this is test."?>), actual
|
49
51
|
end
|
50
52
|
|
53
|
+
def test_headline_secttags
|
54
|
+
@config['structuredxml'] = true
|
55
|
+
actual = compile_block("= HEAD1\n== HEAD1-1\n\n=== HEAD1-1-1\n\n== HEAD1-2\n\n==== HEAD1-2-0-1\n\n===== HEAD1-2-0-1-1\n\n== HEAD1-3\n")
|
56
|
+
expected = '<chapter id="chap:1"><title aid:pstyle="h1">第1章 HEAD1</title><?dtp level="1" section="第1章 HEAD1"?>' +
|
57
|
+
'<sect id="sect:1.1"><title aid:pstyle="h2">1.1 HEAD1-1</title><?dtp level="2" section="1.1 HEAD1-1"?>' +
|
58
|
+
'<sect2 id="sect:1.1.1"><title aid:pstyle="h3">HEAD1-1-1</title><?dtp level="3" section="HEAD1-1-1"?></sect2></sect>' +
|
59
|
+
'<sect id="sect:1.2"><title aid:pstyle="h2">1.2 HEAD1-2</title><?dtp level="2" section="1.2 HEAD1-2"?>' +
|
60
|
+
'<sect3 id="sect:1.2.0.1"><title aid:pstyle="h4">HEAD1-2-0-1</title><?dtp level="4" section="HEAD1-2-0-1"?>' +
|
61
|
+
'<sect4 id="sect:1.2.0.1.1"><title aid:pstyle="h5">HEAD1-2-0-1-1</title><?dtp level="5" section="HEAD1-2-0-1-1"?></sect4></sect3></sect>' +
|
62
|
+
'<sect id="sect:1.3"><title aid:pstyle="h2">1.3 HEAD1-3</title><?dtp level="2" section="1.3 HEAD1-3"?></sect></chapter>'
|
63
|
+
assert_equal expected, actual
|
64
|
+
end
|
65
|
+
|
51
66
|
def test_label
|
52
67
|
actual = compile_block("//label[label_test]\n")
|
53
68
|
assert_equal %Q(<label id='label_test' />), actual
|
@@ -100,6 +115,27 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
100
115
|
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
116
|
end
|
102
117
|
|
118
|
+
def test_table
|
119
|
+
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
120
|
+
expected = <<-EOS.chomp
|
121
|
+
<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>
|
122
|
+
EOS
|
123
|
+
assert_equal expected, actual
|
124
|
+
|
125
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
126
|
+
expected = <<-EOS.chomp
|
127
|
+
<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>
|
128
|
+
EOS
|
129
|
+
assert_equal expected, actual
|
130
|
+
|
131
|
+
@config['caption_position']['table'] = 'bottom'
|
132
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
133
|
+
expected = <<-EOS.chomp
|
134
|
+
<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>
|
135
|
+
EOS
|
136
|
+
assert_equal expected, actual
|
137
|
+
end
|
138
|
+
|
103
139
|
def test_customize_cellwidth
|
104
140
|
actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
105
141
|
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
|
@@ -134,16 +170,20 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
134
170
|
end
|
135
171
|
|
136
172
|
def test_empty_table
|
137
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
138
|
-
assert_equal '
|
173
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
174
|
+
assert_equal 'no rows in the table', e.message
|
139
175
|
|
140
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
141
|
-
assert_equal '
|
176
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
177
|
+
assert_equal 'no rows in the table', e.message
|
142
178
|
end
|
143
179
|
|
144
180
|
def test_emtable
|
145
181
|
actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
|
146
182
|
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
|
183
|
+
|
184
|
+
@config['caption_position']['table'] = 'bottom'
|
185
|
+
actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
|
186
|
+
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
|
147
187
|
end
|
148
188
|
|
149
189
|
def test_table_row_separator
|
@@ -227,9 +267,7 @@ EOS
|
|
227
267
|
end
|
228
268
|
|
229
269
|
def test_dt_inline
|
230
|
-
|
231
|
-
@chapter.instance_eval { @footnote_index = fn }
|
232
|
-
actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
270
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
233
271
|
|
234
272
|
expected = <<-EOS.chomp
|
235
273
|
<dl><dt>foo<footnote>bar</footnote>[]<>&<replace idref="texinline-1"><pre>\\alpha[]</pre></replace></dt><dd></dd></dl>
|
@@ -299,6 +337,145 @@ EOS
|
|
299
337
|
assert_equal expected, actual
|
300
338
|
end
|
301
339
|
|
340
|
+
def test_minicolumn_blocks
|
341
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
342
|
+
src = <<-EOS
|
343
|
+
//#{type}[#{type}1]{
|
344
|
+
|
345
|
+
//}
|
346
|
+
|
347
|
+
//#{type}[#{type}2]{
|
348
|
+
//}
|
349
|
+
EOS
|
350
|
+
|
351
|
+
if type == 'notice' # exception pattern
|
352
|
+
expected = <<-EOS.chomp
|
353
|
+
<#{type}-t><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}-t>
|
354
|
+
EOS
|
355
|
+
else
|
356
|
+
expected = <<-EOS.chomp
|
357
|
+
<#{type}><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}>
|
358
|
+
EOS
|
359
|
+
end
|
360
|
+
assert_equal expected, compile_block(src)
|
361
|
+
|
362
|
+
src = <<-EOS
|
363
|
+
//#{type}[#{type}2]{
|
364
|
+
|
365
|
+
//}
|
366
|
+
|
367
|
+
//#{type}[#{type}3]{
|
368
|
+
|
369
|
+
//}
|
370
|
+
|
371
|
+
//#{type}[#{type}4]{
|
372
|
+
|
373
|
+
//}
|
374
|
+
|
375
|
+
//#{type}[#{type}5]{
|
376
|
+
|
377
|
+
//}
|
378
|
+
|
379
|
+
//#{type}[#{type}6]{
|
380
|
+
|
381
|
+
//}
|
382
|
+
EOS
|
383
|
+
|
384
|
+
if type == 'notice' # exception pattern
|
385
|
+
expected = <<-EOS.chomp
|
386
|
+
<#{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>
|
387
|
+
EOS
|
388
|
+
else
|
389
|
+
expected = <<-EOS.chomp
|
390
|
+
<#{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}>
|
391
|
+
EOS
|
392
|
+
end
|
393
|
+
assert_equal expected, compile_block(src)
|
394
|
+
|
395
|
+
src = <<-EOS
|
396
|
+
//#{type}{
|
397
|
+
|
398
|
+
* A
|
399
|
+
|
400
|
+
1. B
|
401
|
+
|
402
|
+
//}
|
403
|
+
|
404
|
+
//#{type}[OMITEND1]{
|
405
|
+
|
406
|
+
//emlist{
|
407
|
+
LIST
|
408
|
+
//}
|
409
|
+
|
410
|
+
//}
|
411
|
+
//#{type}[OMITEND2]{
|
412
|
+
//}
|
413
|
+
EOS
|
414
|
+
|
415
|
+
if type == 'notice' # exception pattern
|
416
|
+
expected = <<-EOS.chomp
|
417
|
+
<#{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
|
418
|
+
</pre></list></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}-t>
|
419
|
+
EOS
|
420
|
+
else
|
421
|
+
expected = <<-EOS.chomp
|
422
|
+
<#{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
|
423
|
+
</pre></list></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}>
|
424
|
+
EOS
|
425
|
+
end
|
426
|
+
assert_equal expected, compile_block(src)
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def test_minicolumn_blocks_nest_error1
|
431
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
432
|
+
@builder.doc_status.clear
|
433
|
+
src = <<-EOS
|
434
|
+
//#{type}{
|
435
|
+
|
436
|
+
//#{type}{
|
437
|
+
//}
|
438
|
+
|
439
|
+
//}
|
440
|
+
EOS
|
441
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
442
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
def test_minicolumn_blocks_nest_error2
|
447
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
448
|
+
@builder.doc_status.clear
|
449
|
+
src = <<-EOS
|
450
|
+
//#{type}{
|
451
|
+
|
452
|
+
//#{type}{
|
453
|
+
|
454
|
+
//}
|
455
|
+
|
456
|
+
//}
|
457
|
+
EOS
|
458
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
459
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_minicolumn_blocks_nest_error3
|
464
|
+
%w[memo tip info warning important caution notice].each do |type|
|
465
|
+
@builder.doc_status.clear
|
466
|
+
src = <<-EOS
|
467
|
+
//#{type}{
|
468
|
+
|
469
|
+
//note{
|
470
|
+
//}
|
471
|
+
|
472
|
+
//}
|
473
|
+
EOS
|
474
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
475
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
302
479
|
def test_term
|
303
480
|
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
304
481
|
assert_equal '<term><p>test1test1.5</p><p>test<i>2</i></p></term>', actual
|
@@ -329,11 +506,19 @@ EOS
|
|
329
506
|
def test_emlist
|
330
507
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
331
508
|
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
|
509
|
+
|
510
|
+
@config['caption_position']['list'] = 'bottom'
|
511
|
+
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
512
|
+
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
|
332
513
|
end
|
333
514
|
|
334
515
|
def test_emlistnum
|
335
516
|
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
336
517
|
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
|
518
|
+
|
519
|
+
@config['caption_position']['list'] = 'bottom'
|
520
|
+
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
521
|
+
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
|
337
522
|
end
|
338
523
|
|
339
524
|
def test_emlist_listinfo
|
@@ -385,6 +570,17 @@ test1.5
|
|
385
570
|
|
386
571
|
test<i>2</i>
|
387
572
|
</pre></codelist>
|
573
|
+
EOS
|
574
|
+
assert_equal expected, actual
|
575
|
+
|
576
|
+
@config['caption_position']['list'] = 'bottom'
|
577
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
578
|
+
expected = <<-EOS.chomp
|
579
|
+
<codelist><pre>test1
|
580
|
+
test1.5
|
581
|
+
|
582
|
+
test<i>2</i>
|
583
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
388
584
|
EOS
|
389
585
|
assert_equal expected, actual
|
390
586
|
end
|
@@ -400,6 +596,17 @@ EOS
|
|
400
596
|
<span type='lineno'> 3: </span>
|
401
597
|
<span type='lineno'> 4: </span>test<i>2</i>
|
402
598
|
</pre></codelist>
|
599
|
+
EOS
|
600
|
+
assert_equal expected, actual
|
601
|
+
|
602
|
+
@config['caption_position']['list'] = 'bottom'
|
603
|
+
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
604
|
+
expected = <<-EOS.chomp
|
605
|
+
<codelist><pre><span type='lineno'> 1: </span>test1
|
606
|
+
<span type='lineno'> 2: </span>test1.5
|
607
|
+
<span type='lineno'> 3: </span>
|
608
|
+
<span type='lineno'> 4: </span>test<i>2</i>
|
609
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
403
610
|
EOS
|
404
611
|
assert_equal expected, actual
|
405
612
|
end
|
@@ -415,6 +622,17 @@ EOS
|
|
415
622
|
<span type='lineno'>102: </span>
|
416
623
|
<span type='lineno'>103: </span>test<i>2</i>
|
417
624
|
</pre></codelist>
|
625
|
+
EOS
|
626
|
+
assert_equal expected, actual
|
627
|
+
|
628
|
+
@config['caption_position']['list'] = 'bottom'
|
629
|
+
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
630
|
+
expected = <<-EOS.chomp
|
631
|
+
<codelist><pre><span type='lineno'>100: </span>test1
|
632
|
+
<span type='lineno'>101: </span>test1.5
|
633
|
+
<span type='lineno'>102: </span>
|
634
|
+
<span type='lineno'>103: </span>test<i>2</i>
|
635
|
+
</pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
418
636
|
EOS
|
419
637
|
assert_equal expected, actual
|
420
638
|
end
|
@@ -431,6 +649,17 @@ EOS
|
|
431
649
|
</listinfo><listinfo line="3">
|
432
650
|
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
433
651
|
</listinfo></pre></codelist>
|
652
|
+
EOS
|
653
|
+
assert_equal expected, actual
|
654
|
+
|
655
|
+
@config['caption_position']['list'] = 'bottom'
|
656
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
657
|
+
expected = <<-EOS.chomp
|
658
|
+
<codelist><pre><listinfo line="1" begin="1">test1
|
659
|
+
</listinfo><listinfo line="2">test1.5
|
660
|
+
</listinfo><listinfo line="3">
|
661
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
662
|
+
</listinfo></pre><caption>リスト1.1 this is <b>test</b><&>_</caption></codelist>
|
434
663
|
EOS
|
435
664
|
assert_equal expected, actual
|
436
665
|
end
|
@@ -449,6 +678,15 @@ EOS
|
|
449
678
|
<list type='cmd'><caption aid:pstyle='cmd-title'>cap1</caption><pre>lineA
|
450
679
|
lineB
|
451
680
|
</pre></list>
|
681
|
+
EOS
|
682
|
+
assert_equal expected, actual
|
683
|
+
|
684
|
+
@config['caption_position']['list'] = 'bottom'
|
685
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
686
|
+
expected = <<-EOS.chomp
|
687
|
+
<list type='cmd'><pre>lineA
|
688
|
+
lineB
|
689
|
+
</pre><caption aid:pstyle='cmd-title'>cap1</caption></list>
|
452
690
|
EOS
|
453
691
|
assert_equal expected, actual
|
454
692
|
end
|
@@ -461,6 +699,17 @@ bar
|
|
461
699
|
|
462
700
|
buz
|
463
701
|
</pre></source>
|
702
|
+
EOS
|
703
|
+
assert_equal expected, actual
|
704
|
+
|
705
|
+
@config['caption_position']['list'] = 'bottom'
|
706
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
707
|
+
expected = <<-EOS.chomp
|
708
|
+
<source><pre>foo
|
709
|
+
bar
|
710
|
+
|
711
|
+
buz
|
712
|
+
</pre><caption>foo/bar/test.rb</caption></source>
|
464
713
|
EOS
|
465
714
|
assert_equal expected, actual
|
466
715
|
end
|
@@ -498,6 +747,17 @@ EOS
|
|
498
747
|
</listinfo><listinfo line="3">
|
499
748
|
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
500
749
|
</listinfo></insn>
|
750
|
+
EOS
|
751
|
+
assert_equal expected, actual
|
752
|
+
|
753
|
+
@config['caption_position']['list'] = 'bottom'
|
754
|
+
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
755
|
+
expected = <<-EOS.chomp
|
756
|
+
<insn><listinfo line="1" begin="1">test1
|
757
|
+
</listinfo><listinfo line="2">test1.5
|
758
|
+
</listinfo><listinfo line="3">
|
759
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
760
|
+
</listinfo><floattitle type="insn">this is <b>test</b><&>_</floattitle></insn>
|
501
761
|
EOS
|
502
762
|
assert_equal expected, actual
|
503
763
|
end
|
@@ -511,6 +771,17 @@ EOS
|
|
511
771
|
</listinfo><listinfo line="3">
|
512
772
|
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
513
773
|
</listinfo></box>
|
774
|
+
EOS
|
775
|
+
assert_equal expected, actual
|
776
|
+
|
777
|
+
@config['caption_position']['list'] = 'bottom'
|
778
|
+
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
779
|
+
expected = <<-EOS.chomp
|
780
|
+
<box><listinfo line="1" begin="1">test1
|
781
|
+
</listinfo><listinfo line="2">test1.5
|
782
|
+
</listinfo><listinfo line="3">
|
783
|
+
</listinfo><listinfo line="4" end="4">test<i>2</i>
|
784
|
+
</listinfo><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption></box>
|
514
785
|
EOS
|
515
786
|
assert_equal expected, actual
|
516
787
|
end
|
@@ -524,6 +795,17 @@ test1.5
|
|
524
795
|
|
525
796
|
test<i>2</i>
|
526
797
|
</box>
|
798
|
+
EOS
|
799
|
+
assert_equal expected, actual
|
800
|
+
|
801
|
+
@config['caption_position']['list'] = 'bottom'
|
802
|
+
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
803
|
+
expected = <<-EOS.chomp
|
804
|
+
<box>test1
|
805
|
+
test1.5
|
806
|
+
|
807
|
+
test<i>2</i>
|
808
|
+
<caption aid:pstyle="box-title">this is <b>test</b><&>_</caption></box>
|
527
809
|
EOS
|
528
810
|
assert_equal expected, actual
|
529
811
|
end
|
@@ -569,6 +851,10 @@ EOS
|
|
569
851
|
|
570
852
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
571
853
|
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>), actual
|
854
|
+
|
855
|
+
@config['caption_position']['image'] = 'top'
|
856
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
857
|
+
assert_equal %Q(<img><caption>図1.1 sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
|
572
858
|
end
|
573
859
|
|
574
860
|
def test_image_with_metric
|
@@ -602,6 +888,10 @@ EOS
|
|
602
888
|
|
603
889
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
604
890
|
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>), actual
|
891
|
+
|
892
|
+
@config['caption_position']['image'] = 'top'
|
893
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
894
|
+
assert_equal %Q(<img><caption>sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
|
605
895
|
end
|
606
896
|
|
607
897
|
def test_indepimage_without_caption
|
@@ -709,10 +999,16 @@ inside column
|
|
709
999
|
this is @<column>{foo}.
|
710
1000
|
EOS
|
711
1001
|
expected = <<-EOS.chomp
|
712
|
-
<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
|
1002
|
+
<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>
|
713
1003
|
EOS
|
714
1004
|
|
715
1005
|
assert_equal expected, column_helper(review)
|
1006
|
+
|
1007
|
+
@config['chapterlink'] = nil
|
1008
|
+
expected = <<-EOS.chomp
|
1009
|
+
<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>
|
1010
|
+
EOS
|
1011
|
+
assert_equal expected, column_helper(review)
|
716
1012
|
end
|
717
1013
|
|
718
1014
|
def test_column_in_aother_chapter_ref
|
@@ -723,6 +1019,11 @@ EOS
|
|
723
1019
|
idx
|
724
1020
|
end
|
725
1021
|
|
1022
|
+
actual = compile_inline('test @<column>{chap1|column} test2')
|
1023
|
+
expected = 'test <link href="column-1">コラム「column_cap」</link> test2'
|
1024
|
+
assert_equal expected, actual
|
1025
|
+
|
1026
|
+
@config['chapterlink'] = nil
|
726
1027
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
727
1028
|
expected = 'test コラム「column_cap」 test2'
|
728
1029
|
assert_equal expected, actual
|
@@ -796,8 +1097,8 @@ EOS
|
|
796
1097
|
* AA
|
797
1098
|
EOS
|
798
1099
|
|
799
|
-
|
800
|
-
|
1100
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1101
|
+
assert_match(/too many \*\./, @log_io.string)
|
801
1102
|
end
|
802
1103
|
|
803
1104
|
def test_ul_nest4
|
@@ -832,19 +1133,25 @@ EOS
|
|
832
1133
|
end
|
833
1134
|
|
834
1135
|
def test_inline_unknown
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
1136
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1137
|
+
assert_match(/unknown image: n/, @log_io.string)
|
1138
|
+
|
1139
|
+
@log_io.string = ''
|
1140
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1141
|
+
assert_match(/unknown footnote: n/, @log_io.string)
|
1142
|
+
|
1143
|
+
@log_io.string = ''
|
1144
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1145
|
+
assert_match(/unknown headline: n/, @log_io.string)
|
841
1146
|
%w[list table column].each do |name|
|
842
|
-
|
843
|
-
|
1147
|
+
@log_io.string = ''
|
1148
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1149
|
+
assert_match(/unknown #{name}: n/, @log_io.string)
|
844
1150
|
end
|
845
1151
|
%w[chap chapref title].each do |name|
|
846
|
-
|
847
|
-
|
1152
|
+
@log_io.string = ''
|
1153
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1154
|
+
assert_match(/key not found: "n"/, @log_io.string)
|
848
1155
|
end
|
849
1156
|
end
|
850
1157
|
|
@@ -972,5 +1279,209 @@ EOS
|
|
972
1279
|
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>)
|
973
1280
|
actual = compile_block(src)
|
974
1281
|
assert_equal expected, actual
|
1282
|
+
|
1283
|
+
@config['caption_position']['equation'] = 'bottom'
|
1284
|
+
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>)
|
1285
|
+
actual = compile_block(src)
|
1286
|
+
assert_equal expected, actual
|
1287
|
+
end
|
1288
|
+
|
1289
|
+
def test_nest_error_close1
|
1290
|
+
src = <<-EOS
|
1291
|
+
//beginchild
|
1292
|
+
EOS
|
1293
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1294
|
+
assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
def test_nest_error_close2
|
1298
|
+
src = <<-EOS
|
1299
|
+
* foo
|
1300
|
+
|
1301
|
+
//beginchild
|
1302
|
+
|
1303
|
+
1. foo
|
1304
|
+
|
1305
|
+
//beginchild
|
1306
|
+
|
1307
|
+
: foo
|
1308
|
+
|
1309
|
+
//beginchild
|
1310
|
+
EOS
|
1311
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1312
|
+
assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message
|
1313
|
+
end
|
1314
|
+
|
1315
|
+
def test_nest_error_close3
|
1316
|
+
src = <<-EOS
|
1317
|
+
* foo
|
1318
|
+
|
1319
|
+
//beginchild
|
1320
|
+
|
1321
|
+
1. foo
|
1322
|
+
|
1323
|
+
//beginchild
|
1324
|
+
|
1325
|
+
: foo
|
1326
|
+
|
1327
|
+
//beginchild
|
1328
|
+
|
1329
|
+
//endchild
|
1330
|
+
EOS
|
1331
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
1332
|
+
assert_equal '//beginchild of ol,ul misses //endchild', e.message
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
def test_nest_ul
|
1336
|
+
src = <<-EOS
|
1337
|
+
* UL1
|
1338
|
+
|
1339
|
+
//beginchild
|
1340
|
+
|
1341
|
+
1. UL1-OL1
|
1342
|
+
2. UL1-OL2
|
1343
|
+
|
1344
|
+
* UL1-UL1
|
1345
|
+
* UL1-UL2
|
1346
|
+
|
1347
|
+
: UL1-DL1
|
1348
|
+
UL1-DD1
|
1349
|
+
: UL1-DL2
|
1350
|
+
UL1-DD2
|
1351
|
+
|
1352
|
+
//endchild
|
1353
|
+
|
1354
|
+
* UL2
|
1355
|
+
|
1356
|
+
//beginchild
|
1357
|
+
|
1358
|
+
UL2-PARA
|
1359
|
+
|
1360
|
+
//endchild
|
1361
|
+
EOS
|
1362
|
+
|
1363
|
+
expected = <<-EOS.chomp
|
1364
|
+
<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>
|
1365
|
+
EOS
|
1366
|
+
|
1367
|
+
actual = compile_block(src)
|
1368
|
+
assert_equal expected, actual
|
1369
|
+
end
|
1370
|
+
|
1371
|
+
def test_nest_ol
|
1372
|
+
src = <<-EOS
|
1373
|
+
1. OL1
|
1374
|
+
|
1375
|
+
//beginchild
|
1376
|
+
|
1377
|
+
1. OL1-OL1
|
1378
|
+
2. OL1-OL2
|
1379
|
+
|
1380
|
+
* OL1-UL1
|
1381
|
+
* OL1-UL2
|
1382
|
+
|
1383
|
+
: OL1-DL1
|
1384
|
+
OL1-DD1
|
1385
|
+
: OL1-DL2
|
1386
|
+
OL1-DD2
|
1387
|
+
|
1388
|
+
//endchild
|
1389
|
+
|
1390
|
+
2. OL2
|
1391
|
+
|
1392
|
+
//beginchild
|
1393
|
+
|
1394
|
+
OL2-PARA
|
1395
|
+
|
1396
|
+
//endchild
|
1397
|
+
EOS
|
1398
|
+
|
1399
|
+
expected = <<-EOS.chomp
|
1400
|
+
<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>
|
1401
|
+
EOS
|
1402
|
+
|
1403
|
+
actual = compile_block(src)
|
1404
|
+
assert_equal expected, actual
|
1405
|
+
end
|
1406
|
+
|
1407
|
+
def test_nest_dl
|
1408
|
+
src = <<-EOS
|
1409
|
+
: DL1
|
1410
|
+
|
1411
|
+
//beginchild
|
1412
|
+
|
1413
|
+
1. DL1-OL1
|
1414
|
+
2. DL1-OL2
|
1415
|
+
|
1416
|
+
* DL1-UL1
|
1417
|
+
* DL1-UL2
|
1418
|
+
|
1419
|
+
: DL1-DL1
|
1420
|
+
DL1-DD1
|
1421
|
+
: DL1-DL2
|
1422
|
+
DL1-DD2
|
1423
|
+
|
1424
|
+
//endchild
|
1425
|
+
|
1426
|
+
: DL2
|
1427
|
+
DD2
|
1428
|
+
|
1429
|
+
//beginchild
|
1430
|
+
|
1431
|
+
* DD2-UL1
|
1432
|
+
* DD2-UL2
|
1433
|
+
|
1434
|
+
DD2-PARA
|
1435
|
+
|
1436
|
+
//endchild
|
1437
|
+
EOS
|
1438
|
+
|
1439
|
+
expected = <<-EOS.chomp
|
1440
|
+
<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>
|
1441
|
+
EOS
|
1442
|
+
|
1443
|
+
actual = compile_block(src)
|
1444
|
+
assert_equal expected, actual
|
1445
|
+
end
|
1446
|
+
|
1447
|
+
def test_nest_multi
|
1448
|
+
src = <<-EOS
|
1449
|
+
1. OL1
|
1450
|
+
|
1451
|
+
//beginchild
|
1452
|
+
|
1453
|
+
1. OL1-OL1
|
1454
|
+
|
1455
|
+
//beginchild
|
1456
|
+
|
1457
|
+
* OL1-OL1-UL1
|
1458
|
+
|
1459
|
+
OL1-OL1-PARA
|
1460
|
+
|
1461
|
+
//endchild
|
1462
|
+
|
1463
|
+
2. OL1-OL2
|
1464
|
+
|
1465
|
+
* OL1-UL1
|
1466
|
+
|
1467
|
+
//beginchild
|
1468
|
+
|
1469
|
+
: OL1-UL1-DL1
|
1470
|
+
OL1-UL1-DD1
|
1471
|
+
|
1472
|
+
OL1-UL1-PARA
|
1473
|
+
|
1474
|
+
//endchild
|
1475
|
+
|
1476
|
+
* OL1-UL2
|
1477
|
+
|
1478
|
+
//endchild
|
1479
|
+
EOS
|
1480
|
+
expected = <<-EOS.chomp
|
1481
|
+
<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>
|
1482
|
+
EOS
|
1483
|
+
|
1484
|
+
actual = compile_block(src)
|
1485
|
+
assert_equal expected, actual
|
975
1486
|
end
|
976
1487
|
end
|