review 5.5.0 → 5.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) 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 +40 -0
  8. data/NEWS.md +39 -0
  9. data/README.md +1 -1
  10. data/doc/format.ja.md +70 -33
  11. data/doc/format.md +69 -34
  12. data/doc/quickstart.ja.md +7 -1
  13. data/doc/quickstart.md +7 -1
  14. data/lib/review/book/base.rb +1 -1
  15. data/lib/review/builder.rb +6 -10
  16. data/lib/review/epubmaker/epubcommon.rb +13 -7
  17. data/lib/review/epubmaker/epubv2.rb +0 -5
  18. data/lib/review/epubmaker/epubv3.rb +9 -1
  19. data/lib/review/epubmaker/producer.rb +2 -3
  20. data/lib/review/epubmaker.rb +2 -4
  21. data/lib/review/htmlbuilder.rb +2 -2
  22. data/lib/review/i18n.yml +24 -2
  23. data/lib/review/idgxmlbuilder.rb +29 -10
  24. data/lib/review/idgxmlmaker.rb +11 -1
  25. data/lib/review/img_math.rb +9 -2
  26. data/lib/review/init.rb +10 -5
  27. data/lib/review/latexbuilder.rb +2 -2
  28. data/lib/review/lineinput.rb +2 -2
  29. data/lib/review/makerhelper.rb +2 -2
  30. data/lib/review/pdfmaker.rb +3 -5
  31. data/lib/review/update.rb +3 -7
  32. data/lib/review/version.rb +1 -1
  33. data/lib/review/yamlloader.rb +0 -3
  34. data/review.gemspec +3 -3
  35. data/samples/syntax-book/Gemfile +1 -1
  36. data/templates/latex/config.erb +6 -1
  37. data/templates/latex/review-jlreq/review-base.sty +11 -8
  38. data/templates/latex/review-jsbook/review-base.sty +15 -11
  39. data/templates/opf/epubv2.opf.erb +2 -0
  40. data/templates/opf/epubv3.opf.erb +2 -0
  41. data/templates/opf/opf_manifest_epubv2.opf.erb +2 -0
  42. data/templates/opf/opf_manifest_epubv3.opf.erb +2 -0
  43. data/templates/opf/opf_tocx_epubv3.opf.erb +2 -0
  44. metadata +24 -139
  45. data/test/assets/black.eps +0 -280
  46. data/test/assets/fit.png +0 -0
  47. data/test/assets/header_listener.html +0 -35
  48. data/test/assets/img_math/img1.png +0 -0
  49. data/test/assets/img_math/img2.png +0 -0
  50. data/test/assets/img_math/img3.png +0 -0
  51. data/test/assets/large.gif +0 -0
  52. data/test/assets/large.jpg +0 -0
  53. data/test/assets/large.png +0 -0
  54. data/test/assets/large.svg +0 -65
  55. data/test/assets/syntax_book_index_detail.txt +0 -60
  56. data/test/assets/test.xml.erb +0 -3
  57. data/test/assets/test_template.tex +0 -179
  58. data/test/assets/test_template_backmatter.tex +0 -190
  59. data/test/book_test_helper.rb +0 -44
  60. data/test/run_test.rb +0 -12
  61. data/test/test_book.rb +0 -588
  62. data/test/test_book_chapter.rb +0 -329
  63. data/test/test_book_part.rb +0 -53
  64. data/test/test_builder.rb +0 -126
  65. data/test/test_catalog.rb +0 -174
  66. data/test/test_catalog_converter_cmd.rb +0 -73
  67. data/test/test_compiler.rb +0 -52
  68. data/test/test_configure.rb +0 -91
  69. data/test/test_converter.rb +0 -21
  70. data/test/test_epub3maker.rb +0 -733
  71. data/test/test_epubmaker.rb +0 -931
  72. data/test/test_epubmaker_cmd.rb +0 -56
  73. data/test/test_extentions_hash.rb +0 -66
  74. data/test/test_helper.rb +0 -62
  75. data/test/test_htmlbuilder.rb +0 -3312
  76. data/test/test_htmltoc.rb +0 -29
  77. data/test/test_htmlutils.rb +0 -43
  78. data/test/test_i18n.rb +0 -300
  79. data/test/test_idgxmlbuilder.rb +0 -1487
  80. data/test/test_idgxmlmaker_cmd.rb +0 -50
  81. data/test/test_image_finder.rb +0 -81
  82. data/test/test_img_math.rb +0 -120
  83. data/test/test_index.rb +0 -287
  84. data/test/test_indexbuilder.rb +0 -52
  85. data/test/test_latexbuilder.rb +0 -2964
  86. data/test/test_latexbuilder_v2.rb +0 -1654
  87. data/test/test_lineinput.rb +0 -104
  88. data/test/test_location.rb +0 -30
  89. data/test/test_logger.rb +0 -33
  90. data/test/test_makerhelper.rb +0 -44
  91. data/test/test_markdownbuilder.rb +0 -371
  92. data/test/test_md2inaobuilder.rb +0 -90
  93. data/test/test_pdfmaker.rb +0 -354
  94. data/test/test_pdfmaker_cmd.rb +0 -130
  95. data/test/test_plaintextbuilder.rb +0 -1211
  96. data/test/test_preprocessor.rb +0 -196
  97. data/test/test_review_ext.rb +0 -30
  98. data/test/test_reviewheaderlistener.rb +0 -49
  99. data/test/test_rstbuilder.rb +0 -616
  100. data/test/test_sec_counter.rb +0 -156
  101. data/test/test_template.rb +0 -33
  102. data/test/test_textmaker_cmd.rb +0 -58
  103. data/test/test_textutils.rb +0 -187
  104. data/test/test_tocprinter.rb +0 -46
  105. data/test/test_topbuilder.rb +0 -1298
  106. data/test/test_update.rb +0 -473
  107. data/test/test_webtocprinter.rb +0 -195
  108. data/test/test_yamlloader.rb +0 -186
  109. data/test/test_zip_exporter.rb +0 -106
