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
@@ -3,7 +3,7 @@
3
3
  require 'test_helper'
4
4
  require 'review/compiler'
5
5
  require 'review/book'
6
- require 'review/htmlbuilder'
6
+ require 'review/markdownbuilder'
7
7
  require 'review/i18n'
8
8
 
9
9
  class MARKDOWNBuilderTest < Test::Unit::TestCase
@@ -17,19 +17,55 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase
17
17
  "outencoding" => "UTF-8",
18
18
  "stylesheet" => nil, # for HTMLBuilder
19
19
  }
20
- ReVIEW.book.config = @config
20
+ @book = Book::Base.new(nil)
21
+ @book.config = @config
21
22
  @compiler = ReVIEW::Compiler.new(@builder)
22
- @chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
23
+ @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
23
24
  location = Location.new(nil, nil)
24
25
  @builder.bind(@compiler, @chapter, location)
25
26
  end
26
27
 
28
+ def test_quote
29
+ actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
30
+ assert_equal %Q|\n> foobar\n> \n> buz\n\n|, actual
31
+ end
32
+
27
33
  def test_inline_em
28
- assert_equal "test*foo*abc", @builder.compile_inline("test@<em>{foo}abc")
34
+ assert_equal "test*foo*abc", compile_inline("test@<em>{foo}abc")
29
35
  end
30
36
 
31
37
  def test_inline_strong
32
- assert_equal "test**foo**abc", @builder.compile_inline("test@<strong>{foo}abc")
38
+ assert_equal "test**foo**abc", compile_inline("test@<strong>{foo}abc")
33
39
  end
34
40
 
41
+ def test_ul
42
+ src =<<-EOS
43
+ * AAA
44
+ * BBB
45
+ EOS
46
+ expected = "\n* AAA\n* BBB\n\n"
47
+ actual = compile_block(src)
48
+ assert_equal expected, actual
49
+ end
50
+
51
+ def test_ul_nest1
52
+ src =<<-EOS
53
+ * AAA
54
+ ** AA
55
+ *** A
56
+ EOS
57
+ expected = "\n* AAA\n * AA\n * A\n\n"
58
+ actual = compile_block(src)
59
+ assert_equal expected, actual
60
+ end
61
+
62
+ def test_cmd
63
+ actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
64
+ assert_equal "```\nlineA\nlineB\n```\n", actual
65
+ end
66
+
67
+ def test_table
68
+ actual = compile_block("//table{\ntestA\ttestB\n------------\ncontentA\tcontentB\n//}\n")
69
+ assert_equal "|testA|testB|\n|:--|:--|\n|contentA|contentB|\n\n", actual
70
+ end
35
71
  end
