review 0.6.0 → 0.9.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 (68) hide show
  1. data/ChangeLog +441 -0
  2. data/README.rdoc +25 -0
  3. data/Rakefile +13 -1
  4. data/VERSION +1 -1
  5. data/bin/review-check +1 -1
  6. data/bin/review-compile +19 -10
  7. data/bin/review-epubmaker +114 -17
  8. data/bin/review-index +8 -1
  9. data/bin/review-pdfmaker +378 -0
  10. data/bin/review-preproc +2 -3
  11. data/bin/review-vol +1 -2
  12. data/debian/README.Debian +12 -0
  13. data/debian/README.source +5 -0
  14. data/debian/changelog +5 -0
  15. data/debian/compat +1 -0
  16. data/debian/control +22 -0
  17. data/debian/copyright +60 -0
  18. data/debian/docs +5 -0
  19. data/debian/manpage.1.ex +59 -0
  20. data/debian/patches/path.diff +91 -0
  21. data/debian/patches/series +1 -0
  22. data/debian/review.install +13 -0
  23. data/debian/review.links +4 -0
  24. data/debian/rules +13 -0
  25. data/debian/source/format +1 -0
  26. data/doc/format.rdoc +477 -0
  27. data/doc/format.re +19 -0
  28. data/doc/format_idg.rdoc +180 -0
  29. data/doc/ruby-uuid/README +11 -0
  30. data/doc/ruby-uuid/README.ja +34 -0
  31. data/doc/sample.css +17 -0
  32. data/doc/sample.yaml +8 -4
  33. data/lib/lineinput.rb +1 -1
  34. data/lib/review/book.rb +43 -36
  35. data/lib/review/builder.rb +78 -33
  36. data/lib/review/compiler.rb +45 -48
  37. data/lib/review/epubbuilder.rb +1 -675
  38. data/lib/review/exception.rb +1 -1
  39. data/lib/review/htmlbuilder.rb +627 -49
  40. data/lib/review/htmlutils.rb +5 -0
  41. data/lib/review/idgxmlbuilder.rb +239 -250
  42. data/lib/review/index.rb +84 -7
  43. data/lib/review/latexbuilder.rb +261 -42
  44. data/lib/review/latexutils.rb +15 -6
  45. data/lib/review/preprocessor.rb +40 -6
  46. data/lib/review/textutils.rb +22 -0
  47. data/lib/review/topbuilder.rb +4 -1
  48. data/lib/uuid.rb +312 -0
  49. data/review.gemspec +44 -12
  50. data/test/CHAPS +2 -0
  51. data/test/bib.re +13 -0
  52. data/test/test.re +43 -0
  53. data/test/test_book.rb +1191 -0
  54. data/test/test_builder.rb +147 -0
  55. data/test/test_htmlbuilder.rb +191 -10
  56. data/test/test_htmlutils.rb +24 -0
  57. data/test/test_idgxmlbuilder.rb +310 -0
  58. data/test/test_index.rb +15 -0
  59. data/test/test_latexbuilder.rb +217 -6
  60. data/test/test_lineinput.rb +198 -0
  61. data/test/test_textutils.rb +68 -0
  62. data/test/test_uuid.rb +156 -0
  63. metadata +43 -10
  64. data/doc/format.txt +0 -434
  65. data/doc/format_idg.txt +0 -194
  66. data/doc/format_sjis.txt +0 -313
  67. data/setup.rb +0 -1587
  68. data/test/test_epubbuilder.rb +0 -73