@@ -1,104 +0,0 @@
1
- require 'test_helper'
2
- require 'review/lineinput'
3
- require 'tempfile'
4
- require 'stringio'
5
-
6
- class LineInputTest < Test::Unit::TestCase
7
- def test_initialize
8
- io = StringIO.new
9
- li = LineInput.new(io)
10
- assert_equal 0, li.lineno
11
- assert !li.eof?
12
- assert_equal "#<ReVIEW::LineInput file=#{io.inspect} line=0>", li.inspect
13
- end
14
-
15
- def test_gets
16
- content = "abc\ndef\r\nghi\rjkl"
17
- do_test_gets(StringIO.new(content))
18
- Tempfile.open('lineinput_test') do |io|
19
- io.print content
20
- io.rewind
21
- do_test_gets(io)
22
- end
23
- end
24
-
25
- def do_test_gets(io)
26
- li = LineInput.new(io)
27
-
28
- assert_equal "abc\n", li.gets
29
- assert_equal "def\r\n", li.gets
30
- assert_equal "ghi\rjkl", li.gets
31
- assert_equal 3, li.lineno
32
- assert !li.eof?
33
-
34
- assert_equal nil, li.gets
35
- assert_equal 4, li.lineno # XXX: OK?
36
- assert li.eof?
37
-
38
- assert_equal nil, li.gets
39
- assert_equal 4, li.lineno
40
- assert li.eof?
41
- end
42
-
43
- def test_peek
44
- li = LineInput.new(StringIO.new)
45
- assert_equal nil, li.peek
46
-
47
- li = LineInput.new(StringIO.new('abc'))
48
- assert_equal 'abc', li.peek
49
- end
50
-
51
- def test_next?
52
- li = LineInput.new(StringIO.new)
53
- assert !li.next?
54
-
55
- li = LineInput.new(StringIO.new('abc'))
56
- assert li.next?
57
- end
58
-
59
- def test_each
60
- content = "abc\ndef\nghi"
61
- io = StringIO.new(content)
62
- li = LineInput.new(io)
63
-
64
- data = ''
65
- li.each { |l| data << l }
66
- assert_equal content, data
67
- end
68
-
69
- def test_while_match
70
- io = StringIO.new("abc\ndef\nghi")
71
- li = LineInput.new(io)
72
-
73
- li.while_match(/^[ad]/) do
74
- # skip
75
- end
76
- assert_equal 2, li.lineno
77
- assert_equal 'ghi', li.gets
78
- end
79
-
80
- def test_until_match
81
- io = StringIO.new("abc\ndef\nghi")
82
- li = LineInput.new(io)
83
-
84
- li.until_match(/^[^a]/) do
85
- # skip
86
- end
87
- assert_equal 1, li.lineno
88
- assert_equal "def\n", li.gets
89
- end
90
-
91
- def test_invalid_control_sequence
92
- 0.upto(31) do |n|
93
- content = n.chr
94
- io = StringIO.new(content)
95
- li = ReVIEW::LineInput.new(io)
96
- if [9, 10, 13].include?(n) # TAB, LF, CR
97
- assert_equal content, li.gets
98
- else
99
- e = assert_raise(ReVIEW::SyntaxError) { li.gets }
100
- assert_match(/found invalid control/, e.message)
101
- end
102
- end
103
- end
104
- end
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
- require 'review/compiler'
3
-
4
- class LocationTest < Test::Unit::TestCase
5
- def setup
6
- end
7
-
8
- def test_lineno
9
- f = StringIO.new("a\nb\nc\n")
10
- location = ReVIEW::Location.new('foo', f)
11
- assert_equal 0, location.lineno
12
- f.gets
13
- assert_equal 1, location.lineno
14
- end
15
-
16
- def test_string
17
- location = ReVIEW::Location.new('foo', StringIO.new("a\nb\nc\n"))
18
- assert_equal 'foo:0', location.string
19
- end
20
-
21
- def test_to_s
22
- location = ReVIEW::Location.new('foo', StringIO.new("a\nb\nc\n"))
23
- assert_equal 'foo:0', location.to_s
24
- end
25
-
26
- def test_to_s_nil
27
- location = ReVIEW::Location.new('foo', nil)
28
- assert_equal 'foo:nil', location.to_s
29
- end
30
- end
data/test/test_logger.rb DELETED
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
- require 'review/logger'
3
-
4
- class LoggerTest < Test::Unit::TestCase
5
- def setup
6
- end
7
-
8
- def test_logging
9
- old_stderr = $stderr.dup
10
- IO.pipe do |r, w|
11
- $stderr.reopen(w)
12
- @logger = ReVIEW::Logger.new
13
- @logger.warn('test')
14
- msg = r.readline
15
- $stderr.reopen(old_stderr)
16
-
17
- assert_equal "WARN --: test\n", msg
18
- end
19
- end
20
-
21
- def test_logging_with_progname
22
- old_stderr = $stderr.dup
23
- IO.pipe do |r, w|
24
- $stderr.reopen(w)
25
- @logger = ReVIEW::Logger.new($stderr, progname: 'review-dummy-cmd')
26
- @logger.warn('test')
27
- msg = r.readline
28
- $stderr.reopen(old_stderr)
29
-
30
- assert_equal "WARN review-dummy-cmd: test\n", msg
31
- end
32
- end
33
- end
@@ -1,44 +0,0 @@
1
- require 'test_helper'
2
- require 'review/makerhelper'
3
- require 'tmpdir'
4
- require 'fileutils'
5
-
6
- class MakerHelperTest < Test::Unit::TestCase
7
- include ReVIEW
8
-
9
- def setup
10
- @tmpdir1 = Dir.mktmpdir
11
- @tmpdir2 = Dir.mktmpdir
12
- end
13
-
14
- def teardown
15
- FileUtils.rm_rf(@tmpdir1)
16
- FileUtils.rm_rf(@tmpdir2)
17
- end
18
-
19
- def test_copy_images_to_dir
20
- types = %w[png gif jpg jpeg svg pdf eps]
21
- types.each { |type| touch_file(File.join(@tmpdir1, "foo.#{type}")) }
22
- FileUtils.mkdir(File.join(@tmpdir1, 'subdir'))
23
- touch_file(File.join(@tmpdir1, 'subdir/foo.png'))
24
-
25
- image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2)
26
-
27
- types.each do |type|
28
- assert File.exist?(File.join(@tmpdir2, "foo.#{type}")), "Copying #{type} file failed"
29
- assert image_files.include?(File.join(@tmpdir1, "foo.#{type}"))
30
- end
31
- assert File.exist?(File.join(@tmpdir2, 'subdir/foo.png')), 'Copying a image file in a subdirectory'
32
- assert image_files.include?(File.join(@tmpdir1, 'subdir/foo.png'))
33
- end
34
-
35
- def test_copy_images_to_dir_with_exts
36
- types = %w[png gif jpg jpeg svg pdf eps]
37
- types4epub = %w[png gif jpg jpeg svg]
38
- types.each { |type| touch_file(File.join(@tmpdir1, "foo.#{type}")) }
39
- image_files = MakerHelper.copy_images_to_dir(@tmpdir1, @tmpdir2, exts: types4epub)
40
-
41
- types4epub.each { |type| assert image_files.include?(File.join(@tmpdir1, "foo.#{type}")), "foo.#{type} is not included" }
42
- (types - types4epub).each { |type| assert !image_files.include?(File.join(@tmpdir1, "foo.#{type}")), "foo.#{type} is included" }
43
- end
44
- end
@@ -1,371 +0,0 @@
1
- require 'test_helper'
2
- require 'review/compiler'
3
- require 'review/book'
4
- require 'review/markdownbuilder'
5
- require 'review/i18n'
6
-
7
- class MARKDOWNBuilderTest < Test::Unit::TestCase
8
- include ReVIEW
9
-
10
- def setup
11
- @builder = MARKDOWNBuilder.new
12
- @config = ReVIEW::Configure.values
13
- @book = Book::Base.new('.')
14
- @book.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
- I18n.setup(@config['language'])
20
- end
21
-
22
- def test_quote
23
- actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
24
- expected = <<-EOS
25
-
26
- > foobar
27
- >
28
- > buz
29
-
30
- EOS
31
- assert_equal expected, actual
32
-
33
- @book.config['join_lines_by_lang'] = true
34
- actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
35
- expected = <<-EOS
36
-
37
- > foo bar
38
- >
39
- > buz
40
-
41
- EOS
42
- assert_equal expected, actual
43
- end
44
-
45
- def test_memo
46
- actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
47
- expected = <<-EOS
48
- <div class="memo">
49
- <p class="caption">this is **test**<&>_</p>
50
- test1
51
-
52
- test*2*
53
-
54
- </div>
55
- EOS
56
- assert_equal expected, actual
57
- end
58
-
59
- def test_noindent
60
- actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
61
- expected = <<-EOS
62
- <p class="noindent">foobar</p>
63
-
64
- foo2bar2
65
-
66
- EOS
67
- assert_equal expected, actual
68
-
69
- @book.config['join_lines_by_lang'] = true
70
- actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
71
- expected = <<-EOS
72
- <p class="noindent">foo bar</p>
73
-
74
- foo2 bar2
75
-
76
- EOS
77
- assert_equal expected, actual
78
- end
79
-
80
- def test_inline_em
81
- assert_equal 'test*foo*abc', compile_inline('test@<em>{foo}abc')
82
- end
83
-
84
- def test_inline_strong
85
- assert_equal 'test**foo**abc', compile_inline('test@<strong>{foo}abc')
86
- end
87
-
88
- def test_ul
89
- src = <<-EOS
90
- * AAA
91
- * BBB
92
- EOS
93
- expected = "\n* AAA\n* BBB\n\n"
94
- actual = compile_block(src)
95
- assert_equal expected, actual
96
- end
97
-
98
- def test_inline_comment
99
- actual = compile_inline('test @<comment>{コメント} test2')
100
- assert_equal 'test test2', actual
101
- end
102
-
103
- def test_inline_comment_for_draft
104
- @config['draft'] = true
105
- actual = compile_inline('test @<comment>{コメント} test2')
106
- assert_equal %Q(test <span class="red">コメント</span> test2), actual
107
- end
108
-
109
- def test_endnote
110
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
111
- assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
112
-
113
- actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
114
- expected = <<-'EOS'
115
- <sup>(1)</sup>
116
-
117
- (1) bar
118
- EOS
119
- assert_equal expected, actual
120
- end
121
-
122
- def test_inline_hd_chap
123
- def @chapter.headline_index
124
- item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
125
- idx = Book::HeadlineIndex.new(self)
126
- idx.add_item(item)
127
- idx
128
- end
129
-
130
- @config['secnolevel'] = 2
131
- actual = compile_inline('test @<hd>{chap1|test} test2')
132
- assert_equal 'test <a href="#h1-1-1">「te_st」</a> test2', actual
133
-
134
- actual = compile_inline('test @<hd>{test} test2')
135
- assert_equal 'test <a href="#h1-1-1">「te_st」</a> test2', actual
136
-
137
- @config['secnolevel'] = 3
138
- actual = compile_inline('test @<hd>{chap1|test} test2')
139
- assert_equal 'test <a href="#h1-1-1">「1.1.1 te_st」</a> test2', actual
140
-
141
- @config['chapterlink'] = nil
142
- @config['secnolevel'] = 2
143
- actual = compile_inline('test @<hd>{chap1|test} test2')
144
- assert_equal 'test 「te_st」 test2', actual
145
-
146
- @config['secnolevel'] = 3
147
- actual = compile_inline('test @<hd>{chap1|test} test2')
148
- assert_equal 'test 「1.1.1 te_st」 test2', actual
149
- end
150
-
151
- def test_inline_sec
152
- def @chapter.headline_index
153
- item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st<>')
154
- idx = Book::HeadlineIndex.new(self)
155
- idx.add_item(item)
156
- idx
157
- end
158
-
159
- @config['secnolevel'] = 3
160
- actual = compile_inline('test @<secref>{test}')
161
- assert_equal 'test <a href="#h1-1-1">「1.1.1 te_st<>」</a>', actual
162
- actual = compile_inline('test @<sectitle>{test}')
163
- assert_equal 'test te_st<>', actual
164
- actual = compile_inline('test @<sec>{test}')
165
- assert_equal 'test 1.1.1', actual
166
-
167
- @config['secnolevel'] = 2
168
- actual = compile_inline('test @<secref>{test}')
169
- assert_equal 'test <a href="#h1-1-1">「te_st<>」</a>', actual
170
- actual = compile_inline('test @<sectitle>{test}')
171
- assert_equal 'test te_st<>', actual
172
- assert_raises(ReVIEW::ApplicationError) { compile_block('test @<sec>{test}') }
173
- @config['chapterlink'] = nil
174
- @config['secnolevel'] = 3
175
- actual = compile_inline('test @<secref>{test}')
176
- assert_equal 'test 「1.1.1 te_st<>」', actual
177
- actual = compile_inline('test @<sectitle>{test}')
178
- assert_equal 'test te_st<>', actual
179
- actual = compile_inline('test @<sec>{test}')
180
- assert_equal 'test 1.1.1', actual
181
- end
182
-
183
- def test_ul_nest1
184
- src = <<-EOS
185
- * AAA
186
- ** AA
187
- *** A
188
- EOS
189
- expected = "\n* AAA\n * AA\n * A\n\n"
190
- actual = compile_block(src)
191
- assert_equal expected, actual
192
- end
193
-
194
- def test_cmd
195
- actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
196
- expected = <<-EOS
197
- ```shell-session
198
- lineA
199
- lineB
200
- ```
201
- EOS
202
- assert_equal expected, actual
203
- end
204
-
205
- def test_dlist
206
- actual = compile_block(" : foo\n foo.\n bar.\n")
207
- expected = <<-EOS
208
- <dl>
209
- <dt>foo</dt>
210
- <dd>foo.bar.</dd>
211
- </dl>
212
- EOS
213
- assert_equal expected, actual
214
-
215
- @book.config['join_lines_by_lang'] = true
216
- actual = compile_block(" : foo\n foo.\n bar.\n")
217
- expected = <<-EOS
218
- <dl>
219
- <dt>foo</dt>
220
- <dd>foo. bar.</dd>
221
- </dl>
222
- EOS
223
- assert_equal expected, actual
224
- end
225
-
226
- def test_dlist_with_bracket
227
- actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
228
- expected = <<-EOS
229
- <dl>
230
- <dt>foo[bar]</dt>
231
- <dd>foo.bar.</dd>
232
- </dl>
233
- EOS
234
- assert_equal expected, actual
235
-
236
- @book.config['join_lines_by_lang'] = true
237
- actual = compile_block(" : foo[bar]\n foo.\n bar.\n")
238
- expected = <<-EOS
239
- <dl>
240
- <dt>foo[bar]</dt>
241
- <dd>foo. bar.</dd>
242
- </dl>
243
- EOS
244
- assert_equal expected, actual
245
- end
246
-
247
- def test_dlist_with_comment
248
- source = " : title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
249
- actual = compile_block(source)
250
- expected = <<-EOS
251
- <dl>
252
- <dt>title</dt>
253
- <dd>body</dd>
254
- <dt>title2</dt>
255
- <dd>body2</dd>
256
- </dl>
257
- EOS
258
- assert_equal expected, actual
259
- end
260
-
261
- def test_comment
262
- actual = compile_block('//comment[コメント]')
263
- assert_equal '', actual
264
- end
265
-
266
- def test_comment_for_draft
267
- @config['draft'] = true
268
- actual = compile_block('//comment[コメント]')
269
- assert_equal %Q(<div class="red">コメント</div>\n), actual
270
- end
271
-
272
- def test_list
273
- actual = compile_block(<<-EOS)
274
- //list[name][caption]{
275
- AAA
276
- BBB
277
- //}
278
- EOS
279
-
280
- assert_equal <<-EOS, actual
281
- リスト1.1 caption
282
-
283
- ```
284
- AAA
285
- BBB
286
- ```
287
- EOS
288
- end
289
-
290
- def test_list_lang
291
- actual = compile_block(<<-EOS)
292
- //list[name][caption][ruby]{
293
- AAA
294
- BBB
295
- //}
296
- EOS
297
-
298
- assert_equal <<-EOS, actual
299
- リスト1.1 caption
300
-
301
- ```ruby
302
- AAA
303
- BBB
304
- ```
305
- EOS
306
- end
307
-
308
- def test_listnum
309
- def @chapter.list(_id)
310
- Book::Index::Item.new('test', 1)
311
- end
312
- actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n\tbuz\n//}\n")
313
- expected = <<-EOS
314
- リスト1.1 this is **test**<&>_
315
-
316
- ```
317
- 1: foo
318
- 2: bar
319
- 3: buz
320
- ```
321
- EOS
322
- assert_equal expected, actual
323
- end
324
-
325
- def test_emlist_lang
326
- actual = compile_block(<<-EOS)
327
- //emlist[caption][ruby]{
328
- AAA
329
- BBB
330
- //}
331
- EOS
332
-
333
- assert_equal <<-EOS, actual
334
-
335
- caption
336
-
337
- ```ruby
338
- AAA
339
- BBB
340
- ```
341
-
342
- EOS
343
- end
344
-
345
- def test_table
346
- actual = compile_block("//table{\ntestA\ttestB\n------------\ncontentA\tcontentB\n//}\n")
347
- expected = <<-EOS
348
- |testA|testB|
349
- |:--|:--|
350
- |contentA|contentB|
351
-
352
- EOS
353
- assert_equal expected, actual
354
-
355
- actual = compile_block("//table[foo][FOO]{\ntestA\ttestB\n------------\ncontentA\tcontentB\n//}\n")
356
- expected = <<-EOS
357
- 表1.1: FOO
358
-
359
- |testA|testB|
360
- |:--|:--|
361
- |contentA|contentB|
362
-
363
- EOS
364
- assert_equal expected, actual
365
- end
366
-
367
- def test_ruby
368
- actual = compile_block('@<ruby>{謳,うた}い文句')
369
- assert_equal "<ruby>謳<rp>(</rp><rt>うた</rt><rp>)</rp></ruby>い文句\n\n", actual
370
- end
371
- end
@@ -1,90 +0,0 @@
1
- require 'test_helper'
2
- require 'review/compiler'
3
- require 'review/book'
4
- require 'review/md2inaobuilder'
5
- require 'review/i18n'
6
-
7
- class MD2INAOBuilderTest < Test::Unit::TestCase
8
- include ReVIEW
9
-
10
- def setup
11
- @builder = MD2INAOBuilder.new
12
- @config = ReVIEW::Configure.values
13
- @book = Book::Base.new('.')
14
- @book.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
- I18n.setup('ja')
20
- end
21
-
22
- def test_paragraph
23
- actual = compile_block('Hello, world!')
24
- expected = <<-EOS
25
-  Hello, world!
26
-
27
- EOS
28
- assert_equal expected, actual
29
- end
30
-
31
- def test_cmd
32
- actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
33
- expected = <<-EOS
34
- !!! cmd
35
- lineA
36
- lineB
37
-
38
- EOS
39
- assert_equal expected, actual
40
- end
41
-
42
- def test_dlist
43
- actual = compile_block(" : foo\n foo.\n bar.\n")
44
- expected = <<-EOS
45
- <dl>
46
- <dt>foo</dt>
47
- <dd>foo.bar.</dd>
48
- </dl>
49
- EOS
50
- assert_equal expected, actual
51
-
52
- @book.config['join_lines_by_lang'] = true
53
- actual = compile_block(" : foo\n foo.\n bar.\n")
54
- expected = <<-EOS
55
- <dl>
56
- <dt>foo</dt>
57
- <dd>foo. bar.</dd>
58
- </dl>
59
- EOS
60
- assert_equal expected, actual
61
- end
62
-
63
- def test_list
64
- actual = compile_block(<<-EOS)
65
- //list[name][caption]{
66
- AAA
67
- BBB
68
- //}
69
- EOS
70
-
71
- assert_equal <<-EOS, actual
72
- ●リスト1::caption
73
-
74
- ```
75
- AAA
76
- BBB
77
- ```
78
- EOS
79
- end
80
-
81
- def test_ruby_mono
82
- actual = compile_block('@<ruby>{謳,うた}い文句')
83
- assert_equal " <span class='monoruby'>謳(うた)</span>い文句\n\n", actual
84
- end
85
-
86
- def test_ruby_group
87
- actual = compile_block('@<ruby>{欠伸,あくび}が出る')
88
- assert_equal " <span class='groupruby'>欠伸(あくび)</span>が出る\n\n", actual
89
- end
90
- end