review 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +42 -0
- data/README.rdoc +31 -0
- data/bin/review-catalog-converter +129 -0
- data/bin/review-check +4 -2
- data/bin/review-compile +7 -7
- data/bin/review-index +4 -3
- data/bin/review-init +3 -1
- data/bin/review-pdfmaker +2 -258
- data/bin/review-vol +2 -2
- data/doc/catalog.rdoc +18 -3
- data/doc/format.rdoc +2 -3
- data/doc/quickstart.rdoc +1 -1
- data/lib/epubmaker/epubv2.rb +16 -8
- data/lib/epubmaker/epubv3.rb +44 -12
- data/lib/epubmaker/producer.rb +4 -2
- data/lib/review/book.rb +0 -1
- data/lib/review/book/base.rb +72 -35
- data/lib/review/book/chapter.rb +8 -12
- data/lib/review/book/compilable.rb +8 -8
- data/lib/review/book/image_finder.rb +7 -0
- data/lib/review/book/index.rb +23 -5
- data/lib/review/book/volume.rb +2 -1
- data/lib/review/builder.rb +10 -5
- data/lib/review/catalog.rb +5 -0
- data/lib/review/compiler.rb +1 -1
- data/lib/review/configure.rb +12 -0
- data/lib/review/epubmaker.rb +13 -7
- data/lib/review/htmlbuilder.rb +26 -12
- data/lib/review/i18n.rb +2 -2
- data/lib/review/i18n.yml +21 -0
- data/lib/review/idgxmlbuilder.rb +11 -9
- data/lib/review/latexbuilder.rb +3 -2
- data/lib/review/{review.tex.erb → layout.tex.erb} +9 -1
- data/lib/review/markdownbuilder.rb +126 -4
- data/lib/review/pdfmaker.rb +291 -0
- data/lib/review/tocparser.rb +6 -5
- data/lib/review/tocprinter.rb +5 -2
- data/lib/review/version.rb +1 -1
- data/review.gemspec +1 -1
- data/rubocop-todo.yml +13 -0
- data/test/test_book.rb +95 -133
- data/test/test_book_chapter.rb +16 -21
- data/test/test_builder.rb +12 -7
- data/test/test_catalog.rb +15 -3
- data/test/test_catalog_converter_cmd.rb +73 -0
- data/test/test_epubmaker.rb +5 -5
- data/test/test_helper.rb +32 -21
- data/test/test_htmlbuilder.rb +219 -192
- data/test/test_i18n.rb +46 -19
- data/test/test_idgxmlbuilder.rb +177 -182
- data/test/test_inaobuilder.rb +1 -2
- data/test/test_index.rb +20 -0
- data/test/test_latexbuilder.rb +175 -183
- data/test/test_markdownbuilder.rb +41 -5
- data/test/test_pdfmaker.rb +130 -0
- data/test/test_topbuilder.rb +92 -96
- metadata +10 -6
- data/lib/review/book/parameters.rb +0 -98
- data/test/test_book_parameter.rb +0 -42
data/test/test_builder.rb
CHANGED
@@ -16,7 +16,8 @@ class BuidlerTest < Test::Unit::TestCase
|
|
16
16
|
|
17
17
|
def setup
|
18
18
|
@b = Builder.new
|
19
|
-
|
19
|
+
chap = ReVIEW::Book::Chapter.new(nil, nil, '-', nil)
|
20
|
+
@b.bind(MockCompiler.new, chap, nil)
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_initialize
|
@@ -25,8 +26,9 @@ class BuidlerTest < Test::Unit::TestCase
|
|
25
26
|
|
26
27
|
def test_bind
|
27
28
|
b = Builder.new
|
29
|
+
chap = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load_default, nil, '-', nil)
|
28
30
|
assert_nothing_raised do
|
29
|
-
b.bind(nil,
|
31
|
+
b.bind(nil, chap, nil)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -37,7 +39,8 @@ class BuidlerTest < Test::Unit::TestCase
|
|
37
39
|
end
|
38
40
|
|
39
41
|
b = Builder.new
|
40
|
-
|
42
|
+
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load_default, nil, '-', nil)
|
43
|
+
b.bind(nil, chapter, nil)
|
41
44
|
assert_equal '', b.result
|
42
45
|
end
|
43
46
|
|
@@ -79,8 +82,9 @@ class BuidlerTest < Test::Unit::TestCase
|
|
79
82
|
[:puts, "#{utf8_str}\n", "#{expect}\n"],
|
80
83
|
].each do |m, instr, expstr|
|
81
84
|
b = Builder.new
|
82
|
-
|
83
|
-
|
85
|
+
chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load_default, nil, '-', nil)
|
86
|
+
b.bind(nil, chapter, nil)
|
87
|
+
chapter.book.config = params
|
84
88
|
b.__send__(m, instr)
|
85
89
|
if "".respond_to?(:encode)
|
86
90
|
assert_equal expstr.encode("UTF-8"), b.result
|
@@ -128,9 +132,10 @@ class BuidlerTest < Test::Unit::TestCase
|
|
128
132
|
end
|
129
133
|
|
130
134
|
def test_convert_outencoding
|
131
|
-
|
135
|
+
book = ReVIEW::Book::Base.new(nil)
|
136
|
+
book.config = {'outencoding' => "EUC"}
|
132
137
|
b = Builder.new
|
133
|
-
ret = b.convert_outencoding("a",
|
138
|
+
ret = b.convert_outencoding("a", book.config["outencoding"])
|
134
139
|
assert_equal "a", ret
|
135
140
|
end
|
136
141
|
|
data/test/test_catalog.rb
CHANGED
@@ -28,13 +28,13 @@ ch02.re
|
|
28
28
|
assert_equal("", sut.chaps)
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def test_appendix
|
32
32
|
sut = Catalog.new(yaml)
|
33
33
|
exp =<<-EOS
|
34
34
|
post01.re
|
35
35
|
post02.re
|
36
36
|
EOS
|
37
|
-
assert_equal(exp.chomp, sut.
|
37
|
+
assert_equal(exp.chomp, sut.appendix)
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_chaps_with_parts
|
@@ -72,6 +72,15 @@ part2.re
|
|
72
72
|
sut.parts_with_chaps)
|
73
73
|
end
|
74
74
|
|
75
|
+
def test_postdef
|
76
|
+
sut = Catalog.new(yaml)
|
77
|
+
exp =<<-EOS
|
78
|
+
back01.re
|
79
|
+
back02.re
|
80
|
+
EOS
|
81
|
+
assert_equal(exp.chomp, sut.postdef)
|
82
|
+
end
|
83
|
+
|
75
84
|
private
|
76
85
|
def yaml
|
77
86
|
StringIO.new <<-EOS
|
@@ -84,10 +93,13 @@ CHAPS:
|
|
84
93
|
- ch01.re
|
85
94
|
- ch02.re
|
86
95
|
|
87
|
-
|
96
|
+
APPENDIX:
|
88
97
|
- post01.re
|
89
98
|
- post02.re
|
90
99
|
|
100
|
+
POSTDEF:
|
101
|
+
- back01.re
|
102
|
+
- back02.re
|
91
103
|
EOS
|
92
104
|
end
|
93
105
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'yaml'
|
5
|
+
require 'rbconfig'
|
6
|
+
|
7
|
+
load File.expand_path('../bin/review-catalog-converter', File.dirname(__FILE__))
|
8
|
+
|
9
|
+
class CatalogConverterCmdTest < Test::Unit::TestCase
|
10
|
+
def test_parse_chaps
|
11
|
+
input = <<-EOS
|
12
|
+
ch01.re
|
13
|
+
ch02.re
|
14
|
+
ch03.re
|
15
|
+
EOS
|
16
|
+
|
17
|
+
expected = <<-EOS
|
18
|
+
CHAPS:
|
19
|
+
- ch01.re
|
20
|
+
- ch02.re
|
21
|
+
- ch03.re
|
22
|
+
|
23
|
+
EOS
|
24
|
+
assert_equal expected, parse_chaps(input)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_parse_chaps_empty
|
28
|
+
assert_equal "CHAPS:\n\n", parse_chaps("")
|
29
|
+
assert_equal "CHAPS:\n\n", parse_chaps(nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_parse_parts
|
33
|
+
parts = <<-EOS
|
34
|
+
pt01
|
35
|
+
pt02
|
36
|
+
pt03
|
37
|
+
EOS
|
38
|
+
|
39
|
+
chaps = <<-EOS
|
40
|
+
ch01.re
|
41
|
+
|
42
|
+
ch02.re
|
43
|
+
ch03.re
|
44
|
+
|
45
|
+
ch04.re
|
46
|
+
EOS
|
47
|
+
|
48
|
+
expected = <<-EOS
|
49
|
+
CHAPS:
|
50
|
+
- pt01:
|
51
|
+
- ch01.re
|
52
|
+
- pt02:
|
53
|
+
- ch02.re
|
54
|
+
- ch03.re
|
55
|
+
- pt03:
|
56
|
+
- ch04.re
|
57
|
+
|
58
|
+
EOS
|
59
|
+
|
60
|
+
assert_equal expected, parse_parts(parts, chaps)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_parse_parts_chaps_empty
|
64
|
+
assert_equal "CHAPS:\n\n", parse_parts("", "")
|
65
|
+
assert_equal "CHAPS:\n\n", parse_parts(nil, nil)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_parse_postdef
|
69
|
+
assert_equal "APPENDIX:\n\n", parse_postdef("", true)
|
70
|
+
assert_equal "POSTDEF:\n\n", parse_postdef("")
|
71
|
+
assert_equal "POSTDEF:\n\n", parse_postdef("", false)
|
72
|
+
end
|
73
|
+
end
|
data/test/test_epubmaker.rb
CHANGED
@@ -190,7 +190,7 @@ EOT
|
|
190
190
|
|
191
191
|
def stage3
|
192
192
|
# add more items
|
193
|
-
@producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01", "level" => 1})
|
193
|
+
@producer.contents << Content.new({"file" => "ch01.html", "title" => "CH01<>&\"", "level" => 1})
|
194
194
|
@producer.contents << Content.new({"file" => "ch02.html", "title" => "CH02", "level" => 1})
|
195
195
|
@producer.contents << Content.new({"file" => "ch02.html#S1", "title" => "CH02.1", "level" => 2})
|
196
196
|
@producer.contents << Content.new({"file" => "ch02.html#S1.1", "title" => "CH02.1.1", "level" => 3})
|
@@ -214,7 +214,7 @@ EOT
|
|
214
214
|
def test_stage3_add_various_items
|
215
215
|
stage3
|
216
216
|
expect = [
|
217
|
-
Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01", 1),
|
217
|
+
Content.new("ch01.html", "ch01-html", "application/xhtml+xml", "CH01<>&\"", 1),
|
218
218
|
Content.new("ch02.html", "ch02-html", "application/xhtml+xml", "CH02", 1),
|
219
219
|
Content.new("ch02.html#S1", "ch02-html#S1","html#s1","CH02.1", 2),
|
220
220
|
Content.new("ch02.html#S1.1", "ch02-html#S1-1", "1", "CH02.1.1", 3),
|
@@ -306,7 +306,7 @@ EOT
|
|
306
306
|
</navPoint>
|
307
307
|
<navPoint id="nav-2" playOrder="2">
|
308
308
|
<navLabel>
|
309
|
-
<text>CH01
|
309
|
+
<text>CH01<>&"</text>
|
310
310
|
</navLabel>
|
311
311
|
<content src="ch01.html"/>
|
312
312
|
</navPoint>
|
@@ -404,7 +404,7 @@ EOT
|
|
404
404
|
<body>
|
405
405
|
<h1 class="toc-title">Table of Contents</h1>
|
406
406
|
|
407
|
-
<ul class="toc-h1"><li><a href="ch01.html">CH01
|
407
|
+
<ul class="toc-h1"><li><a href="ch01.html">CH01<>&"</a></li>
|
408
408
|
<li><a href="ch02.html">CH02</a>
|
409
409
|
<ul class="toc-h2"><li><a href="ch02.html#S1">CH02.1</a></li>
|
410
410
|
<li><a href="ch02.html#S2">CH02.2</a></li>
|
@@ -436,7 +436,7 @@ EOT
|
|
436
436
|
<body>
|
437
437
|
<h1 class="toc-title">Table of Contents</h1>
|
438
438
|
<ul class="toc-h1">
|
439
|
-
<li><a href="ch01.html">CH01
|
439
|
+
<li><a href="ch01.html">CH01<>&"</a></li>
|
440
440
|
<li><a href="ch02.html">CH02</a></li>
|
441
441
|
<li><a href="ch02.html#S1">CH02.1</a></li>
|
442
442
|
<li><a href="ch02.html#S2">CH02.2</a></li>
|
data/test/test_helper.rb
CHANGED
@@ -1,27 +1,6 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
|
-
def ul_helper(src, expect)
|
5
|
-
io = StringIO.new(src)
|
6
|
-
li = LineInput.new(io)
|
7
|
-
@compiler.__send__(:compile_ulist, li)
|
8
|
-
assert_equal expect, @builder.raw_result
|
9
|
-
end
|
10
|
-
|
11
|
-
def ol_helper(src, expect)
|
12
|
-
io = StringIO.new(src)
|
13
|
-
li = LineInput.new(io)
|
14
|
-
@compiler.__send__(:compile_olist, li)
|
15
|
-
assert_equal expect, @builder.raw_result
|
16
|
-
end
|
17
|
-
|
18
|
-
def builder_helper(src, expect, method_sym)
|
19
|
-
io = StringIO.new(src)
|
20
|
-
li = LineInput.new(io)
|
21
|
-
@compiler.__send__(method_sym, li)
|
22
|
-
assert_equal expect, @builder.raw_result
|
23
|
-
end
|
24
|
-
|
25
4
|
def touch_file(path)
|
26
5
|
File.open(path, "w").close
|
27
6
|
path
|
@@ -32,3 +11,35 @@ def prepare_samplebook(srcdir)
|
|
32
11
|
FileUtils.cp_r(Dir.glob(samplebook_dir + "/*"), srcdir)
|
33
12
|
YAML.load(File.open(srcdir + "/config.yml"))
|
34
13
|
end
|
14
|
+
|
15
|
+
def compile_inline(text)
|
16
|
+
@builder.compile_inline(text)
|
17
|
+
end
|
18
|
+
|
19
|
+
def compile_block(text)
|
20
|
+
method_name = "compile_block_#{@builder.target_name}"
|
21
|
+
if !self.respond_to?(method_name, true)
|
22
|
+
method_name = "compile_block_default"
|
23
|
+
end
|
24
|
+
self.__send__(method_name, text)
|
25
|
+
end
|
26
|
+
|
27
|
+
def compile_block_default(text)
|
28
|
+
@chapter.content = text
|
29
|
+
@compiler.compile(@chapter)
|
30
|
+
end
|
31
|
+
|
32
|
+
def compile_block_html(text)
|
33
|
+
@chapter.content = text
|
34
|
+
matched = @compiler.compile(@chapter).match(/<body>\n(.+)<\/body>/m)
|
35
|
+
if matched && matched.size > 1
|
36
|
+
matched[1]
|
37
|
+
else
|
38
|
+
""
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def compile_block_idgxml(text)
|
43
|
+
@chapter.content = text
|
44
|
+
@compiler.compile(@chapter).gsub(/.*<doc xmlns:aid="http:\/\/ns.adobe.com\/AdobeInDesign\/4.0\/">/m,"").gsub(/<\/doc>\n/, "")
|
45
|
+
end
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -18,15 +18,16 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
18
18
|
"outencoding" => "UTF-8",
|
19
19
|
"stylesheet" => nil, # for HTMLBuilder
|
20
20
|
})
|
21
|
-
|
21
|
+
@book = Book::Base.new(".")
|
22
|
+
@book.config = @config
|
22
23
|
@compiler = ReVIEW::Compiler.new(@builder)
|
23
|
-
@chapter = Book::Chapter.new(
|
24
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
24
25
|
location = Location.new(nil, nil)
|
25
26
|
@builder.bind(@compiler, @chapter, location)
|
26
27
|
end
|
27
28
|
|
28
29
|
def test_xmlns_ops_prefix_epub3
|
29
|
-
|
30
|
+
@book.config["epubversion"] = 3
|
30
31
|
assert_equal "epub", @builder.xmlns_ops_prefix
|
31
32
|
end
|
32
33
|
|
@@ -35,184 +36,179 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def test_headline_level1
|
38
|
-
|
39
|
-
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this is test.</h1>\n|,
|
39
|
+
actual = compile_block("={test} this is test.\n")
|
40
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this is test.</h1>\n|, actual
|
40
41
|
end
|
41
42
|
|
42
43
|
def test_headline_level1_postdef
|
43
44
|
@chapter.instance_eval do
|
44
|
-
def
|
45
|
+
def on_APPENDIX?
|
45
46
|
true
|
46
47
|
end
|
47
48
|
end
|
48
|
-
|
49
|
-
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録1 this is test.</h1>\n|,
|
49
|
+
actual = compile_block("={test} this is test.\n")
|
50
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録1 this is test.</h1>\n|, actual
|
50
51
|
end
|
51
52
|
|
52
53
|
def test_headline_level2_postdef
|
53
54
|
@chapter.instance_eval do
|
54
|
-
def
|
55
|
+
def on_APPENDIX?
|
55
56
|
true
|
56
57
|
end
|
57
58
|
end
|
58
|
-
|
59
|
-
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|,
|
59
|
+
actual = compile_block("=={test} this is test.\n")
|
60
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|, actual
|
60
61
|
end
|
61
62
|
|
62
63
|
def test_headline_level1_postdef_roman
|
63
64
|
@chapter.book.config["appendix_format"] = "roman"
|
64
65
|
@chapter.instance_eval do
|
65
|
-
def
|
66
|
+
def on_APPENDIX?
|
66
67
|
true
|
67
68
|
end
|
68
69
|
end
|
69
|
-
|
70
|
-
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録I this is test.</h1>\n|,
|
70
|
+
actual = compile_block("={test} this is test.\n")
|
71
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録I this is test.</h1>\n|, actual
|
71
72
|
end
|
72
73
|
|
73
74
|
def test_headline_level2_postdef_roman
|
74
75
|
@chapter.book.config["appendix_format"] = "roman"
|
75
76
|
@chapter.instance_eval do
|
76
|
-
def
|
77
|
+
def on_APPENDIX?
|
77
78
|
true
|
78
79
|
end
|
79
80
|
end
|
80
|
-
|
81
|
-
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>I.1 this is test.</h2>\n|,
|
81
|
+
actual = compile_block("=={test} this is test.\n")
|
82
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>I.1 this is test.</h2>\n|, actual
|
82
83
|
end
|
83
84
|
|
84
85
|
def test_headline_level1_postdef_alpha
|
85
86
|
@chapter.book.config["appendix_format"] = "alpha"
|
86
87
|
@chapter.instance_eval do
|
87
|
-
def
|
88
|
+
def on_APPENDIX?
|
88
89
|
true
|
89
90
|
end
|
90
91
|
end
|
91
|
-
|
92
|
-
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録A this is test.</h1>\n|,
|
92
|
+
actual = compile_block("={test} this is test.\n")
|
93
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>付録A this is test.</h1>\n|, actual
|
93
94
|
end
|
94
95
|
|
95
96
|
def test_headline_level2_postdef_alpha
|
96
97
|
@chapter.book.config["appendix_format"] = "alpha"
|
97
98
|
@chapter.instance_eval do
|
98
|
-
def
|
99
|
+
def on_APPENDIX?
|
99
100
|
true
|
100
101
|
end
|
101
102
|
end
|
102
|
-
|
103
|
-
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>A.1 this is test.</h2>\n|,
|
103
|
+
actual = compile_block("=={test} this is test.\n")
|
104
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>A.1 this is test.</h2>\n|, actual
|
104
105
|
end
|
105
106
|
|
106
107
|
def test_headline_level1_without_secno
|
107
|
-
|
108
|
-
|
109
|
-
assert_equal %Q|<h1 id="test"><a id="h1"></a>this is test.</h1>\n|,
|
108
|
+
@book.config["secnolevel"] = 0
|
109
|
+
actual = compile_block("={test} this is test.\n")
|
110
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>this is test.</h1>\n|, actual
|
110
111
|
end
|
111
112
|
|
112
113
|
def test_headline_level1_with_tricky_id
|
113
|
-
|
114
|
-
assert_equal %Q|<h1 id="id_123-_E3_81_82___3B"><a id="h1"></a>第1章 this is test.</h1>\n|,
|
114
|
+
actual = compile_block("={123 あ_;} this is test.\n")
|
115
|
+
assert_equal %Q|<h1 id="id_123-_E3_81_82___3B"><a id="h1"></a>第1章 this is test.</h1>\n|, actual
|
115
116
|
end
|
116
117
|
|
117
118
|
def test_headline_level1_with_inlinetag
|
118
|
-
|
119
|
-
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this <b>is</b> test.<&"></h1>\n|,
|
119
|
+
actual = compile_block("={test} this @<b>{is} test.<&\">\n")
|
120
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a>第1章 this <b>is</b> test.<&"></h1>\n|, actual
|
120
121
|
end
|
121
122
|
|
122
123
|
def test_headline_level2
|
123
|
-
|
124
|
-
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|,
|
124
|
+
actual = compile_block("=={test} this is test.\n")
|
125
|
+
assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a>1.1 this is test.</h2>\n|, actual
|
125
126
|
end
|
126
127
|
|
127
128
|
def test_headline_level3
|
128
|
-
|
129
|
-
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n|,
|
129
|
+
actual = compile_block("==={test} this is test.\n")
|
130
|
+
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n|, actual
|
130
131
|
end
|
131
132
|
|
132
133
|
def test_headline_level3_with_secno
|
133
|
-
|
134
|
-
|
135
|
-
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>1.0.1 this is test.</h3>\n|,
|
134
|
+
@book.config["secnolevel"] = 3
|
135
|
+
actual = compile_block("==={test} this is test.\n")
|
136
|
+
assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>1.0.1 this is test.</h3>\n|, actual
|
136
137
|
end
|
137
138
|
|
138
139
|
def test_label
|
139
|
-
|
140
|
-
assert_equal %Q|<a id="label_test"></a>\n|,
|
140
|
+
actual = compile_block("//label[label_test]\n")
|
141
|
+
assert_equal %Q|<a id="label_test"></a>\n|, actual
|
141
142
|
end
|
142
143
|
|
143
144
|
def test_label_with_tricky_id
|
144
|
-
|
145
|
-
assert_equal %Q|<a id="id_123-_E3_81_82___3B"></a>\n|,
|
145
|
+
actual = compile_block("//label[123 あ_;]\n")
|
146
|
+
assert_equal %Q|<a id="id_123-_E3_81_82___3B"></a>\n|, actual
|
146
147
|
end
|
147
148
|
|
148
149
|
def test_href
|
149
|
-
|
150
|
-
assert_equal %Q|<a href="http://github.com" class="link">GitHub</a>|,
|
150
|
+
actual = compile_inline("@<href>{http://github.com,GitHub}")
|
151
|
+
assert_equal %Q|<a href="http://github.com" class="link">GitHub</a>|, actual
|
151
152
|
end
|
152
153
|
|
153
154
|
def test_href_without_label
|
154
|
-
|
155
|
-
assert_equal %Q|<a href="http://github.com" class="link">http://github.com</a>|,
|
155
|
+
actual = compile_inline("@<href>{http://github.com}")
|
156
|
+
assert_equal %Q|<a href="http://github.com" class="link">http://github.com</a>|, actual
|
156
157
|
end
|
157
158
|
|
158
159
|
def test_inline_href
|
159
|
-
|
160
|
-
assert_equal %Q|<a href="http://github.com" class="link">Git,Hub</a>|,
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_inline_href_without_label
|
164
|
-
ret = @builder.inline_href("http://github.com")
|
165
|
-
assert_equal %Q|<a href="http://github.com" class="link">http://github.com</a>|, ret
|
160
|
+
actual = compile_inline("@<href>{http://github.com,Git\\,Hub}")
|
161
|
+
assert_equal %Q|<a href="http://github.com" class="link">Git,Hub</a>|, actual
|
166
162
|
end
|
167
163
|
|
168
164
|
def test_inline_raw
|
169
|
-
|
170
|
-
assert_equal %Q|@<tt>{inline}|,
|
165
|
+
actual = compile_inline("@<raw>{@<tt>{inline\\}}")
|
166
|
+
assert_equal %Q|@<tt>{inline}|, actual
|
171
167
|
end
|
172
168
|
|
173
169
|
def test_inline_in_table
|
174
|
-
|
175
|
-
assert_equal %Q|<div class="table">\n<table>\n<tr><th><b>1</b></th><th><i>2</i></th></tr>\n<tr><td><b>3</b></td><td><i>4</i><>&</td></tr>\n</table>\n</div>\n|,
|
170
|
+
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
171
|
+
assert_equal %Q|<div class="table">\n<table>\n<tr><th><b>1</b></th><th><i>2</i></th></tr>\n<tr><td><b>3</b></td><td><i>4</i><>&</td></tr>\n</table>\n</div>\n|, actual
|
176
172
|
end
|
177
173
|
|
178
174
|
def test_inline_br
|
179
|
-
|
180
|
-
assert_equal %Q|<br />|,
|
175
|
+
actual = compile_inline("@<br>{}")
|
176
|
+
assert_equal %Q|<br />|, actual
|
181
177
|
end
|
182
178
|
|
183
179
|
def test_inline_i
|
184
|
-
|
185
|
-
assert_equal %Q|test <i>inline test</i> test2|,
|
180
|
+
actual = compile_inline("test @<i>{inline test} test2")
|
181
|
+
assert_equal %Q|test <i>inline test</i> test2|, actual
|
186
182
|
end
|
187
183
|
|
188
184
|
def test_inline_i_and_escape
|
189
|
-
|
190
|
-
assert_equal %Q|test <i>inline<&;\\ test</i> test2|,
|
185
|
+
actual = compile_inline("test @<i>{inline<&;\\ test} test2")
|
186
|
+
assert_equal %Q|test <i>inline<&;\\ test</i> test2|, actual
|
191
187
|
end
|
192
188
|
|
193
189
|
def test_inline_b
|
194
|
-
|
195
|
-
assert_equal %Q|test <b>inline test</b> test2|,
|
190
|
+
actual = compile_inline("test @<b>{inline test} test2")
|
191
|
+
assert_equal %Q|test <b>inline test</b> test2|, actual
|
196
192
|
end
|
197
193
|
|
198
194
|
def test_inline_b_and_escape
|
199
|
-
|
200
|
-
assert_equal %Q|test <b>inline<&;\\ test</b> test2|,
|
195
|
+
actual = compile_inline("test @<b>{inline<&;\\ test} test2")
|
196
|
+
assert_equal %Q|test <b>inline<&;\\ test</b> test2|, actual
|
201
197
|
end
|
202
198
|
|
203
199
|
def test_inline_tt
|
204
|
-
|
205
|
-
assert_equal %Q|test <tt>inline test</tt> test2|,
|
200
|
+
actual = compile_inline("test @<tt>{inline test} test2")
|
201
|
+
assert_equal %Q|test <tt>inline test</tt> test2|, actual
|
206
202
|
end
|
207
203
|
|
208
204
|
def test_inline_tti
|
209
|
-
|
210
|
-
assert_equal %Q|test <tt><i>inline test</i></tt> test2|,
|
205
|
+
actual = compile_inline("test @<tti>{inline test} test2")
|
206
|
+
assert_equal %Q|test <tt><i>inline test</i></tt> test2|, actual
|
211
207
|
end
|
212
208
|
|
213
209
|
def test_inline_ttb
|
214
|
-
|
215
|
-
assert_equal %Q|test <tt><b>inline test</b></tt> test2|,
|
210
|
+
actual = compile_inline("test @<ttb>{inline test} test2")
|
211
|
+
assert_equal %Q|test <tt><b>inline test</b></tt> test2|, actual
|
216
212
|
end
|
217
213
|
|
218
214
|
def test_inline_hd_chap
|
@@ -222,32 +218,32 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
222
218
|
end
|
223
219
|
|
224
220
|
@config["secnolevel"] = 2
|
225
|
-
|
226
|
-
assert_equal %Q|test 「te_st」 test2|,
|
221
|
+
actual = compile_inline("test @<hd>{chap1|test} test2")
|
222
|
+
assert_equal %Q|test 「te_st」 test2|, actual
|
227
223
|
|
228
224
|
@config["secnolevel"] = 3
|
229
|
-
|
230
|
-
assert_equal %Q|test 「1.1.1 te_st」 test2|,
|
225
|
+
actual = compile_inline("test @<hd>{chap1|test} test2")
|
226
|
+
assert_equal %Q|test 「1.1.1 te_st」 test2|, actual
|
231
227
|
end
|
232
228
|
|
233
229
|
def test_inline_uchar
|
234
|
-
|
235
|
-
assert_equal %Q|test ① test2|,
|
230
|
+
actual = compile_inline("test @<uchar>{2460} test2")
|
231
|
+
assert_equal %Q|test ① test2|, actual
|
236
232
|
end
|
237
233
|
|
238
234
|
def test_inline_ruby
|
239
|
-
|
240
|
-
assert_equal "<ruby><rb>粗雑</rb><rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby><rb>繊細</rb><rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。",
|
235
|
+
actual = compile_inline("@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。")
|
236
|
+
assert_equal "<ruby><rb>粗雑</rb><rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby><rb>繊細</rb><rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。", actual
|
241
237
|
end
|
242
238
|
|
243
239
|
def test_inline_ruby_comma
|
244
|
-
|
245
|
-
assert_equal "<ruby><rb>foo, bar, buz</rb><rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>",
|
240
|
+
actual = compile_inline("@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}")
|
241
|
+
assert_equal "<ruby><rb>foo, bar, buz</rb><rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>", actual
|
246
242
|
end
|
247
243
|
|
248
244
|
def test_inline_ref
|
249
|
-
|
250
|
-
assert_equal %Q|<a target='外部参照<>&'>「●● 外部参照<>&」</a>|,
|
245
|
+
actual = compile_inline("@<ref>{外部参照<>&}")
|
246
|
+
assert_equal %Q|<a target='外部参照<>&'>「●● 外部参照<>&」</a>|, actual
|
251
247
|
end
|
252
248
|
|
253
249
|
def test_inline_mathml
|
@@ -258,37 +254,35 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
258
254
|
return true
|
259
255
|
end
|
260
256
|
@config["mathml"] = true
|
261
|
-
|
257
|
+
actual = compile_inline("@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}")
|
262
258
|
@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>",
|
259
|
+
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>", actual
|
264
260
|
end
|
265
261
|
|
266
262
|
def test_quote
|
267
|
-
|
268
|
-
|
269
|
-
assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n|, @builder.raw_result
|
263
|
+
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
264
|
+
assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n|, actual
|
270
265
|
end
|
271
266
|
|
272
267
|
def test_memo
|
273
|
-
|
274
|
-
assert_equal %Q|<div class="memo">\n<p class="caption">this is <b>test</b><&>_</p>\n<p>test1</p>\n<p>test<i>2</i></p>\n</div>\n|,
|
268
|
+
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
269
|
+
assert_equal %Q|<div class="memo">\n<p class="caption">this is <b>test</b><&>_</p>\n<p>test1</p>\n<p>test<i>2</i></p>\n</div>\n|, actual
|
275
270
|
end
|
276
271
|
|
277
272
|
def test_noindent
|
278
273
|
@builder.noindent
|
279
|
-
|
280
|
-
|
281
|
-
assert_equal %Q|<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n|, @builder.raw_result
|
274
|
+
actual = compile_block("foo\nbar\n\nfoo2\nbar2\n")
|
275
|
+
assert_equal %Q|<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n|, actual
|
282
276
|
end
|
283
277
|
|
284
278
|
def test_flushright
|
285
|
-
|
286
|
-
assert_equal %Q|<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n|,
|
279
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
280
|
+
assert_equal %Q|<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n|, actual
|
287
281
|
end
|
288
282
|
|
289
283
|
def test_centering
|
290
|
-
|
291
|
-
assert_equal %Q|<p class="center">foobar</p>\n<p class="center">buz</p>\n|,
|
284
|
+
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
285
|
+
assert_equal %Q|<p class="center">foobar</p>\n<p class="center">buz</p>\n|, actual
|
292
286
|
end
|
293
287
|
|
294
288
|
def test_image
|
@@ -298,8 +292,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
298
292
|
item
|
299
293
|
end
|
300
294
|
|
301
|
-
|
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|,
|
295
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
296
|
+
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|, actual
|
303
297
|
end
|
304
298
|
|
305
299
|
def test_image_with_metric
|
@@ -309,8 +303,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
309
303
|
item
|
310
304
|
end
|
311
305
|
|
312
|
-
|
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|,
|
306
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
307
|
+
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|, actual
|
314
308
|
end
|
315
309
|
|
316
310
|
def test_image_with_metric2
|
@@ -319,8 +313,9 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
319
313
|
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
320
314
|
item
|
321
315
|
end
|
322
|
-
|
323
|
-
|
316
|
+
|
317
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
318
|
+
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|, actual
|
324
319
|
end
|
325
320
|
|
326
321
|
def test_image_with_tricky_id
|
@@ -330,8 +325,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
330
325
|
item
|
331
326
|
end
|
332
327
|
|
333
|
-
|
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|,
|
328
|
+
actual = compile_block("//image[123 あ_;][sample photo]{\n//}\n")
|
329
|
+
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|, actual
|
335
330
|
end
|
336
331
|
|
337
332
|
def test_indepimage
|
@@ -341,8 +336,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
341
336
|
item
|
342
337
|
end
|
343
338
|
|
344
|
-
|
345
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|,
|
339
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
340
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
346
341
|
end
|
347
342
|
|
348
343
|
def test_indepimage_without_caption
|
@@ -352,8 +347,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
352
347
|
item
|
353
348
|
end
|
354
349
|
|
355
|
-
|
356
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|,
|
350
|
+
actual = compile_block("//indepimage[sampleimg]\n")
|
351
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|, actual
|
357
352
|
end
|
358
353
|
|
359
354
|
def test_indepimage_with_metric
|
@@ -363,8 +358,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
363
358
|
item
|
364
359
|
end
|
365
360
|
|
366
|
-
|
367
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|,
|
361
|
+
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
362
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
368
363
|
end
|
369
364
|
|
370
365
|
def test_indepimage_with_metric2
|
@@ -374,8 +369,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
374
369
|
item
|
375
370
|
end
|
376
371
|
|
377
|
-
|
378
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" class="sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|,
|
372
|
+
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\",latex::ignore=params]\n")
|
373
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" class="sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
|
379
374
|
end
|
380
375
|
|
381
376
|
def test_indepimage_without_caption_but_with_metric
|
@@ -385,17 +380,26 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
385
380
|
item
|
386
381
|
end
|
387
382
|
|
388
|
-
|
389
|
-
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" width="120%" />\n</div>\n|,
|
383
|
+
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
384
|
+
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" width="120%" />\n</div>\n|, actual
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_dlist
|
388
|
+
actual = compile_block(": foo\n foo.\n bar.\n")
|
389
|
+
assert_equal %Q|<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
|
390
|
+
end
|
391
|
+
|
392
|
+
def test_dlist_with_bracket
|
393
|
+
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
394
|
+
assert_equal %Q|<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
|
390
395
|
end
|
391
396
|
|
392
397
|
def test_list
|
393
398
|
def @chapter.list(id)
|
394
399
|
Book::ListIndex::Item.new("samplelist",1)
|
395
400
|
end
|
396
|
-
|
397
|
-
|
398
|
-
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
|
401
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
402
|
+
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
|
399
403
|
end
|
400
404
|
|
401
405
|
def test_list_pygments
|
@@ -407,41 +411,41 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
407
411
|
rescue LoadError
|
408
412
|
return true
|
409
413
|
end
|
410
|
-
|
411
|
-
|
414
|
+
@book.config["pygments"] = true
|
415
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
412
416
|
|
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|,
|
417
|
+
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|, actual
|
414
418
|
end
|
415
419
|
|
416
420
|
def test_emlist
|
417
|
-
|
418
|
-
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|,
|
421
|
+
actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
|
422
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, actual
|
419
423
|
end
|
420
424
|
|
421
425
|
def test_emlist_caption
|
422
|
-
|
423
|
-
assert_equal %Q|<div class="emlist-code">\n<p class="caption">cap1</p>\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|,
|
426
|
+
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
427
|
+
assert_equal %Q|<div class="emlist-code">\n<p class="caption">cap1</p>\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, actual
|
424
428
|
end
|
425
429
|
|
426
430
|
def test_emlist_with_tab
|
427
|
-
|
428
|
-
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|,
|
431
|
+
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
432
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, actual
|
429
433
|
end
|
430
434
|
|
431
435
|
def test_emlist_with_4tab
|
432
|
-
@
|
433
|
-
|
434
|
-
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|,
|
436
|
+
@config["tabwidth"] = 4
|
437
|
+
actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
|
438
|
+
assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, actual
|
435
439
|
end
|
436
440
|
|
437
441
|
def test_cmd
|
438
|
-
|
439
|
-
assert_equal %Q|<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|,
|
442
|
+
actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
|
443
|
+
assert_equal %Q|<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|, actual
|
440
444
|
end
|
441
445
|
|
442
446
|
def test_cmd_caption
|
443
|
-
|
444
|
-
assert_equal %Q|<div class="cmd-code">\n<p class="caption">cap1</p>\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|,
|
447
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
448
|
+
assert_equal %Q|<div class="cmd-code">\n<p class="caption">cap1</p>\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|, actual
|
445
449
|
end
|
446
450
|
|
447
451
|
def test_bib
|
@@ -449,7 +453,15 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
449
453
|
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
450
454
|
end
|
451
455
|
|
452
|
-
assert_equal %Q|<a href="
|
456
|
+
assert_equal %Q|<a href="bib.html#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}")
|
457
|
+
end
|
458
|
+
|
459
|
+
def test_bib_noramlized
|
460
|
+
def @chapter.bibpaper(id)
|
461
|
+
Book::BibpaperIndex::Item.new("sampleb=ib",1,"sample bib")
|
462
|
+
end
|
463
|
+
|
464
|
+
assert_equal %Q|<a href="bib.html#bib-id_sample_3Dbib">[1]</a>|, compile_inline("@<bib>{sample=bib}")
|
453
465
|
end
|
454
466
|
|
455
467
|
def test_bibpaper
|
@@ -457,8 +469,17 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
457
469
|
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
458
470
|
end
|
459
471
|
|
460
|
-
|
461
|
-
assert_equal %Q|<div class=\"bibpaper\">\n<a id=\"bib-samplebib\">[1]</a> sample bib <b>bold</b>\n<p>ab</p></div>\n|,
|
472
|
+
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
473
|
+
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
|
474
|
+
end
|
475
|
+
|
476
|
+
def test_bibpaper_normalized
|
477
|
+
def @chapter.bibpaper(id)
|
478
|
+
Book::BibpaperIndex::Item.new("sample=bib",1,"sample bib")
|
479
|
+
end
|
480
|
+
|
481
|
+
actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
482
|
+
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
|
462
483
|
end
|
463
484
|
|
464
485
|
def test_bibpaper_with_anchor
|
@@ -466,14 +487,12 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
466
487
|
Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
|
467
488
|
end
|
468
489
|
|
469
|
-
|
470
|
-
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|,
|
490
|
+
actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
|
491
|
+
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
|
471
492
|
end
|
472
493
|
|
473
494
|
def column_helper(review)
|
474
|
-
|
475
|
-
chap_singleton.send(:define_method, :content) { review }
|
476
|
-
@compiler.compile(@chapter).match(/<body>\n(.+)<\/body>/m)[1]
|
495
|
+
compile_block(review)
|
477
496
|
end
|
478
497
|
|
479
498
|
def test_column_1
|
@@ -488,7 +507,7 @@ inside column
|
|
488
507
|
|
489
508
|
===[/column]
|
490
509
|
EOS
|
491
|
-
|
510
|
+
expected =<<-EOS
|
492
511
|
<div class="column">
|
493
512
|
|
494
513
|
<h3><a id="column-1"></a>prev column</h3>
|
@@ -500,7 +519,7 @@ EOS
|
|
500
519
|
<p>inside column</p>
|
501
520
|
</div>
|
502
521
|
EOS
|
503
|
-
assert_equal
|
522
|
+
assert_equal expected, column_helper(review)
|
504
523
|
end
|
505
524
|
|
506
525
|
def test_column_2
|
@@ -511,7 +530,7 @@ inside column
|
|
511
530
|
|
512
531
|
=== next level
|
513
532
|
EOS
|
514
|
-
|
533
|
+
expected =<<-EOS
|
515
534
|
<div class="column">
|
516
535
|
|
517
536
|
<h3><a id="column-1"></a>test</h3>
|
@@ -521,7 +540,7 @@ EOS
|
|
521
540
|
<h3><a id="h1-0-1"></a>next level</h3>
|
522
541
|
EOS
|
523
542
|
|
524
|
-
assert_equal
|
543
|
+
assert_equal expected, column_helper(review)
|
525
544
|
end
|
526
545
|
|
527
546
|
def test_column_3
|
@@ -547,7 +566,7 @@ inside column
|
|
547
566
|
|
548
567
|
this is @<column>{foo}.
|
549
568
|
EOS
|
550
|
-
|
569
|
+
expected =<<-EOS
|
551
570
|
<div class="column">
|
552
571
|
|
553
572
|
<h3 id="foo"><a id="column-1"></a>test</h3>
|
@@ -558,7 +577,7 @@ EOS
|
|
558
577
|
<p>this is test.</p>
|
559
578
|
EOS
|
560
579
|
|
561
|
-
assert_equal
|
580
|
+
assert_equal expected, column_helper(review)
|
562
581
|
end
|
563
582
|
|
564
583
|
|
@@ -567,8 +586,9 @@ EOS
|
|
567
586
|
* AAA
|
568
587
|
* BBB
|
569
588
|
EOS
|
570
|
-
|
571
|
-
|
589
|
+
expected = "<ul>\n<li>AAA</li>\n<li>BBB</li>\n</ul>\n"
|
590
|
+
actual = compile_block(src)
|
591
|
+
assert_equal expected, actual
|
572
592
|
end
|
573
593
|
|
574
594
|
def test_ul_cont
|
@@ -578,8 +598,9 @@ EOS
|
|
578
598
|
* BBB
|
579
599
|
-BB
|
580
600
|
EOS
|
581
|
-
|
582
|
-
|
601
|
+
expected = "<ul>\n<li>AAA-AA</li>\n<li>BBB-BB</li>\n</ul>\n"
|
602
|
+
actual = compile_block(src)
|
603
|
+
assert_equal expected, actual
|
583
604
|
end
|
584
605
|
|
585
606
|
def test_ul_nest1
|
@@ -588,7 +609,7 @@ EOS
|
|
588
609
|
** AA
|
589
610
|
EOS
|
590
611
|
|
591
|
-
|
612
|
+
expected =<<-EOS
|
592
613
|
<ul>
|
593
614
|
<li>AAA<ul>
|
594
615
|
<li>AA</li>
|
@@ -596,7 +617,8 @@ EOS
|
|
596
617
|
</li>
|
597
618
|
</ul>
|
598
619
|
EOS
|
599
|
-
|
620
|
+
actual = compile_block(src)
|
621
|
+
assert_equal expected, actual
|
600
622
|
end
|
601
623
|
|
602
624
|
def test_ul_nest2
|
@@ -607,7 +629,7 @@ EOS
|
|
607
629
|
** BB
|
608
630
|
EOS
|
609
631
|
|
610
|
-
|
632
|
+
expected =<<-EOS
|
611
633
|
<ul>
|
612
634
|
<li>AAA<ul>
|
613
635
|
<li>AA</li>
|
@@ -619,7 +641,8 @@ EOS
|
|
619
641
|
</li>
|
620
642
|
</ul>
|
621
643
|
EOS
|
622
|
-
|
644
|
+
actual = compile_block(src)
|
645
|
+
assert_equal expected, actual
|
623
646
|
end
|
624
647
|
|
625
648
|
def test_ul_nest3
|
@@ -630,7 +653,7 @@ EOS
|
|
630
653
|
** BB
|
631
654
|
EOS
|
632
655
|
|
633
|
-
|
656
|
+
expected =<<-EOS
|
634
657
|
<ul>
|
635
658
|
<li><ul>
|
636
659
|
<li>AAA</li>
|
@@ -643,7 +666,8 @@ EOS
|
|
643
666
|
</li>
|
644
667
|
</ul>
|
645
668
|
EOS
|
646
|
-
|
669
|
+
actual = compile_block(src)
|
670
|
+
assert_equal expected, actual
|
647
671
|
end
|
648
672
|
|
649
673
|
def test_ul_nest4
|
@@ -655,7 +679,7 @@ EOS
|
|
655
679
|
** BB
|
656
680
|
EOS
|
657
681
|
|
658
|
-
|
682
|
+
expected =<<-EOS
|
659
683
|
<ul>
|
660
684
|
<li>A<ul>
|
661
685
|
<li>AA<ul>
|
@@ -670,7 +694,8 @@ EOS
|
|
670
694
|
</li>
|
671
695
|
</ul>
|
672
696
|
EOS
|
673
|
-
|
697
|
+
actual = compile_block(src)
|
698
|
+
assert_equal expected, actual
|
674
699
|
end
|
675
700
|
|
676
701
|
def test_ul_nest5
|
@@ -682,7 +707,7 @@ EOS
|
|
682
707
|
** BB
|
683
708
|
EOS
|
684
709
|
|
685
|
-
|
710
|
+
expected =<<-EOS
|
686
711
|
<ul>
|
687
712
|
<li>A<ul>
|
688
713
|
<li>AA<ul>
|
@@ -700,7 +725,8 @@ EOS
|
|
700
725
|
</li>
|
701
726
|
</ul>
|
702
727
|
EOS
|
703
|
-
|
728
|
+
actual = compile_block(src)
|
729
|
+
assert_equal expected, actual
|
704
730
|
end
|
705
731
|
|
706
732
|
def test_ol
|
@@ -709,86 +735,87 @@ EOS
|
|
709
735
|
3. BBB
|
710
736
|
EOS
|
711
737
|
|
712
|
-
|
738
|
+
expected =<<-EOS
|
713
739
|
<ol>
|
714
740
|
<li>AAA</li>
|
715
741
|
<li>BBB</li>
|
716
742
|
</ol>
|
717
743
|
EOS
|
718
|
-
|
744
|
+
actual = compile_block(src)
|
745
|
+
assert_equal expected, actual
|
719
746
|
end
|
720
747
|
|
721
748
|
def test_inline_raw0
|
722
|
-
assert_equal "normal",
|
749
|
+
assert_equal "normal", compile_inline("@<raw>{normal}")
|
723
750
|
end
|
724
751
|
|
725
752
|
def test_inline_raw1
|
726
|
-
assert_equal "body",
|
753
|
+
assert_equal "body", compile_inline("@<raw>{|html|body}")
|
727
754
|
end
|
728
755
|
|
729
756
|
def test_inline_raw2
|
730
|
-
assert_equal "body",
|
757
|
+
assert_equal "body", compile_inline("@<raw>{|html, latex|body}")
|
731
758
|
end
|
732
759
|
|
733
760
|
def test_inline_raw3
|
734
|
-
assert_equal "",
|
761
|
+
assert_equal "", compile_inline("@<raw>{|idgxml, latex|body}")
|
735
762
|
end
|
736
763
|
|
737
764
|
def test_inline_raw4
|
738
|
-
assert_equal "|html body",
|
765
|
+
assert_equal "|html body", compile_inline("@<raw>{|html body}")
|
739
766
|
end
|
740
767
|
|
741
768
|
def test_inline_raw5
|
742
|
-
assert_equal "nor\nmal",
|
769
|
+
assert_equal "nor\nmal", compile_inline("@<raw>{|html|nor\\nmal}")
|
743
770
|
end
|
744
771
|
|
745
772
|
def test_block_raw0
|
746
|
-
|
747
|
-
|
748
|
-
assert_equal
|
773
|
+
actual = compile_block("//raw[<>!\"\\n& ]\n")
|
774
|
+
expected = %Q(<>!\"\n& )
|
775
|
+
assert_equal expected, actual
|
749
776
|
end
|
750
777
|
|
751
778
|
def test_block_raw1
|
752
|
-
|
753
|
-
|
754
|
-
assert_equal
|
779
|
+
actual = compile_block("//raw[|html|<>!\"\\n& ]\n")
|
780
|
+
expected = %Q(<>!\"\n& )
|
781
|
+
assert_equal expected, actual
|
755
782
|
end
|
756
783
|
|
757
784
|
def test_block_raw2
|
758
|
-
|
759
|
-
|
760
|
-
assert_equal
|
785
|
+
actual = compile_block("//raw[|html, latex|<>!\"\\n& ]\n")
|
786
|
+
expected = %Q(<>!\"\n& )
|
787
|
+
assert_equal expected, actual
|
761
788
|
end
|
762
789
|
|
763
790
|
def test_block_raw3
|
764
|
-
|
765
|
-
|
766
|
-
assert_equal
|
791
|
+
actual = compile_block("//raw[|latex, idgxml|<>!\"\\n& ]\n")
|
792
|
+
expected = ''
|
793
|
+
assert_equal expected, actual
|
767
794
|
end
|
768
795
|
|
769
796
|
def test_block_raw4
|
770
|
-
|
771
|
-
|
772
|
-
assert_equal
|
797
|
+
actual = compile_block("//raw[|html <>!\"\\n& ]\n")
|
798
|
+
expected = %Q(|html <>!\"\n& )
|
799
|
+
assert_equal expected, actual
|
773
800
|
end
|
774
801
|
|
775
802
|
def test_inline_fn
|
776
803
|
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
|
777
804
|
@chapter.instance_eval{@footnote_index=fn}
|
778
|
-
|
779
|
-
|
805
|
+
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
806
|
+
expected =<<-'EOS'
|
780
807
|
<div class="footnote" id="fn-foo"><p class="footnote">[<a href="#fnb-foo">*1</a>] bar\a\$buz</p></div>
|
781
808
|
EOS
|
782
|
-
assert_equal
|
809
|
+
assert_equal expected, actual
|
783
810
|
end
|
784
811
|
|
785
812
|
def test_inline_fn_with_tricky_id
|
786
813
|
fn = Book::FootnoteIndex.parse(['//footnote[123 あ_;][bar\\a\\$buz]'])
|
787
814
|
@chapter.instance_eval{@footnote_index=fn}
|
788
|
-
|
789
|
-
|
815
|
+
actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
|
816
|
+
expected =<<-'EOS'
|
790
817
|
<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>
|
791
818
|
EOS
|
792
|
-
assert_equal
|
819
|
+
assert_equal expected, actual
|
793
820
|
end
|
794
821
|
end
|