@@ -0,0 +1,130 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'review/pdfmaker'
5
+
6
+ class PDFMakerTest < Test::Unit::TestCase
7
+ include ReVIEW
8
+
9
+ def setup
10
+ @maker = ReVIEW::PDFMaker.new
11
+ @config = ReVIEW::Configure.values
12
+ @config.merge!({
13
+ "bookname" => "sample",
14
+ "title" => "Sample Book",
15
+ "version" => 2,
16
+ "urnid" => "http://example.jp/",
17
+ "date" => "2011-01-01",
18
+ "language" => "en",
19
+ })
20
+ @output = StringIO.new
21
+ end
22
+
23
+ def test_check_book_existed
24
+ Dir.mktmpdir do |dir|
25
+ Dir.chdir(dir) do
26
+ FileUtils.touch(File.join(dir, "sample.pdf"))
27
+ assert_raises SystemExit do
28
+ @maker.check_book(@config)
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ def test_check_book_none
35
+ Dir.mktmpdir do |dir|
36
+ assert_nothing_raised do
37
+ @maker.check_book(@config)
38
+ end
39
+ end
40
+ end
41
+
42
+ def test_buildpath
43
+ assert_equal(@maker.build_path(@config), "./sample-pdf")
44
+ end
45
+
46
+ def test_parse_opts_help
47
+ io = StringIO.new
48
+ $stdout = io
49
+ assert_raises SystemExit do
50
+ @maker.parse_opts(["-h"])
51
+ end
52
+ $stdout = STDOUT
53
+ io.rewind
54
+ str = io.gets
55
+ assert_equal "Usage: review-pdfmaker configfile\n", str
56
+ end
57
+
58
+ def test_parse_opts_ignore_errors
59
+ io = StringIO.new
60
+ conf, yml = @maker.parse_opts(["--ignore-errors", "hoge.yml"])
61
+ assert_equal conf["ignore-errors"], true
62
+ assert_equal yml, "hoge.yml"
63
+ end
64
+
65
+ def test_make_custom_titlepage
66
+ Dir.mktmpdir do |dir|
67
+ coverfile = "cover.html"
68
+ content = "<html><body>test</body></html>"
69
+ File.open(File.join(dir, "cover.tex"),"w"){|f| f.write(content) }
70
+ page = @maker.make_custom_titlepage(File.join(dir, coverfile))
71
+ assert_equal(content, page)
72
+ end
73
+ end
74
+
75
+ def test_make_authors
76
+ @config.merge!({"aut"=>["テスト太郎","テスト次郎"],
77
+ "csl"=>["監修三郎"],
78
+ "trl"=>["翻訳四郎","翻訳五郎",]})
79
+ Dir.mktmpdir do |dir|
80
+ authors = @maker.make_authors(@config)
81
+ assert_equal("テスト太郎、テスト次郎 著 \\\\\n監修三郎 監修 \\\\\n翻訳四郎、翻訳五郎 訳",
82
+ authors)
83
+ end
84
+ end
85
+
86
+ def test_make_authors_only_aut
87
+ @config.merge!({"aut"=>"テスト太郎"})
88
+ Dir.mktmpdir do |dir|
89
+ authors = @maker.make_authors(@config)
90
+ assert_equal("テスト太郎 著", authors)
91
+ end
92
+ end
93
+
94
+ def test_make_okuduke
95
+ @config.merge!({
96
+ "aut"=>["テスト太郎","テスト次郎"],
97
+ "csl"=>["監修三郎"],
98
+ "trl"=>["翻訳四郎","翻訳五郎"],
99
+ "dsr"=>["デザイン六郎"],
100
+ "ill"=>["イラスト七郎","イラスト八郎"],
101
+ "cov"=>["表紙九郎"],
102
+ "edt"=>["編集十郎"],
103
+ "prt"=>"テスト出版",
104
+ })
105
+ Dir.mktmpdir do |dir|
106
+ okuduke = @maker.make_colophon(@config)
107
+ assert_equal("著 者 & テスト太郎、テスト次郎 \\\\\n監 修 & 監修三郎 \\\\\n翻 訳 & 翻訳四郎、翻訳五郎 \\\\\nデザイン & デザイン六郎 \\\\\nイラスト & イラスト七郎、イラスト八郎 \\\\\n表 紙 & 表紙九郎 \\\\\n編 集 & 編集十郎 \\\\\n発行所 & テスト出版 \\\\\n",
108
+ okuduke)
109
+ end
110
+ end
111
+
112
+
113
+ def test_make_okuduke_dojin
114
+ @config.merge!({
115
+ "aut"=>["テスト太郎","テスト次郎"],
116
+ "csl"=>["監修三郎"],
117
+ "ill"=>["イラスト七郎","イラスト八郎"],
118
+ "pbl"=>"テスト出版",
119
+ "prt"=>"テスト印刷",
120
+ "contact"=>"tarou@example.jp",
121
+ })
122
+ Dir.mktmpdir do |dir|
123
+ I18n.i18n("ja", {"prt" => "印刷所"})
124
+ okuduke = @maker.make_colophon(@config)
125
+ assert_equal("著 者 & テスト太郎、テスト次郎 \\\\\n監 修 & 監修三郎 \\\\\nイラスト & イラスト七郎、イラスト八郎 \\\\\n発行所 & テスト出版 \\\\\n連絡先 & tarou@example.jp \\\\\n印刷所 & テスト印刷 \\\\\n",
126
+ okuduke)
127
+ end
128
+ end
129
+
130
+ end
@@ -11,14 +11,16 @@ class TOPBuidlerTest < Test::Unit::TestCase
11
11
 
12
12
  def setup
13
13
  @builder = TOPBuilder.new()
