review 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +90 -66
- data/.travis.yml +1 -1
- data/Gemfile +0 -1
- data/NEWS.ja.md +82 -0
- data/NEWS.md +83 -0
- data/README.md +5 -3
- data/Rakefile +8 -8
- data/bin/review +1 -5
- data/bin/review-catalog-converter +22 -27
- data/bin/review-check +36 -43
- data/bin/review-checkdep +10 -15
- data/bin/review-compile +37 -55
- data/bin/review-epubmaker +4 -5
- data/bin/review-index +21 -29
- data/bin/review-init +26 -37
- data/bin/review-pdfmaker +0 -2
- data/bin/review-preproc +25 -45
- data/bin/review-validate +19 -18
- data/bin/review-vol +15 -27
- data/doc/config.yml.sample +5 -2
- data/doc/format.ja.md +20 -1
- data/doc/format.md +21 -5
- data/doc/images/review-generate.png +0 -0
- data/lib/epubmaker.rb +1 -3
- data/lib/epubmaker/content.rb +24 -27
- data/lib/epubmaker/epubcommon.rb +135 -148
- data/lib/epubmaker/epubv2.rb +39 -46
- data/lib/epubmaker/epubv3.rb +93 -103
- data/lib/epubmaker/producer.rb +138 -151
- data/lib/epubmaker/zip_exporter.rb +21 -26
- data/lib/review/book.rb +3 -6
- data/lib/review/book/base.rb +78 -103
- data/lib/review/book/chapter.rb +36 -40
- data/lib/review/book/compilable.rb +28 -31
- data/lib/review/book/image_finder.rb +6 -13
- data/lib/review/book/index.rb +100 -121
- data/lib/review/book/page_metric.rb +2 -7
- data/lib/review/book/part.rb +18 -20
- data/lib/review/book/volume.rb +9 -13
- data/lib/review/builder.rb +81 -116
- data/lib/review/catalog.rb +15 -19
- data/lib/review/compiler.rb +64 -83
- data/lib/review/configure.rb +87 -97
- data/lib/review/converter.rb +2 -7
- data/lib/review/epubbuilder.rb +1 -3
- data/lib/review/epubmaker.rb +213 -205
- data/lib/review/exception.rb +2 -4
- data/lib/review/extentions.rb +0 -1
- data/lib/review/extentions/hash.rb +2 -2
- data/lib/review/extentions/string.rb +5 -30
- data/lib/review/htmlbuilder.rb +320 -375
- data/lib/review/htmltoc.rb +4 -7
- data/lib/review/htmlutils.rb +29 -32
- data/lib/review/i18n.rb +33 -44
- data/lib/review/i18n.yml +3 -3
- data/lib/review/idgxmlbuilder.rb +309 -345
- data/lib/review/latexbuilder.rb +175 -212
- data/lib/review/latexindex.rb +2 -8
- data/lib/review/latexutils.rb +33 -43
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +21 -0
- data/lib/review/makerhelper.rb +1 -4
- data/lib/review/markdownbuilder.rb +44 -53
- data/lib/review/md2inaobuilder.rb +6 -12
- data/lib/review/pdfmaker.rb +143 -173
- data/lib/review/preprocessor.rb +64 -101
- data/lib/review/rstbuilder.rb +126 -158
- data/lib/review/sec_counter.rb +18 -34
- data/lib/review/template.rb +4 -5
- data/lib/review/textbuilder.rb +2 -3
- data/lib/review/textutils.rb +7 -13
- data/lib/review/tocparser.rb +31 -56
- data/lib/review/tocprinter.rb +26 -52
- data/lib/review/topbuilder.rb +219 -247
- data/lib/review/unfold.rb +15 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +75 -99
- data/lib/review/webtocprinter.rb +15 -20
- data/lib/review/yamlloader.rb +13 -15
- data/review.gemspec +20 -22
- data/templates/latex/layout.tex.erb +2 -2
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/black.eps +280 -0
- data/test/assets/fit.png +0 -0
- data/test/assets/large.gif +0 -0
- data/test/assets/large.jpg +0 -0
- data/test/assets/large.png +0 -0
- data/test/assets/large.svg +65 -0
- data/test/assets/test_template.tex +1 -1
- data/test/book_test_helper.rb +2 -2
- data/test/run_test.rb +4 -4
- data/test/sample-book/src/Rakefile +21 -22
- data/test/syntax-book/Gemfile +4 -0
- data/test/syntax-book/Rakefile +72 -0
- data/test/syntax-book/appA.re +22 -0
- data/test/syntax-book/bib.re +6 -0
- data/test/syntax-book/catalog.yml +15 -0
- data/test/syntax-book/ch01.re +136 -0
- data/test/syntax-book/ch02.re +351 -0
- data/test/syntax-book/ch03.re +82 -0
- data/test/syntax-book/config.yml +35 -0
- data/test/syntax-book/images/ball.png +0 -0
- data/test/syntax-book/images/cover.jpg +0 -0
- data/test/syntax-book/images/fractal.png +0 -0
- data/test/syntax-book/images/img3-1.png +0 -0
- data/test/syntax-book/images/inlineicon.jpg +0 -0
- data/test/syntax-book/images/logic.png +0 -0
- data/test/syntax-book/images/logic2.png +0 -0
- data/test/syntax-book/images/puzzle.jpg +0 -0
- data/test/syntax-book/images/table.jpg +0 -0
- data/test/syntax-book/part2.re +6 -0
- data/test/syntax-book/pre01.re +26 -0
- data/test/syntax-book/review-ext.rb +14 -0
- data/test/syntax-book/sty/jumoline.sty +310 -0
- data/test/syntax-book/sty/reviewmacro.sty +39 -0
- data/test/syntax-book/style.css +494 -0
- data/test/syntax-book/syntax.dic +2 -0
- data/test/test_book.rb +106 -111
- data/test/test_book_chapter.rb +21 -22
- data/test/test_book_part.rb +3 -5
- data/test/test_builder.rb +11 -22
- data/test/test_catalog.rb +17 -18
- data/test/test_catalog_converter_cmd.rb +5 -5
- data/test/test_compiler.rb +18 -16
- data/test/test_configure.rb +35 -38
- data/test/test_converter.rb +3 -4
- data/test/test_epub3maker.rb +136 -117
- data/test/test_epubmaker.rb +107 -114
- data/test/test_epubmaker_cmd.rb +2 -4
- data/test/test_extentions_hash.rb +32 -33
- data/test/test_helper.rb +9 -11
- data/test/test_htmlbuilder.rb +454 -420
- data/test/test_htmltoc.rb +8 -12
- data/test/test_htmlutils.rb +0 -2
- data/test/test_i18n.rb +159 -150
- data/test/test_idgxmlbuilder.rb +190 -197
- data/test/test_image_finder.rb +21 -22
- data/test/test_index.rb +24 -29
- data/test/test_latexbuilder.rb +274 -264
- data/test/test_lineinput.rb +7 -10
- data/test/test_location.rb +7 -7
- data/test/test_makerhelper.rb +13 -25
- data/test/test_markdownbuilder.rb +23 -26
- data/test/test_md2inaobuilder.rb +8 -11
- data/test/test_pdfmaker.rb +114 -123
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +3 -5
- data/test/test_rstbuilder.rb +92 -97
- data/test/test_template.rb +3 -7
- data/test/test_textutils.rb +27 -27
- data/test/test_tocparser.rb +2 -2
- data/test/test_topbuilder.rb +98 -103
- data/test/test_webtocprinter.rb +5 -6
- data/test/test_yamlloader.rb +42 -42
- data/test/test_zip_exporter.rb +12 -18
- metadata +86 -9
- data/lib/review/ewbbuilder.rb +0 -382
data/test/test_image_finder.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
require 'test_helper'
|
|
3
2
|
require 'review'
|
|
4
3
|
require 'review/book/image_finder'
|
|
@@ -13,12 +12,12 @@ class ImageFinderTest < Test::Unit::TestCase
|
|
|
13
12
|
def test_find_path_pattern1
|
|
14
13
|
dir = Dir.mktmpdir
|
|
15
14
|
begin
|
|
16
|
-
path = dir+
|
|
15
|
+
path = dir + '/builder/ch01/foo.jpg'
|
|
17
16
|
FileUtils.mkdir_p(File.dirname(path))
|
|
18
17
|
FileUtils.touch(path)
|
|
19
18
|
|
|
20
|
-
finder = ReVIEW::Book::ImageFinder.new(dir,
|
|
21
|
-
assert_equal(path, finder.find_path(
|
|
19
|
+
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
|
20
|
+
assert_equal(path, finder.find_path('foo'))
|
|
22
21
|
ensure
|
|
23
22
|
FileUtils.remove_entry_secure dir
|
|
24
23
|
end
|
|
@@ -27,12 +26,12 @@ class ImageFinderTest < Test::Unit::TestCase
|
|
|
27
26
|
def test_find_path_pattern2
|
|
28
27
|
dir = Dir.mktmpdir
|
|
29
28
|
begin
|
|
30
|
-
path = dir+
|
|
29
|
+
path = dir + '/builder/ch01-foo.jpg'
|
|
31
30
|
FileUtils.mkdir_p(File.dirname(path))
|
|
32
31
|
FileUtils.touch(path)
|
|
33
32
|
|
|
34
|
-
finder = ReVIEW::Book::ImageFinder.new(dir,
|
|
35
|
-
assert_equal(path, finder.find_path(
|
|
33
|
+
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
|
34
|
+
assert_equal(path, finder.find_path('foo'))
|
|
36
35
|
ensure
|
|
37
36
|
FileUtils.remove_entry_secure dir
|
|
38
37
|
end
|
|
@@ -41,12 +40,12 @@ class ImageFinderTest < Test::Unit::TestCase
|
|
|
41
40
|
def test_find_path_pattern3
|
|
42
41
|
dir = Dir.mktmpdir
|
|
43
42
|
begin
|
|
44
|
-
path = dir+
|
|
43
|
+
path = dir + '/builder/foo.jpg'
|
|
45
44
|
FileUtils.mkdir_p(File.dirname(path))
|
|
46
45
|
FileUtils.touch(path)
|
|
47
46
|
|
|
48
|
-
finder = ReVIEW::Book::ImageFinder.new(dir,
|
|
49
|
-
assert_equal(path, finder.find_path(
|
|
47
|
+
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
|
48
|
+
assert_equal(path, finder.find_path('foo'))
|
|
50
49
|
ensure
|
|
51
50
|
FileUtils.remove_entry_secure dir
|
|
52
51
|
end
|
|
@@ -55,12 +54,12 @@ class ImageFinderTest < Test::Unit::TestCase
|
|
|
55
54
|
def test_find_path_pattern4
|
|
56
55
|
dir = Dir.mktmpdir
|
|
57
56
|
begin
|
|
58
|
-
path = dir+
|
|
57
|
+
path = dir + '/ch01/foo.jpg'
|
|
59
58
|
FileUtils.mkdir_p(File.dirname(path))
|
|
60
59
|
FileUtils.touch(path)
|
|
61
60
|
|
|
62
|
-
finder = ReVIEW::Book::ImageFinder.new(dir,
|
|
63
|
-
assert_equal(path, finder.find_path(
|
|
61
|
+
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
|
62
|
+
assert_equal(path, finder.find_path('foo'))
|
|
64
63
|
ensure
|
|
65
64
|
FileUtils.remove_entry_secure dir
|
|
66
65
|
end
|
|
@@ -69,12 +68,12 @@ class ImageFinderTest < Test::Unit::TestCase
|
|
|
69
68
|
def test_find_path_pattern5
|
|
70
69
|
dir = Dir.mktmpdir
|
|
71
70
|
begin
|
|
72
|
-
path = dir+
|
|
71
|
+
path = dir + '/ch01-foo.jpg'
|
|
73
72
|
FileUtils.mkdir_p(File.dirname(path))
|
|
74
73
|
FileUtils.touch(path)
|
|
75
74
|
|
|
76
|
-
finder = ReVIEW::Book::ImageFinder.new(dir,
|
|
77
|
-
assert_equal(path, finder.find_path(
|
|
75
|
+
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
|
76
|
+
assert_equal(path, finder.find_path('foo'))
|
|
78
77
|
ensure
|
|
79
78
|
FileUtils.remove_entry_secure dir
|
|
80
79
|
end
|
|
@@ -83,16 +82,16 @@ class ImageFinderTest < Test::Unit::TestCase
|
|
|
83
82
|
def test_find_path_dir_symlink
|
|
84
83
|
dir = Dir.mktmpdir
|
|
85
84
|
begin
|
|
86
|
-
path_src = dir+
|
|
87
|
-
path_dst = dir+
|
|
85
|
+
path_src = dir + '/src'
|
|
86
|
+
path_dst = dir + '/ch01'
|
|
88
87
|
FileUtils.mkdir_p(path_src)
|
|
89
88
|
FileUtils.symlink(path_src, path_dst)
|
|
90
|
-
path_srcimg = path_src+
|
|
91
|
-
path_dstimg = path_dst+
|
|
89
|
+
path_srcimg = path_src + '/foo.jpg'
|
|
90
|
+
path_dstimg = path_dst + '/foo.jpg'
|
|
92
91
|
FileUtils.touch(path_srcimg)
|
|
93
92
|
|
|
94
|
-
finder = ReVIEW::Book::ImageFinder.new(dir,
|
|
95
|
-
assert_equal(path_dstimg, finder.find_path(
|
|
93
|
+
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
|
94
|
+
assert_equal(path_dstimg, finder.find_path('foo'))
|
|
96
95
|
ensure
|
|
97
96
|
FileUtils.remove_entry_secure dir
|
|
98
97
|
end
|
data/test/test_index.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
1
|
require 'test_helper'
|
|
4
2
|
require 'review/book'
|
|
5
3
|
require 'review/book/index'
|
|
@@ -40,7 +38,7 @@ class IndexTest < Test::Unit::TestCase
|
|
|
40
38
|
# rubocop:enable Style/PreferredHashMethods
|
|
41
39
|
end
|
|
42
40
|
|
|
43
|
-
def
|
|
41
|
+
def test_headeline_index
|
|
44
42
|
src = <<-EOB
|
|
45
43
|
= chap1
|
|
46
44
|
== sec1-1
|
|
@@ -57,11 +55,11 @@ class IndexTest < Test::Unit::TestCase
|
|
|
57
55
|
book = Book::Base.load
|
|
58
56
|
chap = Book::Chapter.new(book, 1, '-', nil) # dummy
|
|
59
57
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
60
|
-
assert_equal [2,2], index['sec1-2|sec1-2-2'].number
|
|
61
|
-
assert_equal
|
|
58
|
+
assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
|
|
59
|
+
assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
|
|
62
60
|
end
|
|
63
61
|
|
|
64
|
-
def
|
|
62
|
+
def test_headeline_index2
|
|
65
63
|
src = <<-EOB
|
|
66
64
|
= chap1
|
|
67
65
|
== sec1-1
|
|
@@ -74,11 +72,11 @@ class IndexTest < Test::Unit::TestCase
|
|
|
74
72
|
book = Book::Base.load
|
|
75
73
|
chap = Book::Chapter.new(book, 1, '-', nil) # dummy
|
|
76
74
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
77
|
-
assert_equal [3,1], index['sec1-3|sec1-3-1'].number
|
|
78
|
-
assert_equal
|
|
75
|
+
assert_equal [3, 1], index['sec1-3|sec1-3-1'].number
|
|
76
|
+
assert_equal '1.3.1', index.number('sec1-3|sec1-3-1')
|
|
79
77
|
end
|
|
80
78
|
|
|
81
|
-
def
|
|
79
|
+
def test_headeline_index3
|
|
82
80
|
src = <<-EOB
|
|
83
81
|
= chap1
|
|
84
82
|
== sec1-1
|
|
@@ -92,14 +90,14 @@ class IndexTest < Test::Unit::TestCase
|
|
|
92
90
|
book = Book::Base.load
|
|
93
91
|
chap = Book::Chapter.new(book, 1, '-', nil) # dummy
|
|
94
92
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
95
|
-
assert_equal [2,2], index['sec1-2|sec1-2-2'].number
|
|
96
|
-
assert_equal
|
|
93
|
+
assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
|
|
94
|
+
assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
|
|
97
95
|
|
|
98
|
-
assert_equal [3,1], index['sec1-3|sec1-3-1'].number
|
|
99
|
-
assert_equal
|
|
96
|
+
assert_equal [3, 1], index['sec1-3|sec1-3-1'].number
|
|
97
|
+
assert_equal '1.3.1', index.number('sec1-3|sec1-3-1')
|
|
100
98
|
end
|
|
101
99
|
|
|
102
|
-
def
|
|
100
|
+
def test_headeline_index4
|
|
103
101
|
src = <<-EOB
|
|
104
102
|
= chap1
|
|
105
103
|
====[column] c1
|
|
@@ -111,11 +109,11 @@ class IndexTest < Test::Unit::TestCase
|
|
|
111
109
|
book = Book::Base.load
|
|
112
110
|
chap = Book::Chapter.new(book, 1, '-', nil) # dummy
|
|
113
111
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
114
|
-
assert_equal [2,2], index['sec1-2|sec1-2-2'].number
|
|
115
|
-
assert_equal
|
|
112
|
+
assert_equal [2, 2], index['sec1-2|sec1-2-2'].number
|
|
113
|
+
assert_equal '1.2.2', index.number('sec1-2|sec1-2-2')
|
|
116
114
|
end
|
|
117
115
|
|
|
118
|
-
def
|
|
116
|
+
def test_headeline_index5
|
|
119
117
|
src = <<-EOB
|
|
120
118
|
= chap1
|
|
121
119
|
====[column] c1
|
|
@@ -127,11 +125,11 @@ class IndexTest < Test::Unit::TestCase
|
|
|
127
125
|
book = Book::Base.load
|
|
128
126
|
chap = Book::Chapter.new(book, 1, '-', nil) # dummy
|
|
129
127
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
130
|
-
assert_equal [2,2], index['sec1-2-2'].number
|
|
131
|
-
assert_equal
|
|
128
|
+
assert_equal [2, 2], index['sec1-2-2'].number
|
|
129
|
+
assert_equal '1.2.2', index.number('sec1-2-2')
|
|
132
130
|
end
|
|
133
131
|
|
|
134
|
-
def
|
|
132
|
+
def test_headeline_index6
|
|
135
133
|
src = <<-EOB
|
|
136
134
|
= chap1
|
|
137
135
|
== sec1
|
|
@@ -142,11 +140,11 @@ class IndexTest < Test::Unit::TestCase
|
|
|
142
140
|
book = Book::Base.load
|
|
143
141
|
chap = Book::Chapter.new(book, 1, '-', nil) # dummy
|
|
144
142
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
145
|
-
assert_equal [1,1], index['target'].number
|
|
146
|
-
assert_equal
|
|
143
|
+
assert_equal [1, 1], index['target'].number
|
|
144
|
+
assert_equal '1.1.1', index.number('target')
|
|
147
145
|
end
|
|
148
146
|
|
|
149
|
-
def
|
|
147
|
+
def test_headeline_index7
|
|
150
148
|
src = <<-EOB
|
|
151
149
|
= chap1
|
|
152
150
|
== sec1
|
|
@@ -162,11 +160,11 @@ class IndexTest < Test::Unit::TestCase
|
|
|
162
160
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
163
161
|
|
|
164
162
|
assert_raise ReVIEW::KeyError do
|
|
165
|
-
assert_equal [1,1], index['target'].number
|
|
163
|
+
assert_equal [1, 1], index['target'].number
|
|
166
164
|
end
|
|
167
165
|
end
|
|
168
166
|
|
|
169
|
-
def
|
|
167
|
+
def test_headeline_index8
|
|
170
168
|
src = <<-EOB
|
|
171
169
|
= chap1
|
|
172
170
|
== sec1
|
|
@@ -177,9 +175,6 @@ class IndexTest < Test::Unit::TestCase
|
|
|
177
175
|
book = Book::Base.load
|
|
178
176
|
chap = Book::Chapter.new(book, 1, '-', nil)
|
|
179
177
|
index = Book::HeadlineIndex.parse(src, chap)
|
|
180
|
-
assert_equal
|
|
178
|
+
assert_equal '1.1.1', index.number('sec1-1')
|
|
181
179
|
end
|
|
182
|
-
|
|
183
|
-
|
|
184
180
|
end
|
|
185
|
-
|
data/test/test_latexbuilder.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
require 'test_helper'
|
|
3
2
|
require 'review/compiler'
|
|
4
3
|
require 'review/book'
|
|
@@ -9,159 +8,159 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
|
9
8
|
include ReVIEW
|
|
10
9
|
|
|
11
10
|
def setup
|
|
12
|
-
@builder = LATEXBuilder.new
|
|
11
|
+
@builder = LATEXBuilder.new
|
|
13
12
|
@config = ReVIEW::Configure.values
|
|
14
|
-
@config.merge!(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
@config.merge!(
|
|
14
|
+
'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder
|
|
15
|
+
'toclevel' => 2,
|
|
16
|
+
'stylesheet' => nil, # for EPUBBuilder
|
|
17
|
+
'image_scale2width' => false,
|
|
18
|
+
'texcommand' => 'uplatex'
|
|
19
|
+
)
|
|
21
20
|
@book = Book::Base.new(nil)
|
|
22
21
|
@book.config = @config
|
|
23
22
|
@compiler = ReVIEW::Compiler.new(@builder)
|
|
24
23
|
@chapter = Book::Chapter.new(@book, 1, 'chap1', nil, StringIO.new)
|
|
25
24
|
location = Location.new(nil, nil)
|
|
26
25
|
@builder.bind(@compiler, @chapter, location)
|
|
27
|
-
I18n.setup(
|
|
26
|
+
I18n.setup('ja')
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
def test_headline_level1
|
|
31
30
|
actual = compile_block("={test} this is test.\n")
|
|
32
|
-
assert_equal %Q
|
|
31
|
+
assert_equal %Q(\\chapter{this is test.}\n\\label{chap:chap1}\n), actual
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
def test_headline_level1_without_secno
|
|
36
|
-
@config[
|
|
35
|
+
@config['secnolevel'] = 0
|
|
37
36
|
actual = compile_block("={test} this is test.\n")
|
|
38
|
-
assert_equal %Q
|
|
37
|
+
assert_equal %Q(\\chapter*{this is test.}\n\\addcontentsline{toc}{chapter}{this is test.}\n\\label{chap:chap1}\n), actual
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
def test_headline_level1_with_inlinetag
|
|
42
|
-
actual = compile_block(
|
|
43
|
-
assert_equal %Q
|
|
41
|
+
actual = compile_block(%Q(={test} this @<b>{is} test.<&"_>\n))
|
|
42
|
+
assert_equal %Q(\\chapter{this \\textbf{is} test.\\textless{}\\&"\\textunderscore{}\\textgreater{}}\n\\label{chap:chap1}\n), actual
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
def test_headline_level2
|
|
47
46
|
actual = compile_block("=={test} this is test.\n")
|
|
48
|
-
assert_equal %Q
|
|
47
|
+
assert_equal %Q(\\section{this is test.}\n\\label{sec:1-1}\n\\label{test}\n), actual
|
|
49
48
|
end
|
|
50
49
|
|
|
51
50
|
def test_headline_level3
|
|
52
51
|
actual = compile_block("==={test} this is test.\n")
|
|
53
|
-
assert_equal %Q
|
|
52
|
+
assert_equal %Q(\\subsection*{this is test.}\n\\label{sec:1-0-1}\n\\label{test}\n), actual
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
def test_headline_level3_with_secno
|
|
57
|
-
@config[
|
|
56
|
+
@config['secnolevel'] = 3
|
|
58
57
|
actual = compile_block("==={test} this is test.\n")
|
|
59
|
-
assert_equal %Q
|
|
58
|
+
assert_equal %Q(\\subsection{this is test.}\n\\label{sec:1-0-1}\n\\label{test}\n), actual
|
|
60
59
|
end
|
|
61
60
|
|
|
62
61
|
def test_label
|
|
63
62
|
actual = compile_block("//label[label_test]\n")
|
|
64
|
-
assert_equal %Q
|
|
63
|
+
assert_equal %Q(\\label{label_test}\n), actual
|
|
65
64
|
end
|
|
66
65
|
|
|
67
66
|
def test_href
|
|
68
|
-
actual = compile_inline(
|
|
69
|
-
assert_equal
|
|
67
|
+
actual = compile_inline('@<href>{http://github.com,GitHub}')
|
|
68
|
+
assert_equal '\\href{http://github.com}{GitHub}', actual
|
|
70
69
|
end
|
|
71
70
|
|
|
72
71
|
def test_inline_href
|
|
73
72
|
actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
|
|
74
|
-
assert_equal
|
|
73
|
+
assert_equal '\\href{http://github.com}{Git,Hub}', actual
|
|
75
74
|
end
|
|
76
75
|
|
|
77
76
|
def test_href_without_label
|
|
78
77
|
actual = compile_inline('@<href>{http://github.com}')
|
|
79
|
-
assert_equal
|
|
78
|
+
assert_equal '\\url{http://github.com}', actual
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
def test_href_with_underscore
|
|
83
82
|
actual = compile_inline('@<href>{http://example.com/aaa/bbb, AAA_BBB}')
|
|
84
|
-
assert_equal
|
|
83
|
+
assert_equal '\\href{http://example.com/aaa/bbb}{AAA\\textunderscore{}BBB}', actual
|
|
85
84
|
end
|
|
86
85
|
|
|
87
86
|
def test_href_mailto
|
|
88
87
|
actual = compile_inline('@<href>{mailto:takahashim@example.com, takahashim@example.com}')
|
|
89
|
-
assert_equal
|
|
88
|
+
assert_equal '\\href{mailto:takahashim@example.com}{takahashim@example.com}', actual
|
|
90
89
|
end
|
|
91
90
|
|
|
92
91
|
def test_inline_br
|
|
93
|
-
actual = compile_inline(
|
|
94
|
-
assert_equal %Q
|
|
92
|
+
actual = compile_inline('@<br>{}')
|
|
93
|
+
assert_equal %Q(\\\\\n), actual
|
|
95
94
|
end
|
|
96
95
|
|
|
97
96
|
def test_inline_br_with_other_strings
|
|
98
|
-
actual = compile_inline(
|
|
99
|
-
assert_equal %Q
|
|
97
|
+
actual = compile_inline('abc@<br>{}def')
|
|
98
|
+
assert_equal %Q(abc\\\\\ndef), actual
|
|
100
99
|
end
|
|
101
100
|
|
|
102
101
|
def test_inline_i
|
|
103
|
-
actual = compile_inline(
|
|
104
|
-
assert_equal
|
|
102
|
+
actual = compile_inline('abc@<i>{def}ghi')
|
|
103
|
+
assert_equal 'abc\\textit{def}ghi', actual
|
|
105
104
|
end
|
|
106
105
|
|
|
107
106
|
def test_inline_i_and_escape
|
|
108
|
-
actual = compile_inline(
|
|
109
|
-
assert_equal
|
|
107
|
+
actual = compile_inline('test @<i>{inline<&;\\ test} test2')
|
|
108
|
+
assert_equal 'test \\textit{inline\\textless{}\\&;\\reviewbackslash{} test} test2', actual
|
|
110
109
|
end
|
|
111
110
|
|
|
112
111
|
def test_inline_dtp
|
|
113
|
-
actual = compile_inline(
|
|
114
|
-
assert_equal
|
|
112
|
+
actual = compile_inline('abc@<dtp>{def}ghi')
|
|
113
|
+
assert_equal 'abcghi', actual
|
|
115
114
|
end
|
|
116
115
|
|
|
117
116
|
def test_inline_code
|
|
118
|
-
actual = compile_inline(
|
|
119
|
-
assert_equal
|
|
117
|
+
actual = compile_inline('abc@<code>{def}ghi')
|
|
118
|
+
assert_equal 'abc\\texttt{def}ghi', actual
|
|
120
119
|
end
|
|
121
120
|
|
|
122
121
|
def test_inline_raw
|
|
123
|
-
actual = compile_inline(
|
|
124
|
-
assert_equal
|
|
122
|
+
actual = compile_inline('@<raw>{@<tt>{inline!$%\\}}')
|
|
123
|
+
assert_equal '@<tt>{inline!$%}', actual
|
|
125
124
|
end
|
|
126
125
|
|
|
127
126
|
def test_inline_sup
|
|
128
|
-
actual = compile_inline(
|
|
129
|
-
assert_equal
|
|
127
|
+
actual = compile_inline('abc@<sup>{def}')
|
|
128
|
+
assert_equal 'abc\\textsuperscript{def}', actual
|
|
130
129
|
end
|
|
131
130
|
|
|
132
131
|
def test_inline_sub
|
|
133
|
-
actual = compile_inline(
|
|
134
|
-
assert_equal
|
|
132
|
+
actual = compile_inline('abc@<sub>{def}')
|
|
133
|
+
assert_equal 'abc\\textsubscript{def}', actual
|
|
135
134
|
end
|
|
136
135
|
|
|
137
136
|
def test_inline_b
|
|
138
|
-
actual = compile_inline(
|
|
139
|
-
assert_equal
|
|
137
|
+
actual = compile_inline('abc@<b>{def}')
|
|
138
|
+
assert_equal 'abc\\textbf{def}', actual
|
|
140
139
|
end
|
|
141
140
|
|
|
142
141
|
def test_inline_b_and_escape
|
|
143
|
-
actual = compile_inline(
|
|
144
|
-
assert_equal
|
|
142
|
+
actual = compile_inline('test @<b>{inline<&;\\ test} test2')
|
|
143
|
+
assert_equal 'test \\textbf{inline\\textless{}\\&;\\reviewbackslash{} test} test2', actual
|
|
145
144
|
end
|
|
146
145
|
|
|
147
146
|
def test_inline_em
|
|
148
|
-
actual = compile_inline(
|
|
149
|
-
assert_equal
|
|
147
|
+
actual = compile_inline('abc@<em>{def}')
|
|
148
|
+
assert_equal 'abc\\reviewem{def}', actual
|
|
150
149
|
end
|
|
151
150
|
|
|
152
151
|
def test_inline_strong
|
|
153
|
-
actual = compile_inline(
|
|
154
|
-
assert_equal
|
|
152
|
+
actual = compile_inline('abc@<strong>{def}')
|
|
153
|
+
assert_equal 'abc\\reviewstrong{def}', actual
|
|
155
154
|
end
|
|
156
155
|
|
|
157
156
|
def test_inline_u
|
|
158
|
-
actual = compile_inline(
|
|
159
|
-
assert_equal
|
|
157
|
+
actual = compile_inline('abc@<u>{def}ghi')
|
|
158
|
+
assert_equal 'abc\\reviewunderline{def}ghi', actual
|
|
160
159
|
end
|
|
161
160
|
|
|
162
161
|
def test_inline_m
|
|
163
|
-
actual = compile_inline(
|
|
164
|
-
assert_equal
|
|
162
|
+
actual = compile_inline('abc@<m>{\\alpha^n = \\inf < 2}ghi')
|
|
163
|
+
assert_equal 'abc $\\alpha^n = \\inf < 2$ ghi', actual
|
|
165
164
|
end
|
|
166
165
|
|
|
167
166
|
def test_inline_m2
|
|
@@ -172,49 +171,54 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
|
172
171
|
end
|
|
173
172
|
|
|
174
173
|
def test_inline_tt
|
|
175
|
-
actual = compile_inline(
|
|
176
|
-
assert_equal
|
|
174
|
+
actual = compile_inline('test @<tt>{inline test} test2')
|
|
175
|
+
assert_equal 'test \\texttt{inline test} test2', actual
|
|
177
176
|
end
|
|
178
177
|
|
|
179
178
|
def test_inline_tt_endash
|
|
180
|
-
actual = compile_inline(
|
|
181
|
-
assert_equal
|
|
179
|
+
actual = compile_inline('test @<tt>{in-line --test ---foo ----bar -----buz} --test2')
|
|
180
|
+
assert_equal 'test \\texttt{in{-}line {-}{-}test {-}{-}{-}foo {-}{-}{-}{-}bar {-}{-}{-}{-}{-}buz} {-}{-}test2', actual
|
|
182
181
|
end
|
|
183
182
|
|
|
184
183
|
def test_inline_tti
|
|
185
|
-
actual = compile_inline(
|
|
186
|
-
assert_equal
|
|
184
|
+
actual = compile_inline('test @<tti>{inline test} test2')
|
|
185
|
+
assert_equal 'test \\texttt{\\textit{inline test}} test2', actual
|
|
187
186
|
end
|
|
188
187
|
|
|
189
188
|
def test_inline_ttb
|
|
190
|
-
actual = compile_inline(
|
|
191
|
-
assert_equal
|
|
189
|
+
actual = compile_inline('test @<ttb>{inline test} test2')
|
|
190
|
+
assert_equal 'test \\texttt{\\textbf{inline test}} test2', actual
|
|
192
191
|
end
|
|
193
192
|
|
|
194
193
|
def test_inline_hd_chap
|
|
195
194
|
def @chapter.headline_index
|
|
196
|
-
items = [Book::HeadlineIndex::Item.new(
|
|
195
|
+
items = [Book::HeadlineIndex::Item.new('chap1|test', [1, 1], 'te_st')]
|
|
197
196
|
Book::HeadlineIndex.new(items, self)
|
|
198
197
|
end
|
|
199
198
|
|
|
200
|
-
@config[
|
|
201
|
-
actual = compile_inline(
|
|
202
|
-
assert_equal
|
|
199
|
+
@config['secnolevel'] = 3
|
|
200
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
|
201
|
+
assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def test_inline_pageref
|
|
205
|
+
actual = compile_inline('test p.@<pageref>{p1}')
|
|
206
|
+
assert_equal 'test p.\pageref{p1}', actual
|
|
203
207
|
end
|
|
204
208
|
|
|
205
209
|
def test_inline_ruby_comma
|
|
206
|
-
actual = compile_inline(
|
|
207
|
-
assert_equal
|
|
210
|
+
actual = compile_inline('@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}')
|
|
211
|
+
assert_equal '\\ruby{foo, bar, buz}{フー・バー・バズ}', actual
|
|
208
212
|
end
|
|
209
213
|
|
|
210
214
|
def test_inline_uchar
|
|
211
|
-
actual = compile_inline(
|
|
212
|
-
assert_equal
|
|
215
|
+
actual = compile_inline('test @<uchar>{2460} test2')
|
|
216
|
+
assert_equal 'test \\UTF{2460} test2', actual
|
|
213
217
|
end
|
|
214
218
|
|
|
215
219
|
def test_inline_idx
|
|
216
|
-
actual = compile_inline(
|
|
217
|
-
assert_equal
|
|
220
|
+
actual = compile_inline('@<idx>{__TEST%$}, @<hidx>{__TEST%$}')
|
|
221
|
+
assert_equal '\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}\\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}, \\index{__TEST%$@\\textunderscore{}\\textunderscore{}TEST\\%\\textdollar{}}', actual
|
|
218
222
|
end
|
|
219
223
|
|
|
220
224
|
def test_inline_idx_yomi
|
|
@@ -222,304 +226,304 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
|
222
226
|
require 'MeCab'
|
|
223
227
|
require 'nkf'
|
|
224
228
|
rescue LoadError
|
|
225
|
-
$stderr.puts
|
|
229
|
+
$stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
|
|
226
230
|
return true
|
|
227
231
|
end
|
|
228
232
|
tmpdir = Dir.mktmpdir
|
|
229
233
|
File.write("#{tmpdir}/sample.dic", "強運\tはーどらっく\n")
|
|
230
|
-
@book.config[
|
|
231
|
-
@book.config[
|
|
234
|
+
@book.config['pdfmaker']['makeindex'] = true
|
|
235
|
+
@book.config['pdfmaker']['makeindex_dic'] = "#{tmpdir}/sample.dic"
|
|
232
236
|
@builder.setup_index
|
|
233
|
-
actual = compile_inline(
|
|
237
|
+
actual = compile_inline('@<hidx>{漢字}@<hidx>{強運}@<hidx>{項目@1<<>>項目@2}')
|
|
234
238
|
FileUtils.remove_entry_secure(tmpdir)
|
|
235
|
-
assert_equal %Q
|
|
239
|
+
assert_equal %Q(\\index{かんじ@漢字}\\index{はーどらっく@強運}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}), actual
|
|
236
240
|
end
|
|
237
241
|
|
|
238
242
|
def test_jis_x_0201_kana
|
|
239
243
|
# uplatex can handle half-width kana natively
|
|
240
|
-
actual = compile_inline(
|
|
241
|
-
assert_equal
|
|
242
|
-
# assert_equal %Q
|
|
244
|
+
actual = compile_inline('foo・カンジ、テスト')
|
|
245
|
+
assert_equal 'foo・カンジ、テスト', actual
|
|
246
|
+
# assert_equal %Q(foo\\aj半角{・}\\aj半角{カ}\\aj半角{ン}\\aj半角{シ}\\aj半角{゛}\\aj半角{、}テスト), actual
|
|
243
247
|
end
|
|
244
248
|
|
|
245
249
|
def test_dlist
|
|
246
250
|
actual = compile_block(": foo\n foo.\n bar.\n")
|
|
247
|
-
assert_equal %Q
|
|
251
|
+
assert_equal %Q(\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n), actual
|
|
248
252
|
end
|
|
249
253
|
|
|
250
254
|
def test_dlist_with_bracket
|
|
251
255
|
actual = compile_block(": foo[bar]\n foo.\n bar.\n")
|
|
252
|
-
assert_equal %Q
|
|
256
|
+
assert_equal %Q(\n\\begin{description}\n\\item[foo\\lbrack{}bar\\rbrack{}] \\mbox{} \\\\\nfoo.bar.\n\\end{description}\n), actual
|
|
253
257
|
end
|
|
254
258
|
|
|
255
259
|
def test_dlist_beforeulol
|
|
256
260
|
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
|
|
257
|
-
assert_equal %Q
|
|
261
|
+
assert_equal %Q(\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\npara\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{enumerate}\n\\item bar\n\\end{enumerate}\n\n\\begin{description}\n\\item[foo] \\mbox{} \\\\\nfoo.\n\\end{description}\n\n\\begin{itemize}\n\\item bar\n\\end{itemize}\n), actual
|
|
258
262
|
end
|
|
259
263
|
|
|
260
264
|
def test_cmd
|
|
261
265
|
actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
|
|
262
|
-
assert_equal %Q
|
|
266
|
+
assert_equal %Q(\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n), actual
|
|
263
267
|
end
|
|
264
268
|
|
|
265
269
|
def test_cmd_caption
|
|
266
270
|
actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
267
|
-
assert_equal %Q
|
|
271
|
+
assert_equal %Q(\n\\reviewcmdcaption{cap1}\n\\begin{reviewcmd}\nfoo\nbar\n\nbuz\n\\end{reviewcmd}\n), actual
|
|
268
272
|
end
|
|
269
273
|
|
|
270
274
|
def test_cmd_lst
|
|
271
|
-
@book.config[
|
|
272
|
-
@book.config[
|
|
275
|
+
@book.config['highlight'] = {}
|
|
276
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
273
277
|
actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
|
|
274
|
-
assert_equal %Q
|
|
278
|
+
assert_equal %Q(\\vspace{-1.5em}\\begin{reviewcmdlst}[title={\\relax},language={}]\nfoo\nbar\n\nbuz\n\\end{reviewcmdlst}\n), actual
|
|
275
279
|
end
|
|
276
280
|
|
|
277
281
|
def test_emlist
|
|
278
282
|
actual = compile_block("//emlist{\nfoo\nbar\n\nbuz\n//}\n")
|
|
279
|
-
assert_equal %Q
|
|
283
|
+
assert_equal %Q(\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n), actual
|
|
280
284
|
end
|
|
281
285
|
|
|
282
286
|
def test_emlist_lst
|
|
283
|
-
@book.config[
|
|
284
|
-
@book.config[
|
|
287
|
+
@book.config['highlight'] = {}
|
|
288
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
285
289
|
actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
|
286
|
-
assert_equal %Q
|
|
290
|
+
assert_equal %Q(\n\\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n), actual
|
|
287
291
|
end
|
|
288
292
|
|
|
289
293
|
def test_emlist_lst_without_lang
|
|
290
|
-
@book.config[
|
|
291
|
-
@book.config[
|
|
292
|
-
@book.config[
|
|
294
|
+
@book.config['highlight'] = {}
|
|
295
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
296
|
+
@book.config['highlight']['lang'] = 'sql'
|
|
293
297
|
actual = compile_block("//emlist[]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
|
294
|
-
assert_equal %Q
|
|
298
|
+
assert_equal %Q(\n\\vspace{-1.5em}\\begin{reviewemlistlst}[title={\\relax},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewemlistlst}\n), actual
|
|
295
299
|
end
|
|
296
300
|
|
|
297
301
|
def test_emlist_caption
|
|
298
302
|
actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
299
|
-
assert_equal %Q
|
|
303
|
+
assert_equal %Q(\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\nfoo\nbar\n\nbuz\n\\end{reviewemlist}\n), actual
|
|
300
304
|
end
|
|
301
305
|
|
|
302
306
|
def test_emlist_with_tab
|
|
303
307
|
actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
|
|
304
|
-
assert_equal %Q
|
|
308
|
+
assert_equal %Q(\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n), actual
|
|
305
309
|
end
|
|
306
310
|
|
|
307
311
|
def test_emlist_with_tab4
|
|
308
|
-
@config[
|
|
312
|
+
@config['tabwidth'] = 4
|
|
309
313
|
actual = compile_block("//emlist{\n\tfoo\n\t\tbar\n\n\tbuz\n//}\n")
|
|
310
|
-
assert_equal %Q
|
|
314
|
+
assert_equal %Q(\n\\begin{reviewemlist}\n foo\n bar\n\n buz\n\\end{reviewemlist}\n), actual
|
|
311
315
|
end
|
|
312
316
|
|
|
313
317
|
def test_emlistnum_caption
|
|
314
318
|
actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
315
|
-
assert_equal %Q
|
|
319
|
+
assert_equal %Q(\n\\reviewemlistcaption{cap1}\n\\begin{reviewemlist}\n 1: foo\n 2: bar\n 3: \n 4: buz\n\\end{reviewemlist}\n), actual
|
|
316
320
|
end
|
|
317
321
|
|
|
318
322
|
def test_list
|
|
319
323
|
actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
320
|
-
assert_equal %Q
|
|
324
|
+
assert_equal %Q(\\reviewlistcaption{リスト1.1: cap1}\n\\begin{reviewlist}\nfoo\nbar\n\nbuz\n\\end{reviewlist}\n), actual
|
|
321
325
|
end
|
|
322
326
|
|
|
323
327
|
def test_list_lst
|
|
324
|
-
@book.config[
|
|
325
|
-
@book.config[
|
|
328
|
+
@book.config['highlight'] = {}
|
|
329
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
326
330
|
actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
|
327
|
-
assert_equal %Q
|
|
331
|
+
assert_equal %Q(\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n), actual
|
|
328
332
|
end
|
|
329
333
|
|
|
330
334
|
def test_list_lst_with_lang
|
|
331
|
-
@book.config[
|
|
332
|
-
@book.config[
|
|
333
|
-
@book.config[
|
|
335
|
+
@book.config['highlight'] = {}
|
|
336
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
337
|
+
@book.config['highlight']['lang'] = 'sql'
|
|
334
338
|
actual = compile_block("//list[id1][cap1]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
|
335
|
-
assert_equal %Q
|
|
339
|
+
assert_equal %Q(\\begin{reviewlistlst}[caption={cap1},language={sql}]\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n\\end{reviewlistlst}\n), actual
|
|
336
340
|
end
|
|
337
341
|
|
|
338
342
|
def test_listnum
|
|
339
343
|
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
|
340
|
-
assert_equal %Q
|
|
344
|
+
assert_equal %Q(\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n), actual
|
|
341
345
|
end
|
|
342
346
|
|
|
343
347
|
def test_listnum_linenum
|
|
344
348
|
actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
|
345
|
-
assert_equal %Q
|
|
349
|
+
assert_equal %Q(\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n100: class Foo\n101: def foo\n102: bar\n103: \n104: buz\n105: end\n106: end\n\\end{reviewlist}\n), actual
|
|
346
350
|
end
|
|
347
351
|
|
|
348
352
|
def test_listnum_lst
|
|
349
|
-
@book.config[
|
|
350
|
-
@book.config[
|
|
353
|
+
@book.config['highlight'] = {}
|
|
354
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
351
355
|
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
|
352
|
-
assert_equal %Q
|
|
356
|
+
assert_equal %Q(\\begin{reviewlistnumlst}[caption={ruby},language={}]\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n\\end{reviewlistnumlst}\n), actual
|
|
353
357
|
end
|
|
354
358
|
|
|
355
359
|
def test_listnum_lst_linenum
|
|
356
|
-
@book.config[
|
|
357
|
-
@book.config[
|
|
360
|
+
@book.config['highlight'] = {}
|
|
361
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
358
362
|
actual = compile_block("//firstlinenum[100]\n//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
|
359
|
-
assert_equal %Q
|
|
363
|
+
assert_equal %Q(\\begin{reviewlistnumlst}[caption={ruby},language={},firstnumber=100]\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n\\end{reviewlistnumlst}\n), actual
|
|
360
364
|
end
|
|
361
365
|
|
|
362
366
|
def test_source
|
|
363
367
|
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
364
|
-
assert_equal %Q
|
|
368
|
+
assert_equal %Q(\\reviewsourcecaption{foo/bar/test.rb}\n\\begin{reviewsource}\nfoo\nbar\n\nbuz\n\\end{reviewsource}\n), actual
|
|
365
369
|
end
|
|
366
370
|
|
|
367
371
|
def test_source_lst
|
|
368
|
-
@book.config[
|
|
369
|
-
@book.config[
|
|
372
|
+
@book.config['highlight'] = {}
|
|
373
|
+
@book.config['highlight']['latex'] = 'listings'
|
|
370
374
|
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
|
371
|
-
assert_equal %Q
|
|
375
|
+
assert_equal %Q(\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]\nfoo\nbar\n\nbuz\n\\end{reviewsourcelst}\n), actual
|
|
372
376
|
end
|
|
373
377
|
|
|
374
378
|
def test_quote
|
|
375
379
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
|
376
|
-
assert_equal %Q
|
|
380
|
+
assert_equal %Q(\n\\begin{quote}\nfoobar\n\nbuz\n\\end{quote}\n), actual
|
|
377
381
|
end
|
|
378
382
|
|
|
379
383
|
def test_memo
|
|
380
384
|
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
|
381
|
-
assert_equal %Q
|
|
385
|
+
assert_equal %Q(\\begin{reviewminicolumn}\n\\reviewminicolumntitle{this is \\textbf{test}\\textless{}\\&\\textgreater{}\\textunderscore{}}\ntest1\n\ntest\\textit{2}\n\\end{reviewminicolumn}\n), actual
|
|
382
386
|
end
|
|
383
387
|
|
|
384
388
|
def test_flushright
|
|
385
389
|
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
|
386
|
-
assert_equal %Q
|
|
390
|
+
assert_equal %Q(\n\\begin{flushright}\nfoobar\n\nbuz\n\\end{flushright}\n), actual
|
|
387
391
|
end
|
|
388
392
|
|
|
389
393
|
def test_centering
|
|
390
394
|
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
|
391
|
-
assert_equal %Q
|
|
395
|
+
assert_equal %Q(\n\\begin{center}\nfoobar\n\nbuz\n\\end{center}\n), actual
|
|
392
396
|
end
|
|
393
397
|
|
|
394
398
|
def test_noindent
|
|
395
399
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
396
|
-
assert_equal %Q
|
|
400
|
+
assert_equal %Q(\\noindent\nfoo\nbar\n\nfoo2\nbar2\n), actual
|
|
397
401
|
end
|
|
398
402
|
|
|
399
403
|
def test_image
|
|
400
|
-
def @chapter.image(
|
|
401
|
-
item = Book::ImageIndex::Item.new(
|
|
402
|
-
item.instance_eval{@path=
|
|
404
|
+
def @chapter.image(_id)
|
|
405
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
406
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
403
407
|
item
|
|
404
408
|
end
|
|
405
409
|
|
|
406
410
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
|
407
|
-
assert_equal %Q
|
|
411
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
|
|
408
412
|
end
|
|
409
413
|
|
|
410
414
|
def test_image_with_metric
|
|
411
|
-
def @chapter.image(
|
|
412
|
-
item = Book::ImageIndex::Item.new(
|
|
413
|
-
item.instance_eval{@path=
|
|
415
|
+
def @chapter.image(_id)
|
|
416
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
417
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
414
418
|
item
|
|
415
419
|
end
|
|
416
420
|
|
|
417
421
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
|
418
|
-
assert_equal %Q
|
|
422
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
|
|
419
423
|
end
|
|
420
424
|
|
|
421
425
|
def test_image_with_metric_width
|
|
422
|
-
def @chapter.image(
|
|
423
|
-
item = Book::ImageIndex::Item.new(
|
|
424
|
-
item.instance_eval{@path=
|
|
426
|
+
def @chapter.image(_id)
|
|
427
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
428
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
425
429
|
item
|
|
426
430
|
end
|
|
427
431
|
|
|
428
|
-
@config[
|
|
432
|
+
@config['image_scale2width'] = true
|
|
429
433
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
|
430
|
-
assert_equal %Q
|
|
434
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
|
|
431
435
|
end
|
|
432
436
|
|
|
433
437
|
def test_image_with_metric2
|
|
434
|
-
def @chapter.image(
|
|
435
|
-
item = Book::ImageIndex::Item.new(
|
|
436
|
-
item.instance_eval{@path=
|
|
438
|
+
def @chapter.image(_id)
|
|
439
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
440
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
437
441
|
item
|
|
438
442
|
end
|
|
439
443
|
|
|
440
444
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
|
441
|
-
assert_equal %Q
|
|
445
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
|
|
442
446
|
end
|
|
443
447
|
|
|
444
448
|
def test_image_with_metric2_width
|
|
445
|
-
def @chapter.image(
|
|
446
|
-
item = Book::ImageIndex::Item.new(
|
|
447
|
-
item.instance_eval{@path=
|
|
449
|
+
def @chapter.image(_id)
|
|
450
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
451
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
448
452
|
item
|
|
449
453
|
end
|
|
450
454
|
|
|
451
|
-
@config[
|
|
455
|
+
@config['image_scale2width'] = true
|
|
452
456
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
|
453
|
-
assert_equal %Q
|
|
457
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=1.2\\maxwidth,ignore=params]{./images/chap1-sampleimg.png}\n\\caption{sample photo}\n\\label{image:chap1:sampleimg}\n\\end{reviewimage}\n), actual
|
|
454
458
|
end
|
|
455
459
|
|
|
456
460
|
def test_indepimage
|
|
457
|
-
def @chapter.image(
|
|
458
|
-
item = Book::ImageIndex::Item.new(
|
|
459
|
-
item.instance_eval{@path=
|
|
461
|
+
def @chapter.image(_id)
|
|
462
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
463
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
460
464
|
item
|
|
461
465
|
end
|
|
462
466
|
|
|
463
467
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
|
464
|
-
assert_equal %Q
|
|
468
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
|
|
465
469
|
end
|
|
466
470
|
|
|
467
471
|
def test_indepimage_without_caption
|
|
468
|
-
def @chapter.image(
|
|
469
|
-
item = Book::ImageIndex::Item.new(
|
|
470
|
-
item.instance_eval{@path=
|
|
472
|
+
def @chapter.image(_id)
|
|
473
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
474
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
471
475
|
item
|
|
472
476
|
end
|
|
473
477
|
|
|
474
478
|
# FIXME: indepimage's caption should not be with a counter.
|
|
475
479
|
actual = compile_block("//indepimage[sampleimg]\n")
|
|
476
|
-
assert_equal %Q
|
|
480
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n), actual
|
|
477
481
|
end
|
|
478
482
|
|
|
479
483
|
def test_indepimage_with_metric
|
|
480
|
-
def @chapter.image(
|
|
481
|
-
item = Book::ImageIndex::Item.new(
|
|
482
|
-
item.instance_eval{@path=
|
|
484
|
+
def @chapter.image(_id)
|
|
485
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
486
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
483
487
|
item
|
|
484
488
|
end
|
|
485
489
|
|
|
486
490
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
|
487
|
-
assert_equal %Q
|
|
491
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
|
|
488
492
|
end
|
|
489
493
|
|
|
490
494
|
def test_indepimage_with_metric_width
|
|
491
|
-
def @chapter.image(
|
|
492
|
-
item = Book::ImageIndex::Item.new(
|
|
493
|
-
item.instance_eval{@path=
|
|
495
|
+
def @chapter.image(_id)
|
|
496
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
497
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
494
498
|
item
|
|
495
499
|
end
|
|
496
500
|
|
|
497
|
-
@config[
|
|
501
|
+
@config['image_scale2width'] = true
|
|
498
502
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
|
499
|
-
assert_equal %Q
|
|
503
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[width=1.2\\maxwidth]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
|
|
500
504
|
end
|
|
501
505
|
|
|
502
506
|
def test_indepimage_with_metric2
|
|
503
|
-
def @chapter.image(
|
|
504
|
-
item = Book::ImageIndex::Item.new(
|
|
505
|
-
item.instance_eval{@path=
|
|
507
|
+
def @chapter.image(_id)
|
|
508
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
509
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
506
510
|
item
|
|
507
511
|
end
|
|
508
512
|
|
|
509
|
-
actual = compile_block(
|
|
510
|
-
assert_equal %Q
|
|
513
|
+
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
|
|
514
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2,ignore=params]{./images/chap1-sampleimg.png}\n\\reviewindepimagecaption{図: sample photo}\n\\end{reviewimage}\n), actual
|
|
511
515
|
end
|
|
512
516
|
|
|
513
517
|
def test_indepimage_without_caption_but_with_metric
|
|
514
|
-
def @chapter.image(
|
|
515
|
-
item = Book::ImageIndex::Item.new(
|
|
516
|
-
item.instance_eval{@path=
|
|
518
|
+
def @chapter.image(_id)
|
|
519
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
520
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
517
521
|
item
|
|
518
522
|
end
|
|
519
523
|
|
|
520
524
|
# FIXME: indepimage's caption should not be with a counter.
|
|
521
525
|
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
|
522
|
-
assert_equal %Q
|
|
526
|
+
assert_equal %Q(\\begin{reviewimage}\n\\includegraphics[scale=1.2]{./images/chap1-sampleimg.png}\n\\end{reviewimage}\n), actual
|
|
523
527
|
end
|
|
524
528
|
|
|
525
529
|
def test_table
|
|
@@ -552,48 +556,50 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
|
552
556
|
end
|
|
553
557
|
|
|
554
558
|
def test_imgtable
|
|
555
|
-
def @chapter.image(
|
|
556
|
-
item = Book::ImageIndex::Item.new(
|
|
557
|
-
item.instance_eval{@path=
|
|
559
|
+
def @chapter.image(_id)
|
|
560
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample img')
|
|
561
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
558
562
|
item
|
|
559
563
|
end
|
|
560
564
|
|
|
561
565
|
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
|
562
566
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
567
|
+
expected = <<-EOS
|
|
568
|
+
\\begin{table}[h]
|
|
569
|
+
\\reviewimgtablecaption{test for imgtable}
|
|
570
|
+
\\label{table:chap1:sampleimg}
|
|
571
|
+
\\begin{reviewimage}
|
|
572
|
+
\\includegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
|
573
|
+
\\end{reviewimage}
|
|
574
|
+
\\end{table}
|
|
575
|
+
EOS
|
|
576
|
+
assert_equal expected, actual
|
|
571
577
|
end
|
|
572
578
|
|
|
573
579
|
def test_bib
|
|
574
|
-
def @chapter.bibpaper(
|
|
575
|
-
Book::BibpaperIndex::Item.new(
|
|
580
|
+
def @chapter.bibpaper(_id)
|
|
581
|
+
Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
|
|
576
582
|
end
|
|
577
583
|
|
|
578
|
-
assert_equal
|
|
584
|
+
assert_equal '\\reviewbibref{[1]}{bib:samplebib}', compile_inline('@<bib>{samplebib}')
|
|
579
585
|
end
|
|
580
586
|
|
|
581
587
|
def test_bibpaper
|
|
582
|
-
def @chapter.bibpaper(
|
|
583
|
-
Book::BibpaperIndex::Item.new(
|
|
588
|
+
def @chapter.bibpaper(_id)
|
|
589
|
+
Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
|
|
584
590
|
end
|
|
585
591
|
|
|
586
592
|
actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
|
|
587
|
-
assert_equal %Q
|
|
593
|
+
assert_equal %Q([1] sample bib \\textbf{bold}\n\\label{bib:samplebib}\n\nab\n\n), actual
|
|
588
594
|
end
|
|
589
595
|
|
|
590
596
|
def test_bibpaper_without_body
|
|
591
|
-
def @chapter.bibpaper(
|
|
592
|
-
Book::BibpaperIndex::Item.new(
|
|
597
|
+
def @chapter.bibpaper(_id)
|
|
598
|
+
Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
|
|
593
599
|
end
|
|
594
600
|
|
|
595
601
|
actual = compile_block("//bibpaper[samplebib][sample bib]\n")
|
|
596
|
-
assert_equal %Q
|
|
602
|
+
assert_equal %Q([1] sample bib\n\\label{bib:samplebib}\n\n), actual
|
|
597
603
|
end
|
|
598
604
|
|
|
599
605
|
def column_helper(review)
|
|
@@ -601,7 +607,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
|
601
607
|
end
|
|
602
608
|
|
|
603
609
|
def test_column_1
|
|
604
|
-
review
|
|
610
|
+
review = <<-EOS
|
|
605
611
|
===[column] prev column
|
|
606
612
|
|
|
607
613
|
inside prev column
|
|
@@ -612,7 +618,7 @@ inside column
|
|
|
612
618
|
|
|
613
619
|
===[/column]
|
|
614
620
|
EOS
|
|
615
|
-
expected
|
|
621
|
+
expected = <<-EOS
|
|
616
622
|
|
|
617
623
|
\\begin{reviewcolumn}
|
|
618
624
|
\\hypertarget{column:chap1:1}{}
|
|
@@ -632,19 +638,19 @@ inside column
|
|
|
632
638
|
|
|
633
639
|
\\end{reviewcolumn}
|
|
634
640
|
EOS
|
|
635
|
-
@config[
|
|
641
|
+
@config['toclevel'] = 3
|
|
636
642
|
assert_equal expected, column_helper(review)
|
|
637
643
|
end
|
|
638
644
|
|
|
639
645
|
def test_column_2
|
|
640
|
-
review
|
|
646
|
+
review = <<-EOS
|
|
641
647
|
===[column] test
|
|
642
648
|
|
|
643
649
|
inside column
|
|
644
650
|
|
|
645
651
|
=== next level
|
|
646
652
|
EOS
|
|
647
|
-
expected
|
|
653
|
+
expected = <<-EOS
|
|
648
654
|
|
|
649
655
|
\\begin{reviewcolumn}
|
|
650
656
|
\\hypertarget{column:chap1:1}{}
|
|
@@ -658,29 +664,29 @@ inside column
|
|
|
658
664
|
\\label{sec:1-0-1}
|
|
659
665
|
EOS
|
|
660
666
|
|
|
661
|
-
@config[
|
|
667
|
+
@config['toclevel'] = 1
|
|
662
668
|
assert_equal expected, column_helper(review)
|
|
663
669
|
end
|
|
664
670
|
|
|
665
671
|
def test_column_3
|
|
666
|
-
review
|
|
672
|
+
review = <<-EOS
|
|
667
673
|
===[column] test
|
|
668
674
|
|
|
669
675
|
inside column
|
|
670
676
|
|
|
671
677
|
===[/column_dummy]
|
|
672
678
|
EOS
|
|
673
|
-
assert_raise(ReVIEW::
|
|
679
|
+
assert_raise(ReVIEW::ApplicationError) do
|
|
674
680
|
column_helper(review)
|
|
675
681
|
end
|
|
676
682
|
end
|
|
677
683
|
|
|
678
684
|
def test_ul
|
|
679
|
-
src
|
|
685
|
+
src = <<-EOS
|
|
680
686
|
* AAA
|
|
681
687
|
* BBB
|
|
682
688
|
EOS
|
|
683
|
-
expected
|
|
689
|
+
expected = <<-EOS
|
|
684
690
|
|
|
685
691
|
\\begin{itemize}
|
|
686
692
|
\\item AAA
|
|
@@ -692,11 +698,11 @@ EOS
|
|
|
692
698
|
end
|
|
693
699
|
|
|
694
700
|
def test_ul_with_bracket
|
|
695
|
-
src
|
|
701
|
+
src = <<-EOS
|
|
696
702
|
* AAA
|
|
697
703
|
* []BBB
|
|
698
704
|
EOS
|
|
699
|
-
expected
|
|
705
|
+
expected = <<-EOS
|
|
700
706
|
|
|
701
707
|
\\begin{itemize}
|
|
702
708
|
\\item AAA
|
|
@@ -708,13 +714,13 @@ EOS
|
|
|
708
714
|
end
|
|
709
715
|
|
|
710
716
|
def test_cont
|
|
711
|
-
src
|
|
717
|
+
src = <<-EOS
|
|
712
718
|
* AAA
|
|
713
719
|
-AA
|
|
714
720
|
* BBB
|
|
715
721
|
-BB
|
|
716
722
|
EOS
|
|
717
|
-
expected
|
|
723
|
+
expected = <<-EOS
|
|
718
724
|
|
|
719
725
|
\\begin{itemize}
|
|
720
726
|
\\item AAA{-}AA
|
|
@@ -726,12 +732,12 @@ EOS
|
|
|
726
732
|
end
|
|
727
733
|
|
|
728
734
|
def test_ul_nest1
|
|
729
|
-
src
|
|
735
|
+
src = <<-EOS
|
|
730
736
|
* AAA
|
|
731
737
|
** AA
|
|
732
738
|
EOS
|
|
733
739
|
|
|
734
|
-
expected
|
|
740
|
+
expected = <<-EOS
|
|
735
741
|
|
|
736
742
|
\\begin{itemize}
|
|
737
743
|
\\item AAA
|
|
@@ -747,14 +753,14 @@ EOS
|
|
|
747
753
|
end
|
|
748
754
|
|
|
749
755
|
def test_ul_nest3
|
|
750
|
-
src
|
|
756
|
+
src = <<-EOS
|
|
751
757
|
* AAA
|
|
752
758
|
** AA
|
|
753
759
|
* BBB
|
|
754
760
|
** BB
|
|
755
761
|
EOS
|
|
756
762
|
|
|
757
|
-
expected
|
|
763
|
+
expected = <<-EOS
|
|
758
764
|
|
|
759
765
|
\\begin{itemize}
|
|
760
766
|
\\item AAA
|
|
@@ -776,12 +782,12 @@ EOS
|
|
|
776
782
|
end
|
|
777
783
|
|
|
778
784
|
def test_ol
|
|
779
|
-
src
|
|
785
|
+
src = <<-EOS
|
|
780
786
|
3. AAA
|
|
781
787
|
3. BBB
|
|
782
788
|
EOS
|
|
783
789
|
|
|
784
|
-
expected
|
|
790
|
+
expected = <<-EOS
|
|
785
791
|
|
|
786
792
|
\\begin{enumerate}
|
|
787
793
|
\\item AAA
|
|
@@ -793,11 +799,11 @@ EOS
|
|
|
793
799
|
end
|
|
794
800
|
|
|
795
801
|
def test_ol_with_bracket
|
|
796
|
-
src
|
|
802
|
+
src = <<-EOS
|
|
797
803
|
1. AAA
|
|
798
804
|
2. []BBB
|
|
799
805
|
EOS
|
|
800
|
-
expected
|
|
806
|
+
expected = <<-EOS
|
|
801
807
|
|
|
802
808
|
\\begin{enumerate}
|
|
803
809
|
\\item AAA
|
|
@@ -843,38 +849,38 @@ EOS
|
|
|
843
849
|
end
|
|
844
850
|
|
|
845
851
|
def test_inline_raw0
|
|
846
|
-
assert_equal
|
|
852
|
+
assert_equal 'normal', compile_inline('@<raw>{normal}')
|
|
847
853
|
end
|
|
848
854
|
|
|
849
855
|
def test_inline_raw1
|
|
850
|
-
assert_equal
|
|
856
|
+
assert_equal 'body', compile_inline('@<raw>{|latex|body}')
|
|
851
857
|
end
|
|
852
858
|
|
|
853
859
|
def test_inline_raw2
|
|
854
|
-
assert_equal
|
|
860
|
+
assert_equal 'body', compile_inline('@<raw>{|html, latex|body}')
|
|
855
861
|
end
|
|
856
862
|
|
|
857
863
|
def test_inline_raw3
|
|
858
|
-
assert_equal
|
|
864
|
+
assert_equal '', compile_inline('@<raw>{|idgxml, html|body}')
|
|
859
865
|
end
|
|
860
866
|
|
|
861
867
|
def test_inline_raw4
|
|
862
|
-
assert_equal
|
|
868
|
+
assert_equal '|latex body', compile_inline('@<raw>{|latex body}')
|
|
863
869
|
end
|
|
864
870
|
|
|
865
871
|
def test_inline_raw5
|
|
866
|
-
assert_equal "nor\nmal", compile_inline(
|
|
872
|
+
assert_equal "nor\nmal", compile_inline('@<raw>{|latex|nor\\nmal}')
|
|
867
873
|
end
|
|
868
874
|
|
|
869
875
|
def test_inline_endash
|
|
870
|
-
actual = compile_inline(
|
|
871
|
-
assert_equal
|
|
876
|
+
actual = compile_inline('- -- --- ----')
|
|
877
|
+
assert_equal '{-} {-}{-} {-}{-}{-} {-}{-}{-}{-}', actual
|
|
872
878
|
end
|
|
873
879
|
|
|
874
880
|
def test_inline_imgref
|
|
875
|
-
def @chapter.image(
|
|
876
|
-
item = Book::ImageIndex::Item.new(
|
|
877
|
-
item.instance_eval{@path=
|
|
881
|
+
def @chapter.image(_id)
|
|
882
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
|
|
883
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
878
884
|
item
|
|
879
885
|
end
|
|
880
886
|
|
|
@@ -884,9 +890,9 @@ EOS
|
|
|
884
890
|
end
|
|
885
891
|
|
|
886
892
|
def test_inline_imgref2
|
|
887
|
-
def @chapter.image(
|
|
888
|
-
item = Book::NumberlessImageIndex::Item.new(
|
|
889
|
-
item.instance_eval{@path=
|
|
893
|
+
def @chapter.image(_id)
|
|
894
|
+
item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
|
|
895
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
890
896
|
item
|
|
891
897
|
end
|
|
892
898
|
|
|
@@ -896,69 +902,74 @@ EOS
|
|
|
896
902
|
end
|
|
897
903
|
|
|
898
904
|
def test_block_raw0
|
|
899
|
-
actual = compile_block(
|
|
900
|
-
expected = %Q(
|
|
905
|
+
actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
|
|
906
|
+
expected = %Q(<>!"\n& )
|
|
901
907
|
assert_equal expected, actual
|
|
902
908
|
end
|
|
903
909
|
|
|
904
910
|
def test_block_raw1
|
|
905
|
-
actual = compile_block(
|
|
906
|
-
expected = %Q(
|
|
911
|
+
actual = compile_block(%Q(//raw[|latex|<>!"\\n& ]\n))
|
|
912
|
+
expected = %Q(<>!"\n& )
|
|
907
913
|
assert_equal expected, actual
|
|
908
914
|
end
|
|
909
915
|
|
|
910
916
|
def test_block_raw2
|
|
911
|
-
actual = compile_block(
|
|
912
|
-
expected = %Q(
|
|
917
|
+
actual = compile_block(%Q(//raw[|html, latex|<>!"\\n& ]\n))
|
|
918
|
+
expected = %Q(<>!"\n& )
|
|
913
919
|
assert_equal expected, actual
|
|
914
920
|
end
|
|
915
921
|
|
|
916
922
|
def test_block_raw3
|
|
917
|
-
actual = compile_block(
|
|
923
|
+
actual = compile_block(%Q(//raw[|html, idgxml|<>!"\\n& ]\n))
|
|
918
924
|
expected = ''
|
|
919
925
|
assert_equal expected, actual
|
|
920
926
|
end
|
|
921
927
|
|
|
922
928
|
def test_block_raw4
|
|
923
|
-
actual = compile_block(
|
|
924
|
-
expected = %Q(|latex
|
|
929
|
+
actual = compile_block(%Q(//raw[|latex <>!"\\n& ]\n))
|
|
930
|
+
expected = %Q(|latex <>!"\n& )
|
|
925
931
|
assert_equal expected, actual
|
|
926
932
|
end
|
|
927
933
|
|
|
928
934
|
def test_comment
|
|
929
|
-
actual = compile_block(
|
|
930
|
-
assert_equal
|
|
935
|
+
actual = compile_block('//comment[コメント]')
|
|
936
|
+
assert_equal '', actual
|
|
931
937
|
end
|
|
932
938
|
|
|
933
939
|
def test_comment_for_draft
|
|
934
|
-
@config[
|
|
935
|
-
actual = compile_block(
|
|
936
|
-
assert_equal %Q
|
|
940
|
+
@config['draft'] = true
|
|
941
|
+
actual = compile_block('//comment[コメント]')
|
|
942
|
+
assert_equal %Q(\\pdfcomment{コメント}\n), actual
|
|
937
943
|
end
|
|
938
944
|
|
|
939
945
|
def test_inline_comment
|
|
940
|
-
actual = compile_inline(
|
|
941
|
-
assert_equal
|
|
946
|
+
actual = compile_inline('test @<comment>{コメント} test2')
|
|
947
|
+
assert_equal 'test test2', actual
|
|
942
948
|
end
|
|
943
949
|
|
|
944
950
|
def test_inline_comment_for_draft
|
|
945
|
-
@config[
|
|
946
|
-
actual = compile_inline(
|
|
947
|
-
assert_equal
|
|
951
|
+
@config['draft'] = true
|
|
952
|
+
actual = compile_inline('test @<comment>{コメント} test2')
|
|
953
|
+
assert_equal 'test \\pdfcomment{コメント} test2', actual
|
|
954
|
+
end
|
|
955
|
+
|
|
956
|
+
def test_inline_fence
|
|
957
|
+
actual = compile_inline('test @<code>|@<code>{$サンプル$}|')
|
|
958
|
+
assert_equal 'test \\texttt{@\\textless{}code\\textgreater{}\\{\\textdollar{}サンプル\\textdollar{}\\}}', actual
|
|
948
959
|
end
|
|
949
960
|
|
|
950
961
|
def test_appendix_list
|
|
951
962
|
@chapter.instance_eval do
|
|
952
|
-
def
|
|
963
|
+
def on_appendix?
|
|
953
964
|
true
|
|
954
965
|
end
|
|
955
966
|
end
|
|
956
|
-
src
|
|
967
|
+
src = <<-EOS
|
|
957
968
|
@<list>{foo}
|
|
958
969
|
//list[foo][FOO]{
|
|
959
970
|
//}
|
|
960
971
|
EOS
|
|
961
|
-
expected
|
|
972
|
+
expected = <<-EOS
|
|
962
973
|
|
|
963
974
|
\\reviewlistref{A.1}
|
|
964
975
|
|
|
@@ -972,17 +983,17 @@ EOS
|
|
|
972
983
|
|
|
973
984
|
def test_appendix_table
|
|
974
985
|
@chapter.instance_eval do
|
|
975
|
-
def
|
|
986
|
+
def on_appendix?
|
|
976
987
|
true
|
|
977
988
|
end
|
|
978
989
|
end
|
|
979
|
-
src
|
|
990
|
+
src = <<-EOS
|
|
980
991
|
@<table>{foo}
|
|
981
992
|
//table[foo][FOO]{
|
|
982
993
|
A B
|
|
983
994
|
//}
|
|
984
995
|
EOS
|
|
985
|
-
expected
|
|
996
|
+
expected = <<-EOS
|
|
986
997
|
|
|
987
998
|
\\reviewtableref{A.1}{table:chap1:foo}
|
|
988
999
|
|
|
@@ -1001,23 +1012,23 @@ EOS
|
|
|
1001
1012
|
|
|
1002
1013
|
def test_appendix_image
|
|
1003
1014
|
@chapter.instance_eval do
|
|
1004
|
-
def
|
|
1015
|
+
def on_appendix?
|
|
1005
1016
|
true
|
|
1006
1017
|
end
|
|
1007
1018
|
end
|
|
1008
1019
|
|
|
1009
|
-
def @chapter.image(
|
|
1010
|
-
item = Book::NumberlessImageIndex::Item.new(
|
|
1011
|
-
item.instance_eval{@path=
|
|
1020
|
+
def @chapter.image(_id)
|
|
1021
|
+
item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
|
|
1022
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
1012
1023
|
item
|
|
1013
1024
|
end
|
|
1014
1025
|
|
|
1015
|
-
src
|
|
1026
|
+
src = <<-EOS
|
|
1016
1027
|
@<img>{sampleimg}
|
|
1017
1028
|
//image[sampleimg][FOO]{
|
|
1018
1029
|
//}
|
|
1019
1030
|
EOS
|
|
1020
|
-
expected
|
|
1031
|
+
expected = <<-EOS
|
|
1021
1032
|
|
|
1022
1033
|
\\reviewimageref{A.1}{image:chap1:sampleimg}
|
|
1023
1034
|
|
|
@@ -1030,5 +1041,4 @@ EOS
|
|
|
1030
1041
|
actual = compile_block(src)
|
|
1031
1042
|
assert_equal expected, actual
|
|
1032
1043
|
end
|
|
1033
|
-
|
|
1034
1044
|
end
|