@@ -0,0 +1,147 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'review/builder'
5
+
6
+ require 'review/book'
7
+
8
+ class MockCompiler
9
+ def text(s)
10
+ [:text, s]
11
+ end
12
+ end
13
+
14
+ class BuidlerTest < Test::Unit::TestCase
15
+ include ReVIEW
16
+
17
+ def setup
18
+ @b = Builder.new
19
+ @b.bind(MockCompiler.new, nil, nil)
20
+ end
21
+
22
+ def test_initialize
23
+ assert Builder.new
24
+ end
25
+
26
+ def test_bind
27
+ b = Builder.new
28
+ assert_nothing_raised do
29
+ b.bind(nil, nil, nil)
30
+ end
31
+ end
32
+
33
+ def test_result
34
+ b = Builder.new
35
+ assert_raises(NoMethodError) do # XXX: OK?
36
+ b.result
37
+ end
38
+
39
+ b = Builder.new
40
+ b.bind(nil, nil, nil)
41
+ assert_equal '', b.result
42
+ end
43
+
44
+ def test_print_and_puts
45
+ b = Builder.new
46
+ assert_raises(NoMethodError) do # XXX: OK?
47
+ b.print ""
48
+ end
49
+ assert_raises(NoMethodError) do # XXX: OK?
50
+ b.puts ""
51
+ end
52
+
53
+ if "".respond_to?(:encode)
54
+ utf8_str = "あいうえお"
55
+ eucjp_str = "あいうえお".encode("EUC-JP")
56
+ sjis_str = "あいうえお".encode("Shift_JIS")
57
+ jis_str = "あいうえお".encode("ISO-2022-JP")
58
+ else
59
+ utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお"
60
+ eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"
61
+ sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"
62
+ jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42"
63
+ end
64
+
65
+ [
66
+ ['EUC', eucjp_str],
67
+ ['SJIS', sjis_str],
68
+ # ['JIS', jis_str],
69
+ # ['jis', jis_str],
70
+ # ['jIs', jis_str],
71
+ ['XYZ', utf8_str],
72
+ ].each do |enc, expect|
73
+ params = {"outencoding" => enc}
74
+
75
+ [
76
+ [:print, utf8_str, expect],
77
+ [:puts, utf8_str, "#{expect}\n"],
78
+ [:print, "#{utf8_str}\n", "#{expect}\n"],
79
+ [:puts, "#{utf8_str}\n", "#{expect}\n"],
80
+ ].each do |m, instr, expstr|
81
+ b = Builder.new
82
+ b.bind(nil, nil, nil)
83
+ ReVIEW.book.param = params
84
+ b.__send__(m, instr)
85
+ if "".respond_to?(:encode)
86
+ assert_equal expstr.encode("UTF-8"), b.result
87
+ else
88
+ assert_equal expstr, b.result
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ def test_not_implemented_methods
95
+ ex = NoMethodError # XXX: OK?
96
+ [
97
+ :list_header, :list_body, :listnum_body,
98
+ :source_header, :source_body,
99
+ :image_image, :image_dummy,
100
+ :table_header, :table_begin, :tr, :th, :table_end,
101
+ :nofunc_text,
102
+ :compile_ruby, :compile_kw, :compile_href,
103
+ :bibpaper_header, :bibpaper_bibpaper,
104
+ :inline_hd_chap,
105
+ ].each do |m|
106
+ b = Builder.new
107
+ assert_raises(ex) { b.__send__(m) }
108
+ end
109
+ end
110
+
111
+ def test_compile_inline
112
+ text = "abc"
113
+ assert_equal [:text, text], @b.compile_inline(text)
114
+ end
115
+
116
+ def test_convert_outencoding_1arg
117
+ ReVIEW.book.param = {'outencoding' => "UTF-8"}
118
+ b = Builder.new
119
+ ret = b.convert_outencoding("a")
120
+ assert_equal "a", ret
121
+ end
122
+
123
+ def test_convert_outencoding_2arg
124
+ ReVIEW.book.param = {'outencoding' => "UTF-8"}
125
+ b = Builder.new
126
+ ret = b.convert_outencoding("a","b")
127
+ assert_equal(["a","b"], ret)
128
+ end
129
+
130
+ class XBuilder < Builder
131
+ def list_header(id, caption)
132
+ end
133
+
134
+ def list_body(lines)
135
+ end
136
+
137
+ def listnum_body(lines)
138
+ end
139
+
140
+ def source_header(caption)
141
+ end
142
+
143
+ def source_body(lines)
144
+ end
145
+ end
146
+ end
147
+
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'test_helper'
2
4
  require 'review/compiler'
