review 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/ChangeLog +65 -0
- data/Gemfile +5 -0
- data/README.rdoc +6 -1
- data/Rakefile +14 -28
- data/bin/review-check +9 -21
- data/bin/review-compile +45 -12
- data/bin/review-epubmaker +477 -220
- data/bin/review-epubmaker-ng +5 -14
- data/bin/review-index +4 -2
- data/bin/review-init +94 -0
- data/bin/review-pdfmaker +70 -287
- data/bin/review-preproc +5 -2
- data/bin/review-vol +4 -11
- data/debian/changelog +3 -3
- data/debian/copyright +5 -3
- data/debian/docs +1 -0
- data/doc/format.rdoc +57 -11
- data/doc/quickstart.rdoc +4 -4
- data/doc/sample.yaml +11 -7
- data/lib/epubmaker.rb +1 -1
- data/lib/epubmaker/epubv2.rb +26 -27
- data/lib/epubmaker/epubv3.rb +13 -13
- data/lib/epubmaker/producer.rb +1 -1
- data/lib/review.rb +3 -4
- data/lib/review/book.rb +17 -581
- data/lib/review/book/base.rb +247 -0
- data/lib/review/book/chapter.rb +81 -0
- data/lib/review/book/compilable.rb +163 -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 +34 -40
- data/lib/review/compiler.rb +32 -13
- data/lib/review/configure.rb +38 -0
- data/lib/review/ewbbuilder.rb +23 -21
- data/lib/review/extentions.rb +3 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/{compat.rb → extentions/string.rb} +11 -0
- data/lib/review/htmlbuilder.rb +162 -74
- data/lib/review/htmlutils.rb +28 -1
- data/lib/review/i18n.yaml +11 -0
- data/lib/review/idgxmlbuilder.rb +119 -35
- data/lib/review/inaobuilder.rb +355 -0
- data/lib/review/latexbuilder.rb +133 -59
- data/lib/review/latexutils.rb +15 -6
- data/lib/review/makerhelper.rb +59 -0
- data/lib/review/markdownbuilder.rb +129 -0
- data/lib/review/preprocessor.rb +20 -7
- data/lib/review/review.tex.erb +250 -0
- data/lib/review/textutils.rb +28 -3
- data/lib/review/tocparser.rb +20 -12
- data/lib/review/tocprinter.rb +7 -3
- data/lib/review/topbuilder.rb +44 -27
- data/lib/review/version.rb +3 -0
- data/review.gemspec +20 -117
- data/test/book_test_helper.rb +35 -0
- data/test/sample-book/README.md +5 -0
- data/test/sample-book/src/CHAPS +2 -0
- data/test/sample-book/src/PREDEF +1 -0
- data/test/sample-book/src/Rakefile +26 -0
- data/test/sample-book/src/_cover.html +3 -0
- data/test/sample-book/src/ch01.re +71 -0
- data/test/sample-book/src/ch02.re +3 -0
- data/test/sample-book/src/config.yml +55 -0
- data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
- data/test/sample-book/src/images/cover.jpg +0 -0
- data/test/sample-book/src/main.css +251 -0
- data/test/sample-book/src/preface.re +15 -0
- data/test/sample-book/src/sty/jumoline.sty +310 -0
- data/test/sample-book/src/sty/samplemacro.sty +21 -0
- data/test/sample-book/src/vendor/jumoline/README +29 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
- data/test/test_book.rb +26 -646
- data/test/test_book_chapter.rb +418 -0
- data/test/test_book_parameter.rb +42 -0
- data/test/test_book_part.rb +53 -0
- data/test/test_builder.rb +17 -10
- data/test/test_compiler.rb +46 -0
- data/test/test_epubmaker.rb +1 -1
- data/test/test_epubmaker_cmd.rb +36 -0
- data/test/test_helper.rb +17 -0
- data/test/test_htmlbuilder.rb +156 -24
- data/test/test_htmlutils.rb +4 -0
- data/test/test_i18n.rb +6 -2
- data/test/test_idgxmlbuilder.rb +33 -11
- data/test/test_inaobuilder.rb +247 -0
- data/test/test_index.rb +31 -0
- data/test/test_latexbuilder.rb +115 -35
- data/test/test_makerhelper.rb +50 -0
- data/test/test_pdfmaker_cmd.rb +36 -0
- data/test/test_preprocessor.rb +7 -7
- data/test/test_topbuilder.rb +6 -7
- data/test/test_uuid.rb +1 -0
- metadata +117 -12
- data/lib/review/index.rb +0 -323
- data/lib/review/volume.rb +0 -66
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'book_test_helper'
|
2
|
+
class PartTest < Test::Unit::TestCase
|
3
|
+
include BookTestHelper
|
4
|
+
|
5
|
+
def test_initialize
|
6
|
+
part = Book::Part.new(nil, nil, nil)
|
7
|
+
assert_equal nil, part.number
|
8
|
+
assert_equal nil, part.chapters
|
9
|
+
assert_equal '', part.name
|
10
|
+
|
11
|
+
part = Book::Part.new(nil, 123, [], 'name')
|
12
|
+
assert_equal 123, part.number
|
13
|
+
assert_equal [], part.chapters
|
14
|
+
assert_equal 'name', part.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_each_chapter
|
18
|
+
part = Book::Part.new(nil, nil, [1, 2, 3])
|
19
|
+
|
20
|
+
tmp = []
|
21
|
+
part.each_chapter do |ch|
|
22
|
+
tmp << ch
|
23
|
+
end
|
24
|
+
assert_equal [1, 2, 3], tmp
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_volume
|
28
|
+
part = Book::Part.new(nil, nil, [])
|
29
|
+
assert part.volume
|
30
|
+
assert_equal 0, part.volume.bytes
|
31
|
+
assert_equal 0, part.volume.chars
|
32
|
+
assert_equal 0, part.volume.lines
|
33
|
+
|
34
|
+
chs = []
|
35
|
+
tfs = [] ## prevent from removing Tempfile
|
36
|
+
Tempfile.open('part_test') do |o|
|
37
|
+
o.print "12345"
|
38
|
+
chs << Book::Chapter.new(nil, nil, nil, o.path)
|
39
|
+
tfs << o
|
40
|
+
end
|
41
|
+
Tempfile.open('part_test') do |o|
|
42
|
+
o.print "67890"
|
43
|
+
chs << Book::Chapter.new(nil, nil, nil, o.path)
|
44
|
+
tfs << o
|
45
|
+
end
|
46
|
+
|
47
|
+
part = Book::Part.new(nil, nil, chs)
|
48
|
+
assert part.volume
|
49
|
+
assert part.volume.bytes > 0
|
50
|
+
assert part.volume.chars > 0
|
51
|
+
assert part.volume.lines > 0
|
52
|
+
end
|
53
|
+
end
|
data/test/test_builder.rb
CHANGED
@@ -98,7 +98,6 @@ class BuidlerTest < Test::Unit::TestCase
|
|
98
98
|
:source_header, :source_body,
|
99
99
|
:image_image, :image_dummy,
|
100
100
|
:table_header, :table_begin, :tr, :th, :table_end,
|
101
|
-
:nofunc_text,
|
102
101
|
:compile_ruby, :compile_kw, :compile_href,
|
103
102
|
:bibpaper_header, :bibpaper_bibpaper,
|
104
103
|
:inline_hd_chap,
|
@@ -113,18 +112,26 @@ class BuidlerTest < Test::Unit::TestCase
|
|
113
112
|
assert_equal [:text, text], @b.compile_inline(text)
|
114
113
|
end
|
115
114
|
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
115
|
+
def test_inline_ruby
|
116
|
+
def @b.compile_ruby(base,ruby)
|
117
|
+
[base,ruby]
|
118
|
+
end
|
119
|
+
str = @b.inline_ruby("foo,bar")
|
120
|
+
assert_equal str, ["foo","bar"]
|
121
|
+
str = @b.inline_ruby("foo\\,\\,,\\,bar,buz")
|
122
|
+
assert_equal str, ["foo,,",",bar,buz"]
|
121
123
|
end
|
122
124
|
|
123
|
-
def
|
124
|
-
|
125
|
+
def test_compile_inline_backslash
|
126
|
+
text = "abc\\d\\#a"
|
127
|
+
assert_equal [:text, text], @b.compile_inline(text)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_convert_outencoding
|
131
|
+
ReVIEW.book.param = {'outencoding' => "EUC"}
|
125
132
|
b = Builder.new
|
126
|
-
ret = b.convert_outencoding("a","
|
127
|
-
assert_equal
|
133
|
+
ret = b.convert_outencoding("a", ReVIEW.book.param["outencoding"])
|
134
|
+
assert_equal "a", ret
|
128
135
|
end
|
129
136
|
|
130
137
|
class XBuilder < Builder
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'review/compiler'
|
5
|
+
require 'review/book'
|
6
|
+
require 'review/latexbuilder'
|
7
|
+
|
8
|
+
class CompilerTest < Test::Unit::TestCase
|
9
|
+
include ReVIEW
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@builder = LATEXBuilder.new()
|
13
|
+
@c = Compiler.new(@builder)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_parse_args
|
17
|
+
args = @c.__send__(:parse_args, "[foo][bar]")
|
18
|
+
assert_equal ["foo","bar"], args
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_parse_args_with_brace1
|
22
|
+
args = @c.__send__(:parse_args, "[fo[\\][\\]o][bar]")
|
23
|
+
assert_equal ["fo[][]o","bar"], args
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_parse_args_with_brace2
|
27
|
+
args = @c.__send__(:parse_args, "[f\\]o\\]o][bar]")
|
28
|
+
assert_equal ["f]o]o","bar"], args
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_parse_args_with_backslash
|
32
|
+
args = @c.__send__(:parse_args, "[foo][bar\\buz]")
|
33
|
+
assert_equal ["foo","bar\\buz"], args
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_parse_args_with_backslash2
|
37
|
+
args = @c.__send__(:parse_args, "[foo][bar\\#\\[\\!]")
|
38
|
+
assert_equal ["foo","bar\\#\\[\\!"], args
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_parse_args_with_backslash3
|
42
|
+
args = @c.__send__(:parse_args, "[foo][bar\\\\buz]")
|
43
|
+
assert_equal ["foo","bar\\buz"], args
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/test/test_epubmaker.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
REVIEW_EPUBMAKER = File.expand_path('../bin/review-epubmaker', File.dirname(__FILE__))
|
9
|
+
|
10
|
+
class EPUBMakerCmdTest < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@tmpdir1 = Dir.mktmpdir
|
13
|
+
@tmpdir2 = Dir.mktmpdir
|
14
|
+
|
15
|
+
@old_rubylib = ENV['RUBYLIB']
|
16
|
+
ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
FileUtils.rm_rf @tmpdir1
|
21
|
+
FileUtils.rm_rf @tmpdir2
|
22
|
+
ENV['RUBYLIB'] = @old_rubylib
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_epubmaker_cmd
|
26
|
+
config = prepare_samplebook(@tmpdir1)
|
27
|
+
builddir = @tmpdir1 + "/" + config['bookname'] + '-epub'
|
28
|
+
assert ! File.exists?(builddir)
|
29
|
+
|
30
|
+
Dir.chdir(@tmpdir1) do
|
31
|
+
system("#{REVIEW_EPUBMAKER} config.yml 1>/dev/null 2>/dev/null")
|
32
|
+
end
|
33
|
+
|
34
|
+
assert File.exists?(builddir)
|
35
|
+
end
|
36
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -8,3 +8,20 @@ def ul_helper(src, expect)
|
|
8
8
|
assert_equal expect, @builder.raw_result
|
9
9
|
end
|
10
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
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -4,6 +4,7 @@ require 'test_helper'
|
|
4
4
|
require 'review/compiler'
|
5
5
|
require 'review/book'
|
6
6
|
require 'review/htmlbuilder'
|
7
|
+
require 'review/i18n'
|
7
8
|
|
8
9
|
class HTMLBuidlerTest < Test::Unit::TestCase
|
9
10
|
include ReVIEW
|
@@ -19,46 +20,46 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
19
20
|
}
|
20
21
|
ReVIEW.book.param = @param
|
21
22
|
@compiler = ReVIEW::Compiler.new(@builder)
|
22
|
-
@chapter = Chapter.new(nil, 1, '-', nil, StringIO.new)
|
23
|
+
@chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
|
23
24
|
location = Location.new(nil, nil)
|
24
25
|
@builder.bind(@compiler, @chapter, location)
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_headline_level1
|
28
29
|
@builder.headline(1,"test","this is test.")
|
29
|
-
assert_equal %Q|<h1 id="test"><a id="h1"
|
30
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this is test.</h1>\n|, @builder.raw_result
|
30
31
|
end
|
31
32
|
|
32
33
|
def test_headline_level1_without_secno
|
33
34
|
@param["secnolevel"] = 0
|
34
35
|
@builder.headline(1,"test","this is test.")
|
35
|
-
assert_equal %Q|<h1 id="test"><a id="h1"
|
36
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>this is test.</h1>\n|, @builder.raw_result
|
36
37
|
end
|
37
38
|
|
38
39
|
def test_headline_level1_with_inlinetag
|
39
40
|
@builder.headline(1,"test","this @<b>{is} test.<&\">")
|
40
|
-
assert_equal %Q|<h1 id="test"><a id="h1"
|
41
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this <b>is</b> test.<&"></h1>\n|, @builder.raw_result
|
41
42
|
end
|
42
43
|
|
43
44
|
def test_headline_level2
|
44
45
|
@builder.headline(2,"test","this is test.")
|
45
|
-
assert_equal %Q|\n<h2 id="test"><a id="h1-1"
|
46
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|, @builder.raw_result
|
46
47
|
end
|
47
48
|
|
48
49
|
def test_headline_level3
|
49
50
|
@builder.headline(3,"test","this is test.")
|
50
|
-
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"
|
51
|
+
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n|, @builder.raw_result
|
51
52
|
end
|
52
53
|
|
53
54
|
def test_headline_level3_with_secno
|
54
55
|
@param["secnolevel"] = 3
|
55
56
|
@builder.headline(3,"test","this is test.")
|
56
|
-
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"
|
57
|
+
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
58
|
end
|
58
59
|
|
59
60
|
def test_label
|
60
61
|
@builder.label("label_test")
|
61
|
-
assert_equal %Q|<a id="label_test"
|
62
|
+
assert_equal %Q|<a id="label_test"></a>\n|, @builder.raw_result
|
62
63
|
end
|
63
64
|
|
64
65
|
def test_href
|
@@ -131,6 +132,21 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
131
132
|
assert_equal %Q|test <tt><b>inline test</b></tt> test2|, ret
|
132
133
|
end
|
133
134
|
|
135
|
+
def test_inline_hd_chap
|
136
|
+
def @chapter.headline_index
|
137
|
+
items = [Book::HeadlineIndex::Item.new("chap1|test", [1, 1], "te_st")]
|
138
|
+
Book::HeadlineIndex.new(items, self)
|
139
|
+
end
|
140
|
+
|
141
|
+
@param["secnolevel"] = 2
|
142
|
+
ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
|
143
|
+
assert_equal %Q|test 「te_st」 test2|, ret
|
144
|
+
|
145
|
+
@param["secnolevel"] = 3
|
146
|
+
ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
|
147
|
+
assert_equal %Q|test 「1.1.1 te_st」 test2|, ret
|
148
|
+
end
|
149
|
+
|
134
150
|
def test_inline_uchar
|
135
151
|
ret = @builder.compile_inline("test @<uchar>{2460} test2")
|
136
152
|
assert_equal %Q|test ① test2|, ret
|
@@ -138,7 +154,17 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
138
154
|
|
139
155
|
def test_inline_ruby
|
140
156
|
ret = @builder.compile_inline("@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。")
|
141
|
-
assert_equal "<ruby><rb>粗雑</rb><rp
|
157
|
+
assert_equal "<ruby><rb>粗雑</rb><rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby><rb>繊細</rb><rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。", ret
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_inline_ruby_comma
|
161
|
+
ret = @builder.compile_inline("@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}")
|
162
|
+
assert_equal "<ruby><rb>foo, bar, buz</rb><rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>", ret
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_inline_ref
|
166
|
+
ret = @builder.compile_inline("@<ref>{外部参照<>&}")
|
167
|
+
assert_equal %Q|<a target='外部参照<>&'>「●● 外部参照<>&」</a>|, ret
|
142
168
|
end
|
143
169
|
|
144
170
|
def test_quote
|
@@ -164,9 +190,14 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
164
190
|
assert_equal %Q|<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n|, @builder.raw_result
|
165
191
|
end
|
166
192
|
|
193
|
+
def test_centering
|
194
|
+
@builder.centering(["foo", "bar", "", "buz"])
|
195
|
+
assert_equal %Q|<p class="center">foobar</p>\n<p class="center">buz</p>\n|, @builder.raw_result
|
196
|
+
end
|
197
|
+
|
167
198
|
def test_image
|
168
199
|
def @chapter.image(id)
|
169
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
200
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
170
201
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
171
202
|
item
|
172
203
|
end
|
@@ -177,7 +208,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
177
208
|
|
178
209
|
def test_image_with_metric
|
179
210
|
def @chapter.image(id)
|
180
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
211
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
181
212
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
182
213
|
item
|
183
214
|
end
|
@@ -188,7 +219,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
188
219
|
|
189
220
|
def test_image_with_metric2
|
190
221
|
def @chapter.image(id)
|
191
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
222
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
192
223
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
193
224
|
item
|
194
225
|
end
|
@@ -198,7 +229,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
198
229
|
|
199
230
|
def test_indepimage
|
200
231
|
def @chapter.image(id)
|
201
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
232
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
202
233
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
203
234
|
item
|
204
235
|
end
|
@@ -209,7 +240,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
209
240
|
|
210
241
|
def test_indepimage_without_caption
|
211
242
|
def @chapter.image(id)
|
212
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
243
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
213
244
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
214
245
|
item
|
215
246
|
end
|
@@ -220,7 +251,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
220
251
|
|
221
252
|
def test_indepimage_with_metric
|
222
253
|
def @chapter.image(id)
|
223
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
254
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
224
255
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
225
256
|
item
|
226
257
|
end
|
@@ -231,7 +262,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
231
262
|
|
232
263
|
def test_indepimage_with_metric2
|
233
264
|
def @chapter.image(id)
|
234
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
265
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
235
266
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
236
267
|
item
|
237
268
|
end
|
@@ -242,7 +273,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
242
273
|
|
243
274
|
def test_indepimage_without_caption_but_with_metric
|
244
275
|
def @chapter.image(id)
|
245
|
-
item = ImageIndex::Item.new("sampleimg",1)
|
276
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
246
277
|
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
247
278
|
item
|
248
279
|
end
|
@@ -251,6 +282,20 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
251
282
|
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" width="120%" />\n</div>\n|, @builder.raw_result
|
252
283
|
end
|
253
284
|
|
285
|
+
def test_list
|
286
|
+
def @chapter.list(id)
|
287
|
+
Book::ListIndex::Item.new("samplelist",1)
|
288
|
+
end
|
289
|
+
@builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_")
|
290
|
+
|
291
|
+
begin # FIXME: Use params instead of exception handling
|
292
|
+
require 'pygments'
|
293
|
+
assert_equal %Q|<div class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b><&>_</p>\n<pre class="list">test1\ntest1.5\n\ntest<span style="color: #666666"><</span>i<span style="color: #666666">>2</</span>i<span style="color: #666666">></span>\n</pre>\n</div>\n|, @builder.raw_result
|
294
|
+
rescue LoadError
|
295
|
+
assert_equal %Q|<div class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b><&>_</p>\n<pre class="list">test1\ntest1.5\n\ntest<i>2</i>\n</pre>\n</div>\n|, @builder.raw_result
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
254
299
|
def test_emlist
|
255
300
|
@builder.emlist(["lineA","lineB"])
|
256
301
|
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, @builder.raw_result
|
@@ -261,6 +306,17 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
261
306
|
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
|
262
307
|
end
|
263
308
|
|
309
|
+
def test_emlist_with_tab
|
310
|
+
@builder.emlist(["\tlineA","\t\tlineB","\tlineC"])
|
311
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, @builder.raw_result
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_emlist_with_4tab
|
315
|
+
@builder.instance_eval{@tabwidth=4}
|
316
|
+
@builder.emlist(["\tlineA","\t\tlineB","\tlineC"])
|
317
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, @builder.raw_result
|
318
|
+
end
|
319
|
+
|
264
320
|
def test_cmd
|
265
321
|
@builder.cmd(["lineA","lineB"])
|
266
322
|
assert_equal %Q|<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|, @builder.raw_result
|
@@ -273,7 +329,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
273
329
|
|
274
330
|
def test_bib
|
275
331
|
def @chapter.bibpaper(id)
|
276
|
-
BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
332
|
+
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
277
333
|
end
|
278
334
|
|
279
335
|
assert_equal %Q|<a href="./bib.html#bib-samplebib">[1]</a>|, @builder.inline_bib("samplebib")
|
@@ -281,11 +337,20 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
281
337
|
|
282
338
|
def test_bibpaper
|
283
339
|
def @chapter.bibpaper(id)
|
284
|
-
BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
340
|
+
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
285
341
|
end
|
286
342
|
|
287
343
|
@builder.bibpaper(["a", "b"], "samplebib", "sample bib @<b>{bold}")
|
288
|
-
assert_equal %Q|<div>\n<a id=\"bib-samplebib\"
|
344
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p></div>\n|, @builder.raw_result
|
345
|
+
end
|
346
|
+
|
347
|
+
def test_bibpaper_with_anchor
|
348
|
+
def @chapter.bibpaper(id)
|
349
|
+
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
350
|
+
end
|
351
|
+
|
352
|
+
@builder.bibpaper(["a", "b"], "samplebib", "sample bib @<href>{http://example.jp}")
|
353
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <a href=\"http://example.jp\" class=\"link\">http://example.jp</a>\n<p>ab</p></div>\n|, @builder.raw_result
|
289
354
|
end
|
290
355
|
|
291
356
|
def column_helper(review)
|
@@ -309,12 +374,12 @@ EOS
|
|
309
374
|
expect =<<-EOS
|
310
375
|
<div class="column">
|
311
376
|
|
312
|
-
<h3><a id="
|
377
|
+
<h3><a id="column-1"></a>prev column</h3>
|
313
378
|
<p>inside prev column</p>
|
314
379
|
</div>
|
315
380
|
<div class="column">
|
316
381
|
|
317
|
-
<h3><a id="
|
382
|
+
<h3><a id="column-2"></a>test</h3>
|
318
383
|
<p>inside column</p>
|
319
384
|
</div>
|
320
385
|
EOS
|
@@ -332,11 +397,11 @@ EOS
|
|
332
397
|
expect =<<-EOS
|
333
398
|
<div class="column">
|
334
399
|
|
335
|
-
<h3><a id="
|
400
|
+
<h3><a id="column-1"></a>test</h3>
|
336
401
|
<p>inside column</p>
|
337
402
|
</div>
|
338
403
|
|
339
|
-
<h3><a id="h1-0-
|
404
|
+
<h3><a id="h1-0-1"></a>next level</h3>
|
340
405
|
EOS
|
341
406
|
|
342
407
|
assert_equal expect, column_helper(review)
|
@@ -439,6 +504,63 @@ EOS
|
|
439
504
|
ul_helper(src, expect)
|
440
505
|
end
|
441
506
|
|
507
|
+
def test_ul_nest4
|
508
|
+
src =<<-EOS
|
509
|
+
* A
|
510
|
+
** AA
|
511
|
+
*** AAA
|
512
|
+
* B
|
513
|
+
** BB
|
514
|
+
EOS
|
515
|
+
|
516
|
+
expect =<<-EOS
|
517
|
+
<ul>
|
518
|
+
<li>A<ul>
|
519
|
+
<li>AA<ul>
|
520
|
+
<li>AAA</li>
|
521
|
+
</ul>
|
522
|
+
</li>
|
523
|
+
</ul>
|
524
|
+
</li>
|
525
|
+
<li>B<ul>
|
526
|
+
<li>BB</li>
|
527
|
+
</ul>
|
528
|
+
</li>
|
529
|
+
</ul>
|
530
|
+
EOS
|
531
|
+
ul_helper(src, expect)
|
532
|
+
end
|
533
|
+
|
534
|
+
def test_ul_nest5
|
535
|
+
src =<<-EOS
|
536
|
+
* A
|
537
|
+
** AA
|
538
|
+
**** AAAA
|
539
|
+
* B
|
540
|
+
** BB
|
541
|
+
EOS
|
542
|
+
|
543
|
+
expect =<<-EOS
|
544
|
+
<ul>
|
545
|
+
<li>A<ul>
|
546
|
+
<li>AA<ul>
|
547
|
+
<li><ul>
|
548
|
+
<li>AAAA</li>
|
549
|
+
</ul>
|
550
|
+
</li>
|
551
|
+
</ul>
|
552
|
+
</li>
|
553
|
+
</ul>
|
554
|
+
</li>
|
555
|
+
<li>B<ul>
|
556
|
+
<li>BB</li>
|
557
|
+
</ul>
|
558
|
+
</li>
|
559
|
+
</ul>
|
560
|
+
EOS
|
561
|
+
ul_helper(src, expect)
|
562
|
+
end
|
563
|
+
|
442
564
|
def test_inline_raw0
|
443
565
|
assert_equal "normal", @builder.inline_raw("normal")
|
444
566
|
end
|
@@ -505,4 +627,14 @@ EOS
|
|
505
627
|
EOS
|
506
628
|
assert_equal expect.chomp, @builder.raw_result
|
507
629
|
end
|
630
|
+
|
631
|
+
def test_inline_fn
|
632
|
+
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
|
633
|
+
@chapter.instance_eval{@footnote_index=fn}
|
634
|
+
@builder.footnote("foo",'bar\\a\\$buz')
|
635
|
+
expect =<<-'EOS'
|
636
|
+
<div class="footnote"><p class="footnote">[<a id="fn-foo">*1</a>] bar\a\$buz</p></div>
|
637
|
+
EOS
|
638
|
+
assert_equal expect, @builder.raw_result
|
639
|
+
end
|
508
640
|
end
|