review 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +42 -0
  3. data/README.rdoc +31 -0
  4. data/bin/review-catalog-converter +129 -0
  5. data/bin/review-check +4 -2
  6. data/bin/review-compile +7 -7
  7. data/bin/review-index +4 -3
  8. data/bin/review-init +3 -1
  9. data/bin/review-pdfmaker +2 -258
  10. data/bin/review-vol +2 -2
  11. data/doc/catalog.rdoc +18 -3
  12. data/doc/format.rdoc +2 -3
  13. data/doc/quickstart.rdoc +1 -1
  14. data/lib/epubmaker/epubv2.rb +16 -8
  15. data/lib/epubmaker/epubv3.rb +44 -12
  16. data/lib/epubmaker/producer.rb +4 -2
  17. data/lib/review/book.rb +0 -1
  18. data/lib/review/book/base.rb +72 -35
  19. data/lib/review/book/chapter.rb +8 -12
  20. data/lib/review/book/compilable.rb +8 -8
  21. data/lib/review/book/image_finder.rb +7 -0
  22. data/lib/review/book/index.rb +23 -5
  23. data/lib/review/book/volume.rb +2 -1
  24. data/lib/review/builder.rb +10 -5
  25. data/lib/review/catalog.rb +5 -0
  26. data/lib/review/compiler.rb +1 -1
  27. data/lib/review/configure.rb +12 -0
  28. data/lib/review/epubmaker.rb +13 -7
  29. data/lib/review/htmlbuilder.rb +26 -12
  30. data/lib/review/i18n.rb +2 -2
  31. data/lib/review/i18n.yml +21 -0
  32. data/lib/review/idgxmlbuilder.rb +11 -9
  33. data/lib/review/latexbuilder.rb +3 -2
  34. data/lib/review/{review.tex.erb → layout.tex.erb} +9 -1
  35. data/lib/review/markdownbuilder.rb +126 -4
  36. data/lib/review/pdfmaker.rb +291 -0
  37. data/lib/review/tocparser.rb +6 -5
  38. data/lib/review/tocprinter.rb +5 -2
  39. data/lib/review/version.rb +1 -1
  40. data/review.gemspec +1 -1
  41. data/rubocop-todo.yml +13 -0
  42. data/test/test_book.rb +95 -133
  43. data/test/test_book_chapter.rb +16 -21
  44. data/test/test_builder.rb +12 -7
  45. data/test/test_catalog.rb +15 -3
  46. data/test/test_catalog_converter_cmd.rb +73 -0
  47. data/test/test_epubmaker.rb +5 -5
  48. data/test/test_helper.rb +32 -21
  49. data/test/test_htmlbuilder.rb +219 -192
  50. data/test/test_i18n.rb +46 -19
  51. data/test/test_idgxmlbuilder.rb +177 -182
  52. data/test/test_inaobuilder.rb +1 -2
  53. data/test/test_index.rb +20 -0
  54. data/test/test_latexbuilder.rb +175 -183
  55. data/test/test_markdownbuilder.rb +41 -5
  56. data/test/test_pdfmaker.rb +130 -0
  57. data/test/test_topbuilder.rb +92 -96
  58. metadata +10 -6
  59. data/lib/review/book/parameters.rb +0 -98
  60. data/test/test_book_parameter.rb +0 -42
@@ -8,13 +8,12 @@ class INAOBuidlerTest < Test::Unit::TestCase
8
8
  include BookTestHelper
9
9
 
10
10
  def setup