3
5
  require 'review/book'
@@ -9,34 +11,213 @@ class HTMLBuidlerTest < Test::Unit::TestCase
9
11
  def setup
10
12
  @builder = HTMLBuilder.new()
11
13
  @param = {
12
- "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
14
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
13
15
  "inencoding" => "UTF-8",
14
16
  "outencoding" => "UTF-8",
15
17
  "subdirmode" => nil,
16
- "stylesheet" => nil, # for EPUBBuilder
18
+ "stylesheet" => nil, # for HTMLBuilder
17
19
  }
18
- compiler = ReVIEW::Compiler.new(@builder)
19
- compiler.setParameter(@param)
20
- chapter = Chapter.new(nil, 1, '-', nil, StringIO.new)
21
- chapter.setParameter(@param)
20
+ ReVIEW.book.param = @param
21
+ @compiler = ReVIEW::Compiler.new(@builder)
22
+ @chapter = Chapter.new(nil, 1, '-', nil, StringIO.new)
22
23
  location = Location.new(nil, nil)
23
- @builder.bind(compiler, chapter, location)
24
+ @builder.bind(@compiler, @chapter, location)
24
25
  end
25
26
 
26
27
  def test_headline_level1
27
28
  @builder.headline(1,"test","this is test.")
28
- assert_equal %Q|<h1 id='test'>this is test.</h1>\n|, @builder.result
29
+ assert_equal %Q|<h1 id="test"><a id="h1" />第1章 this is test.</h1>\n|, @builder.raw_result
30
+ end
31
+
32
+ def test_headline_level1_without_secno
33
+ @param["secnolevel"] = 0
34
+ @builder.headline(1,"test","this is test.")
35
+ assert_equal %Q|<h1 id="test"><a id="h1" />this is test.</h1>\n|, @builder.raw_result
36
+ end
37
+
38
+ def test_headline_level1_with_inlinetag
39
+ @builder.headline(1,"test","this @<b>{is} test.<&\">")
40
+ assert_equal %Q|<h1 id="test"><a id="h1" />第1章 this <b>is</b> test.&lt;&amp;&quot;&gt;</h1>\n|, @builder.raw_result
29
41
  end
30
42
 
31
43
  def test_headline_level2
32
44
  @builder.headline(2,"test","this is test.")
33
- assert_equal %Q|\n<h2 id='test'>this is test.</h2>\n|, @builder.result
45
+ assert_equal %Q|\n<h2 id="test"><a id="h1-1" />1.1 this is test.</h2>\n|, @builder.raw_result
34
46
  end
35
47
 
36
48
  def test_headline_level3
37
49
  @builder.headline(3,"test","this is test.")
