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
@@ -0,0 +1,198 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'lineinput'
|
5
|
+
require 'tempfile'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class LineInputTest < Test::Unit::TestCase
|
9
|
+
def test_initialize
|
10
|
+
io = StringIO.new
|
11
|
+
li = LineInput.new(io)
|
12
|
+
assert_equal 0, li.lineno
|
13
|
+
assert !li.eof?
|
14
|
+
assert_equal "#<LineInput file=#{io.inspect} line=0>", li.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_gets
|
18
|
+
content = "abc\ndef\r\nghi\rjkl"
|
19
|
+
do_test_gets(StringIO.new(content))
|
20
|
+
Tempfile.open("lineinput_test") do |io|
|
21
|
+
io.print content
|
22
|
+
io.rewind
|
23
|
+
do_test_gets(io)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def do_test_gets(io)
|
28
|
+
li = LineInput.new(io)
|
29
|
+
|
30
|
+
assert_equal "abc\n", li.gets
|
31
|
+
assert_equal "def\r\n", li.gets
|
32
|
+
assert_equal "ghi\rjkl", li.gets
|
33
|
+
assert_equal 3, li.lineno
|
34
|
+
assert !li.eof?
|
35
|
+
|
36
|
+
assert_equal nil, li.gets
|
37
|
+
assert_equal 4, li.lineno # XXX: OK?
|
38
|
+
assert li.eof?
|
39
|
+
|
40
|
+
assert_equal nil, li.gets
|
41
|
+
assert_equal 4, li.lineno
|
42
|
+
assert li.eof?
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_ungets
|
46
|
+
io = StringIO.new('abc')
|
47
|
+
li = LineInput.new(io)
|
48
|
+
|
49
|
+
line = li.gets
|
50
|
+
assert_equal line, li.ungets(line)
|
51
|
+
assert_equal 0, li.lineno
|
52
|
+
assert_equal line, li.gets
|
53
|
+
|
54
|
+
li.ungets('xyz')
|
55
|
+
assert_equal 0, li.lineno
|
56
|
+
li.ungets('xyz')
|
57
|
+
assert_equal -1, li.lineno # XXX: OK?
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_peek
|
61
|
+
li = LineInput.new(StringIO.new)
|
62
|
+
assert_equal nil, li.peek
|
63
|
+
|
64
|
+
li = LineInput.new(StringIO.new('abc'))
|
65
|
+
assert_equal 'abc', li.peek
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_next?
|
69
|
+
li = LineInput.new(StringIO.new)
|
70
|
+
assert !li.next?
|
71
|
+
|
72
|
+
li = LineInput.new(StringIO.new('abc'))
|
73
|
+
assert li.next?
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_skip_blank_lines
|
77
|
+
if "".respond_to?(:encode)
|
78
|
+
euc_jp_spc = " ".encode("EUC-JP")
|
79
|
+
else
|
80
|
+
euc_jp_spc = "\xa1\xa1" # EUC-JP 全角空白
|
81
|
+
end
|
82
|
+
[
|
83
|
+
["", 0, nil],
|
84
|
+
["\n \n \nabc", 3, 'abc'],
|
85
|
+
["\t", 1, nil],
|
86
|
+
[euc_jp_spc, 0, euc_jp_spc],
|
87
|
+
].each do |text, n, rest|
|
88
|
+
li = LineInput.new(StringIO.new(text))
|
89
|
+
assert_equal n, li.skip_blank_lines
|
90
|
+
assert_equal rest, li.gets
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_gets_if
|
95
|
+
io = StringIO.new
|
96
|
+
li = LineInput.new(io)
|
97
|
+
assert_equal nil, li.gets_if(//)
|
98
|
+
|
99
|
+
io = StringIO.new("abc\ndef\nghi")
|
100
|
+
li = LineInput.new(io)
|
101
|
+
|
102
|
+
assert_equal "abc\n", li.gets_if(//)
|
103
|
+
assert_equal nil, li.gets_if(/^X/)
|
104
|
+
assert_equal nil, li.gets_if(/^g/)
|
105
|
+
assert_equal "def\n", li.gets_if(/^d/)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_gets_unless
|
109
|
+
io = StringIO.new
|
110
|
+
li = LineInput.new(io)
|
111
|
+
assert_equal nil, li.gets_unless(//)
|
112
|
+
|
113
|
+
io = StringIO.new("abc\ndef\nghi")
|
114
|
+
li = LineInput.new(io)
|
115
|
+
|
116
|
+
assert_equal nil, li.gets_unless(//)
|
117
|
+
assert_equal "abc\n", li.gets_unless(/^X/)
|
118
|
+
assert_equal nil, li.gets_unless(/^d/)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_each
|
122
|
+
content = "abc\ndef\nghi"
|
123
|
+
io = StringIO.new(content)
|
124
|
+
li = LineInput.new(io)
|
125
|
+
|
126
|
+
data = ''
|
127
|
+
li.each {|l| data << l }
|
128
|
+
assert_equal content, data
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_while_match
|
132
|
+
io = StringIO.new("abc\ndef\nghi")
|
133
|
+
li = LineInput.new(io)
|
134
|
+
|
135
|
+
li.while_match(/^[ad]/) {}
|
136
|
+
assert_equal 2, li.lineno
|
137
|
+
assert_equal "ghi", li.gets
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_getlines_while
|
141
|
+
io = StringIO.new("abc\ndef\nghi")
|
142
|
+
li = LineInput.new(io)
|
143
|
+
|
144
|
+
buf = li.getlines_while(/^[ad]/)
|
145
|
+
assert_equal ["abc\n", "def\n"], buf
|
146
|
+
assert_equal 2, li.lineno
|
147
|
+
assert_equal "ghi", li.gets
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_until_match
|
151
|
+
io = StringIO.new("abc\ndef\nghi")
|
152
|
+
li = LineInput.new(io)
|
153
|
+
|
154
|
+
li.until_match(/^[^a]/) {}
|
155
|
+
assert_equal 1, li.lineno
|
156
|
+
assert_equal "def\n", li.gets
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_getlines_until
|
160
|
+
io = StringIO.new("abc\ndef\nghi")
|
161
|
+
li = LineInput.new(io)
|
162
|
+
|
163
|
+
buf = li.getlines_until(/^[^a]/)
|
164
|
+
assert_equal ["abc\n"], buf
|
165
|
+
assert_equal 1, li.lineno
|
166
|
+
assert_equal "def\n", li.gets
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_until_terminator
|
170
|
+
io = StringIO.new("abc\n//}\ndef\nghi\n//}\njkl\nmno")
|
171
|
+
li = LineInput.new(io)
|
172
|
+
|
173
|
+
data = ''
|
174
|
+
li.until_terminator(%r<\A//\}>) {|l| data << l }
|
175
|
+
assert_equal "abc\n", data
|
176
|
+
assert_equal 2, li.lineno
|
177
|
+
|
178
|
+
data = ''
|
179
|
+
li.until_terminator(%r<\A//\}>) {|l| data << l }
|
180
|
+
assert_equal "def\nghi\n", data
|
181
|
+
assert_equal 5, li.lineno
|
182
|
+
|
183
|
+
data = ''
|
184
|
+
li.until_terminator(%r<\A//\}>) {|l| data << l }
|
185
|
+
assert_equal "jkl\nmno", data
|
186
|
+
assert_equal 7, li.lineno
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_until_terminator
|
190
|
+
io = StringIO.new("abc\ndef\n//}\nghi\n//}")
|
191
|
+
li = LineInput.new(io)
|
192
|
+
|
193
|
+
data = li.getblock(%r<\A//\}>)
|
194
|
+
assert_equal ["abc\n", "def\n"], data
|
195
|
+
assert_equal 3, li.lineno
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/preprocessor'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class PreprocessorStripTest < Test::Unit::TestCase
|
6
|
+
include ReVIEW
|
7
|
+
|
8
|
+
def test_gets
|
9
|
+
f = StringIO.new '= Header'
|
10
|
+
s = Preprocessor::Strip.new(f)
|
11
|
+
expect = '= Header'
|
12
|
+
actual = s.gets
|
13
|
+
assert_equal expect, actual
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_gets_with_comment
|
17
|
+
f = StringIO.new '#@warn(write it later)'
|
18
|
+
s = Preprocessor::Strip.new(f)
|
19
|
+
expect = '#@#' + "\n"
|
20
|
+
actual = s.gets
|
21
|
+
assert_equal expect, actual
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/textutils'
|
3
|
+
|
4
|
+
class TextUtilsTest < Test::Unit::TestCase
|
5
|
+
include ReVIEW::TextUtils
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@tu_nil = Object.new
|
9
|
+
@tu_nil.extend ReVIEW::TextUtils
|
10
|
+
def @tu_nil.pre_paragraph;nil;end
|
11
|
+
def @tu_nil.post_paragraph;nil;end
|
12
|
+
|
13
|
+
@tu_p = Object.new
|
14
|
+
@tu_p.extend ReVIEW::TextUtils
|
15
|
+
def @tu_p.pre_paragraph;'<p>';end
|
16
|
+
def @tu_p.post_paragraph;'</p>';end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_detab
|
20
|
+
detabed = detab("\t\tabc")
|
21
|
+
assert_equal " abc", detabed
|
22
|
+
detabed = detab("\tabc\tbcd")
|
23
|
+
assert_equal " abc bcd", detabed
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_detab_with_arg
|
27
|
+
detabed = detab("\t\tabcd\tef",2)
|
28
|
+
assert_equal " abcd ef", detabed
|
29
|
+
detabed = detab("\tabc\tdef", 4)
|
30
|
+
assert_equal " abc def", detabed
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_split_paragraph_empty_nil
|
34
|
+
ret = @tu_nil.split_paragraph([])
|
35
|
+
assert_equal ret, [""]
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_split_paragraph_empty_p
|
39
|
+
ret = @tu_p.split_paragraph([])
|
40
|
+
assert_equal ret, ["<p></p>"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_split_paragraph_p
|
44
|
+
ret = @tu_p.split_paragraph(["abc"])
|
45
|
+
assert_equal ["<p>abc</p>"], ret
|
46
|
+
ret = @tu_p.split_paragraph(["abc","def"])
|
47
|
+
assert_equal ["<p>abcdef</p>"], ret
|
48
|
+
ret = @tu_p.split_paragraph(["abc","","def"])
|
49
|
+
assert_equal ["<p>abc</p>","<p>def</p>"], ret
|
50
|
+
ret = @tu_p.split_paragraph(["abc","","","def"])
|
51
|
+
assert_equal ["<p>abc</p>","<p>def</p>"], ret
|
52
|
+
ret = @tu_p.split_paragraph(["abc","","","def","ghi"])
|
53
|
+
assert_equal ["<p>abc</p>","<p>defghi</p>"], ret
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_split_paragraph_nil
|
57
|
+
ret = @tu_nil.split_paragraph(["abc"])
|
58
|
+
assert_equal ["abc"], ret
|
59
|
+
ret = @tu_nil.split_paragraph(["abc","def"])
|
60
|
+
assert_equal ["abcdef"], ret
|
61
|
+
ret = @tu_nil.split_paragraph(["abc","","def"])
|
62
|
+
assert_equal ["abc","def"], ret
|
63
|
+
ret = @tu_nil.split_paragraph(["abc","","","def"])
|
64
|
+
assert_equal ["abc","def"], ret
|
65
|
+
ret = @tu_nil.split_paragraph(["abc","","","def","ghi"])
|
66
|
+
assert_equal ["abc","defghi"], ret
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'review/compiler'
|
5
|
+
require 'review/book'
|
6
|
+
require 'review/topbuilder'
|
7
|
+
|
8
|
+
class TOPBuidlerTest < Test::Unit::TestCase
|
9
|
+
include ReVIEW
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@builder = TOPBuilder.new()
|
13
|
+
@param = {
|
14
|
+
"secnolevel" => 2,
|
15
|
+
"inencoding" => "UTF-8",
|
16
|
+
"outencoding" => "UTF-8",
|
17
|
+
"subdirmode" => nil,
|
18
|
+
}
|
19
|
+
ReVIEW.book.param = @param
|
20
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
21
|
+
@chapter = Book::Chapter.new(nil, 1, '-', nil, StringIO.new)
|
22
|
+
location = Location.new(nil, nil)
|
23
|
+
@builder.bind(@compiler, @chapter, location)
|
24
|
+
|
25
|
+
@builder.instance_eval do
|
26
|
+
# to ignore lineno in original method
|
27
|
+
def warn(msg)
|
28
|
+
puts msg
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
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
|
+
end
|
37
|
+
|
38
|
+
def test_headline_level1_without_secno
|
39
|
+
@param["secnolevel"] = 0
|
40
|
+
@builder.headline(1,"test","this is test.")
|
41
|
+
assert_equal %Q|■H1■this is test.\n|, @builder.raw_result
|
42
|
+
end
|
43
|
+
|
44
|
+
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
|
+
end
|
48
|
+
|
49
|
+
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
|
+
end
|
53
|
+
|
54
|
+
def test_headline_level3_with_secno
|
55
|
+
@param["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
|
+
end
|
59
|
+
|
60
|
+
def test_href
|
61
|
+
ret = @builder.compile_href("http://github.com", "GitHub")
|
62
|
+
assert_equal %Q|GitHub(△http://github.com☆)|, ret
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_href_without_label
|
66
|
+
ret = @builder.compile_href("http://github.com",nil)
|
67
|
+
assert_equal %Q|△http://github.com☆|, ret
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_inline_raw
|
71
|
+
ret = @builder.inline_raw("@<tt>{inline}")
|
72
|
+
assert_equal %Q|@<tt>{inline}|, ret
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_inline_ruby
|
76
|
+
ret = @builder.compile_ruby("coffin", "bed")
|
77
|
+
assert_equal %Q|coffin◆→DTP連絡:「coffin」に「bed」とルビ←◆|, ret
|
78
|
+
end
|
79
|
+
|
80
|
+
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
|
+
end
|
84
|
+
|
85
|
+
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
|
+
end
|
89
|
+
|
90
|
+
def test_inline_br
|
91
|
+
ret = @builder.inline_br("")
|
92
|
+
assert_equal %Q|\n|, ret
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_inline_uchar
|
96
|
+
ret = @builder.compile_inline("test @<uchar>{2460} test2")
|
97
|
+
assert_equal %Q|test ① test2|, ret
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_inline_in_table
|
101
|
+
@builder.table(["★1☆\t▲2☆", "------------", "★3☆\t▲4☆<>&"])
|
102
|
+
assert_equal %Q|★★1☆☆\t★▲2☆☆\n★3☆\t▲4☆<>&\n◆→終了:表←◆\n\n|, @builder.raw_result
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_paragraph
|
106
|
+
lines = ["foo","bar"]
|
107
|
+
@builder.paragraph(lines)
|
108
|
+
assert_equal %Q|foobar\n|, @builder.raw_result
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_tabbed_paragraph
|
112
|
+
lines = ["\tfoo","bar"]
|
113
|
+
@builder.paragraph(lines)
|
114
|
+
assert_equal %Q|\tfoobar\n|, @builder.raw_result
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_flushright
|
118
|
+
@builder.flushright(["foo", "bar", "","buz"])
|
119
|
+
assert_equal %Q|◆→開始:右寄せ←◆\nfoobar\nbuz\n◆→終了:右寄せ←◆\n\n|, @builder.raw_result
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_noindent
|
123
|
+
@builder.noindent
|
124
|
+
@builder.paragraph(["foo", "bar"])
|
125
|
+
@builder.paragraph(["foo2", "bar2"])
|
126
|
+
assert_equal %Q|◆→DTP連絡:次の1行インデントなし←◆\nfoobar\nfoo2bar2\n|, @builder.raw_result
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_list
|
130
|
+
def @chapter.list(id)
|
131
|
+
Book::ListIndex::Item.new("test",1)
|
132
|
+
end
|
133
|
+
@builder.list(["foo", "bar"], "test", "this is @<b>{test}<&>_")
|
134
|
+
assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\nfoo\nbar\n◆→終了:リスト←◆\n\n|, @builder.raw_result
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_listnum
|
138
|
+
def @chapter.list(id)
|
139
|
+
Book::ListIndex::Item.new("test",1)
|
140
|
+
end
|
141
|
+
@builder.listnum(["foo", "bar"], "test", "this is @<b>{test}<&>_")
|
142
|
+
assert_equal %Q|◆→開始:リスト←◆\nリスト1.1 this is ★test☆<&>_\n\n 1: foo\n 2: bar\n◆→終了:リスト←◆\n\n|, @builder.raw_result
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_emlistnum
|
146
|
+
@builder.emlistnum(["foo", "bar"], "this is @<b>{test}<&>_")
|
147
|
+
assert_equal %Q|◆→開始:インラインリスト←◆\n■this is ★test☆<&>_\n 1: foo\n 2: bar\n◆→終了:インラインリスト←◆\n\n|, @builder.raw_result
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_image
|
151
|
+
def @chapter.image(id)
|
152
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
153
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
154
|
+
item
|
155
|
+
end
|
156
|
+
|
157
|
+
@builder.image(["foo"], "sampleimg","sample photo",nil)
|
158
|
+
assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, @builder.raw_result
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_image_with_metric
|
162
|
+
def @chapter.image(id)
|
163
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
164
|
+
item.instance_eval{@pathes=["./images/chap1-sampleimg.png"]}
|
165
|
+
item
|
166
|
+
end
|
167
|
+
|
168
|
+
@builder.image(["foo"], "sampleimg","sample photo","scale=1.2")
|
169
|
+
assert_equal %Q|◆→開始:図←◆\n図1.1 sample photo\n\n◆→./images/chap1-sampleimg.png←◆\n◆→終了:図←◆\n\n|, @builder.raw_result
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_texequation
|
173
|
+
@builder.texequation(["\\sin", "1^{2}"])
|
174
|
+
assert_equal %Q|◆→開始:TeX式←◆\n\\sin\n1^{2}\n◆→終了:TeX式←◆\n\n|, @builder.raw_result
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_inline_raw0
|
178
|
+
assert_equal "normal", @builder.inline_raw("normal")
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_inline_raw1
|
182
|
+
assert_equal "body", @builder.inline_raw("|top|body")
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_inline_raw2
|
186
|
+
assert_equal "body", @builder.inline_raw("|top, latex|body")
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_inline_raw3
|
190
|
+
assert_equal "", @builder.inline_raw("|idgxml, html|body")
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_inline_raw4
|
194
|
+
assert_equal "|top body", @builder.inline_raw("|top body")
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_inline_raw5
|
198
|
+
assert_equal "nor\nmal", @builder.inline_raw("|top|nor\\nmal")
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_block_raw0
|
202
|
+
@builder.raw("<>!\"\\n& ")
|
203
|
+
expect =<<-EOS
|
204
|
+
<>!"
|
205
|
+
&
|
206
|
+
EOS
|
207
|
+
assert_equal expect.chomp, @builder.raw_result
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_block_raw1
|
211
|
+
@builder.raw("|top|<>!\"\\n& ")
|
212
|
+
expect =<<-EOS
|
213
|
+
<>!"
|
214
|
+
&
|
215
|
+
EOS
|
216
|
+
assert_equal expect.chomp, @builder.raw_result
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_block_raw2
|
220
|
+
@builder.raw("|top, latex|<>!\"\\n& ")
|
221
|
+
expect =<<-EOS
|
222
|
+
<>!\"
|
223
|
+
&
|
224
|
+
EOS
|
225
|
+
assert_equal expect.chomp, @builder.raw_result
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_block_raw3
|
229
|
+
@builder.raw("|latex, idgxml|<>!\"\\n& ")
|
230
|
+
expect =<<-EOS
|
231
|
+
EOS
|
232
|
+
assert_equal expect.chomp, @builder.raw_result
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_block_raw4
|
236
|
+
@builder.raw("|top <>!\"\\n& ")
|
237
|
+
expect =<<-EOS
|
238
|
+
|top <>!\"
|
239
|
+
&
|
240
|
+
EOS
|
241
|
+
assert_equal expect.chomp, @builder.raw_result
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|