review 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +36 -0
- data/.rubocop.yml +1 -0
- data/ChangeLog +102 -0
- data/README.rdoc +2 -2
- data/bin/review-check +18 -16
- data/bin/review-compile +49 -42
- data/bin/review-epubmaker +23 -993
- data/bin/review-epubmaker-legacy +1024 -0
- data/bin/review-index +17 -15
- data/bin/review-init +39 -9
- data/bin/review-pdfmaker +124 -89
- data/bin/review-preproc +16 -14
- data/bin/review-vol +17 -15
- data/debian/docs +1 -1
- data/doc/catalog.rdoc +34 -0
- data/doc/format.rdoc +16 -2
- data/doc/libepubmaker/{config.yaml → config.yml} +63 -19
- data/doc/quickstart.rdoc +1 -1
- data/doc/{sample.yaml → sample.yml} +0 -0
- data/lib/epubmaker.rb +1 -1
- data/lib/epubmaker/content.rb +9 -1
- data/lib/epubmaker/epubv2.rb +59 -7
- data/lib/epubmaker/epubv3.rb +14 -9
- data/lib/epubmaker/producer.rb +68 -27
- data/lib/epubmaker/resource.rb +3 -1
- data/lib/lineinput.rb +2 -2
- data/lib/review/book/base.rb +125 -24
- data/lib/review/book/chapter.rb +42 -0
- data/lib/review/book/compilable.rb +23 -4
- data/lib/review/book/image_finder.rb +64 -0
- data/lib/review/book/index.rb +64 -50
- data/lib/review/book/page_metric.rb +1 -1
- data/lib/review/builder.rb +19 -12
- data/lib/review/catalog.rb +47 -0
- data/lib/review/compiler.rb +3 -2
- data/lib/review/configure.rb +5 -3
- data/lib/review/epubmaker.rb +130 -46
- data/lib/review/ewbbuilder.rb +27 -31
- data/lib/review/extentions/string.rb +4 -4
- data/lib/review/htmlbuilder.rb +140 -79
- data/lib/review/htmllayout.rb +26 -4
- data/lib/review/htmlutils.rb +20 -1
- data/lib/review/i18n.rb +5 -2
- data/lib/review/{i18n.yaml → i18n.yml} +4 -2
- data/lib/review/idgxmlbuilder.rb +65 -39
- data/lib/review/latexbuilder.rb +72 -24
- data/lib/review/latexutils.rb +3 -1
- data/lib/review/makerhelper.rb +8 -2
- data/lib/review/preprocessor.rb +20 -20
- data/lib/review/review.tex.erb +4 -0
- data/lib/review/sec_counter.rb +9 -11
- data/lib/review/tocparser.rb +2 -2
- data/lib/review/tocprinter.rb +12 -12
- data/lib/review/topbuilder.rb +15 -15
- data/lib/review/version.rb +1 -1
- data/lib/uuid.rb +7 -7
- data/review.gemspec +2 -2
- data/rubocop-todo.yml +443 -0
- data/test/sample-book/src/config.yml +2 -2
- data/test/sample-book/src/{main.css → style.css} +0 -0
- data/test/test_book.rb +46 -48
- data/test/test_book_chapter.rb +25 -13
- data/test/test_builder.rb +3 -3
- data/test/test_catalog.rb +107 -0
- data/test/test_epubmaker.rb +6 -6
- data/test/test_htmlbuilder.rb +160 -39
- data/test/test_htmlutils.rb +22 -0
- data/test/test_i18n.rb +2 -2
- data/test/test_idgxmlbuilder.rb +33 -47
- data/test/test_image_finder.rb +82 -0
- data/test/test_inaobuilder.rb +1 -1
- data/test/test_latexbuilder.rb +35 -39
- data/test/test_lineinput.rb +2 -2
- data/test/test_markdownbuilder.rb +2 -2
- data/test/test_topbuilder.rb +39 -23
- metadata +23 -14
- data/bin/review-epubmaker-ng +0 -23
data/test/test_epubmaker.rb
CHANGED
@@ -398,7 +398,7 @@ EOT
|
|
398
398
|
<head>
|
399
399
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
400
400
|
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
401
|
-
<meta name="generator" content="
|
401
|
+
<meta name="generator" content="Re:VIEW"/>
|
402
402
|
<title>Table of Contents</title>
|
403
403
|
</head>
|
404
404
|
<body>
|
@@ -430,7 +430,7 @@ EOT
|
|
430
430
|
<head>
|
431
431
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
432
432
|
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
433
|
-
<meta name="generator" content="
|
433
|
+
<meta name="generator" content="Re:VIEW"/>
|
434
434
|
<title>Table of Contents</title>
|
435
435
|
</head>
|
436
436
|
<body>
|
@@ -460,7 +460,7 @@ EOT
|
|
460
460
|
<head>
|
461
461
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
462
462
|
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
463
|
-
<meta name="generator" content="
|
463
|
+
<meta name="generator" content="Re:VIEW"/>
|
464
464
|
<title>Sample Book</title>
|
465
465
|
</head>
|
466
466
|
<body>
|
@@ -482,7 +482,7 @@ EOT
|
|
482
482
|
<head>
|
483
483
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
484
484
|
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
485
|
-
<meta name="generator" content="
|
485
|
+
<meta name="generator" content="Re:VIEW"/>
|
486
486
|
<title>Sample Book</title>
|
487
487
|
</head>
|
488
488
|
<body>
|
@@ -506,7 +506,7 @@ EOT
|
|
506
506
|
<head>
|
507
507
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
508
508
|
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
509
|
-
<meta name="generator" content="
|
509
|
+
<meta name="generator" content="Re:VIEW"/>
|
510
510
|
<title>Colophon</title>
|
511
511
|
</head>
|
512
512
|
<body>
|
@@ -538,7 +538,7 @@ EOT
|
|
538
538
|
<head>
|
539
539
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
540
540
|
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
541
|
-
<meta name="generator" content="
|
541
|
+
<meta name="generator" content="Re:VIEW"/>
|
542
542
|
<title>Colophon</title>
|
543
543
|
</head>
|
544
544
|
<body>
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -11,13 +11,14 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
def setup
|
13
13
|
@builder = HTMLBuilder.new()
|
14
|
-
@
|
14
|
+
@config = ReVIEW::Configure.values
|
15
|
+
@config.merge!({
|
15
16
|
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
16
17
|
"inencoding" => "UTF-8",
|
17
18
|
"outencoding" => "UTF-8",
|
18
19
|
"stylesheet" => nil, # for HTMLBuilder
|
19
|
-
}
|
20
|
-
ReVIEW.book.
|
20
|
+
})
|
21
|
+
ReVIEW.book.config = @config
|
21
22
|
@compiler = ReVIEW::Compiler.new(@builder)
|
22
23
|
@chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
|
23
24
|
location = Location.new(nil, nil)
|
@@ -25,7 +26,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_xmlns_ops_prefix_epub3
|
28
|
-
ReVIEW.book.
|
29
|
+
ReVIEW.book.config["epubversion"] = 3
|
29
30
|
assert_equal "epub", @builder.xmlns_ops_prefix
|
30
31
|
end
|
31
32
|
|
@@ -38,12 +39,81 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
38
39
|
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this is test.</h1>\n|, @builder.raw_result
|
39
40
|
end
|
40
41
|
|
42
|
+
def test_headline_level1_postdef
|
43
|
+
@chapter.instance_eval do
|
44
|
+
def on_POSTDEF?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
@builder.headline(1,"test","this is test.")
|
49
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録1 this is test.</h1>\n|, @builder.raw_result
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_headline_level2_postdef
|
53
|
+
@chapter.instance_eval do
|
54
|
+
def on_POSTDEF?
|
55
|
+
true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
@builder.headline(2,"test","this is test.")
|
59
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|, @builder.raw_result
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_headline_level1_postdef_roman
|
63
|
+
@chapter.book.config["appendix_format"] = "roman"
|
64
|
+
@chapter.instance_eval do
|
65
|
+
def on_POSTDEF?
|
66
|
+
true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
@builder.headline(1,"test","this is test.")
|
70
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録I this is test.</h1>\n|, @builder.raw_result
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_headline_level2_postdef_roman
|
74
|
+
@chapter.book.config["appendix_format"] = "roman"
|
75
|
+
@chapter.instance_eval do
|
76
|
+
def on_POSTDEF?
|
77
|
+
true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
@builder.headline(2,"test","this is test.")
|
81
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>I.1 this is test.</h2>\n|, @builder.raw_result
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_headline_level1_postdef_alpha
|
85
|
+
@chapter.book.config["appendix_format"] = "alpha"
|
86
|
+
@chapter.instance_eval do
|
87
|
+
def on_POSTDEF?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
@builder.headline(1,"test","this is test.")
|
92
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録A this is test.</h1>\n|, @builder.raw_result
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_headline_level2_postdef_alpha
|
96
|
+
@chapter.book.config["appendix_format"] = "alpha"
|
97
|
+
@chapter.instance_eval do
|
98
|
+
def on_POSTDEF?
|
99
|
+
true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
@builder.headline(2,"test","this is test.")
|
103
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>A.1 this is test.</h2>\n|, @builder.raw_result
|
104
|
+
end
|
105
|
+
|
41
106
|
def test_headline_level1_without_secno
|
42
|
-
ReVIEW.book.
|
107
|
+
ReVIEW.book.config["secnolevel"] = 0
|
43
108
|
@builder.headline(1,"test","this is test.")
|
44
109
|
assert_equal %Q|<h1 id="test"><a id="h1"></a>this is test.</h1>\n|, @builder.raw_result
|
45
110
|
end
|
46
111
|
|
112
|
+
def test_headline_level1_with_tricky_id
|
113
|
+
@builder.headline(1,"123 あ_;","this is test.")
|
114
|
+
assert_equal %Q|<h1 id="id_123-_E3_81_82___3B"><a id="h1"></a>第1章 this is test.</h1>\n|, @builder.raw_result
|
115
|
+
end
|
116
|
+
|
47
117
|
def test_headline_level1_with_inlinetag
|
48
118
|
@builder.headline(1,"test","this @<b>{is} test.<&\">")
|
49
119
|
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this <b>is</b> test.<&"></h1>\n|, @builder.raw_result
|
@@ -60,7 +130,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
60
130
|
end
|
61
131
|
|
62
132
|
def test_headline_level3_with_secno
|
63
|
-
ReVIEW.book.
|
133
|
+
ReVIEW.book.config["secnolevel"] = 3
|
64
134
|
@builder.headline(3,"test","this is test.")
|
65
135
|
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>1.0.1 this is test.</h3>\n|, @builder.raw_result
|
66
136
|
end
|
@@ -70,6 +140,11 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
70
140
|
assert_equal %Q|<a id="label_test"></a>\n|, @builder.raw_result
|
71
141
|
end
|
72
142
|
|
143
|
+
def test_label_with_tricky_id
|
144
|
+
@builder.label("123 あ_;")
|
145
|
+
assert_equal %Q|<a id="id_123-_E3_81_82___3B"></a>\n|, @builder.raw_result
|
146
|
+
end
|
147
|
+
|
73
148
|
def test_href
|
74
149
|
ret = @builder.compile_href("http://github.com", "GitHub")
|
75
150
|
assert_equal %Q|<a href="http://github.com" class="link">GitHub</a>|, ret
|
@@ -146,11 +221,11 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
146
221
|
Book::HeadlineIndex.new(items, self)
|
147
222
|
end
|
148
223
|
|
149
|
-
@
|
224
|
+
@config["secnolevel"] = 2
|
150
225
|
ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
|
151
226
|
assert_equal %Q|test 「te_st」 test2|, ret
|
152
227
|
|
153
|
-
@
|
228
|
+
@config["secnolevel"] = 3
|
154
229
|
ret = @builder.compile_inline("test @<hd>{chap1|test} test2")
|
155
230
|
assert_equal %Q|test 「1.1.1 te_st」 test2|, ret
|
156
231
|
end
|
@@ -175,6 +250,19 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
175
250
|
assert_equal %Q|<a target='外部参照<>&'>「●● 外部参照<>&」</a>|, ret
|
176
251
|
end
|
177
252
|
|
253
|
+
def test_inline_mathml
|
254
|
+
begin
|
255
|
+
require 'math_ml'
|
256
|
+
require "math_ml/symbol/character_reference"
|
257
|
+
rescue LoadError
|
258
|
+
return true
|
259
|
+
end
|
260
|
+
@config["mathml"] = true
|
261
|
+
ret = @builder.compile_inline("@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}")
|
262
|
+
@config["mathml"] = nil
|
263
|
+
assert_equal "<span class=\"equation\"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span>", ret
|
264
|
+
end
|
265
|
+
|
178
266
|
def test_quote
|
179
267
|
lines = ["foo", "bar", "","buz"]
|
180
268
|
@builder.quote(lines)
|
@@ -206,39 +294,50 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
206
294
|
def test_image
|
207
295
|
def @chapter.image(id)
|
208
296
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
209
|
-
item.instance_eval{@
|
297
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
210
298
|
item
|
211
299
|
end
|
212
300
|
|
213
301
|
@builder.image_image("sampleimg","sample photo",nil)
|
214
|
-
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
|
302
|
+
assert_equal %Q|<div id="sampleimg" 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
|
215
303
|
end
|
216
304
|
|
217
305
|
def test_image_with_metric
|
218
306
|
def @chapter.image(id)
|
219
307
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
220
|
-
item.instance_eval{@
|
308
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
221
309
|
item
|
222
310
|
end
|
223
311
|
|
224
312
|
@builder.image_image("sampleimg","sample photo","scale=1.2")
|
225
|
-
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
|
313
|
+
assert_equal %Q|<div id="sampleimg" 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
|
226
314
|
end
|
227
315
|
|
228
316
|
def test_image_with_metric2
|
229
317
|
def @chapter.image(id)
|
230
318
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
231
|
-
item.instance_eval{@
|
319
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
232
320
|
item
|
233
321
|
end
|
234
322
|
@builder.image_image("sampleimg","sample photo","scale=1.2,html::class=sample,latex::ignore=params")
|
235
|
-
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
|
323
|
+
assert_equal %Q|<div id="sampleimg" 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
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_image_with_tricky_id
|
327
|
+
def @chapter.image(id)
|
328
|
+
item = Book::ImageIndex::Item.new("123 あ_;",1)
|
329
|
+
item.instance_eval{@path="./images/chap1-123 あ_;.png"}
|
330
|
+
item
|
331
|
+
end
|
332
|
+
|
333
|
+
@builder.image_image("123 あ_;","sample photo",nil)
|
334
|
+
assert_equal %Q|<div id="id_123-_E3_81_82___3B" class="image">\n<img src="images/chap1-123 あ_;.png" alt="sample photo" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, @builder.raw_result
|
236
335
|
end
|
237
336
|
|
238
337
|
def test_indepimage
|
239
338
|
def @chapter.image(id)
|
240
339
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
241
|
-
item.instance_eval{@
|
340
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
242
341
|
item
|
243
342
|
end
|
244
343
|
|
@@ -249,7 +348,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
249
348
|
def test_indepimage_without_caption
|
250
349
|
def @chapter.image(id)
|
251
350
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
252
|
-
item.instance_eval{@
|
351
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
253
352
|
item
|
254
353
|
end
|
255
354
|
|
@@ -260,7 +359,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
260
359
|
def test_indepimage_with_metric
|
261
360
|
def @chapter.image(id)
|
262
361
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
263
|
-
item.instance_eval{@
|
362
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
264
363
|
item
|
265
364
|
end
|
266
365
|
|
@@ -271,7 +370,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
271
370
|
def test_indepimage_with_metric2
|
272
371
|
def @chapter.image(id)
|
273
372
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
274
|
-
item.instance_eval{@
|
373
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
275
374
|
item
|
276
375
|
end
|
277
376
|
|
@@ -282,7 +381,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
282
381
|
def test_indepimage_without_caption_but_with_metric
|
283
382
|
def @chapter.image(id)
|
284
383
|
item = Book::ImageIndex::Item.new("sampleimg",1)
|
285
|
-
item.instance_eval{@
|
384
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
286
385
|
item
|
287
386
|
end
|
288
387
|
|
@@ -308,7 +407,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
308
407
|
rescue LoadError
|
309
408
|
return true
|
310
409
|
end
|
311
|
-
ReVIEW.book.
|
410
|
+
ReVIEW.book.config["pygments"] = true
|
312
411
|
@builder.list(["test1", "test1.5", "", "test<i>2</i>"], "samplelist", "this is @<b>{test}<&>_")
|
313
412
|
|
314
413
|
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: #008000; font-weight: bold"><i></span>2<span style="color: #008000; font-weight: bold"></i></span>\n</pre>\n</div>\n|, @builder.raw_result
|
@@ -438,6 +537,31 @@ EOS
|
|
438
537
|
end
|
439
538
|
end
|
440
539
|
|
540
|
+
def test_column_ref
|
541
|
+
review =<<-EOS
|
542
|
+
===[column]{foo} test
|
543
|
+
|
544
|
+
inside column
|
545
|
+
|
546
|
+
=== next level
|
547
|
+
|
548
|
+
this is @<column>{foo}.
|
549
|
+
EOS
|
550
|
+
expect =<<-EOS
|
551
|
+
<div class="column">
|
552
|
+
|
553
|
+
<h3 id="foo"><a id="column-1"></a>test</h3>
|
554
|
+
<p>inside column</p>
|
555
|
+
</div>
|
556
|
+
|
557
|
+
<h3><a id="h1-0-1"></a>next level</h3>
|
558
|
+
<p>this is test.</p>
|
559
|
+
EOS
|
560
|
+
|
561
|
+
assert_equal expect, column_helper(review)
|
562
|
+
end
|
563
|
+
|
564
|
+
|
441
565
|
def test_ul
|
442
566
|
src =<<-EOS
|
443
567
|
* AAA
|
@@ -620,44 +744,31 @@ EOS
|
|
620
744
|
|
621
745
|
def test_block_raw0
|
622
746
|
@builder.raw("<>!\"\\n& ")
|
623
|
-
expect
|
624
|
-
<>!"
|
625
|
-
&
|
626
|
-
EOS
|
747
|
+
expect = %Q(<>!\"\n& )
|
627
748
|
assert_equal expect.chomp, @builder.raw_result
|
628
749
|
end
|
629
750
|
|
630
751
|
def test_block_raw1
|
631
752
|
@builder.raw("|html|<>!\"\\n& ")
|
632
|
-
expect
|
633
|
-
<>!"
|
634
|
-
&
|
635
|
-
EOS
|
753
|
+
expect = %Q(<>!\"\n& )
|
636
754
|
assert_equal expect.chomp, @builder.raw_result
|
637
755
|
end
|
638
756
|
|
639
757
|
def test_block_raw2
|
640
758
|
@builder.raw("|html, latex|<>!\"\\n& ")
|
641
|
-
expect
|
642
|
-
<>!\"
|
643
|
-
&
|
644
|
-
EOS
|
759
|
+
expect = %Q(<>!\"\n& )
|
645
760
|
assert_equal expect.chomp, @builder.raw_result
|
646
761
|
end
|
647
762
|
|
648
763
|
def test_block_raw3
|
649
764
|
@builder.raw("|latex, idgxml|<>!\"\\n& ")
|
650
|
-
expect
|
651
|
-
EOS
|
765
|
+
expect = ''
|
652
766
|
assert_equal expect.chomp, @builder.raw_result
|
653
767
|
end
|
654
768
|
|
655
769
|
def test_block_raw4
|
656
770
|
@builder.raw("|html <>!\"\\n& ")
|
657
|
-
expect
|
658
|
-
|html <>!\"
|
659
|
-
&
|
660
|
-
EOS
|
771
|
+
expect = %Q(|html <>!\"\n& )
|
661
772
|
assert_equal expect.chomp, @builder.raw_result
|
662
773
|
end
|
663
774
|
|
@@ -666,7 +777,17 @@ EOS
|
|
666
777
|
@chapter.instance_eval{@footnote_index=fn}
|
667
778
|
@builder.footnote("foo",'bar\\a\\$buz')
|
668
779
|
expect =<<-'EOS'
|
669
|
-
<div class="footnote"><p class="footnote">[<a
|
780
|
+
<div class="footnote" id="fn-foo"><p class="footnote">[<a href="#fnb-foo">*1</a>] bar\a\$buz</p></div>
|
781
|
+
EOS
|
782
|
+
assert_equal expect, @builder.raw_result
|
783
|
+
end
|
784
|
+
|
785
|
+
def test_inline_fn_with_tricky_id
|
786
|
+
fn = Book::FootnoteIndex.parse(['//footnote[123 あ_;][bar\\a\\$buz]'])
|
787
|
+
@chapter.instance_eval{@footnote_index=fn}
|
788
|
+
@builder.footnote("123 あ_;",'bar\\a\\$buz')
|
789
|
+
expect =<<-'EOS'
|
790
|
+
<div class="footnote" id="fn-id_123-_E3_81_82___3B"><p class="footnote">[<a href="#fnb-id_123-_E3_81_82___3B">*1</a>] bar\a\$buz</p></div>
|
670
791
|
EOS
|
671
792
|
assert_equal expect, @builder.raw_result
|
672
793
|
end
|
data/test/test_htmlutils.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'test_helper'
|
2
3
|
require 'review/htmlutils'
|
3
4
|
|
@@ -25,4 +26,25 @@ class HTMLUtilsTest < Test::Unit::TestCase
|
|
25
26
|
def test_strip_html
|
26
27
|
assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
|
27
28
|
end
|
29
|
+
|
30
|
+
def test_escape_comment
|
31
|
+
assert_equal '<', escape_comment('<')
|
32
|
+
assert_equal '>', escape_comment('>')
|
33
|
+
assert_equal '&', escape_comment('&')
|
34
|
+
assert_equal '-', escape_comment('-')
|
35
|
+
assert_equal '--', escape_comment('--')
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_normalize_id
|
39
|
+
assert_equal 'abcxyz', normalize_id('abcxyz')
|
40
|
+
assert_equal 'ABCXYZ', normalize_id('ABCXYZ')
|
41
|
+
assert_equal 'abc0123', normalize_id('abc0123')
|
42
|
+
assert_equal 'a-b-c_x.y.z', normalize_id('a-b-c_x.y.z')
|
43
|
+
assert_equal 'id_a_3Ab_3Ac', normalize_id('a:b:c')
|
44
|
+
assert_equal 'id_0123a-b-c_x.y.z', normalize_id('0123a-b-c_x.y.z')
|
45
|
+
assert_equal 'id_.', normalize_id('.')
|
46
|
+
assert_equal 'id__E3_81_82', normalize_id('あ')
|
47
|
+
assert_equal 'id_-___3B', normalize_id(' _;')
|
48
|
+
end
|
49
|
+
|
28
50
|
end
|
data/test/test_i18n.rb
CHANGED
@@ -49,13 +49,13 @@ class I18nTest < Test::Unit::TestCase
|
|
49
49
|
def _setup_htmlbuilder
|
50
50
|
I18n.i18n "en"
|
51
51
|
@builder = HTMLBuilder.new()
|
52
|
-
@
|
52
|
+
@config = {
|
53
53
|
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
54
54
|
"inencoding" => "UTF-8",
|
55
55
|
"outencoding" => "UTF-8",
|
56
56
|
"stylesheet" => nil, # for HTMLBuilder
|
57
57
|
}
|
58
|
-
ReVIEW.book.
|
58
|
+
ReVIEW.book.config = @config
|
59
59
|
@compiler = ReVIEW::Compiler.new(@builder)
|
60
60
|
@chapter = Book::Chapter.new(Book::Base.new(nil), 1, '-', nil, StringIO.new)
|
61
61
|
location = Location.new(nil, nil)
|