tmtms-review 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +9 -0
- data/COPYING +515 -0
- data/ChangeLog +2083 -0
- data/README.rdoc +50 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/bin/review-check +178 -0
- data/bin/review-checkdep +63 -0
- data/bin/review-compile +205 -0
- data/bin/review-epubmaker +661 -0
- data/bin/review-epubmaker-ng +176 -0
- data/bin/review-index +118 -0
- data/bin/review-pdfmaker +208 -0
- data/bin/review-preproc +142 -0
- data/bin/review-validate +51 -0
- data/bin/review-vol +102 -0
- data/debian/README.Debian +12 -0
- data/debian/README.source +5 -0
- data/debian/changelog +5 -0
- data/debian/compat +1 -0
- data/debian/control +22 -0
- data/debian/copyright +62 -0
- data/debian/docs +6 -0
- data/debian/manpage.1.ex +59 -0
- data/debian/patches/path.diff +91 -0
- data/debian/patches/series +1 -0
- data/debian/review.install +13 -0
- data/debian/review.links +4 -0
- data/debian/rules +13 -0
- data/debian/source/format +1 -0
- data/doc/format.rdoc +582 -0
- data/doc/format_idg.rdoc +180 -0
- data/doc/libepubmaker/sample.yaml +90 -0
- data/doc/quickstart.rdoc +188 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +108 -0
- data/doc/sample.yaml +62 -0
- data/lib/epubmaker.rb +28 -0
- data/lib/epubmaker/content.rb +82 -0
- data/lib/epubmaker/epubv2.rb +418 -0
- data/lib/epubmaker/epubv3.rb +249 -0
- data/lib/epubmaker/producer.rb +204 -0
- data/lib/epubmaker/resource.rb +66 -0
- data/lib/lineinput.rb +155 -0
- data/lib/review.rb +3 -0
- data/lib/review/book.rb +46 -0
- data/lib/review/book/base.rb +235 -0
- data/lib/review/book/chapter.rb +81 -0
- data/lib/review/book/compilable.rb +159 -0
- data/lib/review/book/index.rb +339 -0
- data/lib/review/book/page_metric.rb +38 -0
- data/lib/review/book/parameters.rb +97 -0
- data/lib/review/book/part.rb +44 -0
- data/lib/review/book/volume.rb +65 -0
- data/lib/review/builder.rb +444 -0
- data/lib/review/compiler.rb +550 -0
- data/lib/review/configure.rb +38 -0
- data/lib/review/epubbuilder.rb +18 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/extentions.rb +3 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/extentions/string.rb +33 -0
- data/lib/review/htmlbuilder.rb +1097 -0
- data/lib/review/htmllayout.rb +19 -0
- data/lib/review/htmlutils.rb +36 -0
- data/lib/review/i18n.rb +30 -0
- data/lib/review/i18n.yaml +34 -0
- data/lib/review/idgxmlbuilder.rb +1145 -0
- data/lib/review/latexbuilder.rb +815 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +79 -0
- data/lib/review/preprocessor.rb +563 -0
- data/lib/review/review.tex.erb +232 -0
- data/lib/review/textbuilder.rb +17 -0
- data/lib/review/textutils.rb +66 -0
- data/lib/review/tocparser.rb +342 -0
- data/lib/review/tocprinter.rb +221 -0
- data/lib/review/topbuilder.rb +785 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/uuid.rb +312 -0
- data/review.gemspec +141 -0
- data/test/CHAPS +2 -0
- data/test/bib.re +13 -0
- data/test/book_test_helper.rb +35 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +598 -0
- data/test/test_book_chapter.rb +418 -0
- data/test/test_book_parameter.rb +42 -0
- data/test/test_book_part.rb +50 -0
- data/test/test_builder.rb +144 -0
- data/test/test_compiler.rb +44 -0
- data/test/test_epubmaker.rb +507 -0
- data/test/test_helper.rb +27 -0
- data/test/test_htmlbuilder.rb +554 -0
- data/test/test_htmlutils.rb +28 -0
- data/test/test_i18n.rb +64 -0
- data/test/test_idgxmlbuilder.rb +589 -0
- data/test/test_index.rb +31 -0
- data/test/test_latexbuilder.rb +656 -0
- data/test/test_lineinput.rb +198 -0
- data/test/test_preprocessor.rb +23 -0
- data/test/test_textutils.rb +68 -0
- data/test/test_topbuilder.rb +244 -0
- data/test/test_uuid.rb +156 -0
- metadata +161 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
def ul_helper(src, expect)
|
5
|
+
io = StringIO.new(src)
|
6
|
+
li = LineInput.new(io)
|
7
|
+
@compiler.__send__(:compile_ulist, li)
|
8
|
+
assert_equal expect, @builder.raw_result
|
9
|
+
end
|
10
|
+
|
11
|
+
def builder_helper(src, expect, method_sym)
|
12
|
+
io = StringIO.new(src)
|
13
|
+
li = LineInput.new(io)
|
14
|
+
@compiler.__send__(method_sym, li)
|
15
|
+
assert_equal expect, @builder.raw_result
|
16
|
+
end
|
17
|
+
|
18
|
+
def touch_file(path)
|
19
|
+
File.open(path, "w").close
|
20
|
+
path
|
21
|
+
end
|
22
|
+
|
23
|
+
def prepare_samplebook(srcdir)
|
24
|
+
samplebook_dir = File.expand_path("sample-book/src/", File.dirname(__FILE__))
|
25
|
+
FileUtils.cp_r(Dir.glob(samplebook_dir + "/*"), srcdir)
|
26
|
+
YAML.load(File.open(srcdir + "/config.yml"))
|
27
|
+
end
|
@@ -0,0 +1,554 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'review/compiler'
|
5
|
+
require 'review/book'
|
6
|
+
require 'review/htmlbuilder'
|
7
|
+
|
8
|
+
class HTMLBuidlerTest < Test::Unit::TestCase
|
9
|
+
include ReVIEW
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@builder = HTMLBuilder.new()
|
13
|
+
@param = {
|
14
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
15
|
+
"inencoding" => "UTF-8",
|
16
|
+
"outencoding" => "UTF-8",
|
17
|
+
"subdirmode" => nil,
|
18
|
+
"stylesheet" => nil, # for HTMLBuilder
|
19
|
+
}
|
20
|
+
ReVIEW.book.param = @param
|
21
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
22
|
+
@chapter = Book::Chapter.new(nil, 1, '-', nil, StringIO.new)
|
23
|
+
location = Location.new(nil, nil)
|
24
|
+
@builder.bind(@compiler, @chapter, location)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_headline_level1
|
28
|
+
@builder.headline(1,"test","this is test.")
|
29
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>第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"></a>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"></a>第1章 this <b>is</b> test.<&"></h1>\n|, @builder.raw_result
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_headline_level2
|
44
|
+
@builder.headline(2,"test","this is test.")
|
45
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|, @builder.raw_result
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_headline_level3
|
49
|
+
@builder.headline(3,"test","this is test.")
|
50
|
+
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>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"></a>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"></a>\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_href
|
75
|
+
ret = @builder.inline_href("http://github.com, Git\\,Hub")
|
76
|
+
assert_equal %Q|<a href="http://github.com" class="link">Git,Hub</a>|, ret
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_inline_href_without_label
|
80
|
+
ret = @builder.inline_href("http://github.com")
|
81
|
+
assert_equal %Q|<a href="http://github.com" class="link">http://github.com</a>|, ret
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_inline_raw
|
85
|
+
ret = @builder.inline_raw("@<tt>{inline}")
|
86
|
+
assert_equal %Q|@<tt>{inline}|, ret
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_inline_in_table
|
90
|
+
ret = @builder.table(["<b>1</b>\t<i>2</i>", "------------", "<b>3</b>\t<i>4</i><>&"])
|
91
|
+
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><>&</td></tr>\n</table>\n</div>\n|, @builder.raw_result
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_inline_br
|
95
|
+
ret = @builder.inline_br("")
|
96
|
+
assert_equal %Q|<br />|, ret
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_inline_i
|
100
|
+
ret = @builder.compile_inline("test @<i>{inline test} test2")
|
101
|
+
assert_equal %Q|test <i>inline test</i> test2|, ret
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_inline_i_and_escape
|
105
|
+
ret = @builder.compile_inline("test @<i>{inline<&;\\ test} test2")
|
106
|
+
assert_equal %Q|test <i>inline<&;\\ test</i> test2|, ret
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_inline_b
|
110
|
+
ret = @builder.compile_inline("test @<b>{inline test} test2")
|
111
|
+
assert_equal %Q|test <b>inline test</b> test2|, ret
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_inline_b_and_escape
|
115
|
+
ret = @builder.compile_inline("test @<b>{inline<&;\\ test} test2")
|
116
|
+
assert_equal %Q|test <b>inline<&;\\ test</b> test2|, ret
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_inline_tt
|
120
|
+
ret = @builder.compile_inline("test @<tt>{inline test} test2")
|
121
|
+
assert_equal %Q|test <tt>inline test</tt> test2|, ret
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_inline_tti
|
125
|
+
ret = @builder.compile_inline("test @<tti>{inline test} test2")
|
126
|
+
assert_equal %Q|test <tt><i>inline test</i></tt> test2|, ret
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_inline_ttb
|
130
|
+
ret = @builder.compile_inline("test @<ttb>{inline test} test2")
|
131
|
+
assert_equal %Q|test <tt><b>inline test</b></tt> test2|, ret
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_inline_hd_chap
|
135
|
+
def @chapter.headline_index
|
136
|
+
items = [Book::HeadlineIndex::Item.new("chap1|test", [1, 1], "te_st")]
|
137
|
+
Book::HeadlineIndex.new(items, self)
|
138
|
+
end
|
139
|
+
|
140
|
+
@param["secnolevel"] = 2
|
141
|
+
ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
|
142
|
+
assert_equal %Q|test 「te_st」 test2|, ret
|
143
|
+
|
144
|
+
@param["secnolevel"] = 3
|
145
|
+
ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
|
146
|
+
assert_equal %Q|test 「1.1.1 te_st」 test2|, ret
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_inline_uchar
|
150
|
+
ret = @builder.compile_inline("test @<uchar>{2460} test2")
|
151
|
+
assert_equal %Q|test ① test2|, ret
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_inline_ruby
|
155
|
+
ret = @builder.compile_inline("@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。")
|
156
|
+
assert_equal "<ruby><rb>粗雑</rb><rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby><rb>繊細</rb><rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。", ret
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_inline_ref
|
160
|
+
ret = @builder.compile_inline("@<ref>{外部参照<>&}")
|
161
|
+
assert_equal %Q|<a target='外部参照<>&'>「●● 外部参照<>&」</a>|, ret
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_quote
|
165
|
+
lines = ["foo", "bar", "","buz"]
|
166
|
+
@builder.quote(lines)
|
167
|
+
assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n|, @builder.raw_result
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_memo
|
171
|
+
@builder.memo(["test1", "", "test<i>2</i>"], "this is @<b>{test}<&>_")
|
172
|
+
assert_equal %Q|<div class="memo">\n<p class="caption">this is <b>test</b><&>_</p>\n<p>test1</p>\n<p>test<i>2</i></p>\n</div>\n|, @builder.raw_result
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_noindent
|
176
|
+
@builder.noindent
|
177
|
+
@builder.paragraph(["foo", "bar"])
|
178
|
+
@builder.paragraph(["foo2", "bar2"])
|
179
|
+
assert_equal %Q|<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n|, @builder.raw_result
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_flushright
|
183
|
+
@builder.flushright(["foo", "bar", "", "buz"])
|
184
|
+
assert_equal %Q|<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n|, @builder.raw_result
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_centering
|
188
|
+
@builder.centering(["foo", "bar", "", "buz"])
|
189
|
+
assert_equal %Q|<p class="center">foobar</p>\n<p class="center">buz</p>\n|, @builder.raw_result
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_image
|
193
|
+
def @chapter.image(id)
|
194
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
195
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
196
|
+
item
|
197
|
+
end
|
198
|
+
|
199
|
+
@builder.image_image("sampleimg","sample photo",nil)
|
200
|
+
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
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_image_with_metric
|
204
|
+
def @chapter.image(id)
|
205
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
206
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
207
|
+
item
|
208
|
+
end
|
209
|
+
|
210
|
+
@builder.image_image("sampleimg","sample photo","scale=1.2")
|
211
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, @builder.raw_result
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_image_with_metric2
|
215
|
+
def @chapter.image(id)
|
216
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
217
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
218
|
+
item
|
219
|
+
end
|
220
|
+
@builder.image_image("sampleimg","sample photo","scale=1.2,html::class=sample,latex::ignore=params")
|
221
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" class="sample" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, @builder.raw_result
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_indepimage
|
225
|
+
def @chapter.image(id)
|
226
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
227
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
228
|
+
item
|
229
|
+
end
|
230
|
+
|
231
|
+
@builder.indepimage("sampleimg","sample photo",nil)
|
232
|
+
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
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_indepimage_without_caption
|
236
|
+
def @chapter.image(id)
|
237
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
238
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
239
|
+
item
|
240
|
+
end
|
241
|
+
|
242
|
+
@builder.indepimage("sampleimg",nil,nil)
|
243
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|, @builder.raw_result
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_indepimage_with_metric
|
247
|
+
def @chapter.image(id)
|
248
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
249
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
250
|
+
item
|
251
|
+
end
|
252
|
+
|
253
|
+
@builder.indepimage("sampleimg","sample photo","scale=1.2")
|
254
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, @builder.raw_result
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_indepimage_with_metric2
|
258
|
+
def @chapter.image(id)
|
259
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
260
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
261
|
+
item
|
262
|
+
end
|
263
|
+
|
264
|
+
@builder.indepimage("sampleimg","sample photo","scale=1.2, html::class=\"sample\",latex::ignore=params")
|
265
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" class="sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, @builder.raw_result
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_indepimage_without_caption_but_with_metric
|
269
|
+
def @chapter.image(id)
|
270
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
271
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
272
|
+
item
|
273
|
+
end
|
274
|
+
|
275
|
+
@builder.indepimage("sampleimg",nil,"scale=1.2")
|
276
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" width="120%" />\n</div>\n|, @builder.raw_result
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_emlist
|
280
|
+
@builder.emlist(["lineA","lineB"])
|
281
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, @builder.raw_result
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_emlist_caption
|
285
|
+
@builder.emlist(["lineA","lineB"],"cap1")
|
286
|
+
assert_equal %Q|<div class="emlist-code">\n<p class="caption">cap1</p>\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, @builder.raw_result
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_emlist_with_tab
|
290
|
+
@builder.emlist(["\tlineA","\t\tlineB","\tlineC"])
|
291
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, @builder.raw_result
|
292
|
+
end
|
293
|
+
|
294
|
+
def test_emlist_with_4tab
|
295
|
+
@builder.instance_eval{@tabwidth=4}
|
296
|
+
@builder.emlist(["\tlineA","\t\tlineB","\tlineC"])
|
297
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, @builder.raw_result
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_cmd
|
301
|
+
@builder.cmd(["lineA","lineB"])
|
302
|
+
assert_equal %Q|<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|, @builder.raw_result
|
303
|
+
end
|
304
|
+
|
305
|
+
def test_cmd_caption
|
306
|
+
@builder.cmd(["lineA","lineB"], "cap1")
|
307
|
+
assert_equal %Q|<div class="cmd-code">\n<p class="caption">cap1</p>\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|, @builder.raw_result
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_bib
|
311
|
+
def @chapter.bibpaper(id)
|
312
|
+
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
313
|
+
end
|
314
|
+
|
315
|
+
assert_equal %Q|<a href="./bib.html#bib-samplebib">[1]</a>|, @builder.inline_bib("samplebib")
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_bibpaper
|
319
|
+
def @chapter.bibpaper(id)
|
320
|
+
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
321
|
+
end
|
322
|
+
|
323
|
+
@builder.bibpaper(["a", "b"], "samplebib", "sample bib @<b>{bold}")
|
324
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1] sample bib <b>bold</b></a>\n<p>a\nb\n</p>\n</div>\n|, @builder.raw_result
|
325
|
+
end
|
326
|
+
|
327
|
+
def column_helper(review)
|
328
|
+
chap_singleton = class << @chapter; self; end
|
329
|
+
chap_singleton.send(:define_method, :content) { review }
|
330
|
+
@compiler.compile(@chapter).match(/<body>\n(.+)<\/body>/m)[1]
|
331
|
+
end
|
332
|
+
|
333
|
+
def test_column_1
|
334
|
+
review =<<-EOS
|
335
|
+
===[column] prev column
|
336
|
+
|
337
|
+
inside prev column
|
338
|
+
|
339
|
+
===[column] test
|
340
|
+
|
341
|
+
inside column
|
342
|
+
|
343
|
+
===[/column]
|
344
|
+
EOS
|
345
|
+
expect =<<-EOS
|
346
|
+
<div class="column">
|
347
|
+
|
348
|
+
<h3><a id="h1-0-1"></a>prev column</h3>
|
349
|
+
<p>inside prev column</p>
|
350
|
+
</div>
|
351
|
+
<div class="column">
|
352
|
+
|
353
|
+
<h3><a id="h1-0-2"></a>test</h3>
|
354
|
+
<p>inside column</p>
|
355
|
+
</div>
|
356
|
+
EOS
|
357
|
+
assert_equal expect, column_helper(review)
|
358
|
+
end
|
359
|
+
|
360
|
+
def test_column_2
|
361
|
+
review =<<-EOS
|
362
|
+
===[column] test
|
363
|
+
|
364
|
+
inside column
|
365
|
+
|
366
|
+
=== next level
|
367
|
+
EOS
|
368
|
+
expect =<<-EOS
|
369
|
+
<div class="column">
|
370
|
+
|
371
|
+
<h3><a id="h1-0-1"></a>test</h3>
|
372
|
+
<p>inside column</p>
|
373
|
+
</div>
|
374
|
+
|
375
|
+
<h3><a id="h1-0-2"></a>next level</h3>
|
376
|
+
EOS
|
377
|
+
|
378
|
+
assert_equal expect, column_helper(review)
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_column_3
|
382
|
+
review =<<-EOS
|
383
|
+
===[column] test
|
384
|
+
|
385
|
+
inside column
|
386
|
+
|
387
|
+
===[/column_dummy]
|
388
|
+
EOS
|
389
|
+
assert_raise(ReVIEW::CompileError) do
|
390
|
+
column_helper(review)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
def test_ul
|
395
|
+
src =<<-EOS
|
396
|
+
* AAA
|
397
|
+
* BBB
|
398
|
+
EOS
|
399
|
+
expect = "<ul>\n<li>AAA</li>\n<li>BBB</li>\n</ul>\n"
|
400
|
+
ul_helper(src, expect)
|
401
|
+
end
|
402
|
+
|
403
|
+
def test_ul_cont
|
404
|
+
src =<<-EOS
|
405
|
+
* AAA
|
406
|
+
-AA
|
407
|
+
* BBB
|
408
|
+
-BB
|
409
|
+
EOS
|
410
|
+
expect = "<ul>\n<li>AAA-AA</li>\n<li>BBB-BB</li>\n</ul>\n"
|
411
|
+
ul_helper(src, expect)
|
412
|
+
end
|
413
|
+
|
414
|
+
def test_ul_nest1
|
415
|
+
src =<<-EOS
|
416
|
+
* AAA
|
417
|
+
** AA
|
418
|
+
EOS
|
419
|
+
|
420
|
+
expect =<<-EOS
|
421
|
+
<ul>
|
422
|
+
<li>AAA<ul>
|
423
|
+
<li>AA</li>
|
424
|
+
</ul>
|
425
|
+
</li>
|
426
|
+
</ul>
|
427
|
+
EOS
|
428
|
+
ul_helper(src, expect)
|
429
|
+
end
|
430
|
+
|
431
|
+
def test_ul_nest2
|
432
|
+
src =<<-EOS
|
433
|
+
* AAA
|
434
|
+
** AA
|
435
|
+
* BBB
|
436
|
+
** BB
|
437
|
+
EOS
|
438
|
+
|
439
|
+
expect =<<-EOS
|
440
|
+
<ul>
|
441
|
+
<li>AAA<ul>
|
442
|
+
<li>AA</li>
|
443
|
+
</ul>
|
444
|
+
</li>
|
445
|
+
<li>BBB<ul>
|
446
|
+
<li>BB</li>
|
447
|
+
</ul>
|
448
|
+
</li>
|
449
|
+
</ul>
|
450
|
+
EOS
|
451
|
+
ul_helper(src, expect)
|
452
|
+
end
|
453
|
+
|
454
|
+
def test_ul_nest3
|
455
|
+
src =<<-EOS
|
456
|
+
** AAA
|
457
|
+
* AA
|
458
|
+
* BBB
|
459
|
+
** BB
|
460
|
+
EOS
|
461
|
+
|
462
|
+
expect =<<-EOS
|
463
|
+
<ul>
|
464
|
+
<li><ul>
|
465
|
+
<li>AAA</li>
|
466
|
+
</ul>
|
467
|
+
</li>
|
468
|
+
<li>AA</li>
|
469
|
+
<li>BBB<ul>
|
470
|
+
<li>BB</li>
|
471
|
+
</ul>
|
472
|
+
</li>
|
473
|
+
</ul>
|
474
|
+
EOS
|
475
|
+
ul_helper(src, expect)
|
476
|
+
end
|
477
|
+
|
478
|
+
def test_inline_raw0
|
479
|
+
assert_equal "normal", @builder.inline_raw("normal")
|
480
|
+
end
|
481
|
+
|
482
|
+
def test_inline_raw1
|
483
|
+
assert_equal "body", @builder.inline_raw("|html|body")
|
484
|
+
end
|
485
|
+
|
486
|
+
def test_inline_raw2
|
487
|
+
assert_equal "body", @builder.inline_raw("|html, latex|body")
|
488
|
+
end
|
489
|
+
|
490
|
+
def test_inline_raw3
|
491
|
+
assert_equal "", @builder.inline_raw("|idgxml, latex|body")
|
492
|
+
end
|
493
|
+
|
494
|
+
def test_inline_raw4
|
495
|
+
assert_equal "|html body", @builder.inline_raw("|html body")
|
496
|
+
end
|
497
|
+
|
498
|
+
def test_inline_raw5
|
499
|
+
assert_equal "nor\nmal", @builder.inline_raw("|html|nor\\nmal")
|
500
|
+
end
|
501
|
+
|
502
|
+
def test_block_raw0
|
503
|
+
@builder.raw("<>!\"\\n& ")
|
504
|
+
expect =<<-EOS
|
505
|
+
<>!"
|
506
|
+
&
|
507
|
+
EOS
|
508
|
+
assert_equal expect.chomp, @builder.raw_result
|
509
|
+
end
|
510
|
+
|
511
|
+
def test_block_raw1
|
512
|
+
@builder.raw("|html|<>!\"\\n& ")
|
513
|
+
expect =<<-EOS
|
514
|
+
<>!"
|
515
|
+
&
|
516
|
+
EOS
|
517
|
+
assert_equal expect.chomp, @builder.raw_result
|
518
|
+
end
|
519
|
+
|
520
|
+
def test_block_raw2
|
521
|
+
@builder.raw("|html, latex|<>!\"\\n& ")
|
522
|
+
expect =<<-EOS
|
523
|
+
<>!\"
|
524
|
+
&
|
525
|
+
EOS
|
526
|
+
assert_equal expect.chomp, @builder.raw_result
|
527
|
+
end
|
528
|
+
|
529
|
+
def test_block_raw3
|
530
|
+
@builder.raw("|latex, idgxml|<>!\"\\n& ")
|
531
|
+
expect =<<-EOS
|
532
|
+
EOS
|
533
|
+
assert_equal expect.chomp, @builder.raw_result
|
534
|
+
end
|
535
|
+
|
536
|
+
def test_block_raw4
|
537
|
+
@builder.raw("|html <>!\"\\n& ")
|
538
|
+
expect =<<-EOS
|
539
|
+
|html <>!\"
|
540
|
+
&
|
541
|
+
EOS
|
542
|
+
assert_equal expect.chomp, @builder.raw_result
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_inline_fn
|
546
|
+
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
|
547
|
+
@chapter.instance_eval{@footnote_index=fn}
|
548
|
+
@builder.footnote("foo",'bar\\a\\$buz')
|
549
|
+
expect =<<-'EOS'
|
550
|
+
<div class="footnote"><p class="footnote">[<a id="fn-foo">*1</a>] bar\a\$buz</p></div>
|
551
|
+
EOS
|
552
|
+
assert_equal expect, @builder.raw_result
|
553
|
+
end
|
554
|
+
end
|