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
data/test/test_htmltoc.rb DELETED
@@ -1,29 +0,0 @@
1
- require 'test_helper'
2
- require 'review/htmltoc'
3
-
4
- class HTMLTocTest < Test::Unit::TestCase
5
- include ReVIEW
6
-
7
- def setup
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_tocfilename
14
- toc = HTMLToc.new('/var/tmp')
15
- assert_equal '/var/tmp/toc-html.txt', toc.tocfilename
16
- end
17
-
18
- def test_encode_args
19
- toc = HTMLToc.new('/var/tmp')
20
- assert_equal 'chaptype=pre', toc.encode_args(chaptype: 'pre')
21
- assert_equal 'force_include=true,chaptype=body,properties=foo', toc.encode_args({ force_include: true, chaptype: 'body', 'properties' => 'foo' })
22
- end
23
-
24
- def test_decode_args
25
- toc = HTMLToc.new('/var/tmp')
26
- assert_equal({ chaptype: 'pre' }, toc.decode_args('chaptype=pre'))
27
- assert_equal({ force_include: 'true', chaptype: 'body', properties: 'foo' }, toc.decode_args('force_include=true,chaptype=body,properties=foo'))
28
- end
29
- end
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
- require 'review/htmlutils'
3
-
4
- class HTMLUtilsTest < Test::Unit::TestCase
5
- include ReVIEW::HTMLUtils
6
-
7
- def test_escape_html
8
- assert_equal '&lt;', escape('<')
9
- assert_equal '&lt;&lt;', escape('<<')
10
- assert_equal '_&lt;_&lt;_', escape('_<_<_')
11
- end
12
-
13
- def test_unescape_html
14
- assert_equal '<', unescape('&lt;')
15
- assert_equal '>', unescape('&gt;')
16
- assert_equal '&', unescape('&amp;')
17
- assert_equal '&amp;', unescape('&amp;amp;')
18
- end
19
-
20
- def test_strip_html
21
- assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
22
- end
23
-
24
- def test_escape_comment
25
- assert_equal '<', escape_comment('<')
26
- assert_equal '>', escape_comment('>')
27
- assert_equal '&', escape_comment('&')
28
- assert_equal '&#45;', escape_comment('-')
29
- assert_equal '&#45;&#45;', escape_comment('--')
30
- end
31
-
32
- def test_normalize_id
33
- assert_equal 'abcxyz', normalize_id('abcxyz')
34
- assert_equal 'ABCXYZ', normalize_id('ABCXYZ')
35
- assert_equal 'abc0123', normalize_id('abc0123')
36
- assert_equal 'a-b-c_x.y.z', normalize_id('a-b-c_x.y.z')
37
- assert_equal 'id_a_3Ab_3Ac', normalize_id('a:b:c')
38
- assert_equal 'id_0123a-b-c_x.y.z', normalize_id('0123a-b-c_x.y.z')
39
- assert_equal 'id_.', normalize_id('.')
40
- assert_equal 'id__E3_81_82', normalize_id('あ')
41
- assert_equal 'id_-___3B', normalize_id(' _;')
42
- end
43
- end
data/test/test_i18n.rb DELETED
@@ -1,300 +0,0 @@
1
- require 'test_helper'
2
- require 'review'
3
- require 'tmpdir'
4
-
5
- class I18nTest < Test::Unit::TestCase
6
- include ReVIEW
7
-
8
- def test_load_locale_yml
9
- Dir.mktmpdir do |dir|
10
- Dir.chdir(dir) do
11
- file = File.join(dir, 'locale.yml')
12
- File.write(file, %Q(locale: ja\nfoo: "bar"\n))
13
- I18n.setup
14
- assert_equal 'bar', I18n.t('foo')
15
- end
16
- end
17
- end
18
-
19
- def test_load_locale_yaml
20
- Dir.mktmpdir do |dir|
21
- Dir.chdir(dir) do
22
- file = File.join(dir, 'locale.yaml')
23
- File.write(file, %Q(locale: ja\nfoo: "bar"\n))
24
- assert_raise ReVIEW::ConfigError do
25
- I18n.setup
26
- end
27
- end
28
- end
29
- end
30
-
31
- def test_load_foo_yaml
32
- Dir.mktmpdir do |dir|
33
- Dir.chdir(dir) do
34
- file = File.join(dir, 'foo.yml')
35
- File.write(file, %Q(locale: ja\nfoo: "bar"\n))
36
- I18n.setup('ja', 'foo.yml')
37
- assert_equal 'bar', I18n.t('foo')
38
- end
39
- end
40
- end
41
-
42
- def test_update_foo_yaml
43
- Dir.mktmpdir do |dir|
44
- Dir.chdir(dir) do
45
- file = File.join(dir, 'foo.yml')
46
- File.write(file, %Q(locale: ja\nfoo: "bar"\n))
47
- i18n = ReVIEW::I18n.new('ja')
48
- i18n.update_localefile(File.join(Dir.pwd, 'foo.yml'))
49
- assert_equal 'bar', i18n.t('foo')
50
- end
51
- end
52
- end
53
-
54
- def test_update_foo_yaml_i18nclass
55
- Dir.mktmpdir do |dir|
56
- Dir.chdir(dir) do
57
- file = File.join(dir, 'foo.yml')
58
- File.write(file, %Q(locale: ja\nfoo: "bar"\n))
59
- I18n.setup('ja', 'foo.yml')
60
- assert_equal 'bar', I18n.t('foo')
61
- end
62
- end
63
- end
64
-
65
- def test_load_locale_yml_i18n
66
- Dir.mktmpdir do |dir|
67
- Dir.chdir(dir) do
68
- file = File.join(dir, 'locale.yml')
69
- File.write(file, %Q(ja:\n foo: "bar"\nen:\n foo: "buz"\n))
70
- I18n.setup
71
- assert_equal 'bar', I18n.t('foo')
72
- assert_equal '図', I18n.t('image')
73
- I18n.setup('en')
74
- assert_equal 'buz', I18n.t('foo')
75
- assert_equal 'Figure ', I18n.t('image')
76
- end
77
- end
78
- end
79
-
80
- def test_load_locale_invalid_yml
81
- Dir.mktmpdir do |dir|
82
- Dir.chdir(dir) do
83
- file = File.join(dir, 'locale.yml')
84
- File.write(file, %Q(local: ja\nfoo: "bar"\n))
85
- assert_raises(ReVIEW::KeyError) do
86
- I18n.setup
87
- end
88
- end
89
- end
90
- end
91
-
92
- def test_custom_format
93
- Dir.mktmpdir do |dir|
94
- Dir.chdir(dir) do
95
- file = File.join(dir, 'locale.yml')
96
- File.write(file, "locale: ja\nchapter: 第%pa章")
97
- I18n.setup('ja')
98
- assert_equal '第a章', I18n.t('chapter', 1)
99
-
100
- File.write(file, "locale: ja\nchapter: 第%pA章")
101
- I18n.setup('ja')
102
- assert_equal '第B章', I18n.t('chapter', 2)
103
-
104
- File.write(file, "locale: ja\nchapter: 第%pAW章")
105
- I18n.setup('ja')
106
- assert_equal '第B章', I18n.t('chapter', 2)
107
-
108
- File.write(file, "locale: ja\nchapter: 第%paW章")
109
- I18n.setup('ja')
110
- assert_equal '第b章', I18n.t('chapter', 2)
111
-
112
- File.write(file, "locale: ja\nchapter: 第%pR章")
113
- I18n.setup('ja')
114
- assert_equal '第I章', I18n.t('chapter', 1)
115
-
116
- File.write(file, "locale: ja\nchapter: 第%pr章")
117
- I18n.setup('ja')
118
- assert_equal '第ii章', I18n.t('chapter', 2)
119
-
120
- File.write(file, "locale: ja\nchapter: 第%pRW章")
121
- I18n.setup('ja')
122
- assert_equal '第Ⅻ章', I18n.t('chapter', 12)
123
-
124
- File.write(file, "locale: ja\nchapter: 第%pJ章")
125
- I18n.setup('ja')
126
- assert_equal '第二十七章', I18n.t('chapter', 27)
127
-
128
- File.write(file, "locale: ja\nchapter: 第%pdW章")
129
- I18n.setup('ja')
130
- assert_equal '第1章', I18n.t('chapter', 1)
131
-
132
- File.write(file, "locale: ja\nchapter: 第%pdW章")
133
- I18n.setup('ja')
134
- assert_equal '第27章', I18n.t('chapter', 27)
135
-
136
- File.write(file, "locale: ja\nchapter: 第%pDW章")
137
- I18n.setup('ja')
138
- assert_equal '第1章', I18n.t('chapter', 1)
139
-
140
- File.write(file, "locale: ja\nchapter: 第%pDW章")
141
- I18n.setup('ja')
142
- assert_equal '第27章', I18n.t('chapter', 27)
143
-
144
- File.write(file, "locale: ja\npart: Part %pRW")
145
- I18n.setup('ja')
146
- assert_equal 'Part 0', I18n.t('part', 0)
147
-
148
- File.write(file, "locale: ja\npart: 第%pJ部")
149
- I18n.setup('ja')
150
- assert_equal '第一部', I18n.t('part', 1)
151
- end
152
- end
153
- end
154
-
155
- def test_custom_format_numbers
156
- Dir.mktmpdir do |dir|
157
- Dir.chdir(dir) do
158
- file = File.join(dir, 'locale.yml')
159
-
160
- File.write(file, %Q(locale: ja\nformat_number_header: "%s-%pA:"))
161
- I18n.setup('ja')
162
- assert_equal '1-B:', I18n.t('format_number_header', [1, 2])
163
-
164
- File.write(file, %Q(locale: ja\nformat_number_header: "%s.%pa:"))
165
- I18n.setup('ja')
166
- assert_equal '2.c:', I18n.t('format_number_header', [2, 3])
167
-
168
- File.write(file, %Q(locale: ja\nformat_number_header: "%pA,%pAW:"))
169
- I18n.setup('ja')
170
- assert_equal 'C,D:', I18n.t('format_number_header', [3, 4])
171
-
172
- File.write(file, %Q(locale: ja\nformat_number_header: "%pJ・%pJ:"))
173
- I18n.setup('ja')
174
- assert_equal '十二・二十六:', I18n.t('format_number_header', [12, 26])
175
-
176
- File.write(file, %Q(locale: ja\nformat_number_header: "%pdW―%pdW:"))
177
- I18n.setup('ja')
178
- assert_equal '3―12:', I18n.t('format_number_header', [3, 12])
179
- end
180
- end
181
- end
182
-
183
- def test_format_with_mismatched_number_of_arguments
184
- Dir.mktmpdir do |dir|
185
- Dir.chdir(dir) do
186
- file = File.join(dir, 'locale.yml')
187
-
188
- File.write(file, %Q(locale: ja\nformat_number_header: "%2$d"))
189
- I18n.setup('ja')
190
- assert_equal '10', I18n.t('format_number_header', [1, 10])
191
-
192
- File.write(file, %Q(locale: ja\nformat_number_header: "%2$d-%1$d"))
193
- I18n.setup('ja')
194
- # ERROR: returns raw format
195
- assert_equal '%2$d-%1$d', I18n.t('format_number_header', [1])
196
- end
197
- end
198
- end
199
-
200
- def test_ja
201
- I18n.setup('ja')
202
- assert_equal '図', I18n.t('image')
203
- assert_equal '表', I18n.t('table')
204
- assert_equal '第1章', I18n.t('chapter', 1)
205
- assert_equal 'etc', I18n.t('etc')
206
- end
207
-
208
- def test_ja_with_user_i18n
209
- i18n = I18n.new('ja')
210
- i18n.update({ 'image' => 'ず' }, 'ja')
211
- assert_equal 'ず', i18n.t('image')
212
- assert_equal '表', i18n.t('table')
213
- assert_equal '第1章', i18n.t('chapter', 1)
214
- assert_equal 'etc', i18n.t('etc')
215
- end
216
-
217
- def test_en
218
- I18n.setup('en')
219
- assert_equal 'Figure ', I18n.t('image')
220
- assert_equal 'Table ', I18n.t('table')
221
- assert_equal 'Chapter 1', I18n.t('chapter', 1)
222
- assert_equal 'etc', I18n.t('etc')
223
- end
224
-
225
- def test_nil
226
- I18n.setup('nil')
227
- assert_equal 'image', I18n.t('image')
228
- assert_equal 'table', I18n.t('table')
229
- assert_equal 'etc', I18n.t('etc')
230
- end
231
-
232
- def test_htmlbuilder
233
- _setup_htmlbuilder
234
- actual = compile_block("={test} this is test.\n")
235
- assert_equal %Q(<h1 id="test"><a id="h1"></a><span class="secno">Chapter 1. </span>this is test.</h1>\n), actual
236
- end
237
-
238
- def _setup_htmlbuilder
239
- I18n.setup('en')
240
- @builder = HTMLBuilder.new
241
- @config = ReVIEW::Configure.values.merge(
242
- { 'secnolevel' => 2, # for IDGXMLBuilder, HTMLBuilder
243
- 'stylesheet' => nil, # for HTMLBuilder
244
- 'ext' => '.re' }
245
- )
246
- @book = Book::Base.new('.')
247
- @book.config = @config
248
- @compiler = ReVIEW::Compiler.new(@builder)
249
- @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
250
- location = Location.new(nil, nil)
251
- @builder.bind(@compiler, @chapter, location)
252
- end
253
-
254
- def test_update
255
- i18n = ReVIEW::I18n.new('ja')
256
- hash = { 'foo' => 'bar' }
257
- i18n.update(hash)
258
- assert_equal 'bar', i18n.t('foo')
259
- end
260
-
261
- def test_update_newlocale
262
- i18n = ReVIEW::I18n.new('ja')
263
- hash = { 'foo' => 'bar' }
264
- i18n.update(hash, 'abc')
265
- i18n.locale = 'abc'
266
- assert_equal 'bar', i18n.t('foo')
267
- end
268
-
269
- def test_ja_appendix_alphabet
270
- i18n = I18n.new('ja')
271
- i18n.update({ 'appendix' => '付録%pA' }, 'ja')
272
- assert_equal '付録A', i18n.t('appendix', 1)
273
- assert_equal '付録B', i18n.t('appendix', 2)
274
- assert_equal '付録C', i18n.t('appendix', 3)
275
- end
276
-
277
- def test_ja_part
278
- i18n = I18n.new('ja')
279
- assert_equal '第III部', i18n.t('part', 3)
280
- assert_equal 'III', i18n.t('part_short', 3)
281
- i18n.update({ 'part' => '第%pRW部' }, 'ja')
282
- i18n.update({ 'part_short' => '%pRW' }, 'ja')
283
- assert_equal '第Ⅲ部', i18n.t('part', 3)
284
- assert_equal 'Ⅲ', i18n.t('part_short', 3)
285
- end
286
-
287
- def test_i18n_error
288
- I18n.setup
289
- assert_raises NotImplementedError do
290
- I18n.i18n('ja')
291
- end
292
- assert_raises NotImplementedError do
293
- I18n.i18n('ja', {})
294
- end
295
- end
296
-
297
- def teardown
298
- I18n.setup('ja')
299
- end
300
- end