11
- param = {
11
+ @param = {
12
12
  "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
13
13
  "inencoding" => "UTF-8",
14
14
  "outencoding" => "UTF-8",
15
15
  "stylesheet" => nil, # for HTMLBuilder
16
16
  }
17
- ReVIEW.book.config = param
18
17
  end
19
18
 
20
19
  def test_all
@@ -27,5 +27,25 @@ class IndexTest < Test::Unit::TestCase
27
27
  assert_equal 'foo', item.id
28
28
  assert_equal 'bar\\a\\$buz', item.content
29
29
  end
30
+
31
+ def test_HeadelineIndex
32
+ src = <<-EOB
33
+ = chap1
34
+ == sec1-1
35
+ == sec1-2
36
+ === sec1-2-1
37
+ ===[column] column1
38
+ ==== inside_column
39
+ ===[/column]
40
+ ===[column] column2
41
+ === sec1-2-2
42
+ == sec1-3
43
+ ==== sec1-3-0-1
44
+ EOB
45
+ chap = Book::Chapter.new(nil, 1, '-', nil) # dummy
46
+ index = Book::HeadlineIndex.parse(src, chap)
47
+ assert_equal [2,2], index['sec1-2|sec1-2-2'].number
48
+ assert_equal "1.2.2", index.number('sec1-2|sec1-2-2')
49
+ end
30
50
  end
31
51
 
@@ -10,175 +10,177 @@ class LATEXBuidlerTest < Test::Unit::TestCase
10
10
 
11
11
  def setup
12
12
  @builder = LATEXBuilder.new()
13
- @config = {
13
+ @config = ReVIEW::Configure.values
14
+ @config.merge!( {
14
15
  "secnolevel" => 2, # for IDGXMLBuilder, EPUBBuilder
15
16
  "toclevel" => 2,
16
17
  "inencoding" => "UTF-8",
17
18
  "outencoding" => "UTF-8",
18
19
  "stylesheet" => nil, # for EPUBBuilder
19
- }
20
- ReVIEW.book.config = @config
20
+ })
21
+ @book = Book::Base.new(nil)
22
+ @book.config = @config
21
23
  @compiler = ReVIEW::Compiler.new(@builder)
22
- @chapter = Book::Chapter.new(Book::Base.new(nil), 1, 'chap1', nil, StringIO.new)
24
+ @chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
23
25
  location = Location.new(nil, nil)
24
26
  @builder.bind(@compiler, @chapter, location)
25
27
  end
26
28
 
27
29
  def test_headline_level1
28
- @builder.headline(1,"test","this is test.")
29
- assert_equal %Q|\\chapter{this is test.}\n\\label{chap:chap1}\n|, @builder.result
30
+ actual = compile_block("={test} this is test.\n")
31
+ assert_equal %Q|\\chapter{this is test.}\n\\label{chap:chap1}\n|, actual
30
32
  end
31
33
 
32
34
  def test_headline_level1_without_secno
33
35
  @config["secnolevel"] = 0
34
- @builder.headline(1,"test","this is test.")
35
- assert_equal %Q|\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n|, @builder.result
36
+ actual = compile_block("={test} this is test.\n")
37
+ assert_equal %Q|\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n|, actual
36
38
  end
37
39
 
38
40
  def test_headline_level1_with_inlinetag
39
- @builder.headline(1,"test","this @<b>{is} test.<&\"_>")
40
- assert_equal %Q|\\chapter{this \\textbf{is} test.\\textless{}\\&\"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n|, @builder.result
41
+ actual = compile_block("={test} this @<b>{is} test.<&\"_>\n")
42
+ assert_equal %Q|\\chapter{this \\textbf{is} test.\\textless{}\\&\"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n|, actual
41
43
  end
42
44
 
43
45
  def test_headline_level2
44
- @builder.headline(2,"test","this is test.")
45
- assert_equal %Q|\\section{this is test.}\n\\label{sec:1-1}\n|, @builder.result
46
+ actual = compile_block("=={test} this is test.\n")
47
+ assert_equal %Q|\\section{this is test.}\n\\label{sec:1-1}\n|, actual
46
48
  end
47
49
 
48
50
  def test_headline_level3
49
- @builder.headline(3,"test","this is test.")
50
- assert_equal %Q|\\subsection*{this is test.}\n\\label{sec:1-0-1}\n|, @builder.result
51
+ actual = compile_block("==={test} this is test.\n")
52
+ assert_equal %Q|\\subsection*{this is test.}\n\\label{sec:1-0-1}\n|, actual
51
53
  end
52
54
 
53
55
 
54
56
  def test_headline_level3_with_secno
55
57
  @config["secnolevel"] = 3
56
- @builder.headline(3,"test","this is test.")
57
- assert_equal %Q|\\subsection{this is test.}\n\\label{sec:1-0-1}\n|, @builder.result
58
+ actual = compile_block("==={test} this is test.\n")
59
+ assert_equal %Q|\\subsection{this is test.}\n\\label{sec:1-0-1}\n|, actual
58
60
  end
59
61
 
60
62
  def test_label
61
- @builder.label("label_test")
62
- assert_equal %Q|\\label{label_test}\n|, @builder.result
63
+ actual = compile_block("//label[label_test]\n")
64
+ assert_equal %Q|\\label{label_test}\n|, actual
63
65
  end
64
66
 
65
67
  def test_href
66
- ret = @builder.compile_inline('@<href>{http://github.com,GitHub}')
67
- assert_equal %Q|\\href{http://github.com}{GitHub}|, ret
68
+ actual = compile_inline("@<href>{http://github.com,GitHub}")
69
+ assert_equal %Q|\\href{http://github.com}{GitHub}|, actual
68
70
  end
69
71
 
70
72
  def test_inline_href
71
- ret = @builder.compile_inline('@<href>{http://github.com,Git\\,Hub}')
72
- assert_equal %Q|\\href{http://github.com}{Git,Hub}|, ret
73
+ actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
74
+ assert_equal %Q|\\href{http://github.com}{Git,Hub}|, actual
73
75
  end
74
76
 
75
77
  def test_href_without_label
76
- ret = @builder.compile_inline('@<href>{http://github.com}')
77
- assert_equal %Q|\\url{http://github.com}|, ret
78
+ actual = compile_inline('@<href>{http://github.com}')
79
+ assert_equal %Q|\\url{http://github.com}|, actual
78
80
  end
79
81
 
80
82
  def test_href_with_underscore
81
- ret = @builder.compile_inline('@<href>{http://example.com/aaa/bbb, AAA_BBB}')
82
- assert_equal %Q|\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}|, ret
83
+ actual = compile_inline('@<href>{http://example.com/aaa/bbb, AAA_BBB}')
84
+ assert_equal %Q|\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}|, actual
83
85
  end
84
86
 
85
87
  def test_href_mailto
86
- ret = @builder.compile_inline('@<href>{mailto:takahashim@example.com, takahashim@example.com}')
87
- assert_equal %Q|\\href{mailto:takahashim@example.com}{takahashim@example.com}|, ret
88
+ actual = compile_inline('@<href>{mailto:takahashim@example.com, takahashim@example.com}')
89
+ assert_equal %Q|\\href{mailto:takahashim@example.com}{takahashim@example.com}|, actual
88
90
  end
89
91
 
90
92
  def test_inline_br
91
- ret = @builder.inline_br("")
92
- assert_equal %Q|\\\\\n|, ret
93
+ actual = compile_inline("@<br>{}")
94
+ assert_equal %Q|\\\\\n|, actual
93
95
  end
94
96
 
95
97
  def test_inline_br_with_other_strings
96
- ret = @builder.compile_inline("abc@<br>{}def")
97
- assert_equal %Q|abc\\\\\ndef|, ret
98
+ actual = compile_inline("abc@<br>{}def")
99
+ assert_equal %Q|abc\\\\\ndef|, actual
98
100
  end
99
101
 
100
102
  def test_inline_i
101
- ret = @builder.compile_inline("abc@<i>{def}ghi")
102
- assert_equal %Q|abc\\textit{def}ghi|, ret
103
+ actual = compile_inline("abc@<i>{def}ghi")
104
+ assert_equal %Q|abc\\textit{def}ghi|, actual
103
105
  end
104
106
 
105
107
  def test_inline_i_and_escape
106
- ret = @builder.compile_inline("test @<i>{inline<&;\\ test} test2")
107
- assert_equal %Q|test \\textit{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, ret
108
+ actual = compile_inline("test @<i>{inline<&;\\ test} test2")
109
+ assert_equal %Q|test \\textit{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, actual
108
110
  end
109
111
 
110
112
  def test_inline_dtp
111
- ret = @builder.compile_inline("abc@<dtp>{def}ghi")
112
- assert_equal %Q|abcghi|, ret
113
+ actual = compile_inline("abc@<dtp>{def}ghi")
114
+ assert_equal %Q|abcghi|, actual
113
115
  end
114
116
 
115
117
  def test_inline_code
116
- ret = @builder.compile_inline("abc@<code>{def}ghi")
117
- assert_equal %Q|abc\\texttt{def}ghi|, ret
118
+ actual = compile_inline("abc@<code>{def}ghi")
119
+ assert_equal %Q|abc\\texttt{def}ghi|, actual
118
120
  end
119
121
 
120
122
  def test_inline_raw
121
- ret = @builder.compile_inline("@<raw>{@<tt>{inline!$%\\}}")
122
- assert_equal "@<tt>{inline!$%}", ret
123
+ actual = compile_inline("@<raw>{@<tt>{inline!$%\\}}")
124
+ assert_equal "@<tt>{inline!$%}", actual
123
125
  end
124
126
 
125
127
  def test_inline_sup
126
- ret = @builder.compile_inline("abc@<sup>{def}")
127
- assert_equal %Q|abc\\textsuperscript{def}|, ret
128
+ actual = compile_inline("abc@<sup>{def}")
129
+ assert_equal %Q|abc\\textsuperscript{def}|, actual
128
130
  end
129
131
 
130
132
  def test_inline_sub
131
- ret = @builder.compile_inline("abc@<sub>{def}")
132
- assert_equal %Q|abc\\textsubscript{def}|, ret
133
+ actual = compile_inline("abc@<sub>{def}")
134
+ assert_equal %Q|abc\\textsubscript{def}|, actual
133
135
  end
134
136
 
135
137
  def test_inline_b
136
- ret = @builder.compile_inline("abc@<b>{def}")
137
- assert_equal %Q|abc\\textbf{def}|, ret
138
+ actual = compile_inline("abc@<b>{def}")
139
+ assert_equal %Q|abc\\textbf{def}|, actual
138
140
  end
139
141
 
140
142
  def test_inline_b_and_escape
141
- ret = @builder.compile_inline("test @<b>{inline<&;\\ test} test2")
142
- assert_equal %Q|test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, ret
143
+ actual = compile_inline("test @<b>{inline<&;\\ test} test2")
144
+ assert_equal %Q|test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2|, actual
143
145
  end
144
146
  def test_inline_em
145
- ret = @builder.compile_inline("abc@<em>{def}")
146
- assert_equal %Q|abc\\reviewem{def}|, ret
147
+ actual = compile_inline("abc@<em>{def}")
148
+ assert_equal %Q|abc\\reviewem{def}|, actual
147
149
  end
148
150
 
149
151
  def test_inline_strong
150
- ret = @builder.compile_inline("abc@<strong>{def}")
151
- assert_equal %Q|abc\\reviewstrong{def}|, ret
152
+ actual = compile_inline("abc@<strong>{def}")
153
+ assert_equal %Q|abc\\reviewstrong{def}|, actual
152
154
  end
153
155
 
154
156
  def test_inline_u
155
- ret = @builder.compile_inline("abc@<u>{def}ghi")
156
- assert_equal %Q|abc\\Underline{def}ghi|, ret
157
+ actual = compile_inline("abc@<u>{def}ghi")
158
+ assert_equal %Q|abc\\Underline{def}ghi|, actual
157
159
  end
158
160
 
159
161
  def test_inline_m
160
- ret = @builder.compile_inline("abc@<m>{\\alpha^n = \inf < 2}ghi")
161
- assert_equal "abc $\\alpha^n = inf < 2$ ghi", ret
162
+ actual = compile_inline("abc@<m>{\\alpha^n = \inf < 2}ghi")
163
+ assert_equal "abc $\\alpha^n = inf < 2$ ghi", actual
162
164
  end
163
165
 
164
166
  def test_inline_tt
165
- ret = @builder.compile_inline("test @<tt>{inline test} test2")
166
- assert_equal %Q|test \\texttt{inline test} test2|, ret
167
+ actual = compile_inline("test @<tt>{inline test} test2")
168
+ assert_equal %Q|test \\texttt{inline test} test2|, actual
167
169
  end
168
170
 
169
171
  def test_inline_tt_endash
170
- ret = @builder.compile_inline("test @<tt>{in-line --test ---foo ----bar -----buz} --test2")
171
- assert_equal %Q|test \\texttt{in{-}line {-}{-}test {-}{-}{-}foo {-}{-}{-}{-}bar {-}{-}{-}{-}{-}buz} {-}{-}test2|, ret
172
+ actual = compile_inline("test @<tt>{in-line --test ---foo ----bar -----buz} --test2")
173
+ assert_equal %Q|test \\texttt{in{-}line {-}{-}test {-}{-}{-}foo {-}{-}{-}{-}bar {-}{-}{-}{-}{-}buz} {-}{-}test2|, actual
172
174
  end
173
175
 
174
176
  def test_inline_tti
175
- ret = @builder.compile_inline("test @<tti>{inline test} test2")
176
- assert_equal %Q|test \\texttt{\\textit{inline test}} test2|, ret
177
+ actual = compile_inline("test @<tti>{inline test} test2")
178
+ assert_equal %Q|test \\texttt{\\textit{inline test}} test2|, actual
177
179
  end
178
180
 
179
181
  def test_inline_ttb
180
- ret = @builder.compile_inline("test @<ttb>{inline test} test2")
181
- assert_equal %Q|test \\texttt{\\textbf{inline test}} test2|, ret
182
+ actual = compile_inline("test @<ttb>{inline test} test2")
183
+ assert_equal %Q|test \\texttt{\\textbf{inline test}} test2|, actual
182
184
  end
183
185
 
184
186
  def test_inline_hd_chap
@@ -188,109 +190,94 @@ class LATEXBuidlerTest < Test::Unit::TestCase
188
190
  end
189
191
 
190
192
  @config["secnolevel"] = 3
191
- ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
192
- assert_equal %Q|test 「1.1.1 te\\textunderscore{}st」 test2|, ret
193
+ actual = compile_inline("test @<hd>{chap1|test} test2")
194
+ assert_equal %Q|test 「1.1.1 te\\textunderscore{}st」 test2|, actual
193
195
  end
194
196
 
195
197
  def test_inline_ruby_comma
196
- ret = @builder.compile_inline("@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}")
197
- assert_equal "\\ruby{foo, bar, buz}{フー・バー・バズ}", ret
198
+ actual = compile_inline("@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}")
199
+ assert_equal "\\ruby{foo, bar, buz}{フー・バー・バズ}", actual
198
200
  end
199
201
 
200
202
  def test_inline_uchar
201
- ret = @builder.compile_inline("test @<uchar>{2460} test2")
202
- assert_equal %Q|test \\UTF{2460} test2|, ret
203
+ actual = compile_inline("test @<uchar>{2460} test2")
204
+ assert_equal %Q|test \\UTF{2460} test2|, actual
203
205
  end
204
206
 
205
207
  def test_inline_idx
206
- ret = @builder.compile_inline("@<idx>{__TEST%$}, @<hidx>{__TEST%$}")
207
- assert_equal %Q|\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$}, \\index{__TEST%$}|, ret
208
+ actual = compile_inline("@<idx>{__TEST%$}, @<hidx>{__TEST%$}")
209
+ assert_equal %Q|\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$}, \\index{__TEST%$}|, actual
208
210
  end
209
211
 
210
212
  def test_jis_x_0201_kana
211
- ret = @builder.compile_inline("foo・カンジ、テスト")
212
- assert_equal %Q|foo\\aj半角{・}\\aj半角{カ}\\aj半角{ン}\\aj半角{シ}\\aj半角{゛}\\aj半角{、}テスト|, ret
213
+ actual = compile_inline("foo・カンジ、テスト")
214
+ assert_equal %Q|foo\\aj半角{・}\\aj半角{カ}\\aj半角{ン}\\aj半角{シ}\\aj半角{゛}\\aj半角{、}テスト|, actual
213
215
  end
214
216
 
215
217
  def test_dlist
216
- @builder.dl_begin
217
- @builder.dt "foo"
218
- @builder.dd ["foo.\n", "bar.\n"]
219
- @builder.dl_end
220
- assert_equal %Q|\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\nbar.\n\\end{description}\n|, @builder.result
218
+ actual = compile_block(": foo\n foo.\n bar.\n")
219
+ assert_equal %Q|\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n|, actual
221
220
  end
222
221
 
223
222
  def test_dlist_with_bracket
224
- @builder.dl_begin
225
- @builder.dt "foo[bar]"
226
- @builder.dd ["foo.\n", "bar.\n"]
227
- @builder.dl_end
228
- assert_equal %Q|\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.\nbar.\n\\end{description}\n|, @builder.result
223
+ actual = compile_block(": foo[bar]\n foo.\n bar.\n")
224
+ assert_equal %Q|\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n|, actual
229
225
  end
230
226
 
231
227
  def test_cmd
232
- lines = ["foo", "bar", "","buz"]
233
- @builder.cmd(lines)
234
- assert_equal %Q|\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, @builder.result
228
+ actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
229
+ assert_equal %Q|\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, actual
235
230
  end
236
231
 
237
232
  def test_cmd_caption
238
- lines = ["foo", "bar", "","buz"]
239
- @builder.cmd(lines, "cap1")
240
- assert_equal %Q|\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, @builder.result
233
+ actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
234
+ assert_equal %Q|\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n|, actual
241
235
  end
242
236
 
243
237
  def test_emlist
244
- lines = ["foo", "bar", "","buz"]
245
- @builder.emlist(lines)
246
- assert_equal %Q|\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, @builder.result
238
+ actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
239
+ assert_equal %Q|\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, actual
247
240
  end
248
241
 
249
242
  def test_emlist_caption
250
- lines = ["foo", "bar", "","buz"]
251
- @builder.emlist(lines, "cap1")
252
- assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, @builder.result
243
+ actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
244
+ assert_equal %Q|\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n|, actual
253
245
  end
254
246
 
255
247
  def test_emlist_with_tab
256
- lines = ["\tfoo", "\t\tbar", "","\tbuz"]
257
- @builder.emlist(lines)
258
- assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, @builder.result
248
+ actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
249
+ assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, actual
259
250
  end
260
251
 
261
252
  def test_emlist_with_tab4
262
- lines = ["\tfoo", "\t\tbar", "","\tbuz"]
263
- @builder.instance_eval{@tabwidth=4}
264
- @builder.emlist(lines)
265
- assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, @builder.result
253
+ @config["tabwidth"] = 4
254
+ actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
255
+ assert_equal %Q|\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n|, actual
266
256
  end
267
257
 
268
258
  def test_quote
269
- lines = ["foo", "bar", "","buz"]
270
- @builder.quote(lines)
271
- assert_equal %Q|\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n|, @builder.result
259
+ actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
260
+ assert_equal %Q|\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n|, actual
272
261
  end
273
262
 
274
263
  def test_memo
275
- @builder.memo(["test1", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
276
- assert_equal %Q|\\begin{reviewminicolumn}\n\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}\ntest1\n\ntest<i>2</i>\n\\end{reviewminicolumn}\n|, @builder.result
264
+ actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
265
+ assert_equal %Q|\\begin{reviewminicolumn}\n\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}\ntest1\n\ntest\\textit{2}\n\\end{reviewminicolumn}\n|, actual
277
266
  end
278
267
 
279
268
  def test_flushright
280
- @builder.flushright(["foo", "bar", "","buz"])
281
- assert_equal %Q|\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n|, @builder.raw_result
269
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
270
+ assert_equal %Q|\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n|, actual
282
271
  end
283
272
 
284
273
  def test_centering
285
- @builder.centering(["foo", "bar", "","buz"])
286
- assert_equal %Q|\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n|, @builder.raw_result
274
+ actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
275
+ assert_equal %Q|\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n|, actual
287
276
  end
288
277
 
289
278
  def test_noindent
290
- @builder.noindent
291
- @builder.paragraph(["foo", "bar"])
292
- @builder.paragraph(["foo2", "bar2"])
293
- assert_equal %Q|\\noindent\nfoo\nbar\n\nfoo2\nbar2\n|, @builder.raw_result
279
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
280
+ assert_equal %Q|\\noindent\nfoo\nbar\n\nfoo2\nbar2\n|, actual
294
281
  end
295
282
 
296
283
  def test_image
@@ -300,8 +287,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
300
287
  item
301
288
  end
302
289
 
303
- @builder.image_image("sampleimg","sample photo",nil)
304
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, @builder.raw_result
290
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
291
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, actual
305
292
  end
306
293
 
307
294
  def test_image_with_metric
@@ -311,8 +298,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
311
298
  item
312
299
  end
313
300
 
314
- @builder.image_image("sampleimg","sample photo","scale=1.2")
315
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, @builder.raw_result
301
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
302
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, actual
316
303
  end
317
304
 
318
305
  def test_image_with_metric2
@@ -322,8 +309,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
322
309
  item
323
310
  end
324
311
 
325
- @builder.image_image("sampleimg","sample photo","scale=1.2, html::class=\"sample\", latex::height=3cm")
326
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,height=3cm]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, @builder.raw_result
312
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
313
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n|, actual
327
314
  end
328
315
 
329
316
  def test_indepimage
@@ -333,8 +320,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
333
320
  item
334
321
  end
335
322
 
336
- @builder.indepimage("sampleimg","sample photo",nil)
337
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
323
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
324
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, actual
338
325
  end
339
326
 
340
327
  def test_indepimage_without_caption
@@ -345,8 +332,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
345
332
  end
346
333
 
347
334
  # FIXME: indepimage's caption should not be with a counter.
348
- @builder.indepimage("sampleimg",nil,nil)
349
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, @builder.raw_result
335
+ actual = compile_block("//indepimage[sampleimg]\n")
336
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, actual
350
337
  end
351
338
 
352
339
  def test_indepimage_with_metric
@@ -356,8 +343,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
356
343
  item
357
344
  end
358
345
 
359
- @builder.indepimage("sampleimg","sample photo","scale=1.2")
360
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
346
+ actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
347
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, actual
361
348
  end
362
349
 
363
350
  def test_indepimage_with_metric2
@@ -367,8 +354,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
367
354
  item
368
355
  end
369
356
 
370
- @builder.indepimage("sampleimg","sample photo","scale=1.2, latex::height=3cm, html::class=\"sample\"")
371
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,height=3cm]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, @builder.raw_result
357
+ actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\",latex::ignore=params]\n")
358
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n|, actual
372
359
  end
373
360
 
374
361
  def test_indepimage_without_caption_but_with_metric
@@ -379,8 +366,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
379
366
  end
380
367
 
381
368
  # FIXME: indepimage's caption should not be with a counter.
382
- @builder.indepimage("sampleimg",nil,"scale=1.2")
383
- assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, @builder.raw_result
369
+ actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
370
+ assert_equal %Q|\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n|, actual
384
371
  end
385
372
 
386
373
  def test_bib
@@ -388,7 +375,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
388
375
  Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
389
376
  end
390
377
 
391
- assert_equal "\\reviewbibref{[1]}{bib:samplebib}", @builder.inline_bib("samplebib")
378
+ assert_equal "\\reviewbibref{[1]}{bib:samplebib}", compile_inline("@<bib>{samplebib}")
392
379
  end
393
380
 
394
381
  def test_bibpaper
@@ -396,8 +383,8 @@ class LATEXBuidlerTest < Test::Unit::TestCase
396
383
  Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
397
384
  end
398
385
 
399
- @builder.bibpaper(["a", "b"], "samplebib", "sample bib @<b>{bold}")
400
- assert_equal %Q|[1] sample bib \\textbf{bold}\n\\label{bib:samplebib}\n\nab\n\n|, @builder.raw_result
386
+ actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
387
+ assert_equal %Q|[1] sample bib \\textbf{bold}\n\\label{bib:samplebib}\n\nab\n\n|, actual
401
388
  end
402
389
 
403
390
  def test_bibpaper_without_body
@@ -405,14 +392,12 @@ class LATEXBuidlerTest < Test::Unit::TestCase
405
392
  Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
406
393
  end
407
394
 
408
- @builder.bibpaper([], "samplebib", "sample bib")
409
- assert_equal %Q|[1] sample bib\n\\label{bib:samplebib}\n\n|, @builder.raw_result
395
+ actual = compile_block("//bibpaper[samplebib][sample bib]\n")
396
+ assert_equal %Q|[1] sample bib\n\\label{bib:samplebib}\n\n|, actual
410
397
  end
411
398
 
412
399
  def column_helper(review)
413
- chap_singleton = class << @chapter; self; end
414
- chap_singleton.send(:define_method, :content) { review }
415
- @compiler.compile(@chapter)
400
+ compile_block(review)
416
401
  end
417
402
 
418
403
  def test_column_1
@@ -427,7 +412,7 @@ inside column
427
412
 
428
413
  ===[/column]
429
414
  EOS
430
- expect =<<-EOS
415
+ expected =<<-EOS
431
416
 
432
417
  \\begin{reviewcolumn}
433
418
  \\hypertarget{column:chap1:1}{}
@@ -448,7 +433,7 @@ inside column
448
433
  \\end{reviewcolumn}
449
434
  EOS
450
435
  @config["toclevel"] = 3
451
- assert_equal expect, column_helper(review)
436
+ assert_equal expected, column_helper(review)
452
437
  end
453
438
 
454
439
  def test_column_2
@@ -459,7 +444,7 @@ inside column
459
444
 
460
445
  === next level
461
446
  EOS
462
- expect =<<-EOS
447
+ expected =<<-EOS
463
448
 
464
449
  \\begin{reviewcolumn}
465
450
  \\hypertarget{column:chap1:1}{}
@@ -474,7 +459,7 @@ inside column
474
459
  EOS
475
460
 
476
461
  @config["toclevel"] = 1
477
- assert_equal expect, column_helper(review)
462
+ assert_equal expected, column_helper(review)
478
463
  end
479
464
 
480
465
  def test_column_3
@@ -495,14 +480,15 @@ EOS
495
480
  * AAA
496
481
  * BBB
497
482
  EOS
498
- expect =<<-EOS
483
+ expected =<<-EOS
499
484
 
500
485
  \\begin{itemize}
501
486
  \\item AAA
502
487
  \\item BBB
503
488
  \\end{itemize}
504
489
  EOS
505
- ul_helper(src, expect)
490
+ actual = compile_block(src)
491
+ assert_equal expected, actual
506
492
  end
507
493
 
508
494
  def test_ul_with_bracket
@@ -510,14 +496,15 @@ EOS
510
496
  * AAA
511
497
  * []BBB
512
498
  EOS
513
- expect =<<-EOS
499
+ expected =<<-EOS
514
500
 
515
501
  \\begin{itemize}
516
502
  \\item AAA
517
503
  \\item \\lbrack{}]BBB
518
504
  \\end{itemize}
519
505
  EOS
520
- ul_helper(src, expect)
506
+ actual = compile_block(src)
507
+ assert_equal expected, actual
521
508
  end
522
509
 
523
510
  def test_cont
@@ -527,14 +514,15 @@ EOS
527
514
  * BBB
528
515
  -BB
529
516
  EOS
530
- expect =<<-EOS
517
+ expected =<<-EOS
531
518
 
532
519
  \\begin{itemize}
533
520
  \\item AAA{-}AA
534
521
  \\item BBB{-}BB
535
522
  \\end{itemize}
536
523
  EOS
537
- ul_helper(src, expect)
524
+ actual = compile_block(src)
525
+ assert_equal expected, actual
538
526
  end
539
527
 
540
528
  def test_ul_nest1
@@ -543,7 +531,7 @@ EOS
543
531
  ** AA
544
532
  EOS
545
533
 
546
- expect =<<-EOS
534
+ expected =<<-EOS
547
535
 
548
536
  \\begin{itemize}
549
537
  \\item AAA
@@ -554,7 +542,8 @@ EOS
554
542
 
555
543
  \\end{itemize}
556
544
  EOS
557
- ul_helper(src, expect)
545
+ actual = compile_block(src)
546
+ assert_equal expected, actual
558
547
  end
559
548
 
560
549
  def test_ul_nest3
@@ -565,7 +554,7 @@ EOS
565
554
  ** BB
566
555
  EOS
567
556
 
568
- expect =<<-EOS
557
+ expected =<<-EOS
569
558
 
570
559
  \\begin{itemize}
571
560
  \\item AAA
@@ -582,7 +571,8 @@ EOS
582
571
 
583
572
  \\end{itemize}
584
573
  EOS
585
- ul_helper(src, expect)
574
+ actual = compile_block(src)
575
+ assert_equal expected, actual
586
576
  end
587
577
 
588
578
  def test_ol
@@ -591,14 +581,15 @@ EOS
591
581
  3. BBB
592
582
  EOS
593
583
 
594
- expect =<<-EOS
584
+ expected =<<-EOS
595
585
 
596
586
  \\begin{enumerate}
597
587
  \\item AAA
598
588
  \\item BBB
599
589
  \\end{enumerate}
600
590
  EOS
601
- ol_helper(src, expect)
591
+ actual = compile_block(src)
592
+ assert_equal expected, actual
602
593
  end
603
594
 
604
595
  def test_ol_with_bracket
@@ -606,73 +597,74 @@ EOS
606
597
  1. AAA
607
598
  2. []BBB
608
599
  EOS
609
- expect =<<-EOS
600
+ expected =<<-EOS
610
601
 
611
602
  \\begin{enumerate}
612
603
  \\item AAA
613
604
  \\item \\lbrack{}]BBB
614
605
  \\end{enumerate}
615
606
  EOS
616
- builder_helper(src, expect, :compile_olist)
607
+ actual = compile_block(src)
608
+ assert_equal expected, actual
617
609
  end
618
610
 
619
611
  def test_inline_raw0
620
- assert_equal "normal", @builder.inline_raw("normal")
612
+ assert_equal "normal", compile_inline("@<raw>{normal}")
621
613
  end
622
614
 
623
615
  def test_inline_raw1
624
- assert_equal "body", @builder.inline_raw("|latex|body")
616
+ assert_equal "body", compile_inline("@<raw>{|latex|body}")
625
617
  end
626
618
 
627
619
  def test_inline_raw2
628
- assert_equal "body", @builder.inline_raw("|html, latex|body")
620
+ assert_equal "body", compile_inline("@<raw>{|html, latex|body}")
629
621
  end
630
622
 
631
623
  def test_inline_raw3
632
- assert_equal "", @builder.inline_raw("|idgxml, html|body")
624
+ assert_equal "", compile_inline("@<raw>{|idgxml, html|body}")
633
625
  end
634
626
 
635
627
  def test_inline_raw4
636
- assert_equal "|latex body", @builder.inline_raw("|latex body")
628
+ assert_equal "|latex body", compile_inline("@<raw>{|latex body}")
637
629
  end
638
630
 
639
631
  def test_inline_raw5
640
- assert_equal "nor\nmal", @builder.inline_raw("|latex|nor\\nmal")
632
+ assert_equal "nor\nmal", compile_inline("@<raw>{|latex|nor\\nmal}")
641
633
  end
642
634
 
643
635
  def test_inline_endash
644
- ret = @builder.compile_inline("- -- --- ----")
645
- assert_equal "{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}", ret
636
+ actual = compile_inline("- -- --- ----")
637
+ assert_equal "{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}", actual
646
638
  end
647
639
 
648
640
  def test_block_raw0
649
- @builder.raw("<>!\"\\n& ")
650
- expect = %Q(<>!\"\n& )
651
- assert_equal expect.chomp, @builder.raw_result
641
+ actual = compile_block("//raw[<>!\"\\n& ]\n")
642
+ expected = %Q(<>!\"\n& )
643
+ assert_equal expected, actual
652
644
  end
653
645
 
654
646
  def test_block_raw1
655
- @builder.raw("|latex|<>!\"\\n& ")
656
- expect = %Q(<>!\"\n& )
657
- assert_equal expect.chomp, @builder.raw_result
647
+ actual = compile_block("//raw[|latex|<>!\"\\n& ]\n")
648
+ expected = %Q(<>!\"\n& )
649
+ assert_equal expected, actual
658
650
  end
659
651
 
660
652
  def test_block_raw2
661
- @builder.raw("|html, latex|<>!\"\\n& ")
662
- expect = %Q(<>!\"\n& )
663
- assert_equal expect.chomp, @builder.raw_result
653
+ actual = compile_block("//raw[|html, latex|<>!\"\\n& ]\n")
654
+ expected = %Q(<>!\"\n& )
655
+ assert_equal expected, actual
664
656
  end
665
657
 
666
658
  def test_block_raw3
667
- @builder.raw("|html, idgxml|<>!\"\\n& ")
668
- expect = ''
669
- assert_equal expect.chomp, @builder.raw_result
659
+ actual = compile_block("//raw[|html, idgxml|<>!\"\\n& ]\n")
660
+ expected = ''
661
+ assert_equal expected, actual
670
662
  end
671
663
 
672
664
  def test_block_raw4
673
- @builder.raw("|latex <>!\"\\n& ")
674
- expect = %Q(|latex <>!\"\n& )
675
- assert_equal expect.chomp, @builder.raw_result
665
+ actual = compile_block("//raw[|latex <>!\"\\n& ]\n")
666
+ expected = %Q(|latex <>!\"\n& )
667
+ assert_equal expected, actual
676
668
  end
677
669
 
678
670
  end