14
- @config = {
14
+ @config = ReVIEW::Configure.values
15
+ @config.merge!({
15
16
  "secnolevel" => 2,
16
17
  "inencoding" => "UTF-8",
17
18
  "outencoding" => "UTF-8"
18
- }
19
- ReVIEW.book.config = @config
19
+ })
20
+ @book = Book::Base.new(nil)
21
+ @book.config = @config
20
22
  @compiler = ReVIEW::Compiler.new(@builder)
21
- @chapter = Book::Chapter.new(nil, 1, '-', nil, StringIO.new)
23
+ @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
22
24
  location = Location.new(nil, nil)
23
25
  @builder.bind(@compiler, @chapter, location)
24
26
 
@@ -31,155 +33,151 @@ class TOPBuidlerTest < Test::Unit::TestCase
31
33
  end
32
34
 
33
35
  def test_headline_level1
34
- @builder.headline(1,"test","this is test.")
35
- assert_equal %Q|■H1■第1章 this is test.\n|, @builder.raw_result
36
+ actual = compile_block("={test} this is test.\n")
37
+ assert_equal %Q|■H1■第1章 this is test.\n|, actual
36
38
  end
37
39
 
38
40
  def test_headline_level1_without_secno
39
41
  @config["secnolevel"] = 0
40
- @builder.headline(1,"test","this is test.")
41
- assert_equal %Q|■H1■this is test.\n|, @builder.raw_result
42
+ actual = compile_block("={test} this is test.\n")
43
+ assert_equal %Q|■H1■this is test.\n|, actual
42
44
  end
43
45
 
44
46
  def test_headline_level2
45
- @builder.headline(2,"test","this is test.")
46
- assert_equal %Q|■H2■1.1 this is test.\n|, @builder.raw_result
47
+ actual = compile_block("=={test} this is test.\n")
48
+ assert_equal %Q|■H2■1.1 this is test.\n|, actual
47
49
  end
48
50
 
49
51
  def test_headline_level3
50
- @builder.headline(3,"test","this is test.")
51
- assert_equal %Q|■H3■this is test.\n|, @builder.raw_result
52
+ actual = compile_block("==={test} this is test.\n")
53
+ assert_equal %Q|■H3■this is test.\n|, actual
52
54
  end
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|■H3■1.0.1 this is test.\n|, @builder.raw_result
58
+ actual = compile_block("==={test} this is test.\n")
59
+ assert_equal %Q|■H3■1.0.1 this is test.\n|, actual
58
60
  end
59
61
 
60
62
  def test_href
