review 4.2.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-win.yml +11 -5
- data/.rubocop.yml +113 -24
- data/NEWS.ja.md +94 -0
- data/NEWS.md +94 -0
- data/bin/review-catalog-converter +1 -1
- data/bin/review-check +2 -4
- data/bin/review-checkdep +1 -1
- data/bin/review-compile +8 -14
- data/bin/review-validate +1 -1
- data/doc/config.yml.sample +4 -1
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +83 -4
- data/doc/format.md +84 -7
- data/doc/makeindex.ja.md +2 -2
- data/doc/quickstart.ja.md +3 -3
- data/doc/quickstart.md +2 -2
- data/lib/epubmaker/content.rb +3 -2
- data/lib/epubmaker/epubcommon.rb +33 -25
- data/lib/epubmaker/epubv2.rb +5 -6
- data/lib/epubmaker/epubv3.rb +20 -18
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +61 -25
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +155 -0
- data/lib/review/book/chapter.rb +30 -26
- data/lib/review/book/index.rb +23 -185
- data/lib/review/book/index/item.rb +7 -1
- data/lib/review/book/part.rb +21 -9
- data/lib/review/book/volume.rb +1 -1
- data/lib/review/builder.rb +68 -13
- data/lib/review/catalog.rb +2 -2
- data/lib/review/compiler.rb +159 -73
- data/lib/review/configure.rb +22 -1
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +12 -23
- data/lib/review/htmlbuilder.rb +36 -7
- data/lib/review/htmlutils.rb +7 -10
- data/lib/review/i18n.rb +1 -1
- data/lib/review/idgxmlbuilder.rb +51 -6
- data/lib/review/idgxmlmaker.rb +9 -14
- data/lib/review/index_builder.rb +653 -0
- data/lib/review/init.rb +5 -13
- data/lib/review/latexbuilder.rb +65 -4
- data/lib/review/logger.rb +2 -2
- data/lib/review/makerhelper.rb +11 -0
- data/lib/review/markdownbuilder.rb +19 -1
- data/lib/review/pdfmaker.rb +17 -36
- data/lib/review/plaintextbuilder.rb +48 -2
- data/lib/review/preprocessor.rb +5 -5
- data/lib/review/rstbuilder.rb +25 -6
- data/lib/review/sec_counter.rb +13 -0
- data/lib/review/textmaker.rb +4 -12
- data/lib/review/tocprinter.rb +2 -3
- data/lib/review/topbuilder.rb +26 -0
- data/lib/review/update.rb +7 -7
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +2 -3
- data/lib/review/webmaker.rb +9 -20
- data/review.gemspec +2 -2
- data/samples/sample-book/src/config.yml +1 -1
- data/samples/syntax-book/Gemfile +1 -1
- data/samples/syntax-book/config.yml +1 -1
- data/templates/latex/config.erb +27 -23
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +31 -15
- data/templates/latex/review-jlreq/review-jlreq.cls +8 -24
- data/templates/latex/review-jsbook/README.md +7 -5
- data/templates/latex/review-jsbook/review-base.sty +34 -16
- data/templates/latex/review-jsbook/review-jsbook.cls +4 -2
- data/templates/web/html/layout-html5.html.erb +1 -1
- data/test/assets/test_template.tex +3 -3
- data/test/assets/test_template_backmatter.tex +3 -3
- data/test/book_test_helper.rb +11 -5
- data/test/test_book.rb +54 -63
- data/test/test_book_chapter.rb +93 -52
- data/test/test_builder.rb +24 -15
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +2 -2
- data/test/test_epubmaker.rb +8 -0
- data/test/test_helper.rb +4 -1
- data/test/test_htmlbuilder.rb +627 -56
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +358 -11
- data/test/test_idgxmlmaker_cmd.rb +1 -1
- data/test/test_index.rb +62 -52
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +547 -10
- data/test/test_latexbuilder_v2.rb +43 -5
- data/test/test_logger.rb +7 -7
- data/test/test_makerhelper.rb +0 -12
- data/test/test_markdownbuilder.rb +3 -0
- data/test/test_pdfmaker.rb +13 -12
- data/test/test_pdfmaker_cmd.rb +1 -1
- data/test/test_plaintextbuilder.rb +422 -7
- data/test/test_review_ext.rb +2 -1
- data/test/test_rstbuilder.rb +25 -1
- data/test/test_sec_counter.rb +156 -0
- data/test/test_textmaker_cmd.rb +1 -1
- data/test/test_topbuilder.rb +187 -10
- data/test/test_update.rb +10 -10
- data/test/test_webtocprinter.rb +12 -12
- 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 +14 -6
- data/.rubocop_todo.yml +0 -7
- data/lib/review/book/compilable.rb +0 -174
|
@@ -29,7 +29,7 @@ class IDGXMLMakerCmdTest < Test::Unit::TestCase
|
|
|
29
29
|
ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
|
|
30
30
|
Dir.chdir(@tmpdir1) do
|
|
31
31
|
_o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_IDGXMLMAKER} #{option} #{configfile}")
|
|
32
|
-
|
|
32
|
+
assert_equal '', e
|
|
33
33
|
assert s.success?
|
|
34
34
|
end
|
|
35
35
|
assert File.exist?(File.join(@tmpdir1, targetfile))
|
data/test/test_index.rb
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
require 'test_helper'
|
|
2
|
+
require 'review/compiler'
|
|
2
3
|
require 'review/book'
|
|
3
4
|
require 'review/book/index'
|
|
5
|
+
require 'review/topbuilder'
|
|
6
|
+
require 'review/i18n'
|
|
4
7
|
|
|
5
8
|
class IndexTest < Test::Unit::TestCase
|
|
6
9
|
include ReVIEW
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
@builder = TOPBuilder.new
|
|
13
|
+
@config = ReVIEW::Configure.create(config: { 'secnolevel' => 2, 'language' => 'ja' })
|
|
14
|
+
@book = Book::Base.new(config: @config)
|
|
15
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
|
16
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
|
17
|
+
location = Location.new(nil, nil)
|
|
18
|
+
@builder.bind(@compiler, @chapter, location)
|
|
19
|
+
|
|
20
|
+
I18n.setup(@config['language'])
|
|
21
|
+
end
|
|
22
|
+
|
|
7
23
|
def test_footnote_index
|
|
8
|
-
|
|
24
|
+
compile_block("//footnote[foo][bar]\n")
|
|
25
|
+
fn = @chapter.footnote_index
|
|
9
26
|
items = fn.to_a
|
|
10
27
|
item = items[0]
|
|
11
28
|
assert_equal 'foo', item.id
|
|
@@ -13,7 +30,8 @@ class IndexTest < Test::Unit::TestCase
|
|
|
13
30
|
end
|
|
14
31
|
|
|
15
32
|
def test_footnote_index_with_escape
|
|
16
|
-
|
|
33
|
+
compile_block('//footnote[foo][bar[\]buz]' + "\n")
|
|
34
|
+
fn = @chapter.footnote_index
|
|
17
35
|
items = fn.to_a
|
|
18
36
|
item = items[0]
|
|
19
37
|
assert_equal 'foo', item.id
|
|
@@ -21,7 +39,8 @@ class IndexTest < Test::Unit::TestCase
|
|
|
21
39
|
end
|
|
22
40
|
|
|
23
41
|
def test_footnote_index_with_escape2
|
|
24
|
-
|
|
42
|
+
compile_block('//footnote[foo][bar\\a\\$buz]' + "\n")
|
|
43
|
+
fn = @chapter.footnote_index
|
|
25
44
|
items = fn.to_a
|
|
26
45
|
item = items[0]
|
|
27
46
|
assert_equal 'foo', item.id
|
|
@@ -29,7 +48,8 @@ class IndexTest < Test::Unit::TestCase
|
|
|
29
48
|
end
|
|
30
49
|
|
|
31
50
|
def test_footnote_index_key?
|
|
32
|
-
|
|
51
|
+
compile_block('//footnote[foo][bar]' + "\n")
|
|
52
|
+
fn = @chapter.footnote_index
|
|
33
53
|
assert_equal true, fn.key?('foo')
|
|
34
54
|
|
|
35
55
|
## for compatibility
|
|
@@ -38,7 +58,7 @@ class IndexTest < Test::Unit::TestCase
|
|
|
38
58
|
# rubocop:enable Style/PreferredHashMethods
|
|
39
59
|
end
|
|
40
60
|
|
|
41
|
-
def
|
|
61
|
+
def test_headline_index
|
|
42
62
|
src = <<-EOB
|
|
43
63
|
= chap1
|
|
44
64
|
== sec1-1
|
|
@@ -52,14 +72,13 @@ class IndexTest < Test::Unit::TestCase
|
|
|
52
72
|
== sec1-3
|
|
53
73
|
==== sec1-3-0-1
|
|
54
74
|
EOB
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
75
|
+
compile_block(src)
|
|
76
|
+
index = @chapter.headline_index
|
|
58
77
|
assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
|
|
59
78
|
assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
|
|
60
79
|
end
|
|
61
80
|
|
|
62
|
-
def
|
|
81
|
+
def test_headline_index2
|
|
63
82
|
src = <<-EOB
|
|
64
83
|
= chap1
|
|
65
84
|
== sec1-1
|
|
@@ -69,14 +88,13 @@ class IndexTest < Test::Unit::TestCase
|
|
|
69
88
|
== sec1-3
|
|
70
89
|
=== sec1-3-1
|
|
71
90
|
EOB
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
index = Book::HeadlineIndex.parse(src.lines, chap)
|
|
91
|
+
compile_block(src)
|
|
92
|
+
index = @chapter.headline_index
|
|
75
93
|
assert_equal [3, 1], index['sec1-3|sec1-3-1'].number
|
|
76
94
|
assert_equal '1.3.1', index.number('sec1-3|sec1-3-1')
|
|
77
95
|
end
|
|
78
96
|
|
|
79
|
-
def
|
|
97
|
+
def test_headline_index3
|
|
80
98
|
src = <<-EOB
|
|
81
99
|
= chap1
|
|
82
100
|
== sec1-1
|
|
@@ -87,9 +105,8 @@ class IndexTest < Test::Unit::TestCase
|
|
|
87
105
|
== sec1-3
|
|
88
106
|
=== sec1-3-1
|
|
89
107
|
EOB
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
108
|
+
compile_block(src)
|
|
109
|
+
index = @chapter.headline_index
|
|
93
110
|
assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
|
|
94
111
|
assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
|
|
95
112
|
|
|
@@ -97,7 +114,7 @@ class IndexTest < Test::Unit::TestCase
|
|
|
97
114
|
assert_equal '1.3.1', index.number('sec1-3|sec1-3-1')
|
|
98
115
|
end
|
|
99
116
|
|
|
100
|
-
def
|
|
117
|
+
def test_headline_index4
|
|
101
118
|
src = <<-EOB
|
|
102
119
|
= chap1
|
|
103
120
|
====[column] c1
|
|
@@ -106,14 +123,13 @@ class IndexTest < Test::Unit::TestCase
|
|
|
106
123
|
=== sec1-2-1
|
|
107
124
|
=== sec1-2-2
|
|
108
125
|
EOB
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
126
|
+
compile_block(src)
|
|
127
|
+
index = @chapter.headline_index
|
|
112
128
|
assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
|
|
113
129
|
assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
|
|
114
130
|
end
|
|
115
131
|
|
|
116
|
-
def
|
|
132
|
+
def test_headline_index5
|
|
117
133
|
src = <<-EOB
|
|
118
134
|
= chap1
|
|
119
135
|
====[column] c1
|
|
@@ -122,14 +138,13 @@ class IndexTest < Test::Unit::TestCase
|
|
|
122
138
|
=== sec1-2-1
|
|
123
139
|
=== sec1-2-2
|
|
124
140
|
EOB
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
141
|
+
compile_block(src)
|
|
142
|
+
index = @chapter.headline_index
|
|
128
143
|
assert_equal [2, 2], index['sec1-2-2'].number
|
|
129
144
|
assert_equal '1.2.2', index.number('sec1-2-2')
|
|
130
145
|
end
|
|
131
146
|
|
|
132
|
-
def
|
|
147
|
+
def test_headline_index6
|
|
133
148
|
src = <<-EOB
|
|
134
149
|
= chap1
|
|
135
150
|
== sec1
|
|
@@ -137,34 +152,33 @@ class IndexTest < Test::Unit::TestCase
|
|
|
137
152
|
== sec2
|
|
138
153
|
|
|
139
154
|
EOB
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
155
|
+
compile_block(src)
|
|
156
|
+
index = @chapter.headline_index
|
|
143
157
|
assert_equal [1, 1], index['target'].number
|
|
144
158
|
assert_equal '1.1.1', index.number('target')
|
|
145
159
|
end
|
|
146
160
|
|
|
147
|
-
def
|
|
161
|
+
def test_headline_index7
|
|
148
162
|
src = <<-EOB
|
|
149
163
|
= chap1
|
|
150
164
|
== sec1
|
|
151
165
|
=== target
|
|
152
166
|
^-- dummy target
|
|
167
|
+
|
|
153
168
|
== sec2
|
|
154
169
|
=== target
|
|
155
170
|
^-- real target but it cannot be detected, because there is another one.
|
|
156
171
|
|
|
157
172
|
EOB
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
173
|
+
compile_block(src)
|
|
174
|
+
index = @chapter.headline_index
|
|
161
175
|
|
|
162
176
|
assert_raise ReVIEW::KeyError do
|
|
163
177
|
assert_equal [1, 1], index['target'].number
|
|
164
178
|
end
|
|
165
179
|
end
|
|
166
180
|
|
|
167
|
-
def
|
|
181
|
+
def test_headline_index8
|
|
168
182
|
src = <<-EOB
|
|
169
183
|
= chap1
|
|
170
184
|
== sec1
|
|
@@ -172,13 +186,13 @@ class IndexTest < Test::Unit::TestCase
|
|
|
172
186
|
==== sec1-1-1
|
|
173
187
|
|
|
174
188
|
EOB
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
compile_block(src)
|
|
190
|
+
index = @chapter.headline_index
|
|
191
|
+
|
|
178
192
|
assert_equal '1.1.1', index.number('sec1-1')
|
|
179
193
|
end
|
|
180
194
|
|
|
181
|
-
def
|
|
195
|
+
def test_headline_index9
|
|
182
196
|
src = <<-EOB
|
|
183
197
|
= chap1
|
|
184
198
|
== sec1
|
|
@@ -188,13 +202,12 @@ class IndexTest < Test::Unit::TestCase
|
|
|
188
202
|
==== sec1-1-1
|
|
189
203
|
=== sec1-2
|
|
190
204
|
EOB
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
205
|
+
compile_block(src)
|
|
206
|
+
index = @chapter.headline_index
|
|
194
207
|
assert_equal [1, 1, 1], index['sec1-1-1'].number
|
|
195
208
|
end
|
|
196
209
|
|
|
197
|
-
def
|
|
210
|
+
def test_headline_index10
|
|
198
211
|
src = <<-EOB
|
|
199
212
|
= chap1
|
|
200
213
|
== sec1
|
|
@@ -203,13 +216,12 @@ class IndexTest < Test::Unit::TestCase
|
|
|
203
216
|
==== sec1-1-1
|
|
204
217
|
=== sec1-2
|
|
205
218
|
EOB
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
219
|
+
compile_block(src)
|
|
220
|
+
index = @chapter.headline_index
|
|
209
221
|
assert_equal [1, 1, 1], index['sec1-1-1'].number
|
|
210
222
|
end
|
|
211
223
|
|
|
212
|
-
def
|
|
224
|
+
def test_headline_index11
|
|
213
225
|
src = <<-EOB
|
|
214
226
|
= chap1
|
|
215
227
|
==[nodisp] sec01
|
|
@@ -220,9 +232,8 @@ class IndexTest < Test::Unit::TestCase
|
|
|
220
232
|
==[nonum] sec03
|
|
221
233
|
== sec04
|
|
222
234
|
EOB
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
235
|
+
compile_block(src)
|
|
236
|
+
index = @chapter.headline_index
|
|
226
237
|
assert_equal nil, index['sec01'].number
|
|
227
238
|
assert_equal nil, index['sec02'].number
|
|
228
239
|
assert_equal [1], index['sec1'].number
|
|
@@ -232,7 +243,7 @@ class IndexTest < Test::Unit::TestCase
|
|
|
232
243
|
assert_equal [2], index['sec04'].number
|
|
233
244
|
end
|
|
234
245
|
|
|
235
|
-
def
|
|
246
|
+
def test_headline_index12
|
|
236
247
|
src = <<-EOB
|
|
237
248
|
= chap1
|
|
238
249
|
== A
|
|
@@ -240,9 +251,8 @@ class IndexTest < Test::Unit::TestCase
|
|
|
240
251
|
==[nonum] B
|
|
241
252
|
=== B2
|
|
242
253
|
EOB
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
index = Book::HeadlineIndex.parse(src.lines.to_a, chap)
|
|
254
|
+
compile_block(src)
|
|
255
|
+
index = @chapter.headline_index
|
|
246
256
|
assert_equal [1], index['A'].number
|
|
247
257
|
assert_equal [1, 1], index['A2'].number
|
|
248
258
|
assert_equal nil, index['B'].number
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'review/builder'
|
|
3
|
+
|
|
4
|
+
require 'review/book'
|
|
5
|
+
|
|
6
|
+
class MockCompiler
|
|
7
|
+
def text(s)
|
|
8
|
+
[:text, s]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class IndexBuidlerTest < Test::Unit::TestCase
|
|
13
|
+
include ReVIEW
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
@b = IndexBuilder.new
|
|
17
|
+
chap = ReVIEW::Book::Chapter.new(nil, nil, '-', nil)
|
|
18
|
+
@b.bind(MockCompiler.new, chap, nil)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_initialize
|
|
22
|
+
assert IndexBuilder.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_check_id
|
|
26
|
+
io = StringIO.new
|
|
27
|
+
@b.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
|
28
|
+
@b.check_id('ABC')
|
|
29
|
+
assert_match('', io.string)
|
|
30
|
+
|
|
31
|
+
%w(# % \\ { } [ ] ~ / $ ' " | * ? & < > `).each do |c|
|
|
32
|
+
io = StringIO.new
|
|
33
|
+
@b.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
|
34
|
+
@b.check_id("id#{c}")
|
|
35
|
+
assert_match(/deprecated ID: `#{Regexp.escape(c)}` in `id#{Regexp.escape(c)}`/, io.string)
|
|
36
|
+
end
|
|
37
|
+
io = StringIO.new
|
|
38
|
+
@b.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
|
39
|
+
@b.check_id('A B C#')
|
|
40
|
+
assert_match(/deprecated ID: ` ` in `A B C#`/, io.string)
|
|
41
|
+
|
|
42
|
+
io = StringIO.new
|
|
43
|
+
@b.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
|
44
|
+
@b.check_id("A\tB")
|
|
45
|
+
assert_match(/deprecated ID: `\t` in `A\tB`/, io.string)
|
|
46
|
+
|
|
47
|
+
io = StringIO.new
|
|
48
|
+
@b.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
|
49
|
+
@b.check_id('.ABC')
|
|
50
|
+
assert_match(/deprecated ID: `.ABC` begins from `.`/, io.string)
|
|
51
|
+
end
|
|
52
|
+
end
|
data/test/test_latexbuilder.rb
CHANGED
|
@@ -255,6 +255,10 @@ EOS
|
|
|
255
255
|
|
|
256
256
|
@config['secnolevel'] = 3
|
|
257
257
|
actual = compile_inline('test @<hd>{chap1|test} test2')
|
|
258
|
+
assert_equal 'test \reviewsecref{「1.1.1 te\\textunderscore{}st」}{sec:1-1-1} test2', actual
|
|
259
|
+
|
|
260
|
+
@config['chapterlink'] = nil
|
|
261
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
|
258
262
|
assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
|
|
259
263
|
end
|
|
260
264
|
|
|
@@ -389,9 +393,7 @@ EOS
|
|
|
389
393
|
end
|
|
390
394
|
|
|
391
395
|
def test_dt_inline
|
|
392
|
-
|
|
393
|
-
@chapter.instance_eval { @footnote_index = fn }
|
|
394
|
-
actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
|
396
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
|
395
397
|
|
|
396
398
|
expected = <<-EOS
|
|
397
399
|
|
|
@@ -902,9 +904,11 @@ EOS
|
|
|
902
904
|
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
|
903
905
|
expected = <<-EOS
|
|
904
906
|
\\begin{reviewmemo}[this is \\reviewbold{test}\\textless{}\\&\\textgreater{}\\textunderscore{}]
|
|
907
|
+
|
|
905
908
|
test1
|
|
906
909
|
|
|
907
910
|
test\\reviewit{2}
|
|
911
|
+
|
|
908
912
|
\\end{reviewmemo}
|
|
909
913
|
EOS
|
|
910
914
|
assert_equal expected, actual
|
|
@@ -1270,6 +1274,31 @@ EOS
|
|
|
1270
1274
|
assert_equal expected, actual
|
|
1271
1275
|
end
|
|
1272
1276
|
|
|
1277
|
+
def test_indepimage_nofile
|
|
1278
|
+
def @chapter.image(_id)
|
|
1279
|
+
item = Book::Index::Item.new('sample_img_nofile_', 1)
|
|
1280
|
+
item.instance_eval do
|
|
1281
|
+
def path
|
|
1282
|
+
nil
|
|
1283
|
+
end
|
|
1284
|
+
end
|
|
1285
|
+
item
|
|
1286
|
+
end
|
|
1287
|
+
|
|
1288
|
+
io = StringIO.new
|
|
1289
|
+
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
|
1290
|
+
|
|
1291
|
+
actual = compile_block("//indepimage[sample_img_nofile_][sample photo]\n")
|
|
1292
|
+
expected = <<-EOS
|
|
1293
|
+
\\begin{reviewdummyimage}
|
|
1294
|
+
--[[path = sample\\textunderscore{}img\\textunderscore{}nofile\\textunderscore{} (not exist)]]--
|
|
1295
|
+
\\reviewindepimagecaption{図: sample photo}
|
|
1296
|
+
\\end{reviewdummyimage}
|
|
1297
|
+
EOS
|
|
1298
|
+
assert_equal expected, actual
|
|
1299
|
+
assert_match(/WARN --: :1: image not bound: sample_img_nofile_/, io.string)
|
|
1300
|
+
end
|
|
1301
|
+
|
|
1273
1302
|
def test_table
|
|
1274
1303
|
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
|
1275
1304
|
expected = <<-EOS
|
|
@@ -1312,10 +1341,10 @@ EOS
|
|
|
1312
1341
|
end
|
|
1313
1342
|
|
|
1314
1343
|
def test_empty_table
|
|
1315
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
|
1344
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
|
1316
1345
|
assert_equal ':2: error: no rows in the table', e.message
|
|
1317
1346
|
|
|
1318
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
|
1347
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
|
1319
1348
|
assert_equal ':3: error: no rows in the table', e.message
|
|
1320
1349
|
end
|
|
1321
1350
|
|
|
@@ -1872,12 +1901,16 @@ EOS
|
|
|
1872
1901
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
|
1873
1902
|
expected = <<-EOS
|
|
1874
1903
|
\\begin{reviewnote}
|
|
1904
|
+
|
|
1875
1905
|
A
|
|
1876
1906
|
|
|
1877
1907
|
B
|
|
1908
|
+
|
|
1878
1909
|
\\end{reviewnote}
|
|
1879
1910
|
\\begin{reviewnote}[caption]
|
|
1911
|
+
|
|
1880
1912
|
A
|
|
1913
|
+
|
|
1881
1914
|
\\end{reviewnote}
|
|
1882
1915
|
EOS
|
|
1883
1916
|
assert_equal expected, actual
|
|
@@ -1885,12 +1918,16 @@ EOS
|
|
|
1885
1918
|
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
|
1886
1919
|
expected = <<-EOS
|
|
1887
1920
|
\\begin{reviewmemo}
|
|
1921
|
+
|
|
1888
1922
|
A
|
|
1889
1923
|
|
|
1890
1924
|
B
|
|
1925
|
+
|
|
1891
1926
|
\\end{reviewmemo}
|
|
1892
1927
|
\\begin{reviewmemo}[caption]
|
|
1928
|
+
|
|
1893
1929
|
A
|
|
1930
|
+
|
|
1894
1931
|
\\end{reviewmemo}
|
|
1895
1932
|
EOS
|
|
1896
1933
|
assert_equal expected, actual
|
|
@@ -1898,12 +1935,16 @@ EOS
|
|
|
1898
1935
|
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
|
1899
1936
|
expected = <<-EOS
|
|
1900
1937
|
\\begin{reviewinfo}
|
|
1938
|
+
|
|
1901
1939
|
A
|
|
1902
1940
|
|
|
1903
1941
|
B
|
|
1942
|
+
|
|
1904
1943
|
\\end{reviewinfo}
|
|
1905
1944
|
\\begin{reviewinfo}[caption]
|
|
1945
|
+
|
|
1906
1946
|
A
|
|
1947
|
+
|
|
1907
1948
|
\\end{reviewinfo}
|
|
1908
1949
|
EOS
|
|
1909
1950
|
assert_equal expected, actual
|
|
@@ -1911,12 +1952,16 @@ EOS
|
|
|
1911
1952
|
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
|
1912
1953
|
expected = <<-EOS
|
|
1913
1954
|
\\begin{reviewimportant}
|
|
1955
|
+
|
|
1914
1956
|
A
|
|
1915
1957
|
|
|
1916
1958
|
B
|
|
1959
|
+
|
|
1917
1960
|
\\end{reviewimportant}
|
|
1918
1961
|
\\begin{reviewimportant}[caption]
|
|
1962
|
+
|
|
1919
1963
|
A
|
|
1964
|
+
|
|
1920
1965
|
\\end{reviewimportant}
|
|
1921
1966
|
EOS
|
|
1922
1967
|
assert_equal expected, actual
|
|
@@ -1924,12 +1969,16 @@ EOS
|
|
|
1924
1969
|
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
|
1925
1970
|
expected = <<-EOS
|
|
1926
1971
|
\\begin{reviewcaution}
|
|
1972
|
+
|
|
1927
1973
|
A
|
|
1928
1974
|
|
|
1929
1975
|
B
|
|
1976
|
+
|
|
1930
1977
|
\\end{reviewcaution}
|
|
1931
1978
|
\\begin{reviewcaution}[caption]
|
|
1979
|
+
|
|
1932
1980
|
A
|
|
1981
|
+
|
|
1933
1982
|
\\end{reviewcaution}
|
|
1934
1983
|
EOS
|
|
1935
1984
|
assert_equal expected, actual
|
|
@@ -1937,12 +1986,16 @@ EOS
|
|
|
1937
1986
|
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
|
1938
1987
|
expected = <<-EOS
|
|
1939
1988
|
\\begin{reviewnotice}
|
|
1989
|
+
|
|
1940
1990
|
A
|
|
1941
1991
|
|
|
1942
1992
|
B
|
|
1993
|
+
|
|
1943
1994
|
\\end{reviewnotice}
|
|
1944
1995
|
\\begin{reviewnotice}[caption]
|
|
1996
|
+
|
|
1945
1997
|
A
|
|
1998
|
+
|
|
1946
1999
|
\\end{reviewnotice}
|
|
1947
2000
|
EOS
|
|
1948
2001
|
assert_equal expected, actual
|
|
@@ -1950,12 +2003,16 @@ EOS
|
|
|
1950
2003
|
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
|
1951
2004
|
expected = <<-EOS
|
|
1952
2005
|
\\begin{reviewwarning}
|
|
2006
|
+
|
|
1953
2007
|
A
|
|
1954
2008
|
|
|
1955
2009
|
B
|
|
2010
|
+
|
|
1956
2011
|
\\end{reviewwarning}
|
|
1957
2012
|
\\begin{reviewwarning}[caption]
|
|
2013
|
+
|
|
1958
2014
|
A
|
|
2015
|
+
|
|
1959
2016
|
\\end{reviewwarning}
|
|
1960
2017
|
EOS
|
|
1961
2018
|
assert_equal expected, actual
|
|
@@ -1963,17 +2020,173 @@ EOS
|
|
|
1963
2020
|
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
|
1964
2021
|
expected = <<-EOS
|
|
1965
2022
|
\\begin{reviewtip}
|
|
2023
|
+
|
|
1966
2024
|
A
|
|
1967
2025
|
|
|
1968
2026
|
B
|
|
2027
|
+
|
|
1969
2028
|
\\end{reviewtip}
|
|
1970
2029
|
\\begin{reviewtip}[caption]
|
|
2030
|
+
|
|
1971
2031
|
A
|
|
2032
|
+
|
|
1972
2033
|
\\end{reviewtip}
|
|
1973
2034
|
EOS
|
|
1974
2035
|
assert_equal expected, actual
|
|
1975
2036
|
end
|
|
1976
2037
|
|
|
2038
|
+
def test_minicolumn_blocks
|
|
2039
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
|
2040
|
+
src = <<-EOS
|
|
2041
|
+
//#{type}[#{type}1]{
|
|
2042
|
+
|
|
2043
|
+
//}
|
|
2044
|
+
|
|
2045
|
+
//#{type}[#{type}2]{
|
|
2046
|
+
//}
|
|
2047
|
+
EOS
|
|
2048
|
+
|
|
2049
|
+
expected = <<-EOS
|
|
2050
|
+
\\begin{review#{type}}[#{type}1]
|
|
2051
|
+
\\end{review#{type}}
|
|
2052
|
+
\\begin{review#{type}}[#{type}2]
|
|
2053
|
+
\\end{review#{type}}
|
|
2054
|
+
EOS
|
|
2055
|
+
assert_equal expected, compile_block(src)
|
|
2056
|
+
|
|
2057
|
+
src = <<-EOS
|
|
2058
|
+
//#{type}[#{type}2]{
|
|
2059
|
+
|
|
2060
|
+
//}
|
|
2061
|
+
|
|
2062
|
+
//#{type}[#{type}3]{
|
|
2063
|
+
|
|
2064
|
+
//}
|
|
2065
|
+
|
|
2066
|
+
//#{type}[#{type}4]{
|
|
2067
|
+
|
|
2068
|
+
//}
|
|
2069
|
+
|
|
2070
|
+
//#{type}[#{type}5]{
|
|
2071
|
+
|
|
2072
|
+
//}
|
|
2073
|
+
|
|
2074
|
+
//#{type}[#{type}6]{
|
|
2075
|
+
|
|
2076
|
+
//}
|
|
2077
|
+
EOS
|
|
2078
|
+
|
|
2079
|
+
expected = <<-EOS
|
|
2080
|
+
\\begin{review#{type}}[#{type}2]
|
|
2081
|
+
\\end{review#{type}}
|
|
2082
|
+
\\begin{review#{type}}[#{type}3]
|
|
2083
|
+
\\end{review#{type}}
|
|
2084
|
+
\\begin{review#{type}}[#{type}4]
|
|
2085
|
+
\\end{review#{type}}
|
|
2086
|
+
\\begin{review#{type}}[#{type}5]
|
|
2087
|
+
\\end{review#{type}}
|
|
2088
|
+
\\begin{review#{type}}[#{type}6]
|
|
2089
|
+
\\end{review#{type}}
|
|
2090
|
+
EOS
|
|
2091
|
+
assert_equal expected, compile_block(src)
|
|
2092
|
+
|
|
2093
|
+
src = <<-EOS
|
|
2094
|
+
//#{type}{
|
|
2095
|
+
|
|
2096
|
+
* A
|
|
2097
|
+
|
|
2098
|
+
1. B
|
|
2099
|
+
|
|
2100
|
+
//}
|
|
2101
|
+
|
|
2102
|
+
//#{type}[OMITEND1]{
|
|
2103
|
+
|
|
2104
|
+
//emlist{
|
|
2105
|
+
LIST
|
|
2106
|
+
//}
|
|
2107
|
+
|
|
2108
|
+
//}
|
|
2109
|
+
//#{type}[OMITEND2]{
|
|
2110
|
+
//}
|
|
2111
|
+
EOS
|
|
2112
|
+
|
|
2113
|
+
expected = <<-EOS
|
|
2114
|
+
\\begin{review#{type}}
|
|
2115
|
+
|
|
2116
|
+
\\begin{itemize}
|
|
2117
|
+
\\item A
|
|
2118
|
+
\\end{itemize}
|
|
2119
|
+
|
|
2120
|
+
\\begin{enumerate}
|
|
2121
|
+
\\item B
|
|
2122
|
+
\\end{enumerate}
|
|
2123
|
+
|
|
2124
|
+
\\end{review#{type}}
|
|
2125
|
+
\\begin{review#{type}}[OMITEND1]
|
|
2126
|
+
|
|
2127
|
+
\\begin{reviewlistblock}
|
|
2128
|
+
\\begin{reviewemlist}
|
|
2129
|
+
LIST
|
|
2130
|
+
\\end{reviewemlist}
|
|
2131
|
+
\\end{reviewlistblock}
|
|
2132
|
+
|
|
2133
|
+
\\end{review#{type}}
|
|
2134
|
+
\\begin{review#{type}}[OMITEND2]
|
|
2135
|
+
\\end{review#{type}}
|
|
2136
|
+
EOS
|
|
2137
|
+
assert_equal expected, compile_block(src)
|
|
2138
|
+
end
|
|
2139
|
+
end
|
|
2140
|
+
|
|
2141
|
+
def test_minicolumn_blocks_nest_error1
|
|
2142
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
|
2143
|
+
@builder.doc_status.clear
|
|
2144
|
+
src = <<-EOS
|
|
2145
|
+
//#{type}{
|
|
2146
|
+
|
|
2147
|
+
//#{type}{
|
|
2148
|
+
//}
|
|
2149
|
+
|
|
2150
|
+
//}
|
|
2151
|
+
EOS
|
|
2152
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
2153
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
|
2154
|
+
end
|
|
2155
|
+
end
|
|
2156
|
+
|
|
2157
|
+
def test_minicolumn_blocks_nest_error2
|
|
2158
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
|
2159
|
+
@builder.doc_status.clear
|
|
2160
|
+
src = <<-EOS
|
|
2161
|
+
//#{type}{
|
|
2162
|
+
|
|
2163
|
+
//#{type}{
|
|
2164
|
+
|
|
2165
|
+
//}
|
|
2166
|
+
|
|
2167
|
+
//}
|
|
2168
|
+
EOS
|
|
2169
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
2170
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
|
2171
|
+
end
|
|
2172
|
+
end
|
|
2173
|
+
|
|
2174
|
+
def test_minicolumn_blocks_nest_error3
|
|
2175
|
+
%w[memo tip info warning important caution notice].each do |type|
|
|
2176
|
+
@builder.doc_status.clear
|
|
2177
|
+
src = <<-EOS
|
|
2178
|
+
//#{type}{
|
|
2179
|
+
|
|
2180
|
+
//note{
|
|
2181
|
+
//}
|
|
2182
|
+
|
|
2183
|
+
//}
|
|
2184
|
+
EOS
|
|
2185
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
2186
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
|
2187
|
+
end
|
|
2188
|
+
end
|
|
2189
|
+
|
|
1977
2190
|
def test_inline_raw0
|
|
1978
2191
|
assert_equal 'normal', compile_inline('@<raw>{normal}')
|
|
1979
2192
|
end
|
|
@@ -2111,18 +2324,18 @@ EOS
|
|
|
2111
2324
|
end
|
|
2112
2325
|
|
|
2113
2326
|
def test_inline_unknown
|
|
2114
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
|
2327
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
|
2115
2328
|
assert_equal ':1: error: unknown image: n', e.message
|
|
2116
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
|
2329
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
|
2117
2330
|
assert_equal ':1: error: unknown footnote: n', e.message
|
|
2118
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
|
2331
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
|
2119
2332
|
assert_equal ':1: error: unknown headline: n', e.message
|
|
2120
2333
|
%w[list table column].each do |name|
|
|
2121
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
|
2334
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
|
2122
2335
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
|
2123
2336
|
end
|
|
2124
2337
|
%w[chap chapref title].each do |name|
|
|
2125
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
|
2338
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
|
2126
2339
|
assert_equal ':1: error: key not found: "n"', e.message
|
|
2127
2340
|
end
|
|
2128
2341
|
end
|
|
@@ -2266,4 +2479,328 @@ EOS
|
|
|
2266
2479
|
actual = compile_block(src)
|
|
2267
2480
|
assert_equal expected, actual
|
|
2268
2481
|
end
|
|
2482
|
+
|
|
2483
|
+
def test_nest_error_close1
|
|
2484
|
+
src = <<-EOS
|
|
2485
|
+
//beginchild
|
|
2486
|
+
EOS
|
|
2487
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
2488
|
+
assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
|
2489
|
+
end
|
|
2490
|
+
|
|
2491
|
+
def test_nest_error_close2
|
|
2492
|
+
src = <<-EOS
|
|
2493
|
+
* foo
|
|
2494
|
+
|
|
2495
|
+
//beginchild
|
|
2496
|
+
|
|
2497
|
+
1. foo
|
|
2498
|
+
|
|
2499
|
+
//beginchild
|
|
2500
|
+
|
|
2501
|
+
: foo
|
|
2502
|
+
|
|
2503
|
+
//beginchild
|
|
2504
|
+
EOS
|
|
2505
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
2506
|
+
assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
|
|
2507
|
+
end
|
|
2508
|
+
|
|
2509
|
+
def test_nest_error_close3
|
|
2510
|
+
src = <<-EOS
|
|
2511
|
+
* foo
|
|
2512
|
+
|
|
2513
|
+
//beginchild
|
|
2514
|
+
|
|
2515
|
+
1. foo
|
|
2516
|
+
|
|
2517
|
+
//beginchild
|
|
2518
|
+
|
|
2519
|
+
: foo
|
|
2520
|
+
|
|
2521
|
+
//beginchild
|
|
2522
|
+
|
|
2523
|
+
//endchild
|
|
2524
|
+
EOS
|
|
2525
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
|
2526
|
+
assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
|
|
2527
|
+
end
|
|
2528
|
+
|
|
2529
|
+
def test_nest_ul
|
|
2530
|
+
src = <<-EOS
|
|
2531
|
+
* UL1
|
|
2532
|
+
|
|
2533
|
+
//beginchild
|
|
2534
|
+
|
|
2535
|
+
1. UL1-OL1
|
|
2536
|
+
2. UL1-OL2
|
|
2537
|
+
|
|
2538
|
+
* UL1-UL1
|
|
2539
|
+
* UL1-UL2
|
|
2540
|
+
|
|
2541
|
+
: UL1-DL1
|
|
2542
|
+
UL1-DD1
|
|
2543
|
+
: UL1-DL2
|
|
2544
|
+
UL1-DD2
|
|
2545
|
+
|
|
2546
|
+
//endchild
|
|
2547
|
+
|
|
2548
|
+
* UL2
|
|
2549
|
+
|
|
2550
|
+
//beginchild
|
|
2551
|
+
|
|
2552
|
+
UL2-PARA
|
|
2553
|
+
|
|
2554
|
+
//endchild
|
|
2555
|
+
EOS
|
|
2556
|
+
|
|
2557
|
+
expected = <<-EOS
|
|
2558
|
+
|
|
2559
|
+
\\begin{itemize}
|
|
2560
|
+
\\item UL1
|
|
2561
|
+
|
|
2562
|
+
|
|
2563
|
+
\\begin{enumerate}
|
|
2564
|
+
\\item UL1{-}OL1
|
|
2565
|
+
\\item UL1{-}OL2
|
|
2566
|
+
\\end{enumerate}
|
|
2567
|
+
|
|
2568
|
+
\\begin{itemize}
|
|
2569
|
+
\\item UL1{-}UL1
|
|
2570
|
+
\\item UL1{-}UL2
|
|
2571
|
+
\\end{itemize}
|
|
2572
|
+
|
|
2573
|
+
\\begin{description}
|
|
2574
|
+
\\item[UL1{-}DL1] \\mbox{} \\\\
|
|
2575
|
+
UL1{-}DD1
|
|
2576
|
+
\\item[UL1{-}DL2] \\mbox{} \\\\
|
|
2577
|
+
UL1{-}DD2
|
|
2578
|
+
\\end{description}
|
|
2579
|
+
|
|
2580
|
+
|
|
2581
|
+
\\item UL2
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
UL2{-}PARA
|
|
2585
|
+
|
|
2586
|
+
\\end{itemize}
|
|
2587
|
+
EOS
|
|
2588
|
+
|
|
2589
|
+
actual = compile_block(src)
|
|
2590
|
+
assert_equal expected, actual
|
|
2591
|
+
end
|
|
2592
|
+
|
|
2593
|
+
def test_nest_ol
|
|
2594
|
+
src = <<-EOS
|
|
2595
|
+
1. OL1
|
|
2596
|
+
|
|
2597
|
+
//beginchild
|
|
2598
|
+
|
|
2599
|
+
1. OL1-OL1
|
|
2600
|
+
2. OL1-OL2
|
|
2601
|
+
|
|
2602
|
+
* OL1-UL1
|
|
2603
|
+
* OL1-UL2
|
|
2604
|
+
|
|
2605
|
+
: OL1-DL1
|
|
2606
|
+
OL1-DD1
|
|
2607
|
+
: OL1-DL2
|
|
2608
|
+
OL1-DD2
|
|
2609
|
+
|
|
2610
|
+
//endchild
|
|
2611
|
+
|
|
2612
|
+
2. OL2
|
|
2613
|
+
|
|
2614
|
+
//beginchild
|
|
2615
|
+
|
|
2616
|
+
OL2-PARA
|
|
2617
|
+
|
|
2618
|
+
//endchild
|
|
2619
|
+
EOS
|
|
2620
|
+
|
|
2621
|
+
expected = <<-EOS
|
|
2622
|
+
|
|
2623
|
+
\\begin{enumerate}
|
|
2624
|
+
\\item OL1
|
|
2625
|
+
|
|
2626
|
+
|
|
2627
|
+
\\begin{enumerate}
|
|
2628
|
+
\\item OL1{-}OL1
|
|
2629
|
+
\\item OL1{-}OL2
|
|
2630
|
+
\\end{enumerate}
|
|
2631
|
+
|
|
2632
|
+
\\begin{itemize}
|
|
2633
|
+
\\item OL1{-}UL1
|
|
2634
|
+
\\item OL1{-}UL2
|
|
2635
|
+
\\end{itemize}
|
|
2636
|
+
|
|
2637
|
+
\\begin{description}
|
|
2638
|
+
\\item[OL1{-}DL1] \\mbox{} \\\\
|
|
2639
|
+
OL1{-}DD1
|
|
2640
|
+
\\item[OL1{-}DL2] \\mbox{} \\\\
|
|
2641
|
+
OL1{-}DD2
|
|
2642
|
+
\\end{description}
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
\\item OL2
|
|
2646
|
+
|
|
2647
|
+
|
|
2648
|
+
OL2{-}PARA
|
|
2649
|
+
|
|
2650
|
+
\\end{enumerate}
|
|
2651
|
+
EOS
|
|
2652
|
+
|
|
2653
|
+
actual = compile_block(src)
|
|
2654
|
+
assert_equal expected, actual
|
|
2655
|
+
end
|
|
2656
|
+
|
|
2657
|
+
def test_nest_dl
|
|
2658
|
+
src = <<-EOS
|
|
2659
|
+
: DL1
|
|
2660
|
+
|
|
2661
|
+
//beginchild
|
|
2662
|
+
|
|
2663
|
+
1. DL1-OL1
|
|
2664
|
+
2. DL1-OL2
|
|
2665
|
+
|
|
2666
|
+
* DL1-UL1
|
|
2667
|
+
* DL1-UL2
|
|
2668
|
+
|
|
2669
|
+
: DL1-DL1
|
|
2670
|
+
DL1-DD1
|
|
2671
|
+
: DL1-DL2
|
|
2672
|
+
DL1-DD2
|
|
2673
|
+
|
|
2674
|
+
//endchild
|
|
2675
|
+
|
|
2676
|
+
: DL2
|
|
2677
|
+
DD2
|
|
2678
|
+
|
|
2679
|
+
//beginchild
|
|
2680
|
+
|
|
2681
|
+
* DD2-UL1
|
|
2682
|
+
* DD2-UL2
|
|
2683
|
+
|
|
2684
|
+
DD2-PARA
|
|
2685
|
+
|
|
2686
|
+
//endchild
|
|
2687
|
+
EOS
|
|
2688
|
+
|
|
2689
|
+
expected = <<-EOS
|
|
2690
|
+
|
|
2691
|
+
\\begin{description}
|
|
2692
|
+
\\item[DL1] \\mbox{} \\\\
|
|
2693
|
+
|
|
2694
|
+
|
|
2695
|
+
|
|
2696
|
+
\\begin{enumerate}
|
|
2697
|
+
\\item DL1{-}OL1
|
|
2698
|
+
\\item DL1{-}OL2
|
|
2699
|
+
\\end{enumerate}
|
|
2700
|
+
|
|
2701
|
+
\\begin{itemize}
|
|
2702
|
+
\\item DL1{-}UL1
|
|
2703
|
+
\\item DL1{-}UL2
|
|
2704
|
+
\\end{itemize}
|
|
2705
|
+
|
|
2706
|
+
\\begin{description}
|
|
2707
|
+
\\item[DL1{-}DL1] \\mbox{} \\\\
|
|
2708
|
+
DL1{-}DD1
|
|
2709
|
+
\\item[DL1{-}DL2] \\mbox{} \\\\
|
|
2710
|
+
DL1{-}DD2
|
|
2711
|
+
\\end{description}
|
|
2712
|
+
|
|
2713
|
+
|
|
2714
|
+
\\item[DL2] \\mbox{} \\\\
|
|
2715
|
+
DD2
|
|
2716
|
+
|
|
2717
|
+
|
|
2718
|
+
\\begin{itemize}
|
|
2719
|
+
\\item DD2{-}UL1
|
|
2720
|
+
\\item DD2{-}UL2
|
|
2721
|
+
\\end{itemize}
|
|
2722
|
+
|
|
2723
|
+
DD2{-}PARA
|
|
2724
|
+
|
|
2725
|
+
\\end{description}
|
|
2726
|
+
EOS
|
|
2727
|
+
|
|
2728
|
+
actual = compile_block(src)
|
|
2729
|
+
assert_equal expected, actual
|
|
2730
|
+
end
|
|
2731
|
+
|
|
2732
|
+
def test_nest_multi
|
|
2733
|
+
src = <<-EOS
|
|
2734
|
+
1. OL1
|
|
2735
|
+
|
|
2736
|
+
//beginchild
|
|
2737
|
+
|
|
2738
|
+
1. OL1-OL1
|
|
2739
|
+
|
|
2740
|
+
//beginchild
|
|
2741
|
+
|
|
2742
|
+
* OL1-OL1-UL1
|
|
2743
|
+
|
|
2744
|
+
OL1-OL1-PARA
|
|
2745
|
+
|
|
2746
|
+
//endchild
|
|
2747
|
+
|
|
2748
|
+
2. OL1-OL2
|
|
2749
|
+
|
|
2750
|
+
* OL1-UL1
|
|
2751
|
+
|
|
2752
|
+
//beginchild
|
|
2753
|
+
|
|
2754
|
+
: OL1-UL1-DL1
|
|
2755
|
+
OL1-UL1-DD1
|
|
2756
|
+
|
|
2757
|
+
OL1-UL1-PARA
|
|
2758
|
+
|
|
2759
|
+
//endchild
|
|
2760
|
+
|
|
2761
|
+
* OL1-UL2
|
|
2762
|
+
|
|
2763
|
+
//endchild
|
|
2764
|
+
EOS
|
|
2765
|
+
expected = <<-EOS
|
|
2766
|
+
|
|
2767
|
+
\\begin{enumerate}
|
|
2768
|
+
\\item OL1
|
|
2769
|
+
|
|
2770
|
+
|
|
2771
|
+
\\begin{enumerate}
|
|
2772
|
+
\\item OL1{-}OL1
|
|
2773
|
+
|
|
2774
|
+
|
|
2775
|
+
\\begin{itemize}
|
|
2776
|
+
\\item OL1{-}OL1{-}UL1
|
|
2777
|
+
\\end{itemize}
|
|
2778
|
+
|
|
2779
|
+
OL1{-}OL1{-}PARA
|
|
2780
|
+
|
|
2781
|
+
|
|
2782
|
+
\\item OL1{-}OL2
|
|
2783
|
+
\\end{enumerate}
|
|
2784
|
+
|
|
2785
|
+
\\begin{itemize}
|
|
2786
|
+
\\item OL1{-}UL1
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
\\begin{description}
|
|
2790
|
+
\\item[OL1{-}UL1{-}DL1] \\mbox{} \\\\
|
|
2791
|
+
OL1{-}UL1{-}DD1
|
|
2792
|
+
\\end{description}
|
|
2793
|
+
|
|
2794
|
+
OL1{-}UL1{-}PARA
|
|
2795
|
+
|
|
2796
|
+
|
|
2797
|
+
\\item OL1{-}UL2
|
|
2798
|
+
\\end{itemize}
|
|
2799
|
+
|
|
2800
|
+
\\end{enumerate}
|
|
2801
|
+
EOS
|
|
2802
|
+
|
|
2803
|
+
actual = compile_block(src)
|
|
2804
|
+
assert_equal expected, actual
|
|
2805
|
+
end
|
|
2269
2806
|
end
|