review 5.6.0 → 5.7.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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +31 -0
  3. data/.github/workflows/ruby-tex.yml +1 -1
  4. data/.github/workflows/ruby-win.yml +1 -1
  5. data/.github/workflows/ruby.yml +2 -2
  6. data/.rubocop.yml +13 -2
  7. data/NEWS.ja.md +22 -0
  8. data/NEWS.md +21 -0
  9. data/README.md +1 -1
  10. data/lib/review/book/base.rb +1 -1
  11. data/lib/review/builder.rb +4 -8
  12. data/lib/review/epubmaker/epubcommon.rb +13 -7
  13. data/lib/review/epubmaker/epubv2.rb +0 -5
  14. data/lib/review/epubmaker/epubv3.rb +9 -1
  15. data/lib/review/epubmaker/producer.rb +2 -3
  16. data/lib/review/epubmaker.rb +2 -4
  17. data/lib/review/htmlbuilder.rb +2 -2
  18. data/lib/review/idgxmlbuilder.rb +4 -3
  19. data/lib/review/img_math.rb +9 -2
  20. data/lib/review/init.rb +3 -3
  21. data/lib/review/latexbuilder.rb +1 -1
  22. data/lib/review/lineinput.rb +2 -2
  23. data/lib/review/makerhelper.rb +2 -2
  24. data/lib/review/pdfmaker.rb +3 -5
  25. data/lib/review/update.rb +3 -7
  26. data/lib/review/version.rb +1 -1
  27. data/lib/review/yamlloader.rb +0 -3
  28. data/review.gemspec +2 -3
  29. data/samples/syntax-book/Gemfile +1 -1
  30. data/templates/opf/epubv2.opf.erb +2 -0
  31. data/templates/opf/epubv3.opf.erb +2 -0
  32. data/templates/opf/opf_manifest_epubv2.opf.erb +2 -0
  33. data/templates/opf/opf_manifest_epubv3.opf.erb +2 -0
  34. data/templates/opf/opf_tocx_epubv3.opf.erb +2 -0
  35. metadata +10 -139
  36. data/test/assets/black.eps +0 -280
  37. data/test/assets/fit.png +0 -0
  38. data/test/assets/header_listener.html +0 -35
  39. data/test/assets/img_math/img1.png +0 -0
  40. data/test/assets/img_math/img2.png +0 -0
  41. data/test/assets/img_math/img3.png +0 -0
  42. data/test/assets/large.gif +0 -0
  43. data/test/assets/large.jpg +0 -0
  44. data/test/assets/large.png +0 -0
  45. data/test/assets/large.svg +0 -65
  46. data/test/assets/syntax_book_index_detail.txt +0 -60
  47. data/test/assets/test.xml.erb +0 -3
  48. data/test/assets/test_template.tex +0 -189
  49. data/test/assets/test_template_backmatter.tex +0 -200
  50. data/test/book_test_helper.rb +0 -44
  51. data/test/run_test.rb +0 -12
  52. data/test/test_book.rb +0 -588
  53. data/test/test_book_chapter.rb +0 -329
  54. data/test/test_book_part.rb +0 -53
  55. data/test/test_builder.rb +0 -128
  56. data/test/test_catalog.rb +0 -174
  57. data/test/test_catalog_converter_cmd.rb +0 -73
  58. data/test/test_compiler.rb +0 -52
  59. data/test/test_configure.rb +0 -91
  60. data/test/test_converter.rb +0 -21
  61. data/test/test_epub3maker.rb +0 -733
  62. data/test/test_epubmaker.rb +0 -931
  63. data/test/test_epubmaker_cmd.rb +0 -56
  64. data/test/test_extentions_hash.rb +0 -66
  65. data/test/test_helper.rb +0 -62
  66. data/test/test_htmlbuilder.rb +0 -3315
  67. data/test/test_htmltoc.rb +0 -29
  68. data/test/test_htmlutils.rb +0 -43
  69. data/test/test_i18n.rb +0 -300
  70. data/test/test_idgxmlbuilder.rb +0 -1529
  71. data/test/test_idgxmlmaker_cmd.rb +0 -50
  72. data/test/test_image_finder.rb +0 -81
  73. data/test/test_img_math.rb +0 -120
  74. data/test/test_index.rb +0 -287
  75. data/test/test_indexbuilder.rb +0 -52
  76. data/test/test_latexbuilder.rb +0 -2972
  77. data/test/test_latexbuilder_v2.rb +0 -1654
  78. data/test/test_lineinput.rb +0 -104
  79. data/test/test_location.rb +0 -30
  80. data/test/test_logger.rb +0 -33
  81. data/test/test_makerhelper.rb +0 -44
  82. data/test/test_markdownbuilder.rb +0 -371
  83. data/test/test_md2inaobuilder.rb +0 -90
  84. data/test/test_pdfmaker.rb +0 -354
  85. data/test/test_pdfmaker_cmd.rb +0 -130
  86. data/test/test_plaintextbuilder.rb +0 -1214
  87. data/test/test_preprocessor.rb +0 -196
  88. data/test/test_review_ext.rb +0 -30
  89. data/test/test_reviewheaderlistener.rb +0 -49
  90. data/test/test_rstbuilder.rb +0 -619
  91. data/test/test_sec_counter.rb +0 -156
  92. data/test/test_template.rb +0 -33
  93. data/test/test_textmaker_cmd.rb +0 -58
  94. data/test/test_textutils.rb +0 -187
  95. data/test/test_tocprinter.rb +0 -46
  96. data/test/test_topbuilder.rb +0 -1301
  97. data/test/test_update.rb +0 -473
  98. data/test/test_webtocprinter.rb +0 -195
  99. data/test/test_yamlloader.rb +0 -186
  100. data/test/test_zip_exporter.rb +0 -106
