review 5.0.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tex.yml +35 -0
- data/.github/workflows/ruby-win.yml +8 -4
- data/.github/workflows/ruby.yml +6 -2
- data/.rubocop.yml +24 -9
- data/NEWS.ja.md +215 -0
- data/NEWS.md +215 -1
- data/README.md +7 -6
- data/Rakefile +7 -2
- data/bin/review +2 -4
- data/bin/review-catalog-converter +3 -3
- data/bin/review-check +6 -8
- data/bin/review-checkdep +1 -4
- data/bin/review-compile +10 -20
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +11 -5
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +30 -38
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +3 -3
- data/bin/review-vol +1 -4
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +23 -5
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +49 -12
- data/doc/format.md +52 -12
- data/doc/quickstart.ja.md +11 -1
- data/doc/quickstart.md +11 -2
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review/book/base.rb +4 -0
- data/lib/review/book/book_unit.rb +15 -2
- data/lib/review/book/chapter.rb +3 -0
- data/lib/review/book/index.rb +5 -1
- data/lib/review/book/volume.rb +1 -0
- data/lib/review/builder.rb +90 -54
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +2 -0
- data/lib/review/compiler.rb +88 -52
- data/lib/review/configure.rb +64 -7
- data/lib/review/epubmaker/content.rb +113 -0
- data/lib/review/epubmaker/epubcommon.rb +372 -0
- data/lib/review/epubmaker/epubv2.rb +178 -0
- data/lib/review/epubmaker/epubv3.rb +231 -0
- data/lib/review/epubmaker/producer.rb +167 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/epubmaker.rb +114 -129
- data/lib/review/exception.rb +13 -0
- data/lib/review/htmlbuilder.rb +109 -67
- data/lib/review/htmlutils.rb +1 -1
- data/lib/review/i18n.rb +1 -0
- data/lib/review/i18n.yml +6 -0
- data/lib/review/idgxmlbuilder.rb +72 -48
- data/lib/review/idgxmlmaker.rb +15 -14
- data/lib/review/img_math.rb +239 -0
- data/lib/review/index_builder.rb +90 -32
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +79 -58
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +89 -2
- data/lib/review/makerhelper.rb +7 -206
- data/lib/review/markdownbuilder.rb +44 -4
- data/lib/review/pdfmaker.rb +70 -51
- data/lib/review/plaintextbuilder.rb +20 -11
- data/lib/review/preprocessor/directive.rb +35 -0
- data/lib/review/preprocessor/line.rb +34 -0
- data/lib/review/preprocessor/repository.rb +177 -0
- data/lib/review/preprocessor.rb +105 -301
- data/lib/review/rstbuilder.rb +13 -4
- data/lib/review/sec_counter.rb +1 -0
- data/lib/review/template.rb +11 -1
- data/lib/review/textmaker.rb +23 -20
- data/lib/review/textutils.rb +10 -17
- data/lib/review/tocprinter.rb +93 -71
- data/lib/review/topbuilder.rb +44 -19
- data/lib/review/update.rb +5 -6
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +11 -12
- data/lib/review/webmaker.rb +31 -27
- data/lib/review/webtocprinter.rb +10 -9
- data/lib/review/yamlloader.rb +2 -1
- data/lib/review.rb +1 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config.yml +1 -1
- data/samples/sample-book/src/lib/tasks/review.rake +19 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/ch01.re +1 -1
- data/samples/syntax-book/ch02.re +30 -6
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/html/_colophon.html.erb +23 -0
- data/templates/html/_colophon_history.html.erb +9 -0
- data/templates/html/_cover.html.erb +10 -0
- data/templates/html/_part_body.html.erb +6 -0
- data/templates/html/_titlepage.html.erb +20 -0
- data/templates/html/layout-html5.html.erb +6 -0
- data/templates/html/layout-xhtml1.html.erb +6 -0
- data/templates/latex/config.erb +11 -0
- data/templates/latex/review-jlreq/review-base.sty +7 -9
- data/templates/latex/review-jlreq/review-jlreq.cls +48 -6
- data/templates/latex/review-jlreq/review-style.sty +6 -1
- data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
- data/templates/latex/review-jsbook/review-base.sty +13 -9
- data/templates/latex/review-jsbook/review-jsbook.cls +41 -6
- data/templates/latex/review-jsbook/review-style.sty +6 -1
- data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
- data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
- data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
- data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
- data/templates/web/html/layout-html5.html.erb +6 -5
- data/templates/web/html/layout-xhtml1.html.erb +6 -0
- data/test/assets/header_listener.html +35 -0
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/syntax_book_index_detail.txt +60 -0
- data/test/assets/test_template.tex +7 -1
- data/test/assets/test_template_backmatter.tex +7 -1
- data/test/run_test.rb +1 -1
- data/test/test_book_chapter.rb +27 -4
- data/test/test_builder.rb +10 -8
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epub3maker.rb +168 -124
- data/test/test_epubmaker.rb +248 -131
- data/test/test_epubmaker_cmd.rb +15 -4
- data/test/test_helper.rb +5 -4
- data/test/test_htmlbuilder.rb +170 -31
- data/test/test_idgxmlbuilder.rb +44 -23
- data/test/test_idgxmlmaker_cmd.rb +7 -3
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +30 -4
- data/test/test_indexbuilder.rb +5 -5
- data/test/test_latexbuilder.rb +151 -26
- data/test/test_latexbuilder_v2.rb +18 -10
- data/test/test_lineinput.rb +20 -93
- data/test/test_markdownbuilder.rb +42 -0
- data/test/test_pdfmaker.rb +90 -0
- data/test/test_pdfmaker_cmd.rb +2 -2
- data/test/test_plaintextbuilder.rb +56 -40
- data/test/test_preprocessor.rb +188 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +13 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +5 -1
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +50 -19
- data/test/test_update.rb +34 -34
- data/test/test_zip_exporter.rb +5 -6
- metadata +95 -17
- data/lib/epubmaker/content.rb +0 -111
- data/lib/epubmaker/epubcommon.rb +0 -449
- data/lib/epubmaker/epubv2.rb +0 -142
- data/lib/epubmaker/epubv3.rb +0 -235
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/epubmaker.rb +0 -23
- data/lib/lineinput.rb +0 -155
data/test/test_lineinput.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'lineinput'
|
2
|
+
require 'review/lineinput'
|
3
3
|
require 'tempfile'
|
4
4
|
require 'stringio'
|
5
5
|
|
@@ -9,7 +9,7 @@ class LineInputTest < Test::Unit::TestCase
|
|
9
9
|
li = LineInput.new(io)
|
10
10
|
assert_equal 0, li.lineno
|
11
11
|
assert !li.eof?
|
12
|
-
assert_equal "#<LineInput file=#{io.inspect} line=0>", li.inspect
|
12
|
+
assert_equal "#<ReVIEW::LineInput file=#{io.inspect} line=0>", li.inspect
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_gets
|
@@ -40,21 +40,6 @@ class LineInputTest < Test::Unit::TestCase
|
|
40
40
|
assert li.eof?
|
41
41
|
end
|
42
42
|
|
43
|
-
def test_ungets
|
44
|
-
io = StringIO.new('abc')
|
45
|
-
li = LineInput.new(io)
|
46
|
-
|
47
|
-
line = li.gets
|
48
|
-
assert_equal line, li.ungets(line)
|
49
|
-
assert_equal 0, li.lineno
|
50
|
-
assert_equal line, li.gets
|
51
|
-
|
52
|
-
li.ungets('xyz')
|
53
|
-
assert_equal 0, li.lineno
|
54
|
-
li.ungets('xyz')
|
55
|
-
assert_equal(-1, li.lineno) # XXX: OK?
|
56
|
-
end
|
57
|
-
|
58
43
|
def test_peek
|
59
44
|
li = LineInput.new(StringIO.new)
|
60
45
|
assert_equal nil, li.peek
|
@@ -71,33 +56,6 @@ class LineInputTest < Test::Unit::TestCase
|
|
71
56
|
assert li.next?
|
72
57
|
end
|
73
58
|
|
74
|
-
def test_gets_if
|
75
|
-
io = StringIO.new
|
76
|
-
li = LineInput.new(io)
|
77
|
-
assert_equal nil, li.gets_if(//)
|
78
|
-
|
79
|
-
io = StringIO.new("abc\ndef\nghi")
|
80
|
-
li = LineInput.new(io)
|
81
|
-
|
82
|
-
assert_equal "abc\n", li.gets_if(//)
|
83
|
-
assert_equal nil, li.gets_if(/^X/)
|
84
|
-
assert_equal nil, li.gets_if(/^g/)
|
85
|
-
assert_equal "def\n", li.gets_if(/^d/)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_gets_unless
|
89
|
-
io = StringIO.new
|
90
|
-
li = LineInput.new(io)
|
91
|
-
assert_equal nil, li.gets_unless(//)
|
92
|
-
|
93
|
-
io = StringIO.new("abc\ndef\nghi")
|
94
|
-
li = LineInput.new(io)
|
95
|
-
|
96
|
-
assert_equal nil, li.gets_unless(//)
|
97
|
-
assert_equal "abc\n", li.gets_unless(/^X/)
|
98
|
-
assert_equal nil, li.gets_unless(/^d/)
|
99
|
-
end
|
100
|
-
|
101
59
|
def test_each
|
102
60
|
content = "abc\ndef\nghi"
|
103
61
|
io = StringIO.new(content)
|
@@ -112,17 +70,9 @@ class LineInputTest < Test::Unit::TestCase
|
|
112
70
|
io = StringIO.new("abc\ndef\nghi")
|
113
71
|
li = LineInput.new(io)
|
114
72
|
|
115
|
-
li.while_match(/^[ad]/)
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_getlines_while
|
121
|
-
io = StringIO.new("abc\ndef\nghi")
|
122
|
-
li = LineInput.new(io)
|
123
|
-
|
124
|
-
buf = li.getlines_while(/^[ad]/)
|
125
|
-
assert_equal ["abc\n", "def\n"], buf
|
73
|
+
li.while_match(/^[ad]/) do
|
74
|
+
# skip
|
75
|
+
end
|
126
76
|
assert_equal 2, li.lineno
|
127
77
|
assert_equal 'ghi', li.gets
|
128
78
|
end
|
@@ -131,47 +81,24 @@ class LineInputTest < Test::Unit::TestCase
|
|
131
81
|
io = StringIO.new("abc\ndef\nghi")
|
132
82
|
li = LineInput.new(io)
|
133
83
|
|
134
|
-
li.until_match(/^[^a]/)
|
135
|
-
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_getlines_until
|
140
|
-
io = StringIO.new("abc\ndef\nghi")
|
141
|
-
li = LineInput.new(io)
|
142
|
-
|
143
|
-
buf = li.getlines_until(/^[^a]/)
|
144
|
-
assert_equal ["abc\n"], buf
|
84
|
+
li.until_match(/^[^a]/) do
|
85
|
+
# skip
|
86
|
+
end
|
145
87
|
assert_equal 1, li.lineno
|
146
88
|
assert_equal "def\n", li.gets
|
147
89
|
end
|
148
90
|
|
149
|
-
def
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
assert_equal 5, li.lineno
|
162
|
-
|
163
|
-
data = ''
|
164
|
-
li.until_terminator(%r<\A//\}>) { |l| data << l }
|
165
|
-
assert_equal "jkl\nmno", data
|
166
|
-
assert_equal 8, li.lineno
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_until_terminator2
|
170
|
-
io = StringIO.new("abc\ndef\n//}\nghi\n//}")
|
171
|
-
li = LineInput.new(io)
|
172
|
-
|
173
|
-
data = li.getblock(%r<\A//\}>)
|
174
|
-
assert_equal ["abc\n", "def\n"], data
|
175
|
-
assert_equal 3, li.lineno
|
91
|
+
def test_invalid_control_sequence
|
92
|
+
0.upto(31) do |n|
|
93
|
+
content = n.chr
|
94
|
+
io = StringIO.new(content)
|
95
|
+
li = ReVIEW::LineInput.new(io)
|
96
|
+
if [9, 10, 13].include?(n) # TAB, LF, CR
|
97
|
+
assert_equal content, li.gets
|
98
|
+
else
|
99
|
+
e = assert_raise(ReVIEW::SyntaxError) { li.gets }
|
100
|
+
assert_match(/found invalid control/, e.message)
|
101
|
+
end
|
102
|
+
end
|
176
103
|
end
|
177
104
|
end
|
@@ -106,6 +106,48 @@ EOS
|
|
106
106
|
assert_equal %Q(test <span class="red">コメント</span> test2), actual
|
107
107
|
end
|
108
108
|
|
109
|
+
def test_endnote
|
110
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
111
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
112
|
+
|
113
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
114
|
+
expected = <<-'EOS'
|
115
|
+
<sup>(1)</sup>
|
116
|
+
|
117
|
+
(1) bar
|
118
|
+
EOS
|
119
|
+
assert_equal expected, actual
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_inline_hd_chap
|
123
|
+
def @chapter.headline_index
|
124
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
125
|
+
idx = Book::HeadlineIndex.new(self)
|
126
|
+
idx.add_item(item)
|
127
|
+
idx
|
128
|
+
end
|
129
|
+
|
130
|
+
@config['secnolevel'] = 2
|
131
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
132
|
+
assert_equal 'test <a href="#h1-1-1">「te_st」</a> test2', actual
|
133
|
+
|
134
|
+
actual = compile_inline('test @<hd>{test} test2')
|
135
|
+
assert_equal 'test <a href="#h1-1-1">「te_st」</a> test2', actual
|
136
|
+
|
137
|
+
@config['secnolevel'] = 3
|
138
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
139
|
+
assert_equal 'test <a href="#h1-1-1">「1.1.1 te_st」</a> test2', actual
|
140
|
+
|
141
|
+
@config['chapterlink'] = nil
|
142
|
+
@config['secnolevel'] = 2
|
143
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
144
|
+
assert_equal 'test 「te_st」 test2', actual
|
145
|
+
|
146
|
+
@config['secnolevel'] = 3
|
147
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
148
|
+
assert_equal 'test 「1.1.1 te_st」 test2', actual
|
149
|
+
end
|
150
|
+
|
109
151
|
def test_ul_nest1
|
110
152
|
src = <<-EOS
|
111
153
|
* AAA
|
data/test/test_pdfmaker.rb
CHANGED
@@ -167,6 +167,25 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
+
def test_template_content_with_invalid_localconfig
|
171
|
+
Dir.mktmpdir do |dir|
|
172
|
+
Dir.chdir(dir) do
|
173
|
+
Dir.mkdir('layouts')
|
174
|
+
File.write(File.join('layouts', 'config-local.tex.erb'), %q(<%= not_existed_method %>\n))
|
175
|
+
@maker.basedir = Dir.pwd
|
176
|
+
@maker.erb_config
|
177
|
+
@maker.instance_eval do
|
178
|
+
def error!(msg)
|
179
|
+
msg
|
180
|
+
end
|
181
|
+
end
|
182
|
+
error_msg = @maker.template_content
|
183
|
+
assert_match(/template or configuration error:/, error_msg)
|
184
|
+
assert_match(/undefined local variable or method `not_existed_method'/, error_msg)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
170
189
|
def test_gettemplate_with_backmatter
|
171
190
|
@config.merge!(
|
172
191
|
'backcover' => 'backcover.tex',
|
@@ -261,4 +280,75 @@ class PDFMakerTest < Test::Unit::TestCase
|
|
261
280
|
'2012年1月31日 ver 1.2.1発行']
|
262
281
|
assert_equal expect, history
|
263
282
|
end
|
283
|
+
|
284
|
+
def test_box_setting_is_defined
|
285
|
+
%w[column note memo tip info warning important caution notice].each do |name|
|
286
|
+
@config['pdfmaker']['boxsetting'] = {
|
287
|
+
name => { 'style' => 'simplebox' }
|
288
|
+
}
|
289
|
+
assert !ReVIEW::LaTeXBox.new.tcbox(@config).empty?
|
290
|
+
end
|
291
|
+
@config['pdfmaker']['boxsetting'] = {
|
292
|
+
'invalid' => { 'style' => 'simplebox' }
|
293
|
+
}
|
294
|
+
assert ReVIEW::LaTeXBox.new.tcbox(@config).empty?
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_box_setting_options
|
298
|
+
@config['pdfmaker']['boxsetting'] = {
|
299
|
+
'note' => { 'style' => 'simplebox' },
|
300
|
+
'important' => { 'style' => 'simplebox', 'options' => 'colback=blue,arc=3mm' },
|
301
|
+
'caution' => { 'style' => 'squarecaptionbox', 'options_with_caption' => 'attach boxed title to top bottom' }
|
302
|
+
}
|
303
|
+
|
304
|
+
expected = <<-EOS
|
305
|
+
\\renewenvironment{reviewnote}[1][]{%
|
306
|
+
\\csdef{rv@tmp@withcaption}{true}
|
307
|
+
\\notblank{##1}{
|
308
|
+
\\begin{rv@simplebox@caption}{##1}[]
|
309
|
+
}{
|
310
|
+
\\csundef{rv@tmp@withcaption}
|
311
|
+
\\begin{rv@simplebox@nocaption}[]
|
312
|
+
}
|
313
|
+
}{
|
314
|
+
\\ifcsdef{rv@tmp@withcaption}{
|
315
|
+
\\end{rv@simplebox@caption}
|
316
|
+
}{
|
317
|
+
\\end{rv@simplebox@nocaption}
|
318
|
+
}
|
319
|
+
}
|
320
|
+
\\renewenvironment{reviewimportant}[1][]{%
|
321
|
+
\\csdef{rv@tmp@withcaption}{true}
|
322
|
+
\\notblank{##1}{
|
323
|
+
\\begin{rv@simplebox@caption}{##1}[colback=blue,arc=3mm]
|
324
|
+
}{
|
325
|
+
\\csundef{rv@tmp@withcaption}
|
326
|
+
\\begin{rv@simplebox@nocaption}[colback=blue,arc=3mm]
|
327
|
+
}
|
328
|
+
}{
|
329
|
+
\\ifcsdef{rv@tmp@withcaption}{
|
330
|
+
\\end{rv@simplebox@caption}
|
331
|
+
}{
|
332
|
+
\\end{rv@simplebox@nocaption}
|
333
|
+
}
|
334
|
+
}
|
335
|
+
\\renewenvironment{reviewcaution}[1][]{%
|
336
|
+
\\csdef{rv@tmp@withcaption}{true}
|
337
|
+
\\notblank{##1}{
|
338
|
+
\\begin{rv@squarecaptionbox@caption}{##1}[attach boxed title to top bottom]
|
339
|
+
}{
|
340
|
+
\\csundef{rv@tmp@withcaption}
|
341
|
+
\\begin{rv@squarecaptionbox@nocaption}[]
|
342
|
+
}
|
343
|
+
}{
|
344
|
+
\\ifcsdef{rv@tmp@withcaption}{
|
345
|
+
\\end{rv@squarecaptionbox@caption}
|
346
|
+
}{
|
347
|
+
\\end{rv@squarecaptionbox@nocaption}
|
348
|
+
}
|
349
|
+
}
|
350
|
+
EOS
|
351
|
+
actual = ReVIEW::LaTeXBox.new.tcbox(@config)
|
352
|
+
assert_equal expected, actual
|
353
|
+
end
|
264
354
|
end
|
data/test/test_pdfmaker_cmd.rb
CHANGED
@@ -5,14 +5,14 @@ require 'yaml'
|
|
5
5
|
require 'rbconfig'
|
6
6
|
require 'open3'
|
7
7
|
|
8
|
-
REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker',
|
8
|
+
REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker', __dir__)
|
9
9
|
|
10
10
|
class PDFMakerCmdTest < Test::Unit::TestCase
|
11
11
|
def setup
|
12
12
|
@tmpdir1 = Dir.mktmpdir
|
13
13
|
|
14
14
|
@old_rubylib = ENV['RUBYLIB']
|
15
|
-
ENV['RUBYLIB'] = File.expand_path('../lib',
|
15
|
+
ENV['RUBYLIB'] = File.expand_path('../lib', __dir__)
|
16
16
|
end
|
17
17
|
|
18
18
|
def teardown
|
@@ -14,6 +14,8 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
|
|
14
14
|
@config['language'] = 'ja'
|
15
15
|
@book = Book::Base.new
|
16
16
|
@book.config = @config
|
17
|
+
@log_io = StringIO.new
|
18
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
17
19
|
@compiler = ReVIEW::Compiler.new(@builder)
|
18
20
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
19
21
|
location = Location.new(nil, nil)
|
@@ -90,9 +92,16 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
|
|
90
92
|
assert_equal "\n", actual
|
91
93
|
end
|
92
94
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
95
|
+
def test_inline_asis
|
96
|
+
%w[i b tti ttb bou ami u strong em code ins tcy].each do |tag|
|
97
|
+
actual = compile_inline("test @<#{tag}>{inline test} test2")
|
98
|
+
assert_equal 'test inline test test2', actual
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_inline_del
|
103
|
+
actual = compile_inline('test @<del>{inline test} test2')
|
104
|
+
assert_equal 'test test2', actual
|
96
105
|
end
|
97
106
|
|
98
107
|
def test_inline_i_and_escape
|
@@ -100,11 +109,6 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
|
|
100
109
|
assert_equal 'test inline<&;\\ test test2', actual
|
101
110
|
end
|
102
111
|
|
103
|
-
def test_inline_b
|
104
|
-
actual = compile_inline('test @<b>{inline test} test2')
|
105
|
-
assert_equal 'test inline test test2', actual
|
106
|
-
end
|
107
|
-
|
108
112
|
def test_inline_b_and_escape
|
109
113
|
actual = compile_inline('test @<b>{inline<&;\\ test} test2')
|
110
114
|
assert_equal 'test inline<&;\\ test test2', actual
|
@@ -115,16 +119,6 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
|
|
115
119
|
assert_equal 'test inline test test2}', actual
|
116
120
|
end
|
117
121
|
|
118
|
-
def test_inline_tti
|
119
|
-
actual = compile_inline('test @<tti>{inline test} test2')
|
120
|
-
assert_equal 'test inline test test2', actual
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_inline_ttb
|
124
|
-
actual = compile_inline('test @<ttb>{inline test} test2')
|
125
|
-
assert_equal 'test inline test test2', actual
|
126
|
-
end
|
127
|
-
|
128
122
|
def test_inline_uchar
|
129
123
|
actual = compile_inline('test @<uchar>{2460} test2')
|
130
124
|
assert_equal 'test ① test2', actual
|
@@ -477,10 +471,10 @@ EOS
|
|
477
471
|
|
478
472
|
def test_empty_table
|
479
473
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
480
|
-
assert_equal '
|
474
|
+
assert_equal 'no rows in the table', e.message
|
481
475
|
|
482
476
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
483
|
-
assert_equal '
|
477
|
+
assert_equal 'no rows in the table', e.message
|
484
478
|
end
|
485
479
|
|
486
480
|
def test_inline_table
|
@@ -699,8 +693,8 @@ EOS
|
|
699
693
|
|
700
694
|
//}
|
701
695
|
EOS
|
702
|
-
|
703
|
-
assert_match(/minicolumn cannot be nested:/,
|
696
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
697
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
704
698
|
end
|
705
699
|
end
|
706
700
|
|
@@ -716,8 +710,8 @@ EOS
|
|
716
710
|
|
717
711
|
//}
|
718
712
|
EOS
|
719
|
-
|
720
|
-
assert_match(/minicolumn cannot be nested:/,
|
713
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
714
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
721
715
|
end
|
722
716
|
end
|
723
717
|
|
@@ -732,8 +726,8 @@ EOS
|
|
732
726
|
|
733
727
|
//}
|
734
728
|
EOS
|
735
|
-
|
736
|
-
assert_match(/minicolumn cannot be nested:/,
|
729
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
730
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
737
731
|
end
|
738
732
|
end
|
739
733
|
|
@@ -768,20 +762,42 @@ EOS
|
|
768
762
|
assert_equal %Q(\\sin\n1^{2}\n\n), actual
|
769
763
|
end
|
770
764
|
|
765
|
+
def test_endnote
|
766
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
767
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
768
|
+
|
769
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
770
|
+
expected = <<-'EOS'
|
771
|
+
(1)
|
772
|
+
(1) bar
|
773
|
+
EOS
|
774
|
+
assert_equal expected, actual
|
775
|
+
end
|
776
|
+
|
771
777
|
def test_inline_unknown
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
779
|
+
assert_match(/unknown image: n/, @log_io.string)
|
780
|
+
|
781
|
+
@log_io.string = ''
|
782
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
783
|
+
assert_match(/unknown footnote: n/, @log_io.string)
|
784
|
+
|
785
|
+
@log_io.string = ''
|
786
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<endnote>{n}\n") }
|
787
|
+
assert_match(/unknown endnote: n/, @log_io.string)
|
788
|
+
|
789
|
+
@log_io.string = ''
|
790
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
791
|
+
assert_match(/unknown headline: n/, @log_io.string)
|
778
792
|
%w[list table column].each do |name|
|
779
|
-
|
780
|
-
|
793
|
+
@log_io.string = ''
|
794
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
795
|
+
assert_match(/unknown #{name}: n/, @log_io.string)
|
781
796
|
end
|
782
797
|
%w[chap chapref title].each do |name|
|
783
|
-
|
784
|
-
|
798
|
+
@log_io.string = ''
|
799
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
800
|
+
assert_match(/key not found: "n"/, @log_io.string)
|
785
801
|
end
|
786
802
|
end
|
787
803
|
|
@@ -899,7 +915,7 @@ EOS
|
|
899
915
|
//endchild
|
900
916
|
EOS
|
901
917
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
902
|
-
assert_equal ":1:
|
918
|
+
assert_equal ":1: //endchild is shown, but any opened //beginchild doesn't exist", e.message
|
903
919
|
end
|
904
920
|
|
905
921
|
def test_nest_error_close1
|
@@ -907,7 +923,7 @@ EOS
|
|
907
923
|
//beginchild
|
908
924
|
EOS
|
909
925
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
910
|
-
assert_equal ":1:
|
926
|
+
assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
911
927
|
end
|
912
928
|
|
913
929
|
def test_nest_error_close2
|
@@ -925,7 +941,7 @@ EOS
|
|
925
941
|
//beginchild
|
926
942
|
EOS
|
927
943
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
928
|
-
assert_equal ':12:
|
944
|
+
assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
|
929
945
|
end
|
930
946
|
|
931
947
|
def test_nest_error_close3
|
@@ -945,7 +961,7 @@ EOS
|
|
945
961
|
//endchild
|
946
962
|
EOS
|
947
963
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
948
|
-
assert_equal ':14:
|
964
|
+
assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
|
949
965
|
end
|
950
966
|
|
951
967
|
def test_nest_ul
|