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,156 +0,0 @@
1
- require 'test_helper'
2
- require 'book_test_helper'
3
- require 'review/sec_counter'
4
-
5
- class SecCounterTest < Test::Unit::TestCase
6
- include ReVIEW
7
-
8
- def setup
9
- @book = Book::Base.new
10
- @io = StringIO.new("= sample\n\n")
11
- @chapter = Book::Chapter.new(@book, 1, 'foo', '-', @io)
12
- @part = Book::Part.new(@book, 1, [], 'name')
13
- I18n.setup
14
- end
15
-
16
- def test_initialize
17
- @sec_counter = SecCounter.new(5, @chapter)
18
- assert_equal('1', @sec_counter.anchor(0))
19
- assert_equal('1', @sec_counter.anchor(1))
20
- assert_equal('1-0', @sec_counter.anchor(2))
21
- assert_equal('1-0-0', @sec_counter.anchor(3))
22
- end
23
-
24
- def test_anchor1
25
- @sec_counter = SecCounter.new(5, @chapter)
26
- @sec_counter.inc(3)
27
- assert_equal('1', @sec_counter.anchor(0))
28
- assert_equal('1', @sec_counter.anchor(1))
29
- assert_equal('1-0', @sec_counter.anchor(2))
30
- assert_equal('1-0-1', @sec_counter.anchor(3))
31
- end
32
-
33
- def test_anchor2
34
- @sec_counter = SecCounter.new(5, @chapter)
35
- @sec_counter.inc(2)
36
- @sec_counter.inc(3)
37
- @sec_counter.inc(3)
38
- @sec_counter.inc(4)
39
- assert_equal('1', @sec_counter.anchor(0))
40
- assert_equal('1', @sec_counter.anchor(1))
41
- assert_equal('1-1', @sec_counter.anchor(2))
42
- assert_equal('1-1-2', @sec_counter.anchor(3))
43
- assert_equal('1-1-2-1', @sec_counter.anchor(4))
44
- end
45
-
46
- def test_anchor3
47
- @sec_counter = SecCounter.new(5, @chapter)
48
- @sec_counter.inc(2)
49
- @sec_counter.inc(3)
50
- @sec_counter.inc(3)
51
- @sec_counter.inc(4)
52
- @sec_counter.inc(3)
53
- assert_equal('1', @sec_counter.anchor(0))
54
- assert_equal('1', @sec_counter.anchor(1))
55
- assert_equal('1-1', @sec_counter.anchor(2))
56
- assert_equal('1-1-3', @sec_counter.anchor(3))
57
- assert_equal('1-1-3-0', @sec_counter.anchor(4))
58
- end
59
-
60
- def test_anchor4
61
- @sec_counter = SecCounter.new(5, @chapter)
62
- @sec_counter.inc(2)
63
- @sec_counter.inc(2)
64
- @sec_counter.inc(2)
65
- @sec_counter.inc(3)
66
- @sec_counter.inc(3)
67
- assert_equal('1', @sec_counter.anchor(0))
68
- assert_equal('1', @sec_counter.anchor(1))
69
- assert_equal('1-3', @sec_counter.anchor(2))
70
- assert_equal('1-3-2', @sec_counter.anchor(3))
71
- assert_equal('1-3-2-0', @sec_counter.anchor(4))
72
- end
73
-
74
- def test_anchor_part1
75
- @sec_counter = SecCounter.new(5, @part)
76
- @sec_counter.inc(3)
77
- assert_equal('1', @sec_counter.anchor(0))
78
- assert_equal('1', @sec_counter.anchor(1))
79
- assert_equal('1-0', @sec_counter.anchor(2))
80
- assert_equal('1-0-1', @sec_counter.anchor(3))
81
- end
82
-
83
- def test_anchor_part3
84
- @sec_counter = SecCounter.new(5, @part)
85
- @sec_counter.inc(2)
86
- @sec_counter.inc(3)
87
- @sec_counter.inc(3)
88
- @sec_counter.inc(4)
89
- @sec_counter.inc(3)
90
- assert_equal('1', @sec_counter.anchor(0))
91
- assert_equal('1', @sec_counter.anchor(1))
92
- assert_equal('1-1', @sec_counter.anchor(2))
93
- assert_equal('1-1-3', @sec_counter.anchor(3))
94
- assert_equal('1-1-3-0', @sec_counter.anchor(4))
95
- end
96
-
97
- def test_prefix1
98
- @sec_counter = SecCounter.new(5, @chapter)
99
- @sec_counter.inc(2)
100
- assert_equal('1.1 ', @sec_counter.prefix(2, 3))
101
- assert_equal('1.1.0 ', @sec_counter.prefix(3, 3))
102
- assert_equal('1.1.0 ', @sec_counter.prefix(3, 5))
103
- end
104
-
105
- def test_prefix2
106
- @sec_counter = SecCounter.new(5, @chapter)
107
- @sec_counter.inc(2)
108
- @sec_counter.inc(3)
109
- @sec_counter.inc(3)
110
- @sec_counter.inc(4)
111
- assert_equal('1.1 ', @sec_counter.prefix(2, 5))
112
- assert_equal('1.1 ', @sec_counter.prefix(2, 5))
113
- assert_equal(nil, @sec_counter.prefix(2, 1))
114
- assert_equal('1.1.2 ', @sec_counter.prefix(3, 5))
115
- assert_equal('1.1.2 ', @sec_counter.prefix(3, 3))
116
- assert_equal(nil, @sec_counter.prefix(3, 2))
117
- end
118
-
119
- def test_prefix3
120
- @sec_counter = SecCounter.new(5, @chapter)
121
- @sec_counter.inc(2)
122
- @sec_counter.inc(3)
123
- @sec_counter.inc(3)
124
- @sec_counter.inc(4)
125
- @sec_counter.inc(3)
126
- assert_equal('1.1 ', @sec_counter.prefix(2, 5))
127
- assert_equal('1.1 ', @sec_counter.prefix(2, 5))
128
- assert_equal(nil, @sec_counter.prefix(2, 1))
129
- assert_equal('1.1.3 ', @sec_counter.prefix(3, 5))
130
- assert_equal('1.1.3 ', @sec_counter.prefix(3, 3))
131
- assert_equal(nil, @sec_counter.prefix(3, 2))
132
- assert_equal('1.1.3.0 ', @sec_counter.prefix(4, 5))
133
- end
134
-
135
- def test_prefix_part1
136
- @sec_counter = SecCounter.new(5, @part)
137
- @sec_counter.inc(2)
138
- assert_equal('I.1 ', @sec_counter.prefix(2, 3))
139
- assert_equal('I.1.0 ', @sec_counter.prefix(3, 3))
140
- assert_equal('I.1.0 ', @sec_counter.prefix(3, 5))
141
- end
142
-
143
- def test_prefix_part2
144
- @sec_counter = SecCounter.new(5, @part)
145
- @sec_counter.inc(2)
146
- @sec_counter.inc(3)
147
- @sec_counter.inc(3)
148
- @sec_counter.inc(4)
149
- assert_equal('I.1 ', @sec_counter.prefix(2, 5))
150
- assert_equal('I.1 ', @sec_counter.prefix(2, 5))
151
- assert_equal(nil, @sec_counter.prefix(2, 1))
152
- assert_equal('I.1.2 ', @sec_counter.prefix(3, 5))
153
- assert_equal('I.1.2 ', @sec_counter.prefix(3, 3))
154
- assert_equal(nil, @sec_counter.prefix(3, 2))
155
- end
156
- end
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
- require 'review/template'
3
-
4
- class TemplateTest < Test::Unit::TestCase
5
- include ReVIEW
6
-
7
- def setup
8
- @name = nil
9
- end
10
-
11
- def test_load
12
- tmplfile = File.expand_path('./assets/test.xml.erb', __dir__)
13
- tmpl = ReVIEW::Template.load(tmplfile)
14
- assert_equal("<test>\n<name></name>\n</test>\n", tmpl.result(binding))
15
- end
16
-
17
- def test_open_with_value
18
- tmplfile = File.expand_path('./assets/test.xml.erb', __dir__)
19
- tmpl = ReVIEW::Template.load(tmplfile)
20
- @name = 'test'
21
- assert_equal("<test>\n<name>test</name>\n</test>\n", tmpl.result(binding))
22
- end
23
-
24
- def test_generate
25
- result = ReVIEW::Template.generate(path: './assets/test.xml.erb', binding: binding, template_dir: __dir__)
26
- assert_equal("<test>\n<name></name>\n</test>\n", result)
27
- end
28
-
29
- def test_generate_without_template_dir
30
- result = ReVIEW::Template.generate(path: '../test/assets/test.xml.erb', binding: binding)
31
- assert_equal("<test>\n<name></name>\n</test>\n", result)
32
- end
33
- end
@@ -1,58 +0,0 @@
1
- require 'test_helper'
2
- require 'tmpdir'
3
- require 'fileutils'
4
- require 'yaml'
5
- require 'rbconfig'
6
- require 'open3'
7
-
8
- REVIEW_TEXTMAKER = File.expand_path('../bin/review-textmaker', File.dirname(__FILE__))
9
-
10
- class TEXTMakerCmdTest < Test::Unit::TestCase
11
- def setup
12
- @tmpdir1 = Dir.mktmpdir
13
-
14
- @old_rubylib = ENV['RUBYLIB']
15
- ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
16
- end
17
-
18
- def teardown
19
- FileUtils.rm_rf(@tmpdir1)
20
- ENV['RUBYLIB'] = @old_rubylib
21
- end
22
-
23
- def common_buildtext(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'] + '-text')
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_TEXTMAKER} #{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_textmaker_cmd_samplebook
44
- common_buildtext('sample-book/src', 'config.yml', 'book-text/ch01.txt', nil)
45
- end
46
-
47
- def test_textmaker_cmd_samplebook_plain
48
- common_buildtext('sample-book/src', 'config.yml', 'book-text/ch01.txt', '-n')
49
- end
50
-
51
- def test_textmaker_cmd_syntaxbook
52
- common_buildtext('syntax-book', 'config.yml', 'syntax-book-text/ch01.txt', nil)
53
- end
54
-
55
- def test_textmaker_cmd_syntaxbook_plain
56
- common_buildtext('syntax-book', 'config.yml', 'syntax-book-text/ch01.txt', '-n')
57
- end
58
- end
@@ -1,187 +0,0 @@
1
- require 'test_helper'
2
- require 'review/textutils'
3
-
4
- class TextUtilsTest < Test::Unit::TestCase
5
- include ReVIEW::TextUtils
6
-
7
- def setup
8
- @tu_nil = Object.new
9
- @tu_nil.extend(ReVIEW::TextUtils)
10
- @tu_nil.instance_eval { @book = Book::Base.new('.') }
11
- def @tu_nil.config
12
- @book.config
13
- end
14
-
15
- def @tu_nil.pre_paragraph
16
- nil
17
- end
18
-
19
- def @tu_nil.post_paragraph
20
- nil
21
- end
22
-
23
- @tu_p = Object.new
24
- @tu_p.extend(ReVIEW::TextUtils)
25
- @tu_p.instance_eval { @book = Book::Base.new('.') }
26
- def @tu_p.config
27
- @book.config
28
- end
29
-
30
- def @tu_p.pre_paragraph
31
- '<p>'
32
- end
33
-
34
- def @tu_p.post_paragraph
35
- '</p>'
36
- end
37
- end
38
-
39
- def test_detab
40
- detabed = detab("\t\tabc")
41
- assert_equal ' abc', detabed
42
- detabed = detab("\tabc\tbcd")
43
- assert_equal ' abc bcd', detabed
44
- end
45
-
46
- def test_detab_with_arg
47
- detabed = detab("\t\tabcd\tef", 2)
48
- assert_equal ' abcd ef', detabed
49
- detabed = detab("\tabc\tdef", 4)
50
- assert_equal ' abc def', detabed
51
- end
52
-
53
- def test_split_paragraph_empty_nil
54
- ret = @tu_nil.split_paragraph([])
55
- assert_equal ret, ['']
56
- end
57
-
58
- def test_split_paragraph_empty_p
59
- ret = @tu_p.split_paragraph([])
60
- assert_equal ret, ['<p></p>']
61
- end
62
-
63
- def test_split_paragraph_p
64
- ret = @tu_p.split_paragraph(['abc'])
65
- assert_equal ['<p>abc</p>'], ret
66
- ret = @tu_p.split_paragraph(['abc', 'def'])
67
- assert_equal ['<p>abcdef</p>'], ret
68
- ret = @tu_p.split_paragraph(['abc', '', 'def'])
69
- assert_equal ['<p>abc</p>', '<p>def</p>'], ret
70
- ret = @tu_p.split_paragraph(['abc', '', '', 'def'])
71
- assert_equal ['<p>abc</p>', '<p>def</p>'], ret
72
- ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi'])
73
- assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
74
- ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
75
- assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
76
-
77
- @tu_p.config['join_lines_by_lang'] = true
78
- ret = @tu_p.split_paragraph(['abc'])
79
- assert_equal ['<p>abc</p>'], ret
80
- ret = @tu_p.split_paragraph(['abc', 'def'])
81
- assert_equal ['<p>abc def</p>'], ret
82
- ret = @tu_p.split_paragraph(['abc', '', 'def'])
83
- assert_equal ['<p>abc</p>', '<p>def</p>'], ret
84
- ret = @tu_p.split_paragraph(['abc', '', '', 'def'])
85
- assert_equal ['<p>abc</p>', '<p>def</p>'], ret
86
- ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi'])
87
- assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
88
- ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
89
- assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
90
- end
91
-
92
- def test_split_paragraph_nil
93
- ret = @tu_nil.split_paragraph(['abc'])
94
- assert_equal ['abc'], ret
95
- ret = @tu_nil.split_paragraph(['abc', 'def'])
96
- assert_equal ['abcdef'], ret
97
- ret = @tu_nil.split_paragraph(['abc', '', 'def'])
98
- assert_equal ['abc', 'def'], ret
99
- ret = @tu_nil.split_paragraph(['abc', '', '', 'def'])
100
- assert_equal ['abc', 'def'], ret
101
- ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
102
- assert_equal ['abc', 'defghi'], ret
103
-
104
- @tu_nil.config['join_lines_by_lang'] = true
105
- ret = @tu_nil.split_paragraph(['abc'])
106
- assert_equal ['abc'], ret
107
- ret = @tu_nil.split_paragraph(['abc', 'def'])
108
- assert_equal ['abc def'], ret
109
- ret = @tu_nil.split_paragraph(['abc', '', 'def'])
110
- assert_equal ['abc', 'def'], ret
111
- ret = @tu_nil.split_paragraph(['abc', '', '', 'def'])
112
- assert_equal ['abc', 'def'], ret
113
- ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
114
- assert_equal ['abc', 'def ghi'], ret
115
- end
116
-
117
- def test_split_paragraph_p_lang
118
- ret = @tu_p.split_paragraph(['I', 'have.'])
119
- assert_equal ['<p>Ihave.</p>'], ret
120
- ret = @tu_p.split_paragraph(['I', 'have', '.'])
121
- assert_equal ['<p>Ihave.</p>'], ret
122
- ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
123
- assert_equal ['<p>0123a4</p>'], ret
124
- ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
125
- assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
126
- ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
127
- assert_equal ['<p>こんにちは0814日</p>'], ret
128
- ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
129
- assert_equal ['<p>あaい?a</p>'], ret
130
- ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
131
- assert_equal ['<p>안녕하세요こんにちは</p>'], ret
132
- ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
133
- assert_equal ['<p>Hello안녕하세요처음뵙겠습니다</p>'], ret
134
- ret = @tu_p.split_paragraph([''])
135
- assert_equal ['<p></p>'], ret
136
- # LaTeX
137
- ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
138
- assert_equal ['<p>\tag{a}A\tag{b}B</p>'], ret
139
- ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
140
- assert_equal ['<p>\tag{あ}い\tag{う}A\tag{え}\tag{b}\tag{お}\tag{か}</p>'], ret
141
- # HTML/IDGXML
142
- ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
143
- assert_equal ['<p><b>a</b>A<b>b</b>B</p>'], ret
144
- ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
145
- assert_equal ['<p><b>あ</b>い<b>う</b>A<b>え</b><b>b</b><b>お</b><b>か</b></p>'], ret
146
- # Text
147
- ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
148
- assert_equal ['<p>★a☆A★b☆B</p>'], ret
149
- ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
150
- assert_equal ['<p>★あ☆い★う☆A★え☆★b☆★お☆★か☆</p>'], ret
151
-
152
- @tu_p.config['join_lines_by_lang'] = true
153
- ret = @tu_p.split_paragraph(['I', 'have.'])
154
- assert_equal ['<p>I have.</p>'], ret
155
- ret = @tu_p.split_paragraph(['I', 'have', '.'])
156
- assert_equal ['<p>I have .</p>'], ret # ...OK? (I have. ?)
157
- ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
158
- assert_equal ['<p>01 23 a 4</p>'], ret
159
- ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
160
- assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
161
- ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
162
- assert_equal ['<p>こんにちは0814日</p>'], ret
163
- ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
164
- assert_equal ['<p>あaい? a</p>'], ret
165
- ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
166
- assert_equal ['<p>안녕하세요こんにちは</p>'], ret
167
- ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
168
- assert_equal ['<p>Hello 안녕하세요 처음뵙겠습니다</p>'], ret
169
- ret = @tu_p.split_paragraph([''])
170
- assert_equal ['<p></p>'], ret
171
- # LaTeX
172
- ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
173
- assert_equal ['<p>\tag{a} A \tag{b} B</p>'], ret
174
- ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
175
- assert_equal ['<p>\tag{あ}い\tag{う} A \tag{え} \tag{b} \tag{お} \tag{か}</p>'], ret # ...OK? (\tag{お}\tag{か}?)
176
- # HTML/IDGXML
177
- ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
178
- assert_equal ['<p><b>a</b> A <b>b</b> B</p>'], ret
179
- ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
180
- assert_equal ['<p><b>あ</b>い<b>う</b> A <b>え</b> <b>b</b> <b>お</b> <b>か</b></p>'], ret # ...OK? (<b>お</b><b>か</b>?)
181
- # Text
182
- ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
183
- assert_equal ['<p>★a☆ A ★b☆ B</p>'], ret
184
- ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
185
- assert_equal ['<p>★あ☆い★う☆ A ★え☆ ★b☆ ★お☆ ★か☆</p>'], ret # ...OK? (★お☆★か☆?)
186
- end
187
- end
@@ -1,46 +0,0 @@
1
- require 'test_helper'
2
- require 'review/tocprinter'
3
- require 'unicode/eaw'
4
-
5
- class TOCPrinterTest < Test::Unit::TestCase
6
- def setup
7
- @toc_printer = ReVIEW::TOCPrinter.new
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_calc_linesize
14
- @toc_printer.calc_char_width = nil
15
- size = @toc_printer.calc_linesize('あ いうえおABCD')
16
- assert_equal 10, size
17
- size = @toc_printer.calc_linesize("あ い\nうえ\nおAB\nCD\n")
18
- assert_equal 14, size
19
- end
20
-
21
- def test_calc_linesize_with_char_width
22
- @toc_printer.calc_char_width = true
23
- size = @toc_printer.calc_linesize('あ いうえおABCD')
24
- assert_equal 7.5, size
25
- size = @toc_printer.calc_linesize("あ い\nうえ\nおAB\nCD\n")
26
- assert_equal 9.5, size
27
- end
28
-
29
- def test_execute_syntax_book_detail
30
- Dir.chdir('./samples/syntax-book') do
31
- stdout = $stdout
32
- tmp_io = StringIO.new
33
- $stdout = tmp_io
34
- begin
35
- @toc_printer.execute('-d')
36
- tmp_io.rewind
37
- result = tmp_io.read
38
- path = File.join(assets_dir, 'syntax_book_index_detail.txt')
39
- expected = File.read(path)
40
- assert_equal expected, result
41
- ensure
42
- $stdout = stdout
43
- end
44
- end
45
- end
46
- end