61
- ret = @builder.compile_href("http://github.com", "GitHub")
62
- assert_equal %Q|GitHub(△http://github.com☆)|, ret
63
+ actual = compile_inline("@<href>{http://github.com, GitHub}")
64
+ assert_equal %Q|GitHub(△http://github.com☆)|, actual
63
65
  end
64
66
 
65
67
  def test_href_without_label
66
- ret = @builder.compile_href("http://github.com",nil)
67
- assert_equal %Q|△http://github.com☆|, ret
68
+ actual = compile_inline("@<href>{http://github.com}")
69
+ assert_equal %Q|△http://github.com☆|, actual
68
70
  end
69
71
 
70
72
  def test_inline_raw
71
- ret = @builder.inline_raw("@<tt>{inline}")
72
- assert_equal %Q|@<tt>{inline}|, ret
73
+ actual = compile_inline("@<raw>{@<tt>{inline\}}")
74
+ assert_equal %Q|@<tt>{inline}|, actual
73
75
  end
74
76
 
75
77
  def test_inline_ruby
76
- ret = @builder.compile_ruby("coffin", "bed")
77
- assert_equal %Q|coffin◆→DTP連絡:「coffin」に「bed」とルビ←◆|, ret
78
+ actual = compile_inline("@<ruby>{coffin,bed}")
79
+ assert_equal %Q|coffin◆→DTP連絡:「coffin」に「bed」とルビ←◆|, actual
78
80
  end
79
81
 
80
82
  def test_inline_kw
81
- ret = @builder.compile_inline("@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}")
82
- assert_equal %Q|★ISO☆(International Organization for Standardization) ★Ruby<>☆|, ret
83
+ actual = compile_inline("@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}")
84
+ assert_equal %Q|★ISO☆(International Organization for Standardization) ★Ruby<>☆|, actual
83
85
  end
84
86
 
85
87
  def test_inline_maru
86
- ret = @builder.compile_inline("@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}")
87
- assert_equal %Q|1◆→丸数字1←◆20◆→丸数字20←◆A◆→丸数字A←◆z◆→丸数字z←◆|, ret
88
+ actual = compile_inline("@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}")
89
+ assert_equal %Q|1◆→丸数字1←◆20◆→丸数字20←◆A◆→丸数字A←◆z◆→丸数字z←◆|, 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_i
96
- ret = @builder.compile_inline("test @<i>{inline test} test2")
97
- assert_equal %Q|test ▲inline test☆ test2|, ret
98
+ actual = compile_inline("test @<i>{inline test} test2")
99
+ assert_equal %Q|test ▲inline test☆ test2|, actual
98
100
  end
99
101
 
100
102
  def test_inline_i_and_escape
101
- ret = @builder.compile_inline("test @<i>{inline<&;\\ test} test2")
102
- assert_equal %Q|test ▲inline<&;\\ test☆ test2|, ret
103
+ actual = compile_inline("test @<i>{inline<&;\\ test} test2")
104
+ assert_equal %Q|test ▲inline<&;\\ test☆ test2|, actual
103
105
  end
104
106
 
105
107
  def test_inline_b
106
- ret = @builder.compile_inline("test @<b>{inline test} test2")
107
- assert_equal %Q|test ★inline test☆ test2|, ret
108
+ actual = compile_inline("test @<b>{inline test} test2")
109
+ assert_equal %Q|test ★inline test☆ test2|, actual
108
110
  end
109
111
 
110
112
  def test_inline_b_and_escape
111
- ret = @builder.compile_inline("test @<b>{inline<&;\\ test} test2")
112
- assert_equal %Q|test ★inline<&;\\ test☆ test2|, ret
113
+ actual = compile_inline("test @<b>{inline<&;\\ test} test2")
114
+ assert_equal %Q|test ★inline<&;\\ test☆ test2|, actual
113
115
  end
114
116
 
115
117
  def test_inline_tt
116
- ret = @builder.compile_inline("test @<tt>{inline test} test2@<tt>{\\}}")
117
- assert_equal %Q|test △inline test☆ test2△}☆|, ret
118
+ actual = compile_inline("test @<tt>{inline test} test2@<tt>{\\}}")
119
+ assert_equal %Q|test △inline test☆ test2△}☆|, actual
118
120
  end
119
121
 
120
122
  def test_inline_tti
121
- ret = @builder.compile_inline("test @<tti>{inline test} test2")
122
- assert_equal %Q|test ▲inline test☆◆→等幅フォントイタ←◆ test2|, ret
123
+ actual = compile_inline("test @<tti>{inline test} test2")
124
+ assert_equal %Q|test ▲inline test☆◆→等幅フォントイタ←◆ test2|, actual
123
125
  end
124
126
 
125
127
  def test_inline_ttb
126
- ret = @builder.compile_inline("test @<ttb>{inline test} test2")
127
- assert_equal %Q|test ★inline test☆◆→等幅フォント太字←◆ test2|, ret
128
+ actual = compile_inline("test @<ttb>{inline test} test2")
129
+ assert_equal %Q|test ★inline test☆◆→等幅フォント太字←◆ test2|, actual
128
130
  end
129
131
 
130
132
  def test_inline_uchar
131
- ret = @builder.compile_inline("test @<uchar>{2460} test2")
132
- assert_equal %Q|test ① test2|, ret
133
+ actual = compile_inline("test @<uchar>{2460} test2")
134
+ assert_equal %Q|test ① test2|, actual
133
135
  end
134
136
 
135
137
  def test_inline_in_table
136
- @builder.table(["★1☆\t▲2☆", "------------", "★3☆\t▲4☆<>&"])
137
- assert_equal %Q|★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n|, @builder.raw_result
138
+ actual = compile_block("//table{\n★1☆\t▲2☆\n------------\n★3☆\t▲4☆<>&\n//}\n")
139
+ assert_equal %Q|★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n|, actual
138
140
  end
139
141
 
140
142
  def test_paragraph
141
- lines = ["foo","bar"]
142
- @builder.paragraph(lines)
143
- assert_equal %Q|foobar\n|, @builder.raw_result
143
+ actual = compile_block("foo\nbar\n")
144
+ assert_equal %Q|foobar\n|, actual
144
145
  end
145
146
 
146
147
  def test_tabbed_paragraph
