review 4.0.0 → 5.1.1
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 +31 -0
- data/.github/workflows/ruby-win.yml +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +141 -38
- data/Dockerfile +21 -5
- data/NEWS.ja.md +338 -1
- data/NEWS.md +339 -2
- data/README.md +11 -7
- data/Rakefile +7 -2
- data/appveyor.yml +0 -20
- data/bin/review +2 -4
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -12
- data/bin/review-checkdep +2 -5
- data/bin/review-compile +11 -20
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +5 -86
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +3 -5
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +5 -5
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +55 -12
- data/doc/config.yml.sample-simple +4 -3
- data/doc/format.ja.md +119 -17
- data/doc/format.md +106 -17
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +42 -0
- data/doc/pdfmaker.md +41 -0
- data/doc/quickstart.ja.md +55 -25
- data/doc/quickstart.md +47 -17
- data/lib/review.rb +1 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +69 -30
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +33 -26
- data/lib/review/book/index.rb +39 -206
- data/lib/review/book/index/item.rb +8 -2
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +26 -11
- data/lib/review/book/volume.rb +5 -5
- data/lib/review/builder.rb +124 -27
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +3 -2
- data/lib/review/compiler.rb +197 -91
- data/lib/review/configure.rb +95 -9
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +116 -117
- 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 +168 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/exception.rb +6 -0
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +132 -87
- data/lib/review/htmlutils.rb +8 -11
- data/lib/review/i18n.rb +2 -1
- data/lib/review/idgxmlbuilder.rb +156 -76
- data/lib/review/idgxmlmaker.rb +22 -18
- data/lib/review/img_math.rb +245 -0
- data/lib/review/index_builder.rb +654 -0
- data/lib/review/init.rb +17 -18
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +173 -43
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/logger.rb +42 -3
- data/lib/review/makerhelper.rb +12 -187
- data/lib/review/markdownbuilder.rb +51 -2
- data/lib/review/pdfmaker.rb +78 -73
- data/lib/review/plaintextbuilder.rb +98 -14
- data/lib/review/preprocessor.rb +18 -12
- data/lib/review/rstbuilder.rb +28 -9
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +6 -0
- data/lib/review/textmaker.rb +21 -19
- data/lib/review/textutils.rb +3 -12
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +91 -24
- data/lib/review/update.rb +12 -13
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +34 -33
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +2 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/.gitignore +1 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config.yml +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +26 -6
- data/samples/syntax-book/Gemfile +1 -1
- data/samples/syntax-book/ch01.re +3 -1
- data/samples/syntax-book/ch02.re +28 -21
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-print.yml +3 -0
- data/samples/syntax-book/config.yml +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/review.rake +23 -8
- 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 +41 -29
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +47 -22
- data/templates/latex/review-jlreq/review-jlreq.cls +25 -24
- 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/README.md +7 -5
- data/templates/latex/review-jsbook/review-base.sty +47 -21
- data/templates/latex/review-jsbook/review-jsbook.cls +12 -2
- 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 +9 -8
- 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 +58 -0
- data/test/assets/test_template.tex +12 -9
- data/test/assets/test_template_backmatter.tex +12 -9
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +62 -63
- data/test/test_book_chapter.rb +99 -56
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +24 -15
- data/test/test_catalog.rb +1 -0
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_converter.rb +1 -0
- data/test/test_epub3maker.rb +170 -126
- data/test/test_epubmaker.rb +249 -129
- data/test/test_epubmaker_cmd.rb +14 -7
- data/test/test_helper.rb +23 -11
- data/test/test_htmlbuilder.rb +956 -76
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +568 -10
- data/test/test_idgxmlmaker_cmd.rb +50 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +62 -52
- data/test/test_indexbuilder.rb +52 -0
- data/test/test_latexbuilder.rb +1056 -30
- data/test/test_latexbuilder_v2.rb +52 -12
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +7 -7
- data/test/test_makerhelper.rb +0 -12
- data/test/test_markdownbuilder.rb +32 -0
- data/test/test_pdfmaker.rb +100 -11
- data/test/test_pdfmaker_cmd.rb +101 -7
- data/test/test_plaintextbuilder.rb +531 -25
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +25 -1
- data/test/test_sec_counter.rb +156 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +58 -0
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +365 -10
- data/test/test_update.rb +44 -44
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_zip_exporter.rb +5 -6
- data/vendor/gentombow/LICENSE +1 -1
- data/vendor/gentombow/Makefile +0 -1
- data/vendor/gentombow/bounddvi-en.pdf +0 -0
- data/vendor/gentombow/bounddvi-en.tex +1 -0
- data/vendor/gentombow/bounddvi.pdf +0 -0
- data/vendor/gentombow/bounddvi.sty +30 -7
- data/vendor/gentombow/bounddvi.tex +1 -0
- data/vendor/gentombow/create_archive.sh +1 -0
- data/vendor/gentombow/gentombow-ja.pdf +0 -0
- data/vendor/gentombow/gentombow-ja.tex +9 -0
- data/vendor/gentombow/gentombow.pdf +0 -0
- data/vendor/gentombow/gentombow.sty +32 -10
- data/vendor/gentombow/gentombow.tex +8 -0
- data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
- data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +74 -31
- data/vendor/jsclasses/jis/jsbook.cls +74 -31
- data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +4 -16
- data/vendor/jsclasses/jis/jspf.cls +73 -30
- data/vendor/jsclasses/jis/jsreport.cls +74 -31
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +74 -31
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +4 -17
- data/vendor/jsclasses/jis/okuverb.ins +9 -0
- data/vendor/jsclasses/jis/okuverb.sty +1 -13
- data/vendor/jsclasses/jis/winjis.sty +23 -19
- data/vendor/jsclasses/jsarticle.cls +74 -31
- data/vendor/jsclasses/jsbook.cls +74 -31
- data/vendor/jsclasses/jsclasses.dtx +176 -36
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +4 -16
- data/vendor/jsclasses/jspf.cls +73 -30
- data/vendor/jsclasses/jsreport.cls +74 -31
- data/vendor/jsclasses/jsverb.ins +9 -0
- data/vendor/jsclasses/jsverb.pdf +0 -0
- data/vendor/jsclasses/jsverb.sty +1 -13
- data/vendor/jsclasses/kiyou.cls +74 -31
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +4 -17
- data/vendor/jsclasses/okuverb.ins +9 -0
- data/vendor/jsclasses/okuverb.pdf +0 -0
- data/vendor/jsclasses/okuverb.sty +1 -13
- data/vendor/jsclasses/tests/relfont.tex +10 -0
- data/vendor/jsclasses/winjis.sty +23 -19
- metadata +109 -20
- data/.rubocop_todo.yml +0 -7
- data/lib/epubmaker.rb +0 -23
- data/lib/epubmaker/content.rb +0 -110
- data/lib/epubmaker/epubcommon.rb +0 -441
- data/lib/epubmaker/epubv2.rb +0 -143
- data/lib/epubmaker/epubv3.rb +0 -233
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/lineinput.rb +0 -155
- data/lib/review/book/compilable.rb +0 -178
- data/lib/review/tocparser.rb +0 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/builder'
|
3
|
+
|
4
|
+
require 'review/book'
|
5
|
+
|
6
|
+
class MockCompiler
|
7
|
+
def text(s)
|
8
|
+
[:text, s]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class IndexBuidlerTest < Test::Unit::TestCase
|
13
|
+
include ReVIEW
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@b = IndexBuilder.new
|
17
|
+
chap = ReVIEW::Book::Chapter.new(nil, nil, '-', nil)
|
18
|
+
@b.bind(MockCompiler.new, chap, nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_initialize
|
22
|
+
assert IndexBuilder.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_check_id
|
26
|
+
io = StringIO.new
|
27
|
+
@b.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
28
|
+
@b.check_id('ABC')
|
29
|
+
assert_match('', io.string)
|
30
|
+
|
31
|
+
%w(# % \\ { } [ ] ~ / $ ' " | * ? & < > `).each do |c|
|
32
|
+
io = StringIO.new
|
33
|
+
@b.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
34
|
+
@b.check_id("id#{c}")
|
35
|
+
assert_match(/deprecated ID: `#{Regexp.escape(c)}` in `id#{Regexp.escape(c)}`/, io.string)
|
36
|
+
end
|
37
|
+
io = StringIO.new
|
38
|
+
@b.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
39
|
+
@b.check_id('A B C#')
|
40
|
+
assert_match(/deprecated ID: ` ` in `A B C#`/, io.string)
|
41
|
+
|
42
|
+
io = StringIO.new
|
43
|
+
@b.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
44
|
+
@b.check_id("A\tB")
|
45
|
+
assert_match(/deprecated ID: `\t` in `A\tB`/, io.string)
|
46
|
+
|
47
|
+
io = StringIO.new
|
48
|
+
@b.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
49
|
+
@b.check_id('.ABC')
|
50
|
+
assert_match(/deprecated ID: `.ABC` begins from `.`/, io.string)
|
51
|
+
end
|
52
|
+
end
|
data/test/test_latexbuilder.rb
CHANGED
@@ -14,10 +14,10 @@ class LATEXBuidlerTest < Test::Unit::TestCase
|
|
14
14
|
'secnolevel' => 2, # for IDGXMLBuilder, EPUBBuilder
|
15
15
|
'toclevel' => 2,
|
16
16
|
'stylesheet' => nil, # for EPUBBuilder
|
17
|
-
'image_scale2width' => false,
|
18
17
|
'texcommand' => 'uplatex',
|
19
|
-
'review_version' => '
|
18
|
+
'review_version' => '4'
|
20
19
|
)
|
20
|
+
@config['pdfmaker']['image_scale2width'] = nil
|
21
21
|
@book = Book::Base.new
|
22
22
|
@book.config = @config
|
23
23
|
@compiler = ReVIEW::Compiler.new(@builder)
|
@@ -197,6 +197,16 @@ EOS
|
|
197
197
|
assert_equal 'abc\\reviewunderline{def}ghi', actual
|
198
198
|
end
|
199
199
|
|
200
|
+
def test_inline_ins
|
201
|
+
actual = compile_inline('abc@<ins>{def}ghi')
|
202
|
+
assert_equal 'abc\\reviewinsert{def}ghi', actual
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_inline_del
|
206
|
+
actual = compile_inline('abc@<del>{def}ghi')
|
207
|
+
assert_equal 'abc\\reviewstrike{def}ghi', actual
|
208
|
+
end
|
209
|
+
|
200
210
|
def test_inline_bou
|
201
211
|
actual = compile_inline('傍点の@<bou>{テスト}です。')
|
202
212
|
assert_equal '傍点の\\reviewbou{テスト}です。', actual
|
@@ -247,12 +257,18 @@ EOS
|
|
247
257
|
|
248
258
|
def test_inline_hd_chap
|
249
259
|
def @chapter.headline_index
|
250
|
-
|
251
|
-
Book::HeadlineIndex.new(
|
260
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
261
|
+
idx = Book::HeadlineIndex.new(self)
|
262
|
+
idx.add_item(item)
|
263
|
+
idx
|
252
264
|
end
|
253
265
|
|
254
266
|
@config['secnolevel'] = 3
|
255
267
|
actual = compile_inline('test @<hd>{chap1|test} test2')
|
268
|
+
assert_equal 'test \reviewsecref{「1.1.1 te\\textunderscore{}st」}{sec:1-1-1} test2', actual
|
269
|
+
|
270
|
+
@config['chapterlink'] = nil
|
271
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
256
272
|
assert_equal 'test 「1.1.1 te\\textunderscore{}st」 test2', actual
|
257
273
|
end
|
258
274
|
|
@@ -282,21 +298,73 @@ EOS
|
|
282
298
|
end
|
283
299
|
|
284
300
|
def test_inline_idx_yomi
|
301
|
+
require 'nkf'
|
285
302
|
begin
|
286
303
|
require 'MeCab'
|
287
|
-
require 'nkf'
|
288
304
|
rescue LoadError
|
289
305
|
$stderr.puts 'skip test_inline_idx_yomi (cannot find MeCab)'
|
290
306
|
return true
|
291
307
|
end
|
292
308
|
tmpdir = Dir.mktmpdir
|
293
|
-
File.write(File.join(tmpdir, 'sample.dic'), "強運\tはーどらっく\n")
|
309
|
+
File.write(File.join(tmpdir, 'sample.dic'), "強運\tはーどらっく\nmain(ブロック)\tmain{|}\n")
|
294
310
|
@book.config['pdfmaker']['makeindex'] = true
|
295
311
|
@book.config['pdfmaker']['makeindex_dic'] = "#{tmpdir}/sample.dic"
|
296
312
|
@builder.setup_index
|
297
313
|
actual = compile_inline('@<hidx>{漢字}@<hidx>{強運}@<hidx>{項目@1<<>>項目@2}')
|
298
|
-
FileUtils.remove_entry_secure(tmpdir)
|
299
314
|
assert_equal %Q(\\index{かんじ@漢字}\\index{はーどらっく@強運}\\index{こうもく"@1@項目"@1!こうもく"@2@項目"@2}), actual
|
315
|
+
actual = compile_inline('@<hidx>{main(ブロック)}@<hidx>{あいうえお{\}}')
|
316
|
+
FileUtils.remove_entry_secure(tmpdir)
|
317
|
+
assert_equal %Q(\\index{main{|}@main(ブロック)}\\index{あいうえお{}@あいうえお\\reviewleftcurlybrace{}\\reviewrightcurlybrace{}}), actual
|
318
|
+
end
|
319
|
+
|
320
|
+
def test_inline_idx_escape
|
321
|
+
# as is
|
322
|
+
%w[a あ ' ( ) = ` + ; * : , . ? /].each do |c|
|
323
|
+
actual = @builder.index(c)
|
324
|
+
assert_equal %Q(\\index{#{c}}), actual
|
325
|
+
end
|
326
|
+
actual = @builder.index('[')
|
327
|
+
assert_equal %Q(\\index{[}), actual
|
328
|
+
actual = @builder.index(']')
|
329
|
+
assert_equal %Q(\\index{]}), actual
|
330
|
+
|
331
|
+
# escape display string by "
|
332
|
+
%w[! " @].each do |c|
|
333
|
+
actual = @builder.index(c)
|
334
|
+
assert_equal %Q(\\index{"#{c}@"#{c}}), actual
|
335
|
+
end
|
336
|
+
|
337
|
+
# escape display string by \
|
338
|
+
%w[# % &].each do |c|
|
339
|
+
actual = @builder.index(c)
|
340
|
+
assert_equal %Q(\\index{#{c}@\\#{c}}), actual
|
341
|
+
end
|
342
|
+
|
343
|
+
# escape display string by macro
|
344
|
+
actual = @builder.index('$')
|
345
|
+
assert_equal %Q(\\index{$@\\textdollar{}}), actual
|
346
|
+
actual = @builder.index('-')
|
347
|
+
assert_equal %Q(\\index{-@{-}}), actual
|
348
|
+
actual = @builder.index('~')
|
349
|
+
assert_equal %Q(\\index{~@\\textasciitilde{}}), actual
|
350
|
+
actual = @builder.index('^')
|
351
|
+
assert_equal %Q(\\index{^@\\textasciicircum{}}), actual
|
352
|
+
actual = @builder.index('\\')
|
353
|
+
assert_equal %Q(\\index{\\@\\reviewbackslash{}}), actual
|
354
|
+
actual = @builder.index('<')
|
355
|
+
assert_equal %Q(\\index{<@\\textless{}}), actual
|
356
|
+
actual = @builder.index('>')
|
357
|
+
assert_equal %Q(\\index{>@\\textgreater{}}), actual
|
358
|
+
actual = @builder.index('_')
|
359
|
+
assert_equal %Q(\\index{_@\\textunderscore{}}), actual
|
360
|
+
|
361
|
+
# escape both sort key and display string
|
362
|
+
actual = @builder.index('{')
|
363
|
+
assert_equal %Q(\\index{{@\\reviewleftcurlybrace{}}), actual
|
364
|
+
actual = @builder.index('|')
|
365
|
+
assert_equal %Q(\\index{|@\\textbar{}}), actual
|
366
|
+
actual = @builder.index('}')
|
367
|
+
assert_equal %Q(\\index{}@\\reviewrightcurlybrace{}}), actual
|
300
368
|
end
|
301
369
|
|
302
370
|
def test_jis_x_0201_kana
|
@@ -386,6 +454,19 @@ EOS
|
|
386
454
|
assert_equal expected, actual
|
387
455
|
end
|
388
456
|
|
457
|
+
def test_dt_inline
|
458
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
459
|
+
|
460
|
+
expected = <<-EOS
|
461
|
+
|
462
|
+
\\begin{description}
|
463
|
+
\\item[foo\\protect\\footnotemark{}\\lbrack{}\\rbrack{}\\textless{}\\textgreater{}\\&$\\alpha\\lbrack{}\\rbrack{}$] \\mbox{} \\\\
|
464
|
+
|
465
|
+
\\end{description}
|
466
|
+
EOS
|
467
|
+
assert_equal expected, actual
|
468
|
+
end
|
469
|
+
|
389
470
|
def test_cmd
|
390
471
|
actual = compile_block("//cmd{\nfoo\nbar\n\nbuz\n//}\n")
|
391
472
|
expected = <<-EOS
|
@@ -415,6 +496,22 @@ bar
|
|
415
496
|
buz
|
416
497
|
\\end{reviewcmd}
|
417
498
|
\\end{reviewlistblock}
|
499
|
+
EOS
|
500
|
+
assert_equal expected, actual
|
501
|
+
|
502
|
+
@config['caption_position']['list'] = 'bottom'
|
503
|
+
actual = compile_block("//cmd[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
504
|
+
expected = <<-EOS
|
505
|
+
|
506
|
+
\\begin{reviewlistblock}
|
507
|
+
\\begin{reviewcmd}
|
508
|
+
foo
|
509
|
+
bar
|
510
|
+
|
511
|
+
buz
|
512
|
+
\\end{reviewcmd}
|
513
|
+
\\reviewcmdcaption{cap1}
|
514
|
+
\\end{reviewlistblock}
|
418
515
|
EOS
|
419
516
|
assert_equal expected, actual
|
420
517
|
end
|
@@ -490,6 +587,22 @@ bar
|
|
490
587
|
buz
|
491
588
|
\\end{reviewemlist}
|
492
589
|
\\end{reviewlistblock}
|
590
|
+
EOS
|
591
|
+
assert_equal expected, actual
|
592
|
+
|
593
|
+
@config['caption_position']['list'] = 'bottom'
|
594
|
+
actual = compile_block("//emlist[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
595
|
+
expected = <<-EOS
|
596
|
+
|
597
|
+
\\begin{reviewlistblock}
|
598
|
+
\\begin{reviewemlist}
|
599
|
+
foo
|
600
|
+
bar
|
601
|
+
|
602
|
+
buz
|
603
|
+
\\end{reviewemlist}
|
604
|
+
\\reviewemlistcaption{cap1}
|
605
|
+
\\end{reviewlistblock}
|
493
606
|
EOS
|
494
607
|
assert_equal expected, actual
|
495
608
|
end
|
@@ -556,6 +669,22 @@ EOS
|
|
556
669
|
4: buz
|
557
670
|
\\end{reviewemlist}
|
558
671
|
\\end{reviewlistblock}
|
672
|
+
EOS
|
673
|
+
assert_equal expected, actual
|
674
|
+
|
675
|
+
@config['caption_position']['list'] = 'bottom'
|
676
|
+
actual = compile_block("//emlistnum[cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
677
|
+
expected = <<-EOS
|
678
|
+
|
679
|
+
\\begin{reviewlistblock}
|
680
|
+
\\begin{reviewemlist}
|
681
|
+
1: foo
|
682
|
+
2: bar
|
683
|
+
3:
|
684
|
+
4: buz
|
685
|
+
\\end{reviewemlist}
|
686
|
+
\\reviewemlistcaption{cap1}
|
687
|
+
\\end{reviewlistblock}
|
559
688
|
EOS
|
560
689
|
assert_equal expected, actual
|
561
690
|
end
|
@@ -572,6 +701,21 @@ bar
|
|
572
701
|
buz
|
573
702
|
\\end{reviewlist}
|
574
703
|
\\end{reviewlistblock}
|
704
|
+
EOS
|
705
|
+
assert_equal expected, actual
|
706
|
+
|
707
|
+
@config['caption_position']['list'] = 'bottom'
|
708
|
+
actual = compile_block("//list[id1][cap1]{\nfoo\nbar\n\nbuz\n//}\n")
|
709
|
+
expected = <<-EOS
|
710
|
+
\\begin{reviewlistblock}
|
711
|
+
\\begin{reviewlist}
|
712
|
+
foo
|
713
|
+
bar
|
714
|
+
|
715
|
+
buz
|
716
|
+
\\end{reviewlist}
|
717
|
+
\\reviewlistcaption{リスト1.1: cap1}
|
718
|
+
\\end{reviewlistblock}
|
575
719
|
EOS
|
576
720
|
assert_equal expected, actual
|
577
721
|
end
|
@@ -584,6 +728,16 @@ EOS
|
|
584
728
|
\\begin{reviewlistlst}[caption={cap1},language={sql}]
|
585
729
|
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
|
586
730
|
\\end{reviewlistlst}
|
731
|
+
EOS
|
732
|
+
assert_equal expected, actual
|
733
|
+
|
734
|
+
@config['caption_position']['list'] = 'bottom'
|
735
|
+
# XXX: caption_position won't work with highlight
|
736
|
+
actual = compile_block("//list[id1][cap1][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
|
737
|
+
expected = <<-EOS
|
738
|
+
\\begin{reviewlistlst}[caption={cap1},language={sql}]
|
739
|
+
SELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'
|
740
|
+
\\end{reviewlistlst}
|
587
741
|
EOS
|
588
742
|
assert_equal expected, actual
|
589
743
|
end
|
@@ -616,6 +770,24 @@ EOS
|
|
616
770
|
7: end
|
617
771
|
\\end{reviewlist}
|
618
772
|
\\end{reviewlistblock}
|
773
|
+
EOS
|
774
|
+
assert_equal expected, actual
|
775
|
+
|
776
|
+
@config['caption_position']['list'] = 'bottom'
|
777
|
+
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
778
|
+
expected = <<-EOS
|
779
|
+
\\begin{reviewlistblock}
|
780
|
+
\\begin{reviewlist}
|
781
|
+
1: class Foo
|
782
|
+
2: def foo
|
783
|
+
3: bar
|
784
|
+
4:
|
785
|
+
5: buz
|
786
|
+
6: end
|
787
|
+
7: end
|
788
|
+
\\end{reviewlist}
|
789
|
+
\\reviewlistcaption{リスト1.1: ruby}
|
790
|
+
\\end{reviewlistblock}
|
619
791
|
EOS
|
620
792
|
assert_equal expected, actual
|
621
793
|
end
|
@@ -653,6 +825,22 @@ class Foo
|
|
653
825
|
end
|
654
826
|
end
|
655
827
|
\\end{reviewlistnumlst}
|
828
|
+
EOS
|
829
|
+
assert_equal expected, actual
|
830
|
+
|
831
|
+
@config['caption_position']['list'] = 'bottom'
|
832
|
+
# XXX: caption_position won't work with highlight
|
833
|
+
actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
|
834
|
+
expected = <<-EOS
|
835
|
+
\\begin{reviewlistnumlst}[caption={ruby},language={}]
|
836
|
+
class Foo
|
837
|
+
def foo
|
838
|
+
bar
|
839
|
+
|
840
|
+
buz
|
841
|
+
end
|
842
|
+
end
|
843
|
+
\\end{reviewlistnumlst}
|
656
844
|
EOS
|
657
845
|
assert_equal expected, actual
|
658
846
|
end
|
@@ -687,6 +875,21 @@ bar
|
|
687
875
|
buz
|
688
876
|
\\end{reviewsource}
|
689
877
|
\\end{reviewlistblock}
|
878
|
+
EOS
|
879
|
+
assert_equal expected, actual
|
880
|
+
|
881
|
+
@config['caption_position']['list'] = 'bottom'
|
882
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
883
|
+
expected = <<-EOS
|
884
|
+
\\begin{reviewlistblock}
|
885
|
+
\\begin{reviewsource}
|
886
|
+
foo
|
887
|
+
bar
|
888
|
+
|
889
|
+
buz
|
890
|
+
\\end{reviewsource}
|
891
|
+
\\reviewsourcecaption{foo/bar/test.rb}
|
892
|
+
\\end{reviewlistblock}
|
690
893
|
EOS
|
691
894
|
assert_equal expected, actual
|
692
895
|
end
|
@@ -715,6 +918,19 @@ EOS
|
|
715
918
|
foo
|
716
919
|
bar
|
717
920
|
|
921
|
+
buz
|
922
|
+
\\end{reviewsourcelst}
|
923
|
+
EOS
|
924
|
+
assert_equal expected, actual
|
925
|
+
|
926
|
+
@config['caption_position']['list'] = 'bottom'
|
927
|
+
# XXX: caption_position won't work with highlight
|
928
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
929
|
+
expected = <<-EOS
|
930
|
+
\\begin{reviewsourcelst}[title={foo/bar/test.rb},language={}]
|
931
|
+
foo
|
932
|
+
bar
|
933
|
+
|
718
934
|
buz
|
719
935
|
\\end{reviewsourcelst}
|
720
936
|
EOS
|
@@ -750,9 +966,11 @@ EOS
|
|
750
966
|
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
|
751
967
|
expected = <<-EOS
|
752
968
|
\\begin{reviewmemo}[this is \\reviewbold{test}\\textless{}\\&\\textgreater{}\\textunderscore{}]
|
969
|
+
|
753
970
|
test1
|
754
971
|
|
755
972
|
test\\reviewit{2}
|
973
|
+
|
756
974
|
\\end{reviewmemo}
|
757
975
|
EOS
|
758
976
|
assert_equal expected, actual
|
@@ -857,6 +1075,45 @@ EOS
|
|
857
1075
|
\\end{reviewimage}
|
858
1076
|
EOS
|
859
1077
|
assert_equal expected, actual
|
1078
|
+
|
1079
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1080
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
1081
|
+
expected = <<-EOS
|
1082
|
+
\\begin{reviewimage}%%sampleimg
|
1083
|
+
\\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
|
1084
|
+
\\reviewimagecaption{sample photo}
|
1085
|
+
\\label{image:chap1:sampleimg}
|
1086
|
+
\\end{reviewimage}
|
1087
|
+
EOS
|
1088
|
+
assert_equal expected, actual
|
1089
|
+
|
1090
|
+
actual = compile_block("//image[sampleimg][sample photo][]{\n//}\n")
|
1091
|
+
assert_equal expected, actual
|
1092
|
+
|
1093
|
+
@book.config['pdfmaker']['use_original_image_size'] = nil
|
1094
|
+
@config['caption_position']['image'] = 'top'
|
1095
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
1096
|
+
expected = <<-EOS
|
1097
|
+
\\begin{reviewimage}%%sampleimg
|
1098
|
+
\\reviewimagecaption{sample photo}
|
1099
|
+
\\label{image:chap1:sampleimg}
|
1100
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
1101
|
+
\\end{reviewimage}
|
1102
|
+
EOS
|
1103
|
+
assert_equal expected, actual
|
1104
|
+
|
1105
|
+
actual = compile_block("//image[sampleimg][]{\n//}\n")
|
1106
|
+
expected = <<-EOS
|
1107
|
+
\\begin{reviewimage}%%sampleimg
|
1108
|
+
\\reviewimagecaption{}
|
1109
|
+
\\label{image:chap1:sampleimg}
|
1110
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
1111
|
+
\\end{reviewimage}
|
1112
|
+
EOS
|
1113
|
+
assert_equal expected, actual
|
1114
|
+
|
1115
|
+
actual = compile_block("//image[sampleimg][][]{\n//}\n")
|
1116
|
+
assert_equal expected, actual
|
860
1117
|
end
|
861
1118
|
|
862
1119
|
def test_image_with_metric
|
@@ -875,6 +1132,10 @@ EOS
|
|
875
1132
|
\\end{reviewimage}
|
876
1133
|
EOS
|
877
1134
|
assert_equal expected, actual
|
1135
|
+
|
1136
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1137
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
1138
|
+
assert_equal expected, actual
|
878
1139
|
end
|
879
1140
|
|
880
1141
|
def test_image_with_metric_width
|
@@ -884,7 +1145,7 @@ EOS
|
|
884
1145
|
item
|
885
1146
|
end
|
886
1147
|
|
887
|
-
@config['image_scale2width'] = true
|
1148
|
+
@config['pdfmaker']['image_scale2width'] = true
|
888
1149
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
889
1150
|
expected = <<-EOS
|
890
1151
|
\\begin{reviewimage}%%sampleimg
|
@@ -894,6 +1155,10 @@ EOS
|
|
894
1155
|
\\end{reviewimage}
|
895
1156
|
EOS
|
896
1157
|
assert_equal expected, actual
|
1158
|
+
|
1159
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1160
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
1161
|
+
assert_equal expected, actual
|
897
1162
|
end
|
898
1163
|
|
899
1164
|
def test_image_with_metric2
|
@@ -912,6 +1177,10 @@ EOS
|
|
912
1177
|
\\end{reviewimage}
|
913
1178
|
EOS
|
914
1179
|
assert_equal expected, actual
|
1180
|
+
|
1181
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1182
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
1183
|
+
assert_equal expected, actual
|
915
1184
|
end
|
916
1185
|
|
917
1186
|
def test_image_with_metric2_width
|
@@ -921,7 +1190,7 @@ EOS
|
|
921
1190
|
item
|
922
1191
|
end
|
923
1192
|
|
924
|
-
@config['image_scale2width'] = true
|
1193
|
+
@config['pdfmaker']['image_scale2width'] = true
|
925
1194
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
926
1195
|
expected = <<-EOS
|
927
1196
|
\\begin{reviewimage}%%sampleimg
|
@@ -931,6 +1200,10 @@ EOS
|
|
931
1200
|
\\end{reviewimage}
|
932
1201
|
EOS
|
933
1202
|
assert_equal expected, actual
|
1203
|
+
|
1204
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1205
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
|
1206
|
+
assert_equal expected, actual
|
934
1207
|
end
|
935
1208
|
|
936
1209
|
def test_indepimage
|
@@ -946,6 +1219,30 @@ EOS
|
|
946
1219
|
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
947
1220
|
\\reviewindepimagecaption{図: sample photo}
|
948
1221
|
\\end{reviewimage}
|
1222
|
+
EOS
|
1223
|
+
assert_equal expected, actual
|
1224
|
+
|
1225
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1226
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
1227
|
+
expected = <<-EOS
|
1228
|
+
\\begin{reviewimage}%%sampleimg
|
1229
|
+
\\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
|
1230
|
+
\\reviewindepimagecaption{図: sample photo}
|
1231
|
+
\\end{reviewimage}
|
1232
|
+
EOS
|
1233
|
+
assert_equal expected, actual
|
1234
|
+
|
1235
|
+
actual = compile_block("//indepimage[sampleimg][sample photo][]\n")
|
1236
|
+
assert_equal expected, actual
|
1237
|
+
|
1238
|
+
@book.config['pdfmaker']['use_original_image_size'] = nil
|
1239
|
+
@config['caption_position']['image'] = 'top'
|
1240
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
1241
|
+
expected = <<-EOS
|
1242
|
+
\\begin{reviewimage}%%sampleimg
|
1243
|
+
\\reviewindepimagecaption{図: sample photo}
|
1244
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
1245
|
+
\\end{reviewimage}
|
949
1246
|
EOS
|
950
1247
|
assert_equal expected, actual
|
951
1248
|
end
|
@@ -965,6 +1262,12 @@ EOS
|
|
965
1262
|
\\end{reviewimage}
|
966
1263
|
EOS
|
967
1264
|
assert_equal expected, actual
|
1265
|
+
|
1266
|
+
actual = compile_block("//indepimage[sampleimg][]\n")
|
1267
|
+
assert_equal expected, actual
|
1268
|
+
|
1269
|
+
actual = compile_block("//indepimage[sampleimg][][]\n")
|
1270
|
+
assert_equal expected, actual
|
968
1271
|
end
|
969
1272
|
|
970
1273
|
def test_indepimage_with_metric
|
@@ -982,6 +1285,10 @@ EOS
|
|
982
1285
|
\\end{reviewimage}
|
983
1286
|
EOS
|
984
1287
|
assert_equal expected, actual
|
1288
|
+
|
1289
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1290
|
+
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
1291
|
+
assert_equal expected, actual
|
985
1292
|
end
|
986
1293
|
|
987
1294
|
def test_indepimage_with_metric_width
|
@@ -991,7 +1298,7 @@ EOS
|
|
991
1298
|
item
|
992
1299
|
end
|
993
1300
|
|
994
|
-
@config['image_scale2width'] = true
|
1301
|
+
@config['pdfmaker']['image_scale2width'] = true
|
995
1302
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
996
1303
|
expected = <<-EOS
|
997
1304
|
\\begin{reviewimage}%%sampleimg
|
@@ -1000,6 +1307,10 @@ EOS
|
|
1000
1307
|
\\end{reviewimage}
|
1001
1308
|
EOS
|
1002
1309
|
assert_equal expected, actual
|
1310
|
+
|
1311
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1312
|
+
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
1313
|
+
assert_equal expected, actual
|
1003
1314
|
end
|
1004
1315
|
|
1005
1316
|
def test_indepimage_with_metric2
|
@@ -1017,6 +1328,10 @@ EOS
|
|
1017
1328
|
\\end{reviewimage}
|
1018
1329
|
EOS
|
1019
1330
|
assert_equal expected, actual
|
1331
|
+
|
1332
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1333
|
+
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
|
1334
|
+
assert_equal expected, actual
|
1020
1335
|
end
|
1021
1336
|
|
1022
1337
|
def test_indepimage_without_caption_but_with_metric
|
@@ -1034,6 +1349,35 @@ EOS
|
|
1034
1349
|
\\end{reviewimage}
|
1035
1350
|
EOS
|
1036
1351
|
assert_equal expected, actual
|
1352
|
+
|
1353
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1354
|
+
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
1355
|
+
assert_equal expected, actual
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
def test_indepimage_nofile
|
1359
|
+
def @chapter.image(_id)
|
1360
|
+
item = Book::Index::Item.new('sample_img_nofile_', 1)
|
1361
|
+
item.instance_eval do
|
1362
|
+
def path
|
1363
|
+
nil
|
1364
|
+
end
|
1365
|
+
end
|
1366
|
+
item
|
1367
|
+
end
|
1368
|
+
|
1369
|
+
io = StringIO.new
|
1370
|
+
@builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
1371
|
+
|
1372
|
+
actual = compile_block("//indepimage[sample_img_nofile_][sample photo]\n")
|
1373
|
+
expected = <<-EOS
|
1374
|
+
\\begin{reviewdummyimage}
|
1375
|
+
--[[path = sample\\textunderscore{}img\\textunderscore{}nofile\\textunderscore{} (not exist)]]--
|
1376
|
+
\\reviewindepimagecaption{図: sample photo}
|
1377
|
+
\\end{reviewdummyimage}
|
1378
|
+
EOS
|
1379
|
+
assert_equal expected, actual
|
1380
|
+
assert_match(/WARN --: :1: image not bound: sample_img_nofile_/, io.string)
|
1037
1381
|
end
|
1038
1382
|
|
1039
1383
|
def test_table
|
@@ -1060,27 +1404,52 @@ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
|
1060
1404
|
\\end{table}
|
1061
1405
|
EOS
|
1062
1406
|
assert_equal expected, actual
|
1063
|
-
end
|
1064
|
-
|
1065
|
-
def test_empty_table
|
1066
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
|
1067
|
-
assert_equal ':2: error: no rows in the table', e.message
|
1068
1407
|
|
1069
|
-
|
1070
|
-
assert_equal ':3: error: no rows in the table', e.message
|
1071
|
-
end
|
1072
|
-
|
1073
|
-
def test_customize_cellwidth
|
1074
|
-
actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
1408
|
+
actual = compile_block("//table[foo][]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1075
1409
|
expected = <<-EOS
|
1076
|
-
\\begin{reviewtable}{|
|
1410
|
+
\\begin{reviewtable}{|l|l|}
|
1077
1411
|
\\hline
|
1078
|
-
\\reviewth{
|
1412
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
1413
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
1079
1414
|
\\end{reviewtable}
|
1080
1415
|
EOS
|
1081
1416
|
assert_equal expected, actual
|
1082
1417
|
|
1083
|
-
|
1418
|
+
@config['caption_position']['table'] = 'bottom'
|
1419
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1420
|
+
expected = <<-EOS
|
1421
|
+
\\begin{table}%%foo
|
1422
|
+
\\begin{reviewtable}{|l|l|}
|
1423
|
+
\\hline
|
1424
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
1425
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
1426
|
+
\\end{reviewtable}
|
1427
|
+
\\reviewtablecaption{FOO}
|
1428
|
+
\\label{table:chap1:foo}
|
1429
|
+
\\end{table}
|
1430
|
+
EOS
|
1431
|
+
assert_equal expected, actual
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
def test_empty_table
|
1435
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
1436
|
+
assert_equal ':2: error: no rows in the table', e.message
|
1437
|
+
|
1438
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
1439
|
+
assert_equal ':3: error: no rows in the table', e.message
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
def test_customize_cellwidth
|
1443
|
+
actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
1444
|
+
expected = <<-EOS
|
1445
|
+
\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
|
1446
|
+
\\hline
|
1447
|
+
\\reviewth{A} & B & C \\\\ \\hline
|
1448
|
+
\\end{reviewtable}
|
1449
|
+
EOS
|
1450
|
+
assert_equal expected, actual
|
1451
|
+
|
1452
|
+
actual = compile_block("//tsize[|latex,html|2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
1084
1453
|
expected = <<-EOS
|
1085
1454
|
\\begin{reviewtable}{|p{2mm}|p{3mm}|p{5mm}|}
|
1086
1455
|
\\hline
|
@@ -1164,6 +1533,26 @@ ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
|
1164
1533
|
\\end{reviewtable}
|
1165
1534
|
\\end{table}
|
1166
1535
|
|
1536
|
+
\\begin{reviewtable}{|l|l|}
|
1537
|
+
\\hline
|
1538
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
1539
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
1540
|
+
\\end{reviewtable}
|
1541
|
+
EOS
|
1542
|
+
assert_equal expected, actual
|
1543
|
+
|
1544
|
+
@config['caption_position']['table'] = 'bottom'
|
1545
|
+
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
1546
|
+
expected = <<-EOS
|
1547
|
+
\\begin{table}%%
|
1548
|
+
\\begin{reviewtable}{|l|l|}
|
1549
|
+
\\hline
|
1550
|
+
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
1551
|
+
ccc & ddd\\textless{}\\textgreater{}\\& \\\\ \\hline
|
1552
|
+
\\end{reviewtable}
|
1553
|
+
\\reviewtablecaption*{foo}
|
1554
|
+
\\end{table}
|
1555
|
+
|
1167
1556
|
\\begin{reviewtable}{|l|l|}
|
1168
1557
|
\\hline
|
1169
1558
|
\\reviewth{aaa} & \\reviewth{bbb} \\\\ \\hline
|
@@ -1190,6 +1579,120 @@ EOS
|
|
1190
1579
|
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
1191
1580
|
\\end{reviewimage}
|
1192
1581
|
\\end{table}
|
1582
|
+
EOS
|
1583
|
+
assert_equal expected, actual
|
1584
|
+
|
1585
|
+
actual = compile_block("//imgtable[sampleimg][]{\n//}\n")
|
1586
|
+
expected = <<-EOS
|
1587
|
+
\\label{table:chap1:sampleimg}
|
1588
|
+
\\begin{reviewimage}%%sampleimg
|
1589
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
1590
|
+
\\end{reviewimage}
|
1591
|
+
EOS
|
1592
|
+
assert_equal expected, actual
|
1593
|
+
|
1594
|
+
actual = compile_block("//imgtable[sampleimg][][]{\n//}\n")
|
1595
|
+
assert_equal expected, actual
|
1596
|
+
|
1597
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1598
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
1599
|
+
|
1600
|
+
expected = <<-EOS
|
1601
|
+
\\begin{table}[h]%%sampleimg
|
1602
|
+
\\reviewimgtablecaption{test for imgtable}
|
1603
|
+
\\label{table:chap1:sampleimg}
|
1604
|
+
\\begin{reviewimage}%%sampleimg
|
1605
|
+
\\reviewincludegraphics[ ]{./images/chap1-sampleimg.png}
|
1606
|
+
\\end{reviewimage}
|
1607
|
+
\\end{table}
|
1608
|
+
EOS
|
1609
|
+
assert_equal expected, actual
|
1610
|
+
|
1611
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable][]{\n//}\n")
|
1612
|
+
assert_equal expected, actual
|
1613
|
+
|
1614
|
+
@book.config['pdfmaker']['use_original_image_size'] = nil
|
1615
|
+
@config['caption_position']['table'] = 'bottom'
|
1616
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
1617
|
+
|
1618
|
+
expected = <<-EOS
|
1619
|
+
\\begin{table}[h]%%sampleimg
|
1620
|
+
\\label{table:chap1:sampleimg}
|
1621
|
+
\\begin{reviewimage}%%sampleimg
|
1622
|
+
\\reviewincludegraphics[width=\\maxwidth]{./images/chap1-sampleimg.png}
|
1623
|
+
\\end{reviewimage}
|
1624
|
+
\\reviewimgtablecaption{test for imgtable}
|
1625
|
+
\\end{table}
|
1626
|
+
EOS
|
1627
|
+
assert_equal expected, actual
|
1628
|
+
end
|
1629
|
+
|
1630
|
+
def test_imgtable_with_metrics
|
1631
|
+
def @chapter.image(_id)
|
1632
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
|
1633
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
1634
|
+
item
|
1635
|
+
end
|
1636
|
+
|
1637
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n")
|
1638
|
+
expected = <<-EOS
|
1639
|
+
\\begin{table}[h]%%sampleimg
|
1640
|
+
\\reviewimgtablecaption{test for imgtable}
|
1641
|
+
\\label{table:chap1:sampleimg}
|
1642
|
+
\\begin{reviewimage}%%sampleimg
|
1643
|
+
\\reviewincludegraphics[scale=1.2]{./images/chap1-sampleimg.png}
|
1644
|
+
\\end{reviewimage}
|
1645
|
+
\\end{table}
|
1646
|
+
EOS
|
1647
|
+
assert_equal expected, actual
|
1648
|
+
|
1649
|
+
@book.config['pdfmaker']['use_original_image_size'] = true
|
1650
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable][scale=1.2]{\n//}\n")
|
1651
|
+
assert_equal expected, actual
|
1652
|
+
end
|
1653
|
+
|
1654
|
+
def test_table_row_separator
|
1655
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
1656
|
+
expected = <<-EOS
|
1657
|
+
\\begin{reviewtable}{|l|l|l|}
|
1658
|
+
\\hline
|
1659
|
+
\\reviewth{1} & \\reviewth{2} & \\reviewth{3 4\\textbar{} 5} \\\\ \\hline
|
1660
|
+
a b & c d \\textbar{}e & \\\\ \\hline
|
1661
|
+
\\end{reviewtable}
|
1662
|
+
EOS
|
1663
|
+
actual = compile_block(src)
|
1664
|
+
assert_equal expected, actual
|
1665
|
+
|
1666
|
+
@config['table_row_separator'] = 'singletab'
|
1667
|
+
actual = compile_block(src)
|
1668
|
+
expected = <<-EOS
|
1669
|
+
\\begin{reviewtable}{|l|l|l|l|}
|
1670
|
+
\\hline
|
1671
|
+
\\reviewth{1} & \\reviewth{2} & \\reviewth{} & \\reviewth{3 4\\textbar{} 5} \\\\ \\hline
|
1672
|
+
a b & c d \\textbar{}e & & \\\\ \\hline
|
1673
|
+
\\end{reviewtable}
|
1674
|
+
EOS
|
1675
|
+
assert_equal expected, actual
|
1676
|
+
|
1677
|
+
@config['table_row_separator'] = 'spaces'
|
1678
|
+
actual = compile_block(src)
|
1679
|
+
expected = <<-EOS
|
1680
|
+
\\begin{reviewtable}{|l|l|l|l|l|}
|
1681
|
+
\\hline
|
1682
|
+
\\reviewth{1} & \\reviewth{2} & \\reviewth{3} & \\reviewth{4\\textbar{}} & \\reviewth{5} \\\\ \\hline
|
1683
|
+
a & b & c & d & \\textbar{}e \\\\ \\hline
|
1684
|
+
\\end{reviewtable}
|
1685
|
+
EOS
|
1686
|
+
assert_equal expected, actual
|
1687
|
+
|
1688
|
+
@config['table_row_separator'] = 'verticalbar'
|
1689
|
+
actual = compile_block(src)
|
1690
|
+
expected = <<-EOS
|
1691
|
+
\\begin{reviewtable}{|l|l|}
|
1692
|
+
\\hline
|
1693
|
+
\\reviewth{1 2 3 4} & \\reviewth{5} \\\\ \\hline
|
1694
|
+
a b c d & e \\\\ \\hline
|
1695
|
+
\\end{reviewtable}
|
1193
1696
|
EOS
|
1194
1697
|
assert_equal expected, actual
|
1195
1698
|
end
|
@@ -1501,12 +2004,16 @@ EOS
|
|
1501
2004
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
1502
2005
|
expected = <<-EOS
|
1503
2006
|
\\begin{reviewnote}
|
2007
|
+
|
1504
2008
|
A
|
1505
2009
|
|
1506
2010
|
B
|
2011
|
+
|
1507
2012
|
\\end{reviewnote}
|
1508
2013
|
\\begin{reviewnote}[caption]
|
2014
|
+
|
1509
2015
|
A
|
2016
|
+
|
1510
2017
|
\\end{reviewnote}
|
1511
2018
|
EOS
|
1512
2019
|
assert_equal expected, actual
|
@@ -1514,12 +2021,16 @@ EOS
|
|
1514
2021
|
actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
|
1515
2022
|
expected = <<-EOS
|
1516
2023
|
\\begin{reviewmemo}
|
2024
|
+
|
1517
2025
|
A
|
1518
2026
|
|
1519
2027
|
B
|
2028
|
+
|
1520
2029
|
\\end{reviewmemo}
|
1521
2030
|
\\begin{reviewmemo}[caption]
|
2031
|
+
|
1522
2032
|
A
|
2033
|
+
|
1523
2034
|
\\end{reviewmemo}
|
1524
2035
|
EOS
|
1525
2036
|
assert_equal expected, actual
|
@@ -1527,12 +2038,16 @@ EOS
|
|
1527
2038
|
actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
|
1528
2039
|
expected = <<-EOS
|
1529
2040
|
\\begin{reviewinfo}
|
2041
|
+
|
1530
2042
|
A
|
1531
2043
|
|
1532
2044
|
B
|
2045
|
+
|
1533
2046
|
\\end{reviewinfo}
|
1534
2047
|
\\begin{reviewinfo}[caption]
|
2048
|
+
|
1535
2049
|
A
|
2050
|
+
|
1536
2051
|
\\end{reviewinfo}
|
1537
2052
|
EOS
|
1538
2053
|
assert_equal expected, actual
|
@@ -1540,12 +2055,16 @@ EOS
|
|
1540
2055
|
actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
|
1541
2056
|
expected = <<-EOS
|
1542
2057
|
\\begin{reviewimportant}
|
2058
|
+
|
1543
2059
|
A
|
1544
2060
|
|
1545
2061
|
B
|
2062
|
+
|
1546
2063
|
\\end{reviewimportant}
|
1547
2064
|
\\begin{reviewimportant}[caption]
|
2065
|
+
|
1548
2066
|
A
|
2067
|
+
|
1549
2068
|
\\end{reviewimportant}
|
1550
2069
|
EOS
|
1551
2070
|
assert_equal expected, actual
|
@@ -1553,12 +2072,16 @@ EOS
|
|
1553
2072
|
actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
|
1554
2073
|
expected = <<-EOS
|
1555
2074
|
\\begin{reviewcaution}
|
2075
|
+
|
1556
2076
|
A
|
1557
2077
|
|
1558
2078
|
B
|
2079
|
+
|
1559
2080
|
\\end{reviewcaution}
|
1560
2081
|
\\begin{reviewcaution}[caption]
|
2082
|
+
|
1561
2083
|
A
|
2084
|
+
|
1562
2085
|
\\end{reviewcaution}
|
1563
2086
|
EOS
|
1564
2087
|
assert_equal expected, actual
|
@@ -1566,12 +2089,16 @@ EOS
|
|
1566
2089
|
actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
|
1567
2090
|
expected = <<-EOS
|
1568
2091
|
\\begin{reviewnotice}
|
2092
|
+
|
1569
2093
|
A
|
1570
2094
|
|
1571
2095
|
B
|
2096
|
+
|
1572
2097
|
\\end{reviewnotice}
|
1573
2098
|
\\begin{reviewnotice}[caption]
|
2099
|
+
|
1574
2100
|
A
|
2101
|
+
|
1575
2102
|
\\end{reviewnotice}
|
1576
2103
|
EOS
|
1577
2104
|
assert_equal expected, actual
|
@@ -1579,12 +2106,16 @@ EOS
|
|
1579
2106
|
actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
|
1580
2107
|
expected = <<-EOS
|
1581
2108
|
\\begin{reviewwarning}
|
2109
|
+
|
1582
2110
|
A
|
1583
2111
|
|
1584
2112
|
B
|
2113
|
+
|
1585
2114
|
\\end{reviewwarning}
|
1586
2115
|
\\begin{reviewwarning}[caption]
|
2116
|
+
|
1587
2117
|
A
|
2118
|
+
|
1588
2119
|
\\end{reviewwarning}
|
1589
2120
|
EOS
|
1590
2121
|
assert_equal expected, actual
|
@@ -1592,17 +2123,173 @@ EOS
|
|
1592
2123
|
actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
|
1593
2124
|
expected = <<-EOS
|
1594
2125
|
\\begin{reviewtip}
|
2126
|
+
|
1595
2127
|
A
|
1596
2128
|
|
1597
2129
|
B
|
2130
|
+
|
1598
2131
|
\\end{reviewtip}
|
1599
2132
|
\\begin{reviewtip}[caption]
|
2133
|
+
|
1600
2134
|
A
|
2135
|
+
|
1601
2136
|
\\end{reviewtip}
|
1602
2137
|
EOS
|
1603
2138
|
assert_equal expected, actual
|
1604
2139
|
end
|
1605
2140
|
|
2141
|
+
def test_minicolumn_blocks
|
2142
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2143
|
+
src = <<-EOS
|
2144
|
+
//#{type}[#{type}1]{
|
2145
|
+
|
2146
|
+
//}
|
2147
|
+
|
2148
|
+
//#{type}[#{type}2]{
|
2149
|
+
//}
|
2150
|
+
EOS
|
2151
|
+
|
2152
|
+
expected = <<-EOS
|
2153
|
+
\\begin{review#{type}}[#{type}1]
|
2154
|
+
\\end{review#{type}}
|
2155
|
+
\\begin{review#{type}}[#{type}2]
|
2156
|
+
\\end{review#{type}}
|
2157
|
+
EOS
|
2158
|
+
assert_equal expected, compile_block(src)
|
2159
|
+
|
2160
|
+
src = <<-EOS
|
2161
|
+
//#{type}[#{type}2]{
|
2162
|
+
|
2163
|
+
//}
|
2164
|
+
|
2165
|
+
//#{type}[#{type}3]{
|
2166
|
+
|
2167
|
+
//}
|
2168
|
+
|
2169
|
+
//#{type}[#{type}4]{
|
2170
|
+
|
2171
|
+
//}
|
2172
|
+
|
2173
|
+
//#{type}[#{type}5]{
|
2174
|
+
|
2175
|
+
//}
|
2176
|
+
|
2177
|
+
//#{type}[#{type}6]{
|
2178
|
+
|
2179
|
+
//}
|
2180
|
+
EOS
|
2181
|
+
|
2182
|
+
expected = <<-EOS
|
2183
|
+
\\begin{review#{type}}[#{type}2]
|
2184
|
+
\\end{review#{type}}
|
2185
|
+
\\begin{review#{type}}[#{type}3]
|
2186
|
+
\\end{review#{type}}
|
2187
|
+
\\begin{review#{type}}[#{type}4]
|
2188
|
+
\\end{review#{type}}
|
2189
|
+
\\begin{review#{type}}[#{type}5]
|
2190
|
+
\\end{review#{type}}
|
2191
|
+
\\begin{review#{type}}[#{type}6]
|
2192
|
+
\\end{review#{type}}
|
2193
|
+
EOS
|
2194
|
+
assert_equal expected, compile_block(src)
|
2195
|
+
|
2196
|
+
src = <<-EOS
|
2197
|
+
//#{type}{
|
2198
|
+
|
2199
|
+
* A
|
2200
|
+
|
2201
|
+
1. B
|
2202
|
+
|
2203
|
+
//}
|
2204
|
+
|
2205
|
+
//#{type}[OMITEND1]{
|
2206
|
+
|
2207
|
+
//emlist{
|
2208
|
+
LIST
|
2209
|
+
//}
|
2210
|
+
|
2211
|
+
//}
|
2212
|
+
//#{type}[OMITEND2]{
|
2213
|
+
//}
|
2214
|
+
EOS
|
2215
|
+
|
2216
|
+
expected = <<-EOS
|
2217
|
+
\\begin{review#{type}}
|
2218
|
+
|
2219
|
+
\\begin{itemize}
|
2220
|
+
\\item A
|
2221
|
+
\\end{itemize}
|
2222
|
+
|
2223
|
+
\\begin{enumerate}
|
2224
|
+
\\item B
|
2225
|
+
\\end{enumerate}
|
2226
|
+
|
2227
|
+
\\end{review#{type}}
|
2228
|
+
\\begin{review#{type}}[OMITEND1]
|
2229
|
+
|
2230
|
+
\\begin{reviewlistblock}
|
2231
|
+
\\begin{reviewemlist}
|
2232
|
+
LIST
|
2233
|
+
\\end{reviewemlist}
|
2234
|
+
\\end{reviewlistblock}
|
2235
|
+
|
2236
|
+
\\end{review#{type}}
|
2237
|
+
\\begin{review#{type}}[OMITEND2]
|
2238
|
+
\\end{review#{type}}
|
2239
|
+
EOS
|
2240
|
+
assert_equal expected, compile_block(src)
|
2241
|
+
end
|
2242
|
+
end
|
2243
|
+
|
2244
|
+
def test_minicolumn_blocks_nest_error1
|
2245
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2246
|
+
@builder.doc_status.clear
|
2247
|
+
src = <<-EOS
|
2248
|
+
//#{type}{
|
2249
|
+
|
2250
|
+
//#{type}{
|
2251
|
+
//}
|
2252
|
+
|
2253
|
+
//}
|
2254
|
+
EOS
|
2255
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2256
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2257
|
+
end
|
2258
|
+
end
|
2259
|
+
|
2260
|
+
def test_minicolumn_blocks_nest_error2
|
2261
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2262
|
+
@builder.doc_status.clear
|
2263
|
+
src = <<-EOS
|
2264
|
+
//#{type}{
|
2265
|
+
|
2266
|
+
//#{type}{
|
2267
|
+
|
2268
|
+
//}
|
2269
|
+
|
2270
|
+
//}
|
2271
|
+
EOS
|
2272
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2273
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2274
|
+
end
|
2275
|
+
end
|
2276
|
+
|
2277
|
+
def test_minicolumn_blocks_nest_error3
|
2278
|
+
%w[memo tip info warning important caution notice].each do |type|
|
2279
|
+
@builder.doc_status.clear
|
2280
|
+
src = <<-EOS
|
2281
|
+
//#{type}{
|
2282
|
+
|
2283
|
+
//note{
|
2284
|
+
//}
|
2285
|
+
|
2286
|
+
//}
|
2287
|
+
EOS
|
2288
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2289
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2290
|
+
end
|
2291
|
+
end
|
2292
|
+
|
1606
2293
|
def test_inline_raw0
|
1607
2294
|
assert_equal 'normal', compile_inline('@<raw>{normal}')
|
1608
2295
|
end
|
@@ -1728,7 +2415,7 @@ EOB
|
|
1728
2415
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
1729
2416
|
|
1730
2417
|
io = StringIO.new
|
1731
|
-
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
2418
|
+
@builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
1732
2419
|
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
1733
2420
|
expected = <<-EOS
|
1734
2421
|
|
@@ -1740,18 +2427,18 @@ EOS
|
|
1740
2427
|
end
|
1741
2428
|
|
1742
2429
|
def test_inline_unknown
|
1743
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2430
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1744
2431
|
assert_equal ':1: error: unknown image: n', e.message
|
1745
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2432
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1746
2433
|
assert_equal ':1: error: unknown footnote: n', e.message
|
1747
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2434
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1748
2435
|
assert_equal ':1: error: unknown headline: n', e.message
|
1749
2436
|
%w[list table column].each do |name|
|
1750
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2437
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1751
2438
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
1752
2439
|
end
|
1753
2440
|
%w[chap chapref title].each do |name|
|
1754
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2441
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1755
2442
|
assert_equal ':1: error: key not found: "n"', e.message
|
1756
2443
|
end
|
1757
2444
|
end
|
@@ -1879,5 +2566,344 @@ e=mc^2
|
|
1879
2566
|
EOS
|
1880
2567
|
actual = compile_block(src)
|
1881
2568
|
assert_equal expected, actual
|
2569
|
+
|
2570
|
+
@config['caption_position']['equation'] = 'bottom'
|
2571
|
+
expected = <<-EOS
|
2572
|
+
|
2573
|
+
\\reviewequationref{1.1}
|
2574
|
+
|
2575
|
+
\\begin{reviewequationblock}
|
2576
|
+
\\begin{equation*}
|
2577
|
+
e=mc^2
|
2578
|
+
\\end{equation*}
|
2579
|
+
\\reviewequationcaption{式1.1: The Equivalence of Mass \\reviewit{and} Energy}
|
2580
|
+
\\end{reviewequationblock}
|
2581
|
+
EOS
|
2582
|
+
actual = compile_block(src)
|
2583
|
+
assert_equal expected, actual
|
2584
|
+
end
|
2585
|
+
|
2586
|
+
def test_nest_error_close1
|
2587
|
+
src = <<-EOS
|
2588
|
+
//beginchild
|
2589
|
+
EOS
|
2590
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2591
|
+
assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
2592
|
+
end
|
2593
|
+
|
2594
|
+
def test_nest_error_close2
|
2595
|
+
src = <<-EOS
|
2596
|
+
* foo
|
2597
|
+
|
2598
|
+
//beginchild
|
2599
|
+
|
2600
|
+
1. foo
|
2601
|
+
|
2602
|
+
//beginchild
|
2603
|
+
|
2604
|
+
: foo
|
2605
|
+
|
2606
|
+
//beginchild
|
2607
|
+
EOS
|
2608
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2609
|
+
assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
|
2610
|
+
end
|
2611
|
+
|
2612
|
+
def test_nest_error_close3
|
2613
|
+
src = <<-EOS
|
2614
|
+
* foo
|
2615
|
+
|
2616
|
+
//beginchild
|
2617
|
+
|
2618
|
+
1. foo
|
2619
|
+
|
2620
|
+
//beginchild
|
2621
|
+
|
2622
|
+
: foo
|
2623
|
+
|
2624
|
+
//beginchild
|
2625
|
+
|
2626
|
+
//endchild
|
2627
|
+
EOS
|
2628
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2629
|
+
assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
|
2630
|
+
end
|
2631
|
+
|
2632
|
+
def test_nest_ul
|
2633
|
+
src = <<-EOS
|
2634
|
+
* UL1
|
2635
|
+
|
2636
|
+
//beginchild
|
2637
|
+
|
2638
|
+
1. UL1-OL1
|
2639
|
+
2. UL1-OL2
|
2640
|
+
|
2641
|
+
* UL1-UL1
|
2642
|
+
* UL1-UL2
|
2643
|
+
|
2644
|
+
: UL1-DL1
|
2645
|
+
UL1-DD1
|
2646
|
+
: UL1-DL2
|
2647
|
+
UL1-DD2
|
2648
|
+
|
2649
|
+
//endchild
|
2650
|
+
|
2651
|
+
* UL2
|
2652
|
+
|
2653
|
+
//beginchild
|
2654
|
+
|
2655
|
+
UL2-PARA
|
2656
|
+
|
2657
|
+
//endchild
|
2658
|
+
EOS
|
2659
|
+
|
2660
|
+
expected = <<-EOS
|
2661
|
+
|
2662
|
+
\\begin{itemize}
|
2663
|
+
\\item UL1
|
2664
|
+
|
2665
|
+
|
2666
|
+
\\begin{enumerate}
|
2667
|
+
\\item UL1{-}OL1
|
2668
|
+
\\item UL1{-}OL2
|
2669
|
+
\\end{enumerate}
|
2670
|
+
|
2671
|
+
\\begin{itemize}
|
2672
|
+
\\item UL1{-}UL1
|
2673
|
+
\\item UL1{-}UL2
|
2674
|
+
\\end{itemize}
|
2675
|
+
|
2676
|
+
\\begin{description}
|
2677
|
+
\\item[UL1{-}DL1] \\mbox{} \\\\
|
2678
|
+
UL1{-}DD1
|
2679
|
+
\\item[UL1{-}DL2] \\mbox{} \\\\
|
2680
|
+
UL1{-}DD2
|
2681
|
+
\\end{description}
|
2682
|
+
|
2683
|
+
|
2684
|
+
\\item UL2
|
2685
|
+
|
2686
|
+
|
2687
|
+
UL2{-}PARA
|
2688
|
+
|
2689
|
+
\\end{itemize}
|
2690
|
+
EOS
|
2691
|
+
|
2692
|
+
actual = compile_block(src)
|
2693
|
+
assert_equal expected, actual
|
2694
|
+
end
|
2695
|
+
|
2696
|
+
def test_nest_ol
|
2697
|
+
src = <<-EOS
|
2698
|
+
1. OL1
|
2699
|
+
|
2700
|
+
//beginchild
|
2701
|
+
|
2702
|
+
1. OL1-OL1
|
2703
|
+
2. OL1-OL2
|
2704
|
+
|
2705
|
+
* OL1-UL1
|
2706
|
+
* OL1-UL2
|
2707
|
+
|
2708
|
+
: OL1-DL1
|
2709
|
+
OL1-DD1
|
2710
|
+
: OL1-DL2
|
2711
|
+
OL1-DD2
|
2712
|
+
|
2713
|
+
//endchild
|
2714
|
+
|
2715
|
+
2. OL2
|
2716
|
+
|
2717
|
+
//beginchild
|
2718
|
+
|
2719
|
+
OL2-PARA
|
2720
|
+
|
2721
|
+
//endchild
|
2722
|
+
EOS
|
2723
|
+
|
2724
|
+
expected = <<-EOS
|
2725
|
+
|
2726
|
+
\\begin{enumerate}
|
2727
|
+
\\item OL1
|
2728
|
+
|
2729
|
+
|
2730
|
+
\\begin{enumerate}
|
2731
|
+
\\item OL1{-}OL1
|
2732
|
+
\\item OL1{-}OL2
|
2733
|
+
\\end{enumerate}
|
2734
|
+
|
2735
|
+
\\begin{itemize}
|
2736
|
+
\\item OL1{-}UL1
|
2737
|
+
\\item OL1{-}UL2
|
2738
|
+
\\end{itemize}
|
2739
|
+
|
2740
|
+
\\begin{description}
|
2741
|
+
\\item[OL1{-}DL1] \\mbox{} \\\\
|
2742
|
+
OL1{-}DD1
|
2743
|
+
\\item[OL1{-}DL2] \\mbox{} \\\\
|
2744
|
+
OL1{-}DD2
|
2745
|
+
\\end{description}
|
2746
|
+
|
2747
|
+
|
2748
|
+
\\item OL2
|
2749
|
+
|
2750
|
+
|
2751
|
+
OL2{-}PARA
|
2752
|
+
|
2753
|
+
\\end{enumerate}
|
2754
|
+
EOS
|
2755
|
+
|
2756
|
+
actual = compile_block(src)
|
2757
|
+
assert_equal expected, actual
|
2758
|
+
end
|
2759
|
+
|
2760
|
+
def test_nest_dl
|
2761
|
+
src = <<-EOS
|
2762
|
+
: DL1
|
2763
|
+
|
2764
|
+
//beginchild
|
2765
|
+
|
2766
|
+
1. DL1-OL1
|
2767
|
+
2. DL1-OL2
|
2768
|
+
|
2769
|
+
* DL1-UL1
|
2770
|
+
* DL1-UL2
|
2771
|
+
|
2772
|
+
: DL1-DL1
|
2773
|
+
DL1-DD1
|
2774
|
+
: DL1-DL2
|
2775
|
+
DL1-DD2
|
2776
|
+
|
2777
|
+
//endchild
|
2778
|
+
|
2779
|
+
: DL2
|
2780
|
+
DD2
|
2781
|
+
|
2782
|
+
//beginchild
|
2783
|
+
|
2784
|
+
* DD2-UL1
|
2785
|
+
* DD2-UL2
|
2786
|
+
|
2787
|
+
DD2-PARA
|
2788
|
+
|
2789
|
+
//endchild
|
2790
|
+
EOS
|
2791
|
+
|
2792
|
+
expected = <<-EOS
|
2793
|
+
|
2794
|
+
\\begin{description}
|
2795
|
+
\\item[DL1] \\mbox{} \\\\
|
2796
|
+
|
2797
|
+
|
2798
|
+
|
2799
|
+
\\begin{enumerate}
|
2800
|
+
\\item DL1{-}OL1
|
2801
|
+
\\item DL1{-}OL2
|
2802
|
+
\\end{enumerate}
|
2803
|
+
|
2804
|
+
\\begin{itemize}
|
2805
|
+
\\item DL1{-}UL1
|
2806
|
+
\\item DL1{-}UL2
|
2807
|
+
\\end{itemize}
|
2808
|
+
|
2809
|
+
\\begin{description}
|
2810
|
+
\\item[DL1{-}DL1] \\mbox{} \\\\
|
2811
|
+
DL1{-}DD1
|
2812
|
+
\\item[DL1{-}DL2] \\mbox{} \\\\
|
2813
|
+
DL1{-}DD2
|
2814
|
+
\\end{description}
|
2815
|
+
|
2816
|
+
|
2817
|
+
\\item[DL2] \\mbox{} \\\\
|
2818
|
+
DD2
|
2819
|
+
|
2820
|
+
|
2821
|
+
\\begin{itemize}
|
2822
|
+
\\item DD2{-}UL1
|
2823
|
+
\\item DD2{-}UL2
|
2824
|
+
\\end{itemize}
|
2825
|
+
|
2826
|
+
DD2{-}PARA
|
2827
|
+
|
2828
|
+
\\end{description}
|
2829
|
+
EOS
|
2830
|
+
|
2831
|
+
actual = compile_block(src)
|
2832
|
+
assert_equal expected, actual
|
2833
|
+
end
|
2834
|
+
|
2835
|
+
def test_nest_multi
|
2836
|
+
src = <<-EOS
|
2837
|
+
1. OL1
|
2838
|
+
|
2839
|
+
//beginchild
|
2840
|
+
|
2841
|
+
1. OL1-OL1
|
2842
|
+
|
2843
|
+
//beginchild
|
2844
|
+
|
2845
|
+
* OL1-OL1-UL1
|
2846
|
+
|
2847
|
+
OL1-OL1-PARA
|
2848
|
+
|
2849
|
+
//endchild
|
2850
|
+
|
2851
|
+
2. OL1-OL2
|
2852
|
+
|
2853
|
+
* OL1-UL1
|
2854
|
+
|
2855
|
+
//beginchild
|
2856
|
+
|
2857
|
+
: OL1-UL1-DL1
|
2858
|
+
OL1-UL1-DD1
|
2859
|
+
|
2860
|
+
OL1-UL1-PARA
|
2861
|
+
|
2862
|
+
//endchild
|
2863
|
+
|
2864
|
+
* OL1-UL2
|
2865
|
+
|
2866
|
+
//endchild
|
2867
|
+
EOS
|
2868
|
+
expected = <<-EOS
|
2869
|
+
|
2870
|
+
\\begin{enumerate}
|
2871
|
+
\\item OL1
|
2872
|
+
|
2873
|
+
|
2874
|
+
\\begin{enumerate}
|
2875
|
+
\\item OL1{-}OL1
|
2876
|
+
|
2877
|
+
|
2878
|
+
\\begin{itemize}
|
2879
|
+
\\item OL1{-}OL1{-}UL1
|
2880
|
+
\\end{itemize}
|
2881
|
+
|
2882
|
+
OL1{-}OL1{-}PARA
|
2883
|
+
|
2884
|
+
|
2885
|
+
\\item OL1{-}OL2
|
2886
|
+
\\end{enumerate}
|
2887
|
+
|
2888
|
+
\\begin{itemize}
|
2889
|
+
\\item OL1{-}UL1
|
2890
|
+
|
2891
|
+
|
2892
|
+
\\begin{description}
|
2893
|
+
\\item[OL1{-}UL1{-}DL1] \\mbox{} \\\\
|
2894
|
+
OL1{-}UL1{-}DD1
|
2895
|
+
\\end{description}
|
2896
|
+
|
2897
|
+
OL1{-}UL1{-}PARA
|
2898
|
+
|
2899
|
+
|
2900
|
+
\\item OL1{-}UL2
|
2901
|
+
\\end{itemize}
|
2902
|
+
|
2903
|
+
\\end{enumerate}
|
2904
|
+
EOS
|
2905
|
+
|
2906
|
+
actual = compile_block(src)
|
2907
|
+
assert_equal expected, actual
|
1882
2908
|
end
|
1883
2909
|
end
|