@@ -1,50 +0,0 @@
1
- require 'test_helper'
2
- require 'tmpdir'
3
- require 'fileutils'
4
- require 'yaml'
5
- require 'rbconfig'
6
- require 'open3'
7
-
8
- REVIEW_IDGXMLMAKER = File.expand_path('../bin/review-idgxmlmaker', __dir__)
9
-
10
- class IDGXMLMakerCmdTest < Test::Unit::TestCase
11
- def setup
12
- @tmpdir1 = Dir.mktmpdir
13
-
14
- @old_rubylib = ENV['RUBYLIB']
15
- ENV['RUBYLIB'] = File.expand_path('../lib', __dir__)
16
- end
17
-
18
- def teardown
19
- FileUtils.rm_rf(@tmpdir1)
20
- ENV['RUBYLIB'] = @old_rubylib
21
- end
22
-
23
- def common_buildidgxml(bookdir, configfile, targetfile, option)
24
- unless /mswin|mingw|cygwin/.match?(RUBY_PLATFORM)
25
- config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
26
- builddir = File.join(@tmpdir1, config['bookname'] + '-idgxml')
27
- assert !File.exist?(builddir)
28
-
29
- ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
30
- Dir.chdir(@tmpdir1) do
31
- _o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_IDGXMLMAKER} #{option} #{configfile}")
32
- if defined?(ReVIEW::TTYLogger)
33
- assert_match(/SUCCESS/, e)
34
- else
35
- assert_equal '', e
36
- end
37
- assert s.success?
38
- end
39
- assert File.exist?(File.join(@tmpdir1, targetfile))
40
- end
41
- end
42
-
43
- def test_idgxmlmaker_cmd_samplebook
44
- common_buildidgxml('sample-book/src', 'config.yml', 'book-idgxml/ch01.xml', nil)
45
- end
46
-
47
- def test_idgxmlmaker_cmd_syntaxbook
48
- common_buildidgxml('syntax-book', 'config.yml', 'syntax-book-idgxml/ch01.xml', nil)
49
- end
50
- end
@@ -1,81 +0,0 @@
1
- require 'test_helper'
2
- require 'review'
3
- require 'review/book/image_finder'
4
- require 'fileutils'
5
-
6
- class ImageFinderTest < Test::Unit::TestCase
7
- include ReVIEW
8
-
9
- def setup
10
- if ENV['GITHUB_WORKSPACE']
11
- ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
12
- FileUtils.mkdir_p(ENV['TMPDIR'])
13
- end
14
- @dir = Dir.mktmpdir
15
- end
16
-
17
- def teardown
18
- if @dir
19
- FileUtils.remove_entry_secure(@dir)
20
- end
21
- end
22
-
23
- def test_find_path_pattern1
24
- path = File.join(@dir, 'builder/ch01/foo.jpg')
25
- FileUtils.mkdir_p(File.dirname(path))
26
- FileUtils.touch(path)
27
-
28
- finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
29
-
30
- assert_equal(path, finder.find_path('foo'))
31
- end
32
-
33
- def test_find_path_pattern2
34
- path = File.join(@dir, 'builder/ch01-foo.jpg')
35
- FileUtils.mkdir_p(File.dirname(path))
36
- FileUtils.touch(path)
37
-
38
- finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
39
- assert_equal(path, finder.find_path('foo'))
40
- end
41
-
42
- def test_find_path_pattern3
43
- path = File.join(@dir, 'builder/foo.jpg')
44
- FileUtils.mkdir_p(File.dirname(path))
45
- FileUtils.touch(path)
46
-
47
- finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
48
- assert_equal(path, finder.find_path('foo'))
49
- end
50
-
51
- def test_find_path_pattern4
52
- path = File.join(@dir, 'ch01/foo.jpg')
53
- FileUtils.mkdir_p(File.dirname(path))
54
- FileUtils.touch(path)
55
-
56
- finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
57
- assert_equal(path, finder.find_path('foo'))
58
- end
59
-
60
- def test_find_path_pattern5
61
- path = File.join(@dir, 'ch01-foo.jpg')
62
- FileUtils.mkdir_p(File.dirname(path))
63
- FileUtils.touch(path)
64
-
65
- finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
66
- assert_equal(path, finder.find_path('foo'))
67
- end
68
-
69
- def test_find_path_dir_symlink
70
- path_src = File.join(@dir, 'src')
71
- path_dst = File.join(@dir, 'ch01')
72
- FileUtils.mkdir_p(path_src)
73
- FileUtils.symlink(path_src, path_dst)
74
- path_srcimg = File.join(path_src, 'foo.jpg')
75
- path_dstimg = File.join(path_dst, 'foo.jpg')
76
- FileUtils.touch(path_srcimg)
77
-
78
- finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
79
- assert_equal(path_dstimg, finder.find_path('foo'))
80
- end
81
- end
@@ -1,120 +0,0 @@
1
- require 'test_helper'
2
- require 'review/htmlbuilder'
3
- require 'review/img_math'
4
- require 'mini_magick'
5
-
6
- class ImgMathTest < Test::Unit::TestCase
7
- def setup
8
- @config = ReVIEW::Configure.values
9
- @tmpdir = Dir.mktmpdir
10
- @config.merge!(
11
- 'math_format' => 'imgmath',
12
- 'texcommand' => 'uplatex',
13
- 'imagedir' => @tmpdir
14
- )
15
- @config['imgmath_options']['fontsize'] = 24
16
- @img_math = ReVIEW::ImgMath.new(@config)
17
- end
18
-
19
- def teardown
20
- @img_math.cleanup_mathimg
21
- FileUtils.rm_rf(@tmpdir)
22
- end
23
-
24
- def test_defer_math_image_pathname
25
- str1 = '$A > B \\gg C$'
26
- key1 = Digest::SHA256.hexdigest(str1)
27
- img_path1 = @img_math.defer_math_image(str1, key1)
28
-
29
- assert_equal "_gen_#{key1}.png", File.basename(img_path1)
30
- end
31
-
32
- def test_defer_math_image
33
- unless support_latex_in_tests? && support_pdftocairo_in_tests?
34
- $stderr.puts 'skip test_defer_math_image'
35
- return true
36
- end
37
-
38
- str1 = '$\\sum_{i=1}^nf_n(x) \\in \\mathbb{R}$'
39
- key1 = Digest::SHA256.hexdigest(str1)
40
- img_path1 = @img_math.defer_math_image(str1, key1)
41
- str2 = '$\\sum_{i=1}^nf_n(X) \\in \\mathbb{R}$'
42
- key2 = Digest::SHA256.hexdigest(str2)
43
- img_path2 = @img_math.defer_math_image(str2, key2)
44
- @img_math.make_math_images
45
-
46
- assert File.exist?(img_path1)
47
- assert File.exist?(img_path2)
48
-
49
- val1 = compare_images(img_path1, File.join(assets_dir, 'img_math/img1.png'))
50
- assert_equal 0, val1
51
-
52
- val2 = compare_images(img_path2, File.join(assets_dir, 'img_math/img2.png'))
53
- assert_equal 0, val2
54
-
55
- val3 = compare_images(img_path1, img_path2)
56
- assert val3 > 100
57
- end
58
-
59
- def test_make_math_image_pathname
60
- unless support_latex_in_tests?
61
- $stderr.puts 'skip test_make_math_image_pathname'
62
- return true
63
- end
64
-
65
- str1 = '$A > B \\gg C$'
66
- key1 = Digest::SHA256.hexdigest(str1)
67
- img_path1 = @img_math.make_math_image(str1, key1)
68
-
69
- assert_equal "_gen_#{key1}.png", File.basename(img_path1)
70
- end
71
-
72
- def test_make_math_image
73
- unless support_latex_in_tests?
74
- $stderr.puts 'skip test_make_math_image'
75
- return true
76
- end
77
- str1 = '$A > B \\gg C$'
78
- key1 = Digest::SHA256.hexdigest(str1)
79
- img_path1 = @img_math.make_math_image(str1, key1)
80
-
81
- assert File.exist?(img_path1)
82
-
83
- val1 = compare_images(img_path1, File.join(assets_dir, 'img_math/img3.png'))
84
- assert val1 < 10
85
- end
86
-
87
- private
88
-
89
- def compare_images(image1, image2)
90
- compare = MiniMagick::Tool::Compare.new(whiny: false)
91
- compare << '-fuzz'
92
- compare << '10%'
93
- compare.metric('AE')
94
- compare << image1
95
- compare << image2
96
- compare << File.join(@tmpdir, 'diff.jpg')
97
-
98
- compare.call do |_, dist, _|
99
- return dist.to_i
100
- end
101
- end
102
-
103
- def support_latex_in_tests?
104
- begin
105
- `uplatex -v`
106
- true
107
- rescue StandardError
108
- false
109
- end
110
- end
111
-
112
- def support_pdftocairo_in_tests?
113
- begin
114
- `pdftocairo -v`
115
- true
116
- rescue StandardError
117
- false
118
- end
119
- end
120
- end
data/test/test_index.rb DELETED
@@ -1,287 +0,0 @@
1
- require 'test_helper'
2
- require 'review/compiler'
3
- require 'review/book'
4
- require 'review/book/index'
5
- require 'review/topbuilder'
6
- require 'review/i18n'
7
-
8
- class IndexTest < Test::Unit::TestCase
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
- @log_io = StringIO.new
16
- ReVIEW.logger = ReVIEW::Logger.new(@log_io)
17
- @compiler = ReVIEW::Compiler.new(@builder)
18
- @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
19
- location = Location.new(nil, nil)
20
- @builder.bind(@compiler, @chapter, location)
21
-
22
- I18n.setup(@config['language'])
23
- end
24
-
25
- def test_footnote_index
26
- compile_block("@<fn>{foo}\n//footnote[foo][bar]\n")
27
- fn = @chapter.footnote_index
28
- items = fn.to_a
29
- item = items[0]
30
- assert_equal 'foo', item.id
31
- assert_equal 'bar', item.content
32
-
33
- compile_block("//footnote[foo][bar]\n")
34
- assert_match(/ID foo is not referred/, @log_io.string)
35
- end
36
-
37
- def test_footnote_index_with_escape
38
- compile_block("@<fn>{foo}\n" + '//footnote[foo][bar[\]buz]' + "\n")
39
- fn = @chapter.footnote_index
40
- items = fn.to_a
41
- item = items[0]
42
- assert_equal 'foo', item.id
43
- assert_equal 'bar[]buz', item.content
44
- end
45
-
46
- def test_footnote_index_with_escape2
47
- compile_block("@<fn>{foo}\n" + '//footnote[foo][bar\\a\\$buz]' + "\n")
48
- fn = @chapter.footnote_index
49
- items = fn.to_a
50
- item = items[0]
51
- assert_equal 'foo', item.id
52
- assert_equal 'bar\\a\\$buz', item.content
53
- end
54
-
55
- def test_footnote_index_key?
56
- compile_block("@<fn>{foo}\n" + '//footnote[foo][bar]' + "\n")
57
- fn = @chapter.footnote_index
58
- assert_equal true, fn.key?('foo')
59
-
60
- ## for compatibility
61
- # rubocop:disable Style/PreferredHashMethods
62
- assert_equal true, fn.has_key?('foo')
63
- # rubocop:enable Style/PreferredHashMethods
64
- end
65
-
66
- def test_endnote_index
67
- compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
68
- endnote = @chapter.endnote_index
69
- items = endnote.to_a
70
- item = items[0]
71
- assert_equal 'foo', item.id
72
- assert_equal 'bar', item.content
73
- assert_equal true, endnote.key?('foo')
74
- # rubocop:disable Style/PreferredHashMethods
75
- assert_equal true, endnote.has_key?('foo')
76
- # rubocop:enable Style/PreferredHashMethods
77
-
78
- e = assert_raises(ReVIEW::ApplicationError) do
79
- compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n")
80
- end
81
- assert_equal ':3: //endnote is found but //printendnotes is not found.', e.message
82
-
83
- compile_block("//endnote[foo][bar]\n//printendnotes\n")
84
- assert_match(/ID foo is not referred/, @log_io.string)
85
- end
86
-
87
- def test_headline_index
88
- src = <<-EOB
89
- = chap1
90
- == sec1-1
91
- == sec1-2
92
- === sec1-2-1
93
- ===[column] column1
94
- ==== inside_column
95
- ===[/column]
96
- ===[column] column2
97
- === sec1-2-2
98
- == sec1-3
99
- ==== sec1-3-0-1
100
- EOB
101
- compile_block(src)
102
- index = @chapter.headline_index
103
- assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
104
- assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
105
- end
106
-
107
- def test_headline_index2
108
- src = <<-EOB
109
- = chap1
110
- == sec1-1
111
- == sec1-2
112
- === sec1-2-1
113
- ===[column] column1
114
- == sec1-3
115
- === sec1-3-1
116
- EOB
117
- compile_block(src)
118
- index = @chapter.headline_index
119
- assert_equal [3, 1], index['sec1-3|sec1-3-1'].number
120
- assert_equal '1.3.1', index.number('sec1-3|sec1-3-1')
121
- end
122
-
123
- def test_headline_index3
124
- src = <<-EOB
125
- = chap1
126
- == sec1-1
127
- == sec1-2
128
- === sec1-2-1
129
- ===[column] column1
130
- === sec1-2-2
131
- == sec1-3
132
- === sec1-3-1
133
- EOB
134
- compile_block(src)
135
- index = @chapter.headline_index
136
- assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
137
- assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
138
-
139
- assert_equal [3, 1], index['sec1-3|sec1-3-1'].number
140
- assert_equal '1.3.1', index.number('sec1-3|sec1-3-1')
141
- end
142
-
143
- def test_headline_index4
144
- src = <<-EOB
145
- = chap1
146
- ====[column] c1
147
- == sec1-1
148
- == sec1-2
149
- === sec1-2-1
150
- === sec1-2-2
151
- EOB
152
- compile_block(src)
153
- index = @chapter.headline_index
154
- assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
155
- assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
156
- end
157
-
158
- def test_headline_index5
159
- src = <<-EOB
160
- = chap1
161
- ====[column] c1
162
- == sec1-1
163
- == sec1-2
164
- === sec1-2-1
165
- === sec1-2-2
166
- EOB
167
- compile_block(src)
168
- index = @chapter.headline_index
169
- assert_equal [2, 2], index['sec1-2-2'].number
170
- assert_equal '1.2.2', index.number('sec1-2-2')
171
- end
172
-
173
- def test_headline_index6
174
- src = <<-EOB
175
- = chap1
176
- == sec1
177
- === target
178
- == sec2
179
-
180
- EOB
181
- compile_block(src)
182
- index = @chapter.headline_index
183
- assert_equal [1, 1], index['target'].number
184
- assert_equal '1.1.1', index.number('target')
185
- end
186
-
187
- def test_headline_index7
188
- src = <<-EOB
189
- = chap1
190
- == sec1
191
- === target
192
- ^-- dummy target
193
-
194
- == sec2
195
- === target
196
- ^-- real target but it cannot be detected, because there is another one.
197
-
198
- EOB
199
- compile_block(src)
200
- index = @chapter.headline_index
201
-
202
- assert_raise ReVIEW::KeyError do
203
- assert_equal [1, 1], index['target'].number
204
- end
205
- end
206
-
207
- def test_headline_index8
208
- src = <<-EOB
209
- = chap1
210
- == sec1
211
- === sec1-1
212
- ==== sec1-1-1
213
-
214
- EOB
215
- compile_block(src)
216
- index = @chapter.headline_index
217
-
218
- assert_equal '1.1.1', index.number('sec1-1')
219
- end
220
-
221
- def test_headline_index9
222
- src = <<-EOB
223
- = chap1
224
- == sec1
225
- === sec1-1
226
- ===[column] column1
227
- ===[/column]
228
- ==== sec1-1-1
229
- === sec1-2
230
- EOB
231
- compile_block(src)
232
- index = @chapter.headline_index
233
- assert_equal [1, 1, 1], index['sec1-1-1'].number
234
- end
235
-
236
- def test_headline_index10
237
- src = <<-EOB
238
- = chap1
239
- == sec1
240
- === sec1-1
241
- ====[column] column1
242
- ==== sec1-1-1
243
- === sec1-2
244
- EOB
245
- compile_block(src)
246
- index = @chapter.headline_index
247
- assert_equal [1, 1, 1], index['sec1-1-1'].number
248
- end
249
-
250
- def test_headline_index11
251
- src = <<-EOB
252
- = chap1
253
- ==[nodisp] sec01
254
- ==[notoc] sec02
255
- == sec1
256
- ===[nodisp] sec1-0
257
- === sec1-1
258
- ==[nonum] sec03
259
- == sec04
260
- EOB
261
- compile_block(src)
262
- index = @chapter.headline_index
263
- assert_equal nil, index['sec01'].number
264
- assert_equal nil, index['sec02'].number
265
- assert_equal [1], index['sec1'].number
266
- assert_equal nil, index['sec1-0'].number
267
- assert_equal [1, 1], index['sec1-1'].number
268
- assert_equal nil, index['sec03'].number
269
- assert_equal [2], index['sec04'].number
270
- end
271
-
272
- def test_headline_index12
273
- src = <<-EOB
274
- = chap1
275
- == A
276
- === A2
277
- ==[nonum] B
278
- === B2
279
- EOB
280
- compile_block(src)
281
- index = @chapter.headline_index
282
- assert_equal [1], index['A'].number
283
- assert_equal [1, 1], index['A2'].number
284
- assert_equal nil, index['B'].number
285
- assert_equal [1, 2], index['B2'].number
286
- end
287
- end
@@ -1,52 +0,0 @@
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