review 4.0.0 → 4.1.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-win.yml +39 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +10 -7
- data/Dockerfile +21 -5
- data/NEWS.ja.md +101 -1
- data/NEWS.md +102 -2
- data/README.md +10 -7
- data/appveyor.yml +0 -20
- data/bin/review-compile +1 -1
- data/bin/review-validate +1 -1
- data/doc/config.yml.sample +12 -1
- data/doc/config.yml.sample-simple +1 -0
- data/doc/format.ja.md +16 -4
- data/doc/format.md +2 -1
- data/doc/quickstart.ja.md +40 -23
- data/doc/quickstart.md +33 -15
- data/lib/review/book/base.rb +8 -7
- data/lib/review/book/index.rb +50 -56
- data/lib/review/book/index/item.rb +1 -1
- data/lib/review/builder.rb +26 -4
- data/lib/review/compiler.rb +6 -3
- data/lib/review/configure.rb +5 -3
- data/lib/review/epubmaker.rb +15 -2
- data/lib/review/extentions/string.rb +0 -4
- data/lib/review/htmlbuilder.rb +4 -15
- data/lib/review/idgxmlbuilder.rb +10 -19
- data/lib/review/idgxmlmaker.rb +10 -3
- data/lib/review/init.rb +8 -1
- data/lib/review/latexbuilder.rb +13 -6
- data/lib/review/pdfmaker.rb +24 -9
- data/lib/review/rstbuilder.rb +2 -2
- data/lib/review/textmaker.rb +7 -1
- data/lib/review/tocparser.rb +6 -2
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +8 -1
- data/review.gemspec +2 -2
- data/samples/sample-book/src/.gitignore +1 -0
- data/samples/sample-book/src/config-ebook.yml +4 -0
- data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
- data/samples/sample-book/src/config.yml +1 -1
- data/samples/sample-book/src/lib/tasks/review.rake +10 -6
- data/samples/syntax-book/ch01.re +4 -2
- data/samples/syntax-book/ch02.re +8 -16
- 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/lib/tasks/review.rake +23 -8
- data/templates/latex/config.erb +6 -6
- data/templates/latex/review-jlreq/review-base.sty +14 -4
- data/templates/latex/review-jlreq/review-jlreq.cls +10 -1
- data/templates/latex/review-jlreq/review-style.sty +1 -1
- data/templates/latex/review-jsbook/review-base.sty +10 -0
- data/templates/latex/review-jsbook/review-jsbook.cls +1 -1
- data/templates/latex/review-jsbook/review-style.sty +1 -1
- data/test/assets/test_template.tex +6 -6
- data/test/assets/test_template_backmatter.tex +6 -6
- data/test/test_book.rb +8 -0
- data/test/test_book_chapter.rb +4 -2
- data/test/test_catalog.rb +1 -0
- data/test/test_epubmaker_cmd.rb +12 -5
- data/test/test_helper.rb +11 -6
- data/test/test_htmlbuilder.rb +80 -8
- data/test/test_idgxmlbuilder.rb +57 -2
- data/test/test_idgxmlmaker_cmd.rb +46 -0
- data/test/test_image_finder.rb +52 -70
- data/test/test_index.rb +12 -12
- data/test/test_latexbuilder.rb +171 -8
- data/test/test_latexbuilder_v2.rb +9 -7
- data/test/test_pdfmaker_cmd.rb +99 -5
- data/test/test_textmaker_cmd.rb +54 -0
- data/test/test_topbuilder.rb +59 -0
- data/vendor/jsclasses/LICENSE +1 -1
- data/vendor/jsclasses/jis/jsarticle.cls +53 -14
- data/vendor/jsclasses/jis/jsbook.cls +53 -14
- data/vendor/jsclasses/jis/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jis/jslogo.dtx +4 -4
- data/vendor/jsclasses/jis/jslogo.sty +3 -3
- data/vendor/jsclasses/jis/jspf.cls +52 -13
- data/vendor/jsclasses/jis/jsreport.cls +53 -14
- data/vendor/jsclasses/jis/kiyou.cls +53 -14
- data/vendor/jsclasses/jis/okumacro.dtx +4 -5
- data/vendor/jsclasses/jis/okumacro.sty +3 -4
- data/vendor/jsclasses/jsarticle.cls +53 -14
- data/vendor/jsclasses/jsbook.cls +53 -14
- data/vendor/jsclasses/jsclasses.dtx +84 -25
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.dtx +4 -4
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +3 -3
- data/vendor/jsclasses/jspf.cls +52 -13
- data/vendor/jsclasses/jsreport.cls +53 -14
- data/vendor/jsclasses/kiyou.cls +53 -14
- data/vendor/jsclasses/okumacro.dtx +4 -5
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +3 -4
- metadata +15 -6
- data/samples/syntax-book/review-ext.rb +0 -14
data/test/test_book.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'book_test_helper'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
class BookTest < Test::Unit::TestCase
|
4
5
|
include BookTestHelper
|
5
6
|
|
7
|
+
def setup
|
8
|
+
if ENV['GITHUB_WORKSPACE']
|
9
|
+
ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
|
10
|
+
FileUtils.mkdir_p(ENV['TMPDIR'])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
def assert_same_path(expected, result, *options)
|
7
15
|
require 'pathname'
|
8
16
|
ex_path = Pathname(expected).realpath
|
data/test/test_book_chapter.rb
CHANGED
@@ -37,11 +37,13 @@ class ChapterTest < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
def test_size
|
39
39
|
ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io)
|
40
|
-
|
40
|
+
filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
|
41
|
+
assert_equal filesize, ch.size
|
41
42
|
|
42
43
|
File.open(__FILE__, 'r') do |i|
|
43
44
|
ch = Book::Chapter.new(nil, nil, nil, nil, i)
|
44
|
-
|
45
|
+
filesize = IO.read(__FILE__, mode: 'rt:BOM|utf-8').size
|
46
|
+
assert_equal filesize, ch.size
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
data/test/test_catalog.rb
CHANGED
data/test/test_epubmaker_cmd.rb
CHANGED
@@ -21,18 +21,25 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
|
|
21
21
|
ENV['RUBYLIB'] = @old_rubylib
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def common_buildepub(bookdir, configfile, targetepubfile)
|
25
25
|
if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
|
26
|
-
config = prepare_samplebook(@tmpdir1)
|
26
|
+
config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
|
27
27
|
builddir = File.join(@tmpdir1, config['bookname'] + '-epub')
|
28
28
|
assert !File.exist?(builddir)
|
29
29
|
|
30
30
|
ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
|
31
31
|
Dir.chdir(@tmpdir1) do
|
32
|
-
system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER}
|
32
|
+
system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} #{configfile} 1>/dev/null 2>/dev/null")
|
33
33
|
end
|
34
|
-
|
35
|
-
assert File.exist?(builddir)
|
34
|
+
assert File.exist?(File.join(@tmpdir1, targetepubfile))
|
36
35
|
end
|
37
36
|
end
|
37
|
+
|
38
|
+
def test_epubmaker_cmd_samplebook
|
39
|
+
common_buildepub('sample-book/src', 'config.yml', 'book.epub')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_epubmaker_cmd_syntaxbook
|
43
|
+
common_buildepub('syntax-book', 'config.yml', 'syntax-book.epub')
|
44
|
+
end
|
38
45
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
|
2
2
|
require 'test/unit'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'review/yamlloader'
|
5
|
+
require 'review/extentions'
|
4
6
|
|
5
7
|
def touch_file(path)
|
6
8
|
FileUtils.touch(path)
|
@@ -10,13 +12,16 @@ def assets_dir
|
|
10
12
|
File.join(File.dirname(__FILE__), 'assets')
|
11
13
|
end
|
12
14
|
|
13
|
-
def prepare_samplebook(srcdir)
|
14
|
-
samplebook_dir = File.expand_path(
|
15
|
+
def prepare_samplebook(srcdir, bookdir, latextemplatedir, configfile)
|
16
|
+
samplebook_dir = File.expand_path("../samples/#{bookdir}/", File.dirname(__FILE__))
|
15
17
|
FileUtils.cp_r(Dir.glob(File.join(samplebook_dir, '*')), srcdir)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
if latextemplatedir
|
19
|
+
# copy from review-jsbook or review-jlreq
|
20
|
+
template_dir = File.expand_path("../templates/latex/#{latextemplatedir}/", File.dirname(__FILE__))
|
21
|
+
FileUtils.cp(Dir.glob(File.join(template_dir, '*')), File.join(srcdir, 'sty'))
|
22
|
+
end
|
23
|
+
loader = ReVIEW::YAMLLoader.new
|
24
|
+
loader.load_file(File.open(File.join(srcdir, configfile)))
|
20
25
|
end
|
21
26
|
|
22
27
|
def compile_inline(text)
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -244,8 +244,10 @@ EOS
|
|
244
244
|
|
245
245
|
def test_inline_hd_chap
|
246
246
|
def @chapter.headline_index
|
247
|
-
|
248
|
-
Book::HeadlineIndex.new(
|
247
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
248
|
+
idx = Book::HeadlineIndex.new(self)
|
249
|
+
idx.add_item(item)
|
250
|
+
idx
|
249
251
|
end
|
250
252
|
|
251
253
|
@config['secnolevel'] = 2
|
@@ -270,8 +272,10 @@ EOS
|
|
270
272
|
end
|
271
273
|
|
272
274
|
def @chapter.headline_index
|
273
|
-
|
274
|
-
Book::HeadlineIndex.new(
|
275
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
276
|
+
idx = Book::HeadlineIndex.new(self)
|
277
|
+
idx.add_item(item)
|
278
|
+
idx
|
275
279
|
end
|
276
280
|
|
277
281
|
actual = compile_inline('test @<hd>{test} test2')
|
@@ -293,8 +297,10 @@ EOS
|
|
293
297
|
end
|
294
298
|
|
295
299
|
def @chapter.headline_index
|
296
|
-
|
297
|
-
Book::HeadlineIndex.new(
|
300
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
301
|
+
idx = Book::HeadlineIndex.new(self)
|
302
|
+
idx.add_item(item)
|
303
|
+
idx
|
298
304
|
end
|
299
305
|
|
300
306
|
actual = compile_inline('test @<hd>{test} test2')
|
@@ -772,6 +778,20 @@ EOS
|
|
772
778
|
assert_equal expected, actual
|
773
779
|
end
|
774
780
|
|
781
|
+
def test_dt_inline
|
782
|
+
fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
|
783
|
+
@chapter.instance_eval { @footnote_index = fn }
|
784
|
+
actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
785
|
+
|
786
|
+
expected = <<-EOS
|
787
|
+
<dl>
|
788
|
+
<dt>foo<a id="fnb-bar" href="#fn-bar" class="noteref" epub:type="noteref">*1</a>[]<>&<span class="equation">\\alpha[]</span></dt>
|
789
|
+
<dd></dd>
|
790
|
+
</dl>
|
791
|
+
EOS
|
792
|
+
assert_equal expected, actual
|
793
|
+
end
|
794
|
+
|
775
795
|
def test_list
|
776
796
|
def @chapter.list(_id)
|
777
797
|
Book::Index::Item.new('samplelist', 1)
|
@@ -1637,8 +1657,10 @@ EOS
|
|
1637
1657
|
|
1638
1658
|
def test_column_in_aother_chapter_ref
|
1639
1659
|
def @chapter.column_index
|
1640
|
-
|
1641
|
-
Book::ColumnIndex.new
|
1660
|
+
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
1661
|
+
idx = Book::ColumnIndex.new
|
1662
|
+
idx.add_item(item)
|
1663
|
+
idx
|
1642
1664
|
end
|
1643
1665
|
|
1644
1666
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
@@ -2109,6 +2131,56 @@ EOS
|
|
2109
2131
|
assert_equal expected, actual
|
2110
2132
|
end
|
2111
2133
|
|
2134
|
+
def test_table_row_separator
|
2135
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
2136
|
+
expected = <<-EOS
|
2137
|
+
<div class="table">
|
2138
|
+
<table>
|
2139
|
+
<tr><th>1</th><th>2</th><th>3 4| 5</th></tr>
|
2140
|
+
<tr><td>a b</td><td>c d |e</td><td></td></tr>
|
2141
|
+
</table>
|
2142
|
+
</div>
|
2143
|
+
EOS
|
2144
|
+
actual = compile_block(src)
|
2145
|
+
assert_equal expected, actual
|
2146
|
+
|
2147
|
+
@config['table_row_separator'] = 'singletab'
|
2148
|
+
actual = compile_block(src)
|
2149
|
+
expected = <<-EOS
|
2150
|
+
<div class="table">
|
2151
|
+
<table>
|
2152
|
+
<tr><th>1</th><th>2</th><th></th><th>3 4| 5</th></tr>
|
2153
|
+
<tr><td>a b</td><td>c d |e</td><td></td><td></td></tr>
|
2154
|
+
</table>
|
2155
|
+
</div>
|
2156
|
+
EOS
|
2157
|
+
assert_equal expected, actual
|
2158
|
+
|
2159
|
+
@config['table_row_separator'] = 'spaces'
|
2160
|
+
actual = compile_block(src)
|
2161
|
+
expected = <<-EOS
|
2162
|
+
<div class="table">
|
2163
|
+
<table>
|
2164
|
+
<tr><th>1</th><th>2</th><th>3</th><th>4|</th><th>5</th></tr>
|
2165
|
+
<tr><td>a</td><td>b</td><td>c</td><td>d</td><td>|e</td></tr>
|
2166
|
+
</table>
|
2167
|
+
</div>
|
2168
|
+
EOS
|
2169
|
+
assert_equal expected, actual
|
2170
|
+
|
2171
|
+
@config['table_row_separator'] = 'verticalbar'
|
2172
|
+
actual = compile_block(src)
|
2173
|
+
expected = <<-EOS
|
2174
|
+
<div class="table">
|
2175
|
+
<table>
|
2176
|
+
<tr><th>1 2 3 4</th><th>5</th></tr>
|
2177
|
+
<tr><td>a b c d</td><td>e</td></tr>
|
2178
|
+
</table>
|
2179
|
+
</div>
|
2180
|
+
EOS
|
2181
|
+
assert_equal expected, actual
|
2182
|
+
end
|
2183
|
+
|
2112
2184
|
def test_major_blocks
|
2113
2185
|
actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
|
2114
2186
|
expected = <<-EOS
|
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -146,6 +146,36 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
146
146
|
assert_equal %Q(<table><caption>foo</caption><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>), actual
|
147
147
|
end
|
148
148
|
|
149
|
+
def test_table_row_separator
|
150
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
151
|
+
expected = <<-EOS.chomp
|
152
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="3"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">c d |e</td></tbody></table>
|
153
|
+
EOS
|
154
|
+
actual = compile_block(src)
|
155
|
+
assert_equal expected, actual
|
156
|
+
|
157
|
+
@config['table_row_separator'] = 'singletab'
|
158
|
+
actual = compile_block(src)
|
159
|
+
expected = <<-EOS.chomp
|
160
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="4"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086"></td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">c d |e</td></tbody></table>
|
161
|
+
EOS
|
162
|
+
assert_equal expected, actual
|
163
|
+
|
164
|
+
@config['table_row_separator'] = 'spaces'
|
165
|
+
actual = compile_block(src)
|
166
|
+
expected = <<-EOS.chomp
|
167
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="5"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">3</td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">4|</td><td xyh="5,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">a</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">b</td><td xyh="3,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">c</td><td xyh="4,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">d</td><td xyh="5,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">|e</td></tbody></table>
|
168
|
+
EOS
|
169
|
+
assert_equal expected, actual
|
170
|
+
|
171
|
+
@config['table_row_separator'] = 'verticalbar'
|
172
|
+
actual = compile_block(src)
|
173
|
+
expected = <<-EOS.chomp
|
174
|
+
<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">1 2 3 4</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">a b c d</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">e</td></tbody></table>
|
175
|
+
EOS
|
176
|
+
assert_equal expected, actual
|
177
|
+
end
|
178
|
+
|
149
179
|
def test_inline_br
|
150
180
|
actual = compile_inline('@<br>{}')
|
151
181
|
assert_equal "\n", actual
|
@@ -196,6 +226,17 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
196
226
|
assert_equal %Q(<dl><dt>foo</dt><dd>foo.</dd></dl><p>para</p><dl><dt>foo</dt><dd>foo.</dd></dl><ol><li aid:pstyle="ol-item" olnum="1" num="1">bar</li></ol><dl><dt>foo</dt><dd>foo.</dd></dl><ul><li aid:pstyle="ul-item">bar</li></ul>), actual
|
197
227
|
end
|
198
228
|
|
229
|
+
def test_dt_inline
|
230
|
+
fn = Book::FootnoteIndex.parse(['//footnote[bar][bar]'])
|
231
|
+
@chapter.instance_eval { @footnote_index = fn }
|
232
|
+
actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
233
|
+
|
234
|
+
expected = <<-EOS.chomp
|
235
|
+
<dl><dt>foo<footnote>bar</footnote>[]<>&<replace idref="texinline-1"><pre>\\alpha[]</pre></replace></dt><dd></dd></dl>
|
236
|
+
EOS
|
237
|
+
assert_equal expected, actual
|
238
|
+
end
|
239
|
+
|
199
240
|
def test_paragraph
|
200
241
|
actual = compile_block("foo\nbar\n")
|
201
242
|
assert_equal '<p>foobar</p>', actual
|
@@ -430,6 +471,18 @@ EOS
|
|
430
471
|
<source><pre>foo
|
431
472
|
bar
|
432
473
|
|
474
|
+
buz
|
475
|
+
</pre></source>
|
476
|
+
EOS
|
477
|
+
assert_equal expected, actual
|
478
|
+
end
|
479
|
+
|
480
|
+
def test_source_nil_caption
|
481
|
+
actual = compile_block("//source{\nfoo\nbar\n\nbuz\n//}\n")
|
482
|
+
expected = <<-EOS.chomp
|
483
|
+
<source><pre>foo
|
484
|
+
bar
|
485
|
+
|
433
486
|
buz
|
434
487
|
</pre></source>
|
435
488
|
EOS
|
@@ -664,8 +717,10 @@ EOS
|
|
664
717
|
|
665
718
|
def test_column_in_aother_chapter_ref
|
666
719
|
def @chapter.column_index
|
667
|
-
|
668
|
-
Book::ColumnIndex.new
|
720
|
+
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
721
|
+
idx = Book::ColumnIndex.new
|
722
|
+
idx.add_item(item)
|
723
|
+
idx
|
669
724
|
end
|
670
725
|
|
671
726
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'yaml'
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'open3'
|
7
|
+
|
8
|
+
REVIEW_IDGXMLMAKER = File.expand_path('../bin/review-idgxmlmaker', File.dirname(__FILE__))
|
9
|
+
|
10
|
+
class IDGXMLMakerCmdTest < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@tmpdir1 = Dir.mktmpdir
|
13
|
+
|
14
|
+
@old_rubylib = ENV['RUBYLIB']
|
15
|
+
ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
FileUtils.rm_rf(@tmpdir1)
|
20
|
+
ENV['RUBYLIB'] = @old_rubylib
|
21
|
+
end
|
22
|
+
|
23
|
+
def common_buildidgxml(bookdir, configfile, targetfile, option)
|
24
|
+
if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
|
25
|
+
config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
|
26
|
+
builddir = File.join(@tmpdir1, config['bookname'] + '-idgxml')
|
27
|
+
assert !File.exist?(builddir)
|
28
|
+
|
29
|
+
ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
|
30
|
+
Dir.chdir(@tmpdir1) do
|
31
|
+
_o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_IDGXMLMAKER} #{option} #{configfile}")
|
32
|
+
STDERR.puts e unless e.empty?
|
33
|
+
assert s.success?
|
34
|
+
end
|
35
|
+
assert File.exist?(File.join(@tmpdir1, targetfile))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_idgxmlmaker_cmd_samplebook
|
40
|
+
common_buildidgxml('sample-book/src', 'config.yml', 'book-idgxml/ch01.xml', nil)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_idgxmlmaker_cmd_syntaxbook
|
44
|
+
common_buildidgxml('syntax-book', 'config.yml', 'syntax-book-idgxml/ch01.xml', nil)
|
45
|
+
end
|
46
|
+
end
|
data/test/test_image_finder.rb
CHANGED
@@ -7,93 +7,75 @@ class ImageFinderTest < Test::Unit::TestCase
|
|
7
7
|
include ReVIEW
|
8
8
|
|
9
9
|
def setup
|
10
|
+
if ENV['GITHUB_WORKSPACE']
|
11
|
+
ENV['TMPDIR'] = File.join(ENV['GITHUB_WORKSPACE'], 'tmp_review')
|
12
|
+
FileUtils.mkdir_p(ENV['TMPDIR'])
|
13
|
+
end
|
14
|
+
@dir = Dir.mktmpdir
|
10
15
|
end
|
11
16
|
|
12
|
-
def
|
13
|
-
dir
|
14
|
-
|
15
|
-
path = File.join(dir, 'builder/ch01/foo.jpg')
|
16
|
-
FileUtils.mkdir_p(File.dirname(path))
|
17
|
-
FileUtils.touch(path)
|
18
|
-
|
19
|
-
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
20
|
-
assert_equal(path, finder.find_path('foo'))
|
21
|
-
ensure
|
22
|
-
FileUtils.remove_entry_secure(dir)
|
17
|
+
def teardown
|
18
|
+
if @dir
|
19
|
+
FileUtils.remove_entry_secure(@dir)
|
23
20
|
end
|
24
21
|
end
|
25
22
|
|
23
|
+
def test_find_path_pattern1
|
24
|
+
path = File.join(@dir, 'builder/ch01/foo.jpg')
|
25
|
+
FileUtils.mkdir_p(File.dirname(path))
|
26
|
+
FileUtils.touch(path)
|
27
|
+
|
28
|
+
finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
|
29
|
+
|
30
|
+
assert_equal(path, finder.find_path('foo'))
|
31
|
+
end
|
32
|
+
|
26
33
|
def test_find_path_pattern2
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
34
|
-
assert_equal(path, finder.find_path('foo'))
|
35
|
-
ensure
|
36
|
-
FileUtils.remove_entry_secure(dir)
|
37
|
-
end
|
34
|
+
path = File.join(@dir, 'builder/ch01-foo.jpg')
|
35
|
+
FileUtils.mkdir_p(File.dirname(path))
|
36
|
+
FileUtils.touch(path)
|
37
|
+
|
38
|
+
finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
|
39
|
+
assert_equal(path, finder.find_path('foo'))
|
38
40
|
end
|
39
41
|
|
40
42
|
def test_find_path_pattern3
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
48
|
-
assert_equal(path, finder.find_path('foo'))
|
49
|
-
ensure
|
50
|
-
FileUtils.remove_entry_secure(dir)
|
51
|
-
end
|
43
|
+
path = File.join(@dir, 'builder/foo.jpg')
|
44
|
+
FileUtils.mkdir_p(File.dirname(path))
|
45
|
+
FileUtils.touch(path)
|
46
|
+
|
47
|
+
finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
|
48
|
+
assert_equal(path, finder.find_path('foo'))
|
52
49
|
end
|
53
50
|
|
54
51
|
def test_find_path_pattern4
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
62
|
-
assert_equal(path, finder.find_path('foo'))
|
63
|
-
ensure
|
64
|
-
FileUtils.remove_entry_secure(dir)
|
65
|
-
end
|
52
|
+
path = File.join(@dir, 'ch01/foo.jpg')
|
53
|
+
FileUtils.mkdir_p(File.dirname(path))
|
54
|
+
FileUtils.touch(path)
|
55
|
+
|
56
|
+
finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
|
57
|
+
assert_equal(path, finder.find_path('foo'))
|
66
58
|
end
|
67
59
|
|
68
60
|
def test_find_path_pattern5
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
76
|
-
assert_equal(path, finder.find_path('foo'))
|
77
|
-
ensure
|
78
|
-
FileUtils.remove_entry_secure(dir)
|
79
|
-
end
|
61
|
+
path = File.join(@dir, 'ch01-foo.jpg')
|
62
|
+
FileUtils.mkdir_p(File.dirname(path))
|
63
|
+
FileUtils.touch(path)
|
64
|
+
|
65
|
+
finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
|
66
|
+
assert_equal(path, finder.find_path('foo'))
|
80
67
|
end
|
81
68
|
|
82
69
|
def test_find_path_dir_symlink
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
finder = ReVIEW::Book::ImageFinder.new(dir, 'ch01', 'builder', ['.jpg'])
|
94
|
-
assert_equal(path_dstimg, finder.find_path('foo'))
|
95
|
-
ensure
|
96
|
-
FileUtils.remove_entry_secure(dir)
|
97
|
-
end
|
70
|
+
path_src = File.join(@dir, 'src')
|
71
|
+
path_dst = File.join(@dir, 'ch01')
|
72
|
+
FileUtils.mkdir_p(path_src)
|
73
|
+
FileUtils.symlink(path_src, path_dst)
|
74
|
+
path_srcimg = File.join(path_src, 'foo.jpg')
|
75
|
+
path_dstimg = File.join(path_dst, 'foo.jpg')
|
76
|
+
FileUtils.touch(path_srcimg)
|
77
|
+
|
78
|
+
finder = ReVIEW::Book::ImageFinder.new(@dir, 'ch01', 'builder', ['.jpg'])
|
79
|
+
assert_equal(path_dstimg, finder.find_path('foo'))
|
98
80
|
end
|
99
81
|
end
|