38
- assert_equal %Q|\n<h3 id='test'>this is test.</h3>\n|, @builder.result
50
+ assert_equal %Q|\n<h3 id="test"><a id="h1-0-1" />this is test.</h3>\n|, @builder.raw_result
51
+ end
52
+
53
+ def test_headline_level3_with_secno
54
+ @param["secnolevel"] = 3
55
+ @builder.headline(3,"test","this is test.")
56
+ assert_equal %Q|\n<h3 id="test"><a id="h1-0-1" />1.0.1 this is test.</h3>\n|, @builder.raw_result
57
+ end
58
+
59
+ def test_label
60
+ @builder.label("label_test")
61
+ assert_equal %Q|<a id="label_test" />\n|, @builder.raw_result
62
+ end
63
+
64
+ def test_href
65
+ ret = @builder.compile_href("http://github.com", "GitHub")
66
+ assert_equal %Q|<a href="http://github.com" class="link">GitHub</a>|, ret
67
+ end
68
+
69
+ def test_href_without_label
70
+ ret = @builder.compile_href("http://github.com",nil)
71
+ assert_equal %Q|<a href="http://github.com" class="link">http://github.com</a>|, ret
72
+ end
73
+
74
+ def test_inline_raw
75
+ ret = @builder.inline_raw("@<tt>{inline}")
76
+ assert_equal %Q|@&lt;tt&gt;{inline}|, ret
77
+ end
78
+
79
+ def test_inline_in_table
80
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
81
+ assert_equal %Q|<div class="table">\n<table>\n<tr><th><b>1</b></th><th><i>2</i></th></tr>\n<tr><td><b>3</b></td><td><i>4</i>&lt;&gt;&amp;</td></tr>\n</table>\n</div>\n|, @builder.raw_result
82
+ end
83
+
84
+ def test_inline_br
85
+ ret = @builder.inline_br("")
86
+ assert_equal %Q|<br />|, ret
87
+ end
88
+
89
+ def test_inline_i
90
+ ret = @builder.compile_inline("test @<i>{inline test} test2")
91
+ assert_equal %Q|test <i>inline test</i> test2|, ret
92
+ end
93
+
94
+ def test_inline_i_and_escape
95
+ ret = @builder.compile_inline("test @<i>{inline<&;\\ test} test2")
96
+ assert_equal %Q|test <i>inline&lt;&amp;;\\ test</i> test2|, ret
97
+ end
98
+
99
+ def test_inline_b
100
+ ret = @builder.compile_inline("test @<b>{inline test} test2")
101
+ assert_equal %Q|test <b>inline test</b> test2|, ret
102
+ end
103
+
104
+ def test_inline_b_and_escape
105
+ ret = @builder.compile_inline("test @<b>{inline<&;\\ test} test2")
106
+ assert_equal %Q|test <b>inline&lt;&amp;;\\ test</b> test2|, ret
107
+ end
108
+
109
+ def test_inline_tt
110
+ ret = @builder.compile_inline("test @<tt>{inline test} test2")
111
+ assert_equal %Q|test <tt>inline test</tt> test2|, ret
112
+ end
113
+
114
+ def test_inline_tti
115
+ ret = @builder.compile_inline("test @<tti>{inline test} test2")
116
+ assert_equal %Q|test <tt><i>inline test</i></tt> test2|, ret
117
+ end
118
+
119
+ def test_inline_ttb
120
+ ret = @builder.compile_inline("test @<ttb>{inline test} test2")
121
+ assert_equal %Q|test <tt><b>inline test</b></tt> test2|, ret
122
+ end
123
+
124
+ def test_inline_uchar
125
+ ret = @builder.compile_inline("test @<uchar>{2460} test2")
126
+ assert_equal %Q|test &#x2460; test2|, ret
127
+ end
128
+
129
+ def test_quote
130
+ lines = ["foo", "bar", "","buz"]
131
+ @builder.quote(lines)
132
+ assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n|, @builder.raw_result
133
+ end
134
+
135
+ def test_memo
136
+ @builder.memo(["test1", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
137
+ assert_equal %Q|<div class="memo">\n<p class="caption">this is <b>test</b>&lt;&amp;&gt;_</p>\n<p>test1</p>\n<p>test<i>2</i></p>\n</div>\n|, @builder.raw_result
138
+ end
139
+
140
+ def test_noindent
141
+ @builder.noindent
142
+ @builder.paragraph(["foo", "bar"])
143
+ @builder.paragraph(["foo2", "bar2"])
144
+ assert_equal %Q|<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n|, @builder.raw_result
145
+ end
146
+
147
+ def test_flushright
148
+ @builder.flushright(["foo", "bar", "", "buz"])
149
+ assert_equal %Q|<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n|, @builder.raw_result
150
+ end
151
+
152
+ def test_raw
153
+ @builder.raw("<&>\\n")
154
+ assert_equal %Q|<&>\n|, @builder.raw_result
155
+ end
156
+
157
+ def test_image
158
+ def @chapter.image(id)
159
+ item = ImageIndex::Item.new("sampleimg",1)
160
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
161
+ item
162
+ end
163
+
164
+ @builder.image_image("sampleimg","sample photo",nil)
165
+ assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, @builder.raw_result
166
+ end
167
+
168
+ def test_image_with_metric
169
+ def @chapter.image(id)
170
+ item = ImageIndex::Item.new("sampleimg",1)
171
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
172
+ item
173
+ end
174
+
175
+ @builder.image_image("sampleimg","sample photo","scale=1.2")
176
+ assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, @builder.raw_result
177
+ end
178
+
179
+ def test_indepimage
180
+ def @chapter.image(id)
181
+ item = ImageIndex::Item.new("sampleimg",1)
182
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
183
+ item
184
+ end
185
+
186
+ @builder.indepimage("sampleimg","sample photo",nil)
187
+ assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, @builder.raw_result
39
188
  end
40
189
 
190
+ def test_indepimage_without_caption
191
+ def @chapter.image(id)
192
+ item = ImageIndex::Item.new("sampleimg",1)
193
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
194
+ item
195
+ end
196
+
197
+ @builder.indepimage("sampleimg",nil,nil)
198
+ assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n|, @builder.raw_result
199
+ end
200
+
201
+ def test_indepimage_with_metric
202
+ def @chapter.image(id)
203
+ item = ImageIndex::Item.new("sampleimg",1)
204
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
205
+ item
206
+ end
207
+
208
+ @builder.indepimage("sampleimg","sample photo","scale=1.2")
209
+ assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, @builder.raw_result
210
+ end
211
+
212
+ def test_indepimage_without_caption_but_with_metric
213
+ def @chapter.image(id)
214
+ item = ImageIndex::Item.new("sampleimg",1)
215
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
216
+ item
217
+ end
218
+
219
+ @builder.indepimage("sampleimg",nil,"scale=1.2")
220
+ assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n|, @builder.raw_result
221
+ end
41
222
 
42
223
  end
@@ -0,0 +1,24 @@
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_html('<')
9
+ assert_equal '&lt;&lt;', escape_html('<<')
10
+ assert_equal '_&lt;_&lt;_', escape_html('_<_<_')
11
+ end
12
+
13
+ def test_escape_html_ex
14
+ keys = ESC.keys
15
+ ESC['.'] = 'X'
16
+ ESC.each_pair do |ch, ref|
17
+ if keys.include?(ch)
18
+ assert_equal ref, escape_html(ch)
19
+ else
20
+ assert_equal ch, escape_html(ch)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,310 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'review/compiler'
5
+ require 'review/book'
6
+ require 'review/idgxmlbuilder'
7
+
8
+ class IDGXMLBuidlerTest < Test::Unit::TestCase
9
+ include ReVIEW
10
+
11
+ def setup
12
+ @builder = IDGXMLBuilder.new()
13
+ @param = {
14
+ "secnolevel" => 2,
15
+ "inencoding" => "UTF-8",
16
+ "outencoding" => "UTF-8",
17
+ "nolf" => true,
18
+ "tableopt" => "10",
19
+ "subdirmode" => nil,
20
+ }
21
+ ReVIEW.book.param = @param
22
+ @compiler = ReVIEW::Compiler.new(@builder)
23
+ @chapter = Chapter.new(nil, 1, '-', nil, StringIO.new)
24
+ location = Location.new(nil, nil)
25
+ @builder.bind(@compiler, @chapter, location)
26
+ end
27
+
28
+ def test_headline_level1
29
+ @builder.headline(1,"test","this is test.")
30
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h1">第1章 this is test.</title><?dtp level="1" section="第1章 this is test."?>|, @builder.raw_result
31
+ end
32
+
33
+ def test_headline_level1_without_secno
34
+ @param["secnolevel"] = 0
35
+ @builder.headline(1,"test","this is test.")
36
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h1">this is test.</title><?dtp level="1" section="this is test."?>|, @builder.raw_result
37
+ end
38
+
39
+ def test_headline_level2
40
+ @builder.headline(2,"test","this is test.")
41
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h2">1.1 this is test.</title><?dtp level="2" section="1.1 this is test."?>|, @builder.raw_result
42
+ end
43
+
44
+ def test_headline_level3
45
+ @builder.headline(3,"test","this is test.")
46
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h3">this is test.</title><?dtp level="3" section="this is test."?>|, @builder.raw_result
47
+ end
48
+
49
+
50
+ def test_headline_level3_with_secno
51
+ @param["secnolevel"] = 3
52
+ @builder.headline(3,"test","this is test.")
53
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><title id="test" aid:pstyle="h3">1.0.1 this is test.</title><?dtp level="3" section="1.0.1 this is test."?>|, @builder.raw_result
54
+ end
55
+
56
+ def test_label
57
+ @builder.label("label_test")
58
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><label id='label_test' />|, @builder.raw_result
59
+ end
60
+
61
+ def test_href
62
+ ret = @builder.compile_href("http://github.com", "GitHub")
63
+ assert_equal %Q|<a linkurl='http://github.com'>GitHub</a>|, ret
64
+ end
65
+
66
+ def test_href_without_label
67
+ ret = @builder.compile_href("http://github.com",nil)
68
+ assert_equal %Q|<a linkurl='http://github.com'>http://github.com</a>|, ret
69
+ end
70
+
71
+ def test_inline_raw
72
+ ret = @builder.inline_raw("@<tt>{inline}")
73
+ assert_equal %Q|@<tt>{inline}|, ret
74
+ end
75
+
76
+ def test_inline_in_table
77
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
78
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i>&lt;&gt;&amp;</td></tbody></table>|, @builder.raw_result
79
+ end
80
+
81
+ def test_inline_in_table_without_header
82
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
83
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i>&lt;&gt;&amp;</td></tbody></table>|, @builder.raw_result
84
+ end
85
+
86
+ def test_inline_in_table_without_cellwidth
87
+ @param["tableopt"] = nil
88
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
89
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody><tr type="header"><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i>&lt;&gt;&amp;</tr></tbody></table>|, @builder.raw_result
90
+ @param["tableopt"] = 10
91
+ end
92
+
93
+ def test_inline_in_table_without_header_and_cellwidth
94
+ @param["tableopt"] = nil
95
+ ret = @builder.table(["<b>1</b>\t<i>2</i>", "<b>3</b>\t<i>4</i>&lt;&gt;&amp;"])
96
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><table><tbody><tr><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i>&lt;&gt;&amp;</tr></tbody></table>|, @builder.raw_result
97
+ @param["tableopt"] = 10
98
+ end
99
+
100
+ def test_inline_br
101
+ ret = @builder.inline_br("")
102
+ assert_equal %Q|\n|, ret
103
+ end
104
+
105
+ def test_inline_uchar
106
+ ret = @builder.compile_inline("test @<uchar>{2460} test2")
107
+ assert_equal %Q|test &#x2460; test2|, ret
108
+ end
109
+
110
+ def test_inline_ruby
111
+ ret = @builder.compile_ruby("coffin", "bed")
112
+ assert_equal %Q|<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>coffin</aid:rb><aid:rt>bed</aid:rt></aid:ruby></GroupRuby>|, ret
113
+ end
114
+
115
+ def test_inline_kw
116
+ ret = @builder.compile_inline("@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}")
117
+ assert_equal %Q|<keyword>ISO(International Organization for Standardization)</keyword><index value="ISO" /><index value="International Organization for Standardization" /> <keyword>Ruby&lt;&gt;</keyword><index value="Ruby&lt;&gt;" />|, ret
118
+ end
119
+
120
+ def test_inline_maru
121
+ ret = @builder.compile_inline("@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}")
122
+ assert_equal %Q|&#x2460;&#x2473;&#x24b6;&#x24e9;|, ret
123
+ end
124
+
125
+ def test_inline_ttb
126
+ ret = @builder.inline_ttb("test * <>\"")
127
+ assert_equal %Q|<tt style='bold'>test * &lt;&gt;&quot;</tt><index value='test ESCAPED_ASTERISK &lt;&gt;&quot;' />|, ret
128
+ end
129
+
130
+ def test_inline_ttbold
131
+ ret = @builder.inline_ttbold("test * <>\"")
132
+ assert_equal %Q|<tt style='bold'>test * &lt;&gt;&quot;</tt><index value='test ESCAPED_ASTERISK &lt;&gt;&quot;' />|, ret
133
+ end
134
+
135
+ def test_inline_balloon
136
+ ret = @builder.inline_balloon("@maru[1]test")
137
+ assert_equal %Q|<balloon>&#x2460;test</balloon>|, ret
138
+ end
139
+
140
+ def test_inline_m
141
+ ret = @builder.compile_inline("@<m>{\\sin} @<m>{\\frac{1\\}{2\\}}")
142
+ assert_equal %Q|<replace idref="texinline-1"><pre>\\sin</pre></replace> <replace idref="texinline-2"><pre>\\frac{1}{2}</pre></replace>|, ret
143
+ end
144
+
145
+ def test_paragraph
146
+ lines = ["foo","bar"]
147
+ @builder.paragraph(lines)
148
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p>foobar</p>|, @builder.raw_result
149
+ end
150
+
151
+ def test_tabbed_paragraph
152
+ lines = ["\tfoo","bar"]
153
+ @builder.paragraph(lines)
154
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p inlist="1">foobar</p>|, @builder.raw_result
155
+ end
156
+
157
+ def test_quote
158
+ lines = ["foo","bar","","buz"]
159
+ @builder.quote(lines)
160
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><quote><p>foobar</p><p>buz</p></quote>|, @builder.raw_result
161
+ end
162
+
163
+ def test_quote_deprecated
164
+ lines = ["foo","","buz"]
165
+ ReVIEW.book.param["deprecated-blocklines"] = true
166
+ @builder.quote(lines)
167
+ ReVIEW.book.param["deprecated-blocklines"] = nil
168
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><quote>foo\n\nbuz</quote>|, @builder.raw_result
169
+ end
170
+
171
+ def test_note
172
+ @builder.note(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
173
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><note><title aid:pstyle='note-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></note>|, @builder.raw_result
174
+ end
175
+
176
+ def test_memo
177
+ @builder.memo(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
178
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><memo><title aid:pstyle='memo-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></memo>|, @builder.raw_result
179
+ end
180
+
181
+ def test_term
182
+ @builder.term(["test1", "test1.5", "", "test<i>2</i>"])
183
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><term><p>test1test1.5</p><p>test<i>2</i></p></term>|, @builder.raw_result
184
+ end
185
+
186
+ def test_term_deprecated
187
+ ReVIEW.book.param["deprecated-blocklines"] = true
188
+ @builder.term(["test1", "test1.5", "", "test<i>2</i>"])
189
+ ReVIEW.book.param["deprecated-blocklines"] = nil
190
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><term>test1\ntest1.5\n\ntest<i>2</i></term>|, @builder.raw_result
191
+ end
192
+
193
+ def test_notice
194
+ @builder.notice(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
195
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><notice-t><title aid:pstyle='notice-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></notice-t>|, @builder.raw_result
196
+ end
197
+
198
+ def test_notice_without_caption
199
+ @builder.notice(["test1", "test1.5", "", "test<i>2</i>"], nil)
200
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><notice><p>test1test1.5</p><p>test<i>2</i></p></notice>|, @builder.raw_result
201
+ end
202
+
203
+ def test_point
204
+ @builder.point(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
205
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><point-t><title aid:pstyle='point-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></point-t>|, @builder.raw_result
206
+ end
207
+
208
+ def test_point_without_caption
209
+ @builder.point(["test1", "test1.5", "", "test<i>2</i>"], nil)
210
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><point><p>test1test1.5</p><p>test<i>2</i></p></point>|, @builder.raw_result
211
+ end
212
+
213
+ def test_insn
214
+ @param["listinfo"] = true
215
+ @builder.insn(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
216
+ @param["listinfo"] = nil
217
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><insn><floattitle type="insn">this is <b>test</b>&lt;&amp;&gt;_</floattitle><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></insn>|, @builder.raw_result
218
+ end
219
+
220
+ def test_box
221
+ @param["listinfo"] = true
222
+ @builder.box(["test1", "test1.5", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
223
+ @param["listinfo"] = nil
224
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><box><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></box>|, @builder.raw_result
225
+ end
226
+
227
+ def test_flushright
228
+ @builder.flushright(["foo", "bar", "","buz"])
229
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p align='right'>foobar</p><p align='right'>buz</p>|, @builder.raw_result
230
+ end
231
+
232
+ def test_noindent
233
+ @builder.noindent
234
+ @builder.paragraph(["foo", "bar"])
235
+ @builder.paragraph(["foo2", "bar2"])
236
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>|, @builder.raw_result
237
+ end
238
+
239
+ def test_raw
240
+ @builder.raw("<&>\\n")
241
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><&>\n|, @builder.raw_result
242
+ end
243
+
244
+ def test_image
245
+ def @chapter.image(id)
246
+ item = ImageIndex::Item.new("sampleimg",1)
247
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
248
+ item
249
+ end
250
+
251
+ @builder.image_image("sampleimg","sample photo",nil)
252
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result
253
+ end
254
+
255
+ def test_image_with_metric
256
+ def @chapter.image(id)
257
+ item = ImageIndex::Item.new("sampleimg",1)
258
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
259
+ item
260
+ end
261
+
262
+ @builder.image_image("sampleimg","sample photo","scale=1.2")
263
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>|, @builder.raw_result
264
+ end
265
+
266
+ def test_indepimage
267
+ def @chapter.image(id)
268
+ item = ImageIndex::Item.new("sampleimg",1)
269
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
270
+ item
271
+ end
272
+
273
+ @builder.indepimage("sampleimg","sample photo",nil)
274
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>|, @builder.raw_result
275
+ end
276
+
277
+ def test_indepimage_without_caption
278
+ def @chapter.image(id)
279
+ item = ImageIndex::Item.new("sampleimg",1)
280
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
281
+ item
282
+ end
283
+
284
+ @builder.indepimage("sampleimg",nil,nil)
285
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" /></img>|, @builder.raw_result
286
+ end
287
+
288
+ def test_indepimage_with_metric
289
+ def @chapter.image(id)
290
+ item = ImageIndex::Item.new("sampleimg",1)
291
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
292
+ item
293
+ end
294
+
295
+ @builder.indepimage("sampleimg","sample photo","scale=1.2")
296
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>|, @builder.raw_result
297
+ end
298
+
299
+ def test_indepimage_without_caption_but_with_metric
300
+ def @chapter.image(id)
301
+ item = ImageIndex::Item.new("sampleimg",1)
302
+ item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
303
+ item
304
+ end
305
+
306
+ @builder.indepimage("sampleimg",nil,"scale=1.2")
307
+ assert_equal %Q|<?xml version="1.0" encoding="UTF-8"?>\n<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"><img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /></img>|, @builder.raw_result
308
+ end
309
+
310
+ end