147
- lines = ["\tfoo","bar"]
148
- @builder.paragraph(lines)
149
- assert_equal %Q|\tfoobar\n|, @builder.raw_result
148
+ actual = compile_block("\tfoo\nbar\n")
149
+ assert_equal %Q|\tfoobar\n|, actual
150
150
  end
151
151
 
152
152
  def test_flushright
153
- @builder.flushright(["foo", "bar", "","buz"])
154
- assert_equal %Q|◆→開始:右寄せ←◆\nfoobar\nbuz\n◆→終了:右寄せ←◆\n\n|, @builder.raw_result
153
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
154
+ assert_equal %Q|◆→開始:右寄せ←◆\nfoobar\nbuz\n◆→終了:右寄せ←◆\n\n|, actual
155
155
  end
156
156
 
157
157
  def test_noindent
158
- @builder.noindent
159
- @builder.paragraph(["foo", "bar"])
160
- @builder.paragraph(["foo2", "bar2"])
161
- assert_equal %Q|◆→DTP連絡:次の1行インデントなし←◆\nfoobar\nfoo2bar2\n|, @builder.raw_result
158
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
159
+ assert_equal %Q|◆→DTP連絡:次の1行インデントなし←◆\nfoobar\nfoo2bar2\n|, actual
162
160
  end
163
161
 
164
162
  def test_list
165
163
  def @chapter.list(id)
166
164
  Book::ListIndex::Item.new("test",1)
167
165
  end
168
- @builder.list(["foo", "bar"], "test", "this is @<b>{test}<&>_")
169
- assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\nfoo\nbar\n◆→終了:リスト←◆\n\n|, @builder.raw_result
166
+ actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
167
+ assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\nfoo\nbar\n◆→終了:リスト←◆\n\n|, actual
170
168
  end
171
169
 
172
170
  def test_listnum
173
171
  def @chapter.list(id)
174
172
  Book::ListIndex::Item.new("test",1)
175
173
  end
176
- @builder.listnum(["foo", "bar"], "test", "this is @<b>{test}<&>_")
177
- assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\n 1: foo\n 2: bar\n◆→終了:リスト←◆\n\n|, @builder.raw_result
174
+ actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
175
+ assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\n 1: foo\n 2: bar\n◆→終了:リスト←◆\n\n|, actual
178
176
  end
179
177
 
180
178
  def test_emlistnum
181
- @builder.emlistnum(["foo", "bar"], "this is @<b>{test}<&>_")
182
- assert_equal %Q|◆→開始:インラインリスト←◆\n■this is ★test☆<&>_\n 1: foo\n 2: bar\n◆→終了:インラインリスト←◆\n\n|, @builder.raw_result
179
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
180
+ assert_equal %Q|◆→開始:インラインリスト←◆\n■this is ★test☆<&>_\n 1: foo\n 2: bar\n◆→終了:インラインリスト←◆\n\n|, actual
183
181
  end
184
182
 
185
183
  def test_image
@@ -189,8 +187,8 @@ class TOPBuidlerTest < Test::Unit::TestCase
189
187
  item
190
188
  end
191
189
 
192
- @builder.image(["foo"], "sampleimg","sample photo",nil)
193
- assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, @builder.raw_result
190
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
191
+ assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, actual
194
192
  end
195
193
 
196
194
  def test_image_with_metric
@@ -200,73 +198,71 @@ class TOPBuidlerTest < Test::Unit::TestCase
200
198
  item
201
199
  end
202
200
 
203
- @builder.image(["foo"], "sampleimg","sample photo","scale=1.2")
204
- assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, @builder.raw_result
201
+ actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
202
+ assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, actual
205
203
  end
206
204
 
207
205
  def test_texequation
208
- @builder.texequation(["\\sin", "1^{2}"])
209
- assert_equal %Q|◆→開始:TeX式←◆\n\\sin\n1^{2}\n◆→終了:TeX式←◆\n\n|, @builder.raw_result
206
+ actual = compile_block("//texequation{\n\\sin\n1^{2}\n//}\n")
207
+ assert_equal %Q|◆→開始:TeX式←◆\n\\sin\n1^{2}\n◆→終了:TeX式←◆\n\n|, actual
210
208
  end
211
209
 
212
210
  def test_inline_raw0
