review 2.0.0.beta1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +66 -1
- data/.rubocop_todo.yml +617 -0
- data/.travis.yml +16 -1
- data/ChangeLog +48 -0
- data/Dockerfile +22 -0
- data/Gemfile +0 -1
- data/README.md +97 -0
- data/Rakefile +10 -11
- data/appveyor.yml +9 -0
- data/bin/review +46 -0
- data/bin/review-check +8 -21
- data/bin/review-compile +26 -43
- data/bin/review-index +9 -22
- data/bin/review-init +21 -25
- data/bin/review-preproc +9 -13
- data/bin/review-validate +1 -1
- data/bin/review-vol +3 -17
- data/bin/review-webmaker +15 -0
- data/doc/NEWS.ja.md +534 -0
- data/doc/NEWS.md +538 -0
- data/doc/catalog.ja.md +10 -18
- data/doc/catalog.md +5 -9
- data/doc/config.yml.sample +319 -0
- data/doc/customize_epub.ja.md +42 -0
- data/doc/format.ja.md +320 -288
- data/doc/format.md +277 -170
- data/doc/format_idg.ja.md +82 -175
- data/doc/pdfmaker.ja.md +61 -0
- data/doc/pdfmaker.md +65 -0
- data/doc/quickstart.ja.md +88 -98
- data/doc/quickstart.md +72 -110
- data/doc/sample.css +41 -0
- data/doc/writing_vertical.ja.md +55 -0
- data/doc/writing_vertical.md +5 -0
- data/lib/epubmaker/content.rb +3 -3
- data/lib/epubmaker/epubcommon.rb +173 -145
- data/lib/epubmaker/epubv2.rb +24 -77
- data/lib/epubmaker/epubv3.rb +72 -73
- data/lib/epubmaker/producer.rb +54 -30
- data/lib/lineinput.rb +48 -0
- data/lib/review/book.rb +0 -1
- data/lib/review/book/base.rb +47 -27
- data/lib/review/book/chapter.rb +48 -19
- data/lib/review/book/compilable.rb +10 -14
- data/lib/review/book/index.rb +10 -19
- data/lib/review/book/page_metric.rb +0 -10
- data/lib/review/book/part.rb +17 -3
- data/lib/review/builder.rb +84 -68
- data/lib/review/catalog.rb +5 -1
- data/lib/review/compiler.rb +327 -4657
- data/lib/review/configure.rb +84 -10
- data/lib/review/converter.rb +28 -0
- data/lib/review/epubbuilder.rb +1 -1
- data/lib/review/epubmaker.rb +142 -158
- data/lib/review/ewbbuilder.rb +5 -5
- data/lib/review/exception.rb +1 -1
- data/lib/review/extentions.rb +1 -1
- data/lib/review/extentions/hash.rb +15 -0
- data/lib/review/extentions/string.rb +2 -1
- data/lib/review/htmlbuilder.rb +364 -348
- data/lib/review/htmltoc.rb +44 -0
- data/lib/review/htmlutils.rb +12 -6
- data/lib/review/i18n.rb +78 -6
- data/lib/review/i18n.yml +7 -4
- data/lib/review/idgxmlbuilder.rb +226 -267
- data/lib/review/latexbuilder.rb +281 -274
- data/lib/review/latexutils.rb +56 -49
- data/lib/review/makerhelper.rb +8 -4
- data/lib/review/markdownbuilder.rb +80 -124
- data/lib/review/pdfmaker.rb +197 -138
- data/lib/review/preprocessor.rb +16 -67
- data/lib/review/template.rb +24 -0
- data/lib/review/textbuilder.rb +1 -1
- data/lib/review/textutils.rb +18 -24
- data/lib/review/tocparser.rb +51 -106
- data/lib/review/tocprinter.rb +61 -117
- data/lib/review/topbuilder.rb +119 -126
- data/lib/review/unfold.rb +2 -2
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +302 -0
- data/lib/review/webtocprinter.rb +48 -0
- data/lib/review/yamlloader.rb +47 -0
- data/review.gemspec +3 -3
- data/templates/html/layout-html5.html.erb +17 -0
- data/templates/html/layout-xhtml1.html.erb +20 -0
- data/{lib/review → templates/latex}/layout.tex.erb +107 -115
- data/templates/ncx/epubv2.ncx.erb +11 -0
- data/templates/opf/epubv2.opf.erb +21 -0
- data/templates/opf/epubv3.opf.erb +18 -0
- data/templates/web/html/layout-html5.html.erb +56 -0
- data/templates/web/html/layout-xhtml1.html.erb +20 -0
- data/templates/xml/container.xml.erb +6 -0
- data/test/assets/test.xml.erb +3 -0
- data/test/assets/test_template.tex +28 -71
- data/test/assets/test_template_backmatter.tex +1 -9
- data/test/sample-book/src/Rakefile +12 -3
- data/{doc/sample.yml → test/sample-book/src/config-epub2.yml} +92 -147
- data/test/sample-book/src/config.yml +40 -154
- data/test/sample-book/src/style-web.css +45 -0
- data/test/sample-book/src/style.css +23 -1
- data/test/test.re +1 -1
- data/test/test_book.rb +15 -17
- data/test/test_book_chapter.rb +2 -80
- data/test/test_book_part.rb +1 -1
- data/test/test_builder.rb +28 -6
- data/test/test_catalog.rb +17 -0
- data/test/test_compiler.rb +14 -59
- data/test/test_configure.rb +94 -0
- data/test/test_converter.rb +21 -0
- data/test/test_epub3maker.rb +155 -3
- data/test/test_epubmaker.rb +245 -30
- data/test/test_epubmaker_cmd.rb +2 -2
- data/test/test_extentions_hash.rb +60 -0
- data/test/test_helper.rb +4 -47
- data/test/test_htmlbuilder.rb +282 -175
- data/test/test_htmltoc.rb +33 -0
- data/test/test_i18n.rb +134 -70
- data/test/test_idgxmlbuilder.rb +58 -39
- data/test/test_latexbuilder.rb +132 -14
- data/test/test_lineinput.rb +5 -26
- data/test/test_makerhelper.rb +6 -4
- data/test/test_markdownbuilder.rb +23 -5
- data/test/test_pdfmaker.rb +86 -20
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +1 -1
- data/test/test_template.rb +27 -0
- data/test/test_textutils.rb +36 -0
- data/test/test_tocparser.rb +25 -0
- data/test/test_topbuilder.rb +34 -2
- data/test/test_yamlloader.rb +188 -0
- metadata +71 -29
- data/README.rdoc +0 -81
- data/bin/review-epubmaker-legacy +0 -1024
- data/doc/ruby-uuid/README +0 -11
- data/doc/ruby-uuid/README.ja +0 -34
- data/lib/review/compiler/literals_1_8.kpeg +0 -19
- data/lib/review/compiler/literals_1_8.rb +0 -432
- data/lib/review/compiler/literals_1_9.kpeg +0 -22
- data/lib/review/compiler/literals_1_9.rb +0 -435
- data/lib/review/extentions/array.rb +0 -25
- data/lib/review/htmllayout.rb +0 -41
- data/lib/review/inaobuilder.rb +0 -357
- data/lib/review/location.rb +0 -24
- data/lib/review/node.rb +0 -267
- data/lib/review/review.kpeg +0 -724
- data/lib/uuid.rb +0 -312
- data/rubocop-todo.yml +0 -456
- data/test/test_inaobuilder.rb +0 -247
- data/test/test_uuid.rb +0 -157
data/test/test_htmlbuilder.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
|
-
require 'review
|
5
|
-
require 'review/book'
|
6
|
-
require 'review/htmlbuilder'
|
7
|
-
require 'review/i18n'
|
4
|
+
require 'review'
|
8
5
|
|
9
6
|
class HTMLBuidlerTest < Test::Unit::TestCase
|
10
7
|
include ReVIEW
|
@@ -14,10 +11,9 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
14
11
|
@builder = HTMLBuilder.new()
|
15
12
|
@config = ReVIEW::Configure.values
|
16
13
|
@config.merge!({
|
17
|
-
"secnolevel" => 2,
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"stylesheet" => nil, # for HTMLBuilder
|
14
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
15
|
+
"stylesheet" => nil, # for HTMLBuilder
|
16
|
+
"htmlext" => "html",
|
21
17
|
})
|
22
18
|
@book = Book::Base.new(".")
|
23
19
|
@book.config = @config
|
@@ -29,11 +25,11 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
29
25
|
end
|
30
26
|
|
31
27
|
def test_xmlns_ops_prefix_epub3
|
32
|
-
@book.config["epubversion"] = 3
|
33
28
|
assert_equal "epub", @builder.xmlns_ops_prefix
|
34
29
|
end
|
35
30
|
|
36
31
|
def test_xmlns_ops_prefix_epub2
|
32
|
+
@book.config["epubversion"] = 2
|
37
33
|
assert_equal "ops", @builder.xmlns_ops_prefix
|
38
34
|
end
|
39
35
|
|
@@ -49,7 +45,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
49
45
|
end
|
50
46
|
end
|
51
47
|
actual = compile_block("={test} this is test.\n")
|
52
|
-
assert_equal %Q|<h1 id="test"><a id="
|
48
|
+
assert_equal %Q|<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n|, actual
|
53
49
|
end
|
54
50
|
|
55
51
|
def test_headline_level2_postdef
|
@@ -59,51 +55,50 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
59
55
|
end
|
60
56
|
end
|
61
57
|
actual = compile_block("=={test} this is test.\n")
|
62
|
-
assert_equal %Q
|
58
|
+
assert_equal %Q|\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
|
63
59
|
end
|
64
60
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
61
|
+
def test_headline_postdef_roman
|
62
|
+
Dir.mktmpdir do |dir|
|
63
|
+
Dir.chdir(dir) do
|
64
|
+
file = File.join(dir, "locale.yml")
|
65
|
+
File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pR")}
|
66
|
+
I18n.setup("ja")
|
67
|
+
@chapter.instance_eval do
|
68
|
+
def on_APPENDIX?
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
75
72
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
83
|
-
actual = compile_block("=={test} this is test.\n")
|
84
|
-
assert_equal %Q|<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n|, actual
|
85
|
-
end
|
73
|
+
actual = compile_block("={test} this is test.\n")
|
74
|
+
assert_equal %Q|<h1 id="test"><a id="hI"></a><span class="secno">付録I </span>this is test.</h1>\n|, actual
|
75
|
+
|
76
|
+
actual = compile_block("=={test} this is test.\n")
|
77
|
+
assert_equal %Q|\n<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n|, actual
|
86
78
|
|
87
|
-
def test_headline_level1_postdef_alpha
|
88
|
-
@chapter.book.config["appendix_format"] = "alpha"
|
89
|
-
@chapter.instance_eval do
|
90
|
-
def on_APPENDIX?
|
91
|
-
true
|
92
79
|
end
|
93
80
|
end
|
94
|
-
actual = compile_block("={test} this is test.\n")
|
95
|
-
assert_equal %Q|<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n|, actual
|
96
81
|
end
|
97
82
|
|
98
|
-
def
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
83
|
+
def test_headline_postdef_alpha
|
84
|
+
Dir.mktmpdir do |dir|
|
85
|
+
Dir.chdir(dir) do
|
86
|
+
file = File.join(dir, "locale.yml")
|
87
|
+
File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pA")}
|
88
|
+
I18n.setup("ja")
|
89
|
+
@chapter.instance_eval do
|
90
|
+
def on_APPENDIX?
|
91
|
+
true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
actual = compile_block("={test} this is test.\n")
|
96
|
+
assert_equal %Q|<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n|, actual
|
97
|
+
|
98
|
+
actual = compile_block("=={test} this is test.\n")
|
99
|
+
assert_equal %Q|\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
|
103
100
|
end
|
104
101
|
end
|
105
|
-
actual = compile_block("=={test} this is test.\n")
|
106
|
-
assert_equal %Q|<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
|
107
102
|
end
|
108
103
|
|
109
104
|
def test_headline_level1_without_secno
|
@@ -124,18 +119,18 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
124
119
|
|
125
120
|
def test_headline_level2
|
126
121
|
actual = compile_block("=={test} this is test.\n")
|
127
|
-
assert_equal %Q
|
122
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
|
128
123
|
end
|
129
124
|
|
130
125
|
def test_headline_level3
|
131
126
|
actual = compile_block("==={test} this is test.\n")
|
132
|
-
assert_equal %Q
|
127
|
+
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n|, actual
|
133
128
|
end
|
134
129
|
|
135
130
|
def test_headline_level3_with_secno
|
136
131
|
@book.config["secnolevel"] = 3
|
137
132
|
actual = compile_block("==={test} this is test.\n")
|
138
|
-
assert_equal %Q
|
133
|
+
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a><span class="secno">1.0.1 </span>this is test.</h3>\n|, actual
|
139
134
|
end
|
140
135
|
|
141
136
|
def test_label
|
@@ -161,6 +156,34 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
161
156
|
def test_inline_href
|
162
157
|
actual = compile_inline("@<href>{http://github.com,Git\\,Hub}")
|
163
158
|
assert_equal %Q|<a href="http://github.com" class="link">Git,Hub</a>|, actual
|
159
|
+
|
160
|
+
@book.config["epubmaker"] ||= {}
|
161
|
+
@book.config["epubmaker"]["externallink"] = false
|
162
|
+
actual = compile_inline("@<href>{http://github.com&q=1,Git\\,Hub}")
|
163
|
+
assert_equal %Q|<a href="http://github.com&q=1" class="link">Git,Hub</a>|, actual
|
164
|
+
|
165
|
+
actual = compile_inline("@<href>{http://github.com&q=1}")
|
166
|
+
assert_equal %Q|<a href="http://github.com&q=1" class="link">http://github.com&q=1</a>|, actual
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_inline_href_epubmaker
|
170
|
+
@book.config.maker = "epubmaker"
|
171
|
+
actual = compile_inline("@<href>{http://github.com,Git\\,Hub}")
|
172
|
+
assert_equal %Q|<a href="http://github.com" class="link">Git,Hub</a>|, actual
|
173
|
+
|
174
|
+
@book.config["epubmaker"] ||= {}
|
175
|
+
@book.config["epubmaker"]["externallink"] = false
|
176
|
+
actual = compile_inline("@<href>{http://github.com&q=1,Git\\,Hub}")
|
177
|
+
assert_equal %Q|Git,Hub(http://github.com&q=1)|, actual
|
178
|
+
|
179
|
+
actual = compile_inline("@<href>{http://github.com&q=1}")
|
180
|
+
assert_equal %Q|http://github.com&q=1|, actual
|
181
|
+
|
182
|
+
@book.config["epubmaker"]["externallink"] = true
|
183
|
+
actual = compile_inline("@<href>{http://github.com&q=1,Git\\,Hub}")
|
184
|
+
assert_equal %Q|<a href="http://github.com&q=1" class="link">Git,Hub</a>|, actual
|
185
|
+
actual = compile_inline("@<href>{http://github.com&q=1}")
|
186
|
+
assert_equal %Q|<a href="http://github.com&q=1" class="link">http://github.com&q=1</a>|, actual
|
164
187
|
end
|
165
188
|
|
166
189
|
def test_inline_raw
|
@@ -200,17 +223,17 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
200
223
|
|
201
224
|
def test_inline_tt
|
202
225
|
actual = compile_inline("test @<tt>{inline test} test2")
|
203
|
-
assert_equal %Q|test <tt>inline test</
|
226
|
+
assert_equal %Q|test <code class="tt">inline test</code> test2|, actual
|
204
227
|
end
|
205
228
|
|
206
229
|
def test_inline_tti
|
207
230
|
actual = compile_inline("test @<tti>{inline test} test2")
|
208
|
-
assert_equal %Q|test <tt><i>inline test</i></
|
231
|
+
assert_equal %Q|test <code class="tt"><i>inline test</i></code> test2|, actual
|
209
232
|
end
|
210
233
|
|
211
234
|
def test_inline_ttb
|
212
235
|
actual = compile_inline("test @<ttb>{inline test} test2")
|
213
|
-
assert_equal %Q|test <tt><b>inline test</b></
|
236
|
+
assert_equal %Q|test <code class="tt"><b>inline test</b></code> test2|, actual
|
214
237
|
end
|
215
238
|
|
216
239
|
def test_inline_hd_chap
|
@@ -229,35 +252,49 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
229
252
|
end
|
230
253
|
|
231
254
|
def test_inline_hd_chap_postdef_roman
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
255
|
+
Dir.mktmpdir do |dir|
|
256
|
+
Dir.chdir(dir) do
|
257
|
+
file = File.join(dir, "locale.yml")
|
258
|
+
File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pR")}
|
259
|
+
I18n.setup("ja")
|
260
|
+
@chapter.instance_eval do
|
261
|
+
def on_APPENDIX?
|
262
|
+
true
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def @chapter.headline_index
|
267
|
+
items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
|
268
|
+
Book::HeadlineIndex.new(items, self)
|
269
|
+
end
|
270
|
+
|
271
|
+
actual = compile_inline("test @<hd>{test} test2")
|
272
|
+
assert_equal %Q|test 「I.1 te_st」 test2|, actual
|
236
273
|
end
|
237
274
|
end
|
238
|
-
def @chapter.headline_index
|
239
|
-
items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
|
240
|
-
Book::HeadlineIndex.new(items, self)
|
241
|
-
end
|
242
|
-
|
243
|
-
actual = compile_inline("test @<hd>{test} test2")
|
244
|
-
assert_equal %Q|test 「I.1 te_st」 test2|, actual
|
245
275
|
end
|
246
276
|
|
247
277
|
def test_inline_hd_chap_postdef_alpha
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
278
|
+
Dir.mktmpdir do |dir|
|
279
|
+
Dir.chdir(dir) do
|
280
|
+
file = File.join(dir, "locale.yml")
|
281
|
+
File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pA")}
|
282
|
+
I18n.setup("ja")
|
283
|
+
@chapter.instance_eval do
|
284
|
+
def on_APPENDIX?
|
285
|
+
true
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def @chapter.headline_index
|
290
|
+
items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
|
291
|
+
Book::HeadlineIndex.new(items, self)
|
292
|
+
end
|
293
|
+
|
294
|
+
actual = compile_inline("test @<hd>{test} test2")
|
295
|
+
assert_equal %Q|test 「A.1 te_st」 test2|, actual
|
252
296
|
end
|
253
297
|
end
|
254
|
-
def @chapter.headline_index
|
255
|
-
items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
|
256
|
-
Book::HeadlineIndex.new(items, self)
|
257
|
-
end
|
258
|
-
|
259
|
-
actual = compile_inline("test @<hd>{test} test2")
|
260
|
-
assert_equal %Q|test 「A.1 te_st」 test2|, actual
|
261
298
|
end
|
262
299
|
|
263
300
|
def test_inline_uchar
|
@@ -267,12 +304,12 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
267
304
|
|
268
305
|
def test_inline_ruby
|
269
306
|
actual = compile_inline("@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。")
|
270
|
-
assert_equal "<ruby
|
307
|
+
assert_equal "<ruby>粗雑<rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby>繊細<rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。", actual
|
271
308
|
end
|
272
309
|
|
273
310
|
def test_inline_ruby_comma
|
274
311
|
actual = compile_inline("@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}")
|
275
|
-
assert_equal "<ruby
|
312
|
+
assert_equal "<ruby>foo, bar, buz<rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>", actual
|
276
313
|
end
|
277
314
|
|
278
315
|
def test_inline_ref
|
@@ -320,7 +357,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
320
357
|
|
321
358
|
def test_quote
|
322
359
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
323
|
-
assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p
|
360
|
+
assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n|, actual
|
324
361
|
end
|
325
362
|
|
326
363
|
def test_memo
|
@@ -363,7 +400,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
363
400
|
end
|
364
401
|
|
365
402
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
366
|
-
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo"
|
403
|
+
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, actual
|
367
404
|
end
|
368
405
|
|
369
406
|
def test_image_with_metric2
|
@@ -374,7 +411,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
374
411
|
end
|
375
412
|
|
376
413
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
377
|
-
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo"
|
414
|
+
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, actual
|
378
415
|
end
|
379
416
|
|
380
417
|
def test_image_with_tricky_id
|
@@ -418,7 +455,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
418
455
|
end
|
419
456
|
|
420
457
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
421
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo"
|
458
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
422
459
|
end
|
423
460
|
|
424
461
|
def test_indepimage_with_metric2
|
@@ -429,7 +466,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
429
466
|
end
|
430
467
|
|
431
468
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\",latex::ignore=params]\n")
|
432
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo"
|
469
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
433
470
|
end
|
434
471
|
|
435
472
|
def test_indepimage_without_caption_but_with_metric
|
@@ -440,7 +477,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
440
477
|
end
|
441
478
|
|
442
479
|
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
443
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt=""
|
480
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n|, actual
|
444
481
|
end
|
445
482
|
|
446
483
|
def test_dlist
|
@@ -477,10 +514,11 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
477
514
|
$stderr.puts "skip test_list_pygments_lang (cannot find pygments.rb)"
|
478
515
|
return true
|
479
516
|
end
|
480
|
-
@book.config["
|
517
|
+
@book.config["highlight"] = {}
|
518
|
+
@book.config["highlight"]["html"] = "pygments"
|
481
519
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
482
520
|
|
483
|
-
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>
|
521
|
+
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|, actual
|
484
522
|
end
|
485
523
|
|
486
524
|
def test_list_pygments_lang
|
@@ -493,14 +531,15 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
493
531
|
$stderr.puts "skip test_list_pygments_lang (cannot find pygments.rb)"
|
494
532
|
return true
|
495
533
|
end
|
496
|
-
@book.config["
|
534
|
+
@book.config["highlight"] = {}
|
535
|
+
@book.config["highlight"]["html"] = "pygments"
|
497
536
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
498
537
|
|
499
538
|
assert_equal %Q|<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n| +
|
500
539
|
%Q|<pre class=\"list\"><span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n| +
|
501
540
|
%Q| (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">\|</span>i<span style=\"color: #666666\">\|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}\n| +
|
502
541
|
%Q| <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n| +
|
503
|
-
%Q|<span style=\"color: #008000; font-weight: bold\">end</span
|
542
|
+
%Q|<span style=\"color: #008000; font-weight: bold\">end</span>\n| +
|
504
543
|
%Q|</pre>\n| +
|
505
544
|
%Q|</div>\n|, actual
|
506
545
|
end
|
@@ -515,10 +554,40 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
515
554
|
$stderr.puts "skip test_list_pygments_nulllang (cannot find pygments.rb)"
|
516
555
|
return true
|
517
556
|
end
|
518
|
-
@book.config["
|
557
|
+
@book.config["highlight"] = {}
|
558
|
+
@book.config["highlight"]["html"] = "pygments"
|
519
559
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
520
560
|
|
521
|
-
assert_equal "<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<pre class=\"list\">def foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend</pre>\n</div>\n", actual
|
561
|
+
assert_equal "<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<pre class=\"list\">def foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n</pre>\n</div>\n", actual
|
562
|
+
end
|
563
|
+
|
564
|
+
def test_listnum
|
565
|
+
def @chapter.list(id)
|
566
|
+
Book::ListIndex::Item.new("samplelist",1)
|
567
|
+
end
|
568
|
+
|
569
|
+
@book.config["highlight"] = false
|
570
|
+
actual = compile_block(<<-EOS)
|
571
|
+
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
572
|
+
def foo(a1, a2=:test)
|
573
|
+
(1..3).times{|i| a.include?(:foo)}
|
574
|
+
return true
|
575
|
+
end
|
576
|
+
//}
|
577
|
+
EOS
|
578
|
+
|
579
|
+
expected =<<-EOS
|
580
|
+
<div class="code">
|
581
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
582
|
+
<pre class="list"> 1: def foo(a1, a2=:test)
|
583
|
+
2: (1..3).times{|i| a.include?(:foo)}
|
584
|
+
3: return true
|
585
|
+
4: end
|
586
|
+
</pre>
|
587
|
+
</div>
|
588
|
+
EOS
|
589
|
+
|
590
|
+
assert_equal expected, actual
|
522
591
|
end
|
523
592
|
|
524
593
|
def test_listnum_pygments_lang
|
@@ -531,10 +600,11 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
531
600
|
$stderr.puts "skip test_listnum_pygments_lang (cannot find pygments.rb)"
|
532
601
|
return true
|
533
602
|
end
|
534
|
-
@book.config["
|
603
|
+
@book.config["highlight"] = {}
|
604
|
+
@book.config["highlight"]["html"] = "pygments"
|
535
605
|
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
536
606
|
|
537
|
-
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">|</span>i<span style=\"color: #666666\">|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div
|
607
|
+
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">|</span>i<span style=\"color: #666666\">|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div>\n</div>\n", actual
|
538
608
|
end
|
539
609
|
|
540
610
|
def test_listnum_pygments_lang_without_lang
|
@@ -552,7 +622,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
552
622
|
@book.config["highlight"]["lang"] = "ruby"
|
553
623
|
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
|
554
624
|
|
555
|
-
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">|</span>i<span style=\"color: #666666\">|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div
|
625
|
+
assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b><&>_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</span> <span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span> (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">|</span>i<span style=\"color: #666666\">|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div>\n</div>\n", actual
|
556
626
|
end
|
557
627
|
|
558
628
|
|
@@ -568,9 +638,10 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
568
638
|
$stderr.puts "skip test_emlist_pygments_lang (cannot find pygments.rb)"
|
569
639
|
return true
|
570
640
|
end
|
571
|
-
@book.config["
|
641
|
+
@book.config["highlight"] = {}
|
642
|
+
@book.config["highlight"]["html"] = "pygments"
|
572
643
|
actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
573
|
-
assert_equal "<div class=\"emlist-code\">\n<pre class=\"emlist\"><span style=\"color: #008000; font-weight: bold\">SELECT</span> <span style=\"color: #008000; font-weight: bold\">COUNT</span>(<span style=\"color: #666666\">*</span>) <span style=\"color: #008000; font-weight: bold\">FROM</span> tests <span style=\"color: #008000; font-weight: bold\">WHERE</span> tests.<span style=\"color: #008000; font-weight: bold\">no</span> <span style=\"color: #666666\">></span> <span style=\"color: #666666\">10</span> <span style=\"color: #008000; font-weight: bold\">AND</span> test.name <span style=\"color: #008000; font-weight: bold\">LIKE</span> <span style=\"color: #BA2121\">'ABC%'</span
|
644
|
+
assert_equal "<div class=\"emlist-code\">\n<pre class=\"emlist\"><span style=\"color: #008000; font-weight: bold\">SELECT</span> <span style=\"color: #008000; font-weight: bold\">COUNT</span>(<span style=\"color: #666666\">*</span>) <span style=\"color: #008000; font-weight: bold\">FROM</span> tests <span style=\"color: #008000; font-weight: bold\">WHERE</span> tests.<span style=\"color: #008000; font-weight: bold\">no</span> <span style=\"color: #666666\">></span> <span style=\"color: #666666\">10</span> <span style=\"color: #008000; font-weight: bold\">AND</span> test.name <span style=\"color: #008000; font-weight: bold\">LIKE</span> <span style=\"color: #BA2121\">'ABC%'</span>\n</pre>\n</div>\n", actual
|
574
645
|
end
|
575
646
|
|
576
647
|
def test_emlist_caption
|
@@ -583,6 +654,19 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
583
654
|
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, actual
|
584
655
|
end
|
585
656
|
|
657
|
+
def test_emlistnum
|
658
|
+
@book.config["highlight"] = false
|
659
|
+
actual = compile_block("//emlistnum{\nlineA\nlineB\n//}\n")
|
660
|
+
expected =<<-EOS
|
661
|
+
<div class="emlistnum-code">
|
662
|
+
<pre class="emlist"> 1: lineA
|
663
|
+
2: lineB
|
664
|
+
</pre>
|
665
|
+
</div>
|
666
|
+
EOS
|
667
|
+
assert_equal expected, actual
|
668
|
+
end
|
669
|
+
|
586
670
|
def test_emlist_with_4tab
|
587
671
|
@config["tabwidth"] = 4
|
588
672
|
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
@@ -600,9 +684,10 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
600
684
|
rescue LoadError
|
601
685
|
return true
|
602
686
|
end
|
603
|
-
@book.config["
|
687
|
+
@book.config["highlight"] = {}
|
688
|
+
@book.config["highlight"]["html"] = "pygments"
|
604
689
|
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
605
|
-
assert_equal "<div class=\"cmd-code\">\n<pre class=\"cmd\"><span style=\"color: #888888\">lineA</span>\n<span style=\"color: #888888\">lineB</span
|
690
|
+
assert_equal "<div class=\"cmd-code\">\n<pre class=\"cmd\"><span style=\"color: #888888\">lineA</span>\n<span style=\"color: #888888\">lineB</span>\n</pre>\n</div>\n", actual
|
606
691
|
end
|
607
692
|
|
608
693
|
def test_cmd_caption
|
@@ -626,13 +711,22 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
626
711
|
assert_equal %Q|<a href="bib.html#bib-id_sample_3Dbib">[1]</a>|, compile_inline("@<bib>{sample=bib}")
|
627
712
|
end
|
628
713
|
|
714
|
+
def test_bib_htmlext
|
715
|
+
def @chapter.bibpaper(id)
|
716
|
+
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
717
|
+
end
|
718
|
+
|
719
|
+
@config["htmlext"] = "xhtml"
|
720
|
+
assert_equal %Q|<a href="bib.xhtml#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}")
|
721
|
+
end
|
722
|
+
|
629
723
|
def test_bibpaper
|
630
724
|
def @chapter.bibpaper(id)
|
631
725
|
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
632
726
|
end
|
633
727
|
|
634
728
|
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
635
|
-
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p
|
729
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p></div>\n|, actual
|
636
730
|
end
|
637
731
|
|
638
732
|
def test_bibpaper_normalized
|
@@ -641,7 +735,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
641
735
|
end
|
642
736
|
|
643
737
|
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
644
|
-
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-id_sample_3Dbib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p
|
738
|
+
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-id_sample_3Dbib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p></div>\n|, actual
|
645
739
|
end
|
646
740
|
|
647
741
|
def test_bibpaper_with_anchor
|
@@ -650,7 +744,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
650
744
|
end
|
651
745
|
|
652
746
|
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
653
|
-
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
|
747
|
+
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|, actual
|
654
748
|
end
|
655
749
|
|
656
750
|
def column_helper(review)
|
@@ -698,6 +792,7 @@ EOS
|
|
698
792
|
<h3><a id="column-1"></a>test</h3>
|
699
793
|
<p>inside column</p>
|
700
794
|
</div>
|
795
|
+
|
701
796
|
<h3><a id="h1-0-1"></a>next level</h3>
|
702
797
|
EOS
|
703
798
|
|
@@ -733,6 +828,7 @@ EOS
|
|
733
828
|
<h3 id="foo"><a id="column-1"></a>test</h3>
|
734
829
|
<p>inside column</p>
|
735
830
|
</div>
|
831
|
+
|
736
832
|
<h3><a id="h1-0-1"></a>next level</h3>
|
737
833
|
<p>this is コラム「test」.</p>
|
738
834
|
EOS
|
@@ -740,6 +836,16 @@ EOS
|
|
740
836
|
assert_equal expected, column_helper(review)
|
741
837
|
end
|
742
838
|
|
839
|
+
def test_column_in_aother_chapter_ref
|
840
|
+
def @chapter.column_index
|
841
|
+
items = [Book::ColumnIndex::Item.new("chap1|column", 1, "column_cap")]
|
842
|
+
Book::ColumnIndex.new(items)
|
843
|
+
end
|
844
|
+
|
845
|
+
actual = compile_inline("test @<column>{chap1|column} test2")
|
846
|
+
expected = "test コラム「column_cap」 test2"
|
847
|
+
assert_equal expected, actual
|
848
|
+
end
|
743
849
|
|
744
850
|
def test_ul
|
745
851
|
src =<<-EOS
|
@@ -889,70 +995,6 @@ EOS
|
|
889
995
|
assert_equal expected, actual
|
890
996
|
end
|
891
997
|
|
892
|
-
def test_ul_in_note
|
893
|
-
src =<<-EOS
|
894
|
-
//note{
|
895
|
-
|
896
|
-
aaaa
|
897
|
-
bbb
|
898
|
-
|
899
|
-
* A
|
900
|
-
* B
|
901
|
-
//}
|
902
|
-
EOS
|
903
|
-
|
904
|
-
expected =<<-EOS
|
905
|
-
<div class=\"note\">
|
906
|
-
<p>aaaabbb</p>
|
907
|
-
<ul>
|
908
|
-
<li>A</li>
|
909
|
-
<li>B</li>
|
910
|
-
</ul>
|
911
|
-
</div>
|
912
|
-
EOS
|
913
|
-
actual = compile_block(src)
|
914
|
-
assert_equal expected, actual
|
915
|
-
end
|
916
|
-
|
917
|
-
def test_ul_in_note_and_emlist
|
918
|
-
src =<<-EOS
|
919
|
-
//note{
|
920
|
-
|
921
|
-
aaaa
|
922
|
-
bbb
|
923
|
-
|
924
|
-
//emlist{
|
925
|
-
abc
|
926
|
-
ddd
|
927
|
-
* A
|
928
|
-
* B
|
929
|
-
//}
|
930
|
-
|
931
|
-
* A
|
932
|
-
* B
|
933
|
-
//}
|
934
|
-
EOS
|
935
|
-
|
936
|
-
expected =<<-EOS
|
937
|
-
<div class=\"note\">
|
938
|
-
<p>aaaabbb</p>
|
939
|
-
<div class="emlist-code">
|
940
|
-
<pre class="emlist">abc
|
941
|
-
ddd
|
942
|
-
* A
|
943
|
-
* B
|
944
|
-
</pre>
|
945
|
-
</div>
|
946
|
-
<ul>
|
947
|
-
<li>A</li>
|
948
|
-
<li>B</li>
|
949
|
-
</ul>
|
950
|
-
</div>
|
951
|
-
EOS
|
952
|
-
actual = compile_block(src)
|
953
|
-
assert_equal expected, actual
|
954
|
-
end
|
955
|
-
|
956
998
|
def test_ol
|
957
999
|
src =<<-EOS
|
958
1000
|
3. AAA
|
@@ -1028,7 +1070,7 @@ EOS
|
|
1028
1070
|
@chapter.instance_eval{@footnote_index=fn}
|
1029
1071
|
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
1030
1072
|
expected =<<-'EOS'
|
1031
|
-
<div class="footnote" id="fn-foo"><p class="footnote">[
|
1073
|
+
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote">[*1] bar\a\$buz</p></div>
|
1032
1074
|
EOS
|
1033
1075
|
assert_equal expected, actual
|
1034
1076
|
end
|
@@ -1038,27 +1080,92 @@ EOS
|
|
1038
1080
|
@chapter.instance_eval{@footnote_index=fn}
|
1039
1081
|
actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
|
1040
1082
|
expected =<<-'EOS'
|
1041
|
-
<div class="footnote" id="fn-id_123-_E3_81_82___3B"><p class="footnote">[
|
1083
|
+
<div class="footnote" epub:type="footnote" id="fn-id_123-_E3_81_82___3B"><p class="footnote">[*1] bar\a\$buz</p></div>
|
1042
1084
|
EOS
|
1043
1085
|
assert_equal expected, actual
|
1044
1086
|
end
|
1045
1087
|
|
1088
|
+
def test_inline_hd
|
1089
|
+
book = ReVIEW::Book::Base.load
|
1090
|
+
book.catalog = ReVIEW::Catalog.new({"CHAPS"=>%w(ch1.re ch2.re)})
|
1091
|
+
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
1092
|
+
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
1093
|
+
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
1094
|
+
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
1095
|
+
book.parts = [ReVIEW::Book::Part.new(self, nil, [chap1, chap2])]
|
1096
|
+
builder = ReVIEW::HTMLBuilder.new
|
1097
|
+
comp = ReVIEW::Compiler.new(builder)
|
1098
|
+
builder.bind(comp, chap2, nil)
|
1099
|
+
hd = builder.inline_hd("ch1|test1-1")
|
1100
|
+
assert_equal "「1.1 test1-1」", hd
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
def test_inline_hd_for_part
|
1104
|
+
book = ReVIEW::Book::Base.load
|
1105
|
+
book.catalog = ReVIEW::Catalog.new({"CHAPS"=>%w(ch1.re ch2.re)})
|
1106
|
+
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
1107
|
+
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
1108
|
+
io_p1 = StringIO.new("= part1\n\nfoo\n\n== part1-1\n\nbar\n\n== part1-2\n\nbar\n\n")
|
1109
|
+
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
1110
|
+
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
1111
|
+
book.parts = [ReVIEW::Book::Part.new(self, 1, [chap1, chap2], "part1.re", io_p1)]
|
1112
|
+
builder = ReVIEW::HTMLBuilder.new
|
1113
|
+
comp = ReVIEW::Compiler.new(builder)
|
1114
|
+
builder.bind(comp, chap2, nil)
|
1115
|
+
hd = builder.inline_hd("part1|part1-1")
|
1116
|
+
assert_equal "「1.1 part1-1」", hd
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
def test_table
|
1120
|
+
actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1121
|
+
assert_equal %Q|<div class="table">\n<table>\n<tr><th>aaa</th><th>bbb</th></tr>\n<tr><td>ccc</td><td>ddd<>&</td></tr>\n</table>\n</div>\n|,
|
1122
|
+
actual
|
1123
|
+
end
|
1124
|
+
|
1125
|
+
def test_imgtable
|
1126
|
+
def @chapter.image(id)
|
1127
|
+
item = Book::ImageIndex::Item.new("sampleimg",1, 'sample img')
|
1128
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
1129
|
+
item
|
1130
|
+
end
|
1046
1131
|
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
assert_equal %Q|<a href="http://github.com" class="link"><b>G</b>itHub</a>|, actual
|
1132
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
1133
|
+
expected = %Q|<div id="sampleimg" class="imgtable image">\n<p class="caption">表1.1: test for imgtable</p>\n<img src="images/chap1-sampleimg.png" alt="test for imgtable" />\n</div>\n|
|
1134
|
+
assert_equal expected, actual
|
1051
1135
|
end
|
1052
1136
|
|
1053
|
-
def
|
1054
|
-
actual =
|
1055
|
-
|
1056
|
-
|
1137
|
+
def test_major_blocks
|
1138
|
+
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
1139
|
+
expected = %Q(<div class="note">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="note">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1140
|
+
assert_equal expected, actual
|
1057
1141
|
|
1058
|
-
|
1059
|
-
|
1060
|
-
assert_equal
|
1061
|
-
end
|
1142
|
+
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
1143
|
+
expected = %Q(<div class="memo">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="memo">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1144
|
+
assert_equal expected, actual
|
1062
1145
|
|
1146
|
+
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
1147
|
+
expected = %Q(<div class="info">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="info">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1148
|
+
assert_equal expected, actual
|
1149
|
+
|
1150
|
+
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
1151
|
+
expected = %Q(<div class="important">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="important">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1152
|
+
assert_equal expected, actual
|
1153
|
+
|
1154
|
+
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
1155
|
+
expected = %Q(<div class="caution">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="caution">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1156
|
+
assert_equal expected, actual
|
1157
|
+
|
1158
|
+
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
1159
|
+
expected = %Q(<div class="notice">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="notice">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1160
|
+
assert_equal expected, actual
|
1161
|
+
|
1162
|
+
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
1163
|
+
expected = %Q(<div class="warning">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="warning">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1164
|
+
assert_equal expected, actual
|
1165
|
+
|
1166
|
+
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
1167
|
+
expected = %Q(<div class="tip">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="tip">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
|
1168
|
+
assert_equal expected, actual
|
1169
|
+
end
|
1063
1170
|
|
1064
1171
|
end
|