213
- assert_equal "normal", @builder.inline_raw("normal")
211
+ assert_equal "normal", compile_inline("@<raw>{normal}")
214
212
  end
215
213
 
216
214
  def test_inline_raw1
217
- assert_equal "body", @builder.inline_raw("|top|body")
215
+ assert_equal "body", compile_inline("@<raw>{|top|body}")
218
216
  end
219
217
 
220
218
  def test_inline_raw2
221
- assert_equal "body", @builder.inline_raw("|top, latex|body")
219
+ assert_equal "body", compile_inline("@<raw>{|top, latex|body}")
222
220
  end
223
221
 
224
222
  def test_inline_raw3
225
- assert_equal "", @builder.inline_raw("|idgxml, html|body")
223
+ assert_equal "", compile_inline("@<raw>{|idgxml, html|body}")
226
224
  end
227
225
 
228
226
  def test_inline_raw4
229
- assert_equal "|top body", @builder.inline_raw("|top body")
227
+ assert_equal "|top body", compile_inline("@<raw>{|top body}")
230
228
  end
231
229
 
232
230
  def test_inline_raw5
233
- assert_equal "nor\nmal", @builder.inline_raw("|top|nor\\nmal")
231
+ assert_equal "nor\nmal", compile_inline("@<raw>{|top|nor\\nmal}")
234
232
  end
235
233
 
236
234
  def test_block_raw0
237
- @builder.raw("<>!\"\\n& ")
238
- expect = %Q(<>!\"\n& )
239
- assert_equal expect.chomp, @builder.raw_result
235
+ actual = compile_block("//raw[<>!\"\\n& ]\n")
236
+ expected = %Q(<>!\"\n& )
237
+ assert_equal expected.chomp, actual
240
238
  end
241
239
 
242
240
  def test_block_raw1
243
- @builder.raw("|top|<>!\"\\n& ")
244
- expect = %Q(<>!\"\n& )
245
- assert_equal expect.chomp, @builder.raw_result
241
+ actual = compile_block("//raw[|top|<>!\"\\n& ]\n")
242
+ expected = %Q(<>!\"\n& )
243
+ assert_equal expected.chomp, actual
246
244
  end
247
245
 
248
246
  def test_block_raw2
249
- @builder.raw("|top, latex|<>!\"\\n& ")
250
- expect = %Q(<>!\"\n& )
251
- assert_equal expect.chomp, @builder.raw_result
247
+ actual = compile_block("//raw[|top, latex|<>!\"\\n& ]\n")
248
+ expected = %Q(<>!\"\n& )
249
+ assert_equal expected.chomp, actual
252
250
  end
253
251
 
254
252
  def test_block_raw3
255
- @builder.raw("|latex, idgxml|<>!\"\\n& ")
256
- expect = ''
257
- assert_equal expect.chomp, @builder.raw_result
253
+ actual = compile_block("//raw[|latex, idgxml|<>!\"\\n& ]\n")
254
+ expected = ''
255
+ assert_equal expected.chomp, actual
258
256
  end
259
257
 
260
258
  def test_block_raw4
261
- @builder.raw("|top <>!\"\\n& ")
262
- expect = %Q(|top <>!\"\n& )
263
- assert_equal expect.chomp, @builder.raw_result
259
+ actual = compile_block("//raw[|top <>!\"\\n& ]\n")
260
+ expected = %Q(|top <>!\"\n& )
261
+ assert_equal expected.chomp, actual
264
262
  end
265
263
 
266
264
  def column_helper(review)
267
- chap_singleton = class << @chapter; self; end
268
- chap_singleton.send(:define_method, :content) { review }
269
- @compiler.compile(@chapter)
265
+ compile_block(review)
270
266
  end
271
267
 
272
268
  def test_column_ref
@@ -279,7 +275,7 @@ inside column
279
275
 
280
276
  this is @<column>{foo}.
281
277
  EOS
282
- expect =<<-EOS
278
+ expected =<<-EOS
283
279
  ◆→開始:コラム←◆
284
280
  ■test
285
281
  inside column
@@ -289,7 +285,7 @@ inside column
289
285
  this is test.
290
286
  EOS
291
287
 
292
- assert_equal expect, column_helper(review)
288
+ assert_equal expected, column_helper(review)
293
289
  end
294
290
 
295
291
  end