review 2.5.0 → 3.0.0.preview1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +28 -10
- data/.travis.yml +11 -2
- data/NEWS.ja.md +89 -17
- data/NEWS.md +92 -0
- data/README.md +1 -1
- data/Rakefile +0 -13
- data/bin/review-catalog-converter +83 -37
- data/bin/review-check +17 -5
- data/bin/review-compile +1 -1
- data/bin/review-index +6 -0
- data/bin/review-init +3 -155
- data/bin/review-preproc +0 -5
- data/bin/review-validate +21 -7
- data/bin/review-vol +13 -5
- data/doc/config.yml.sample +12 -7
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +39 -3
- data/doc/format.md +39 -3
- data/doc/format_idg.ja.md +0 -4
- data/doc/pdfmaker.ja.md +1 -1
- data/doc/pdfmaker.md +1 -1
- data/doc/sample.css +7 -0
- data/lib/epubmaker/content.rb +31 -12
- data/lib/epubmaker/epubcommon.rb +10 -3
- data/lib/epubmaker/epubv2.rb +11 -3
- data/lib/epubmaker/epubv3.rb +11 -3
- data/lib/epubmaker/producer.rb +55 -20
- data/lib/review/book/base.rb +63 -48
- data/lib/review/book/chapter.rb +19 -7
- data/lib/review/book/compilable.rb +5 -20
- data/lib/review/book/image_finder.rb +10 -3
- data/lib/review/book/index.rb +30 -9
- data/lib/review/book/part.rb +9 -6
- data/lib/review/book.rb +0 -14
- data/lib/review/builder.rb +110 -18
- data/lib/review/catalog.rb +24 -4
- data/lib/review/compiler.rb +3 -1
- data/lib/review/configure.rb +43 -9
- data/lib/review/epubmaker/reviewheaderlistener.rb +57 -0
- data/lib/review/epubmaker.rb +129 -85
- data/lib/review/htmlbuilder.rb +76 -58
- data/lib/review/htmlutils.rb +20 -13
- data/lib/review/i18n.rb +6 -2
- data/lib/review/idgxmlbuilder.rb +52 -41
- data/lib/review/init.rb +194 -0
- data/lib/review/latexbuilder.rb +118 -34
- data/lib/review/latexutils.rb +5 -5
- data/lib/review/logger.rb +2 -1
- data/lib/review/makerhelper.rb +1 -1
- data/lib/review/markdownbuilder.rb +66 -6
- data/lib/review/md2inaobuilder.rb +2 -2
- data/lib/review/pdfmaker.rb +74 -22
- data/lib/review/plaintextbuilder.rb +8 -4
- data/lib/review/preprocessor.rb +14 -17
- data/lib/review/sec_counter.rb +8 -2
- data/lib/review/textmaker.rb +2 -2
- data/lib/review/textutils.rb +9 -2
- data/lib/review/tocparser.rb +7 -4
- data/lib/review/tocprinter.rb +3 -1
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +19 -7
- data/lib/review/webtocprinter.rb +8 -4
- data/review.gemspec +4 -3
- data/templates/latex/config.erb +84 -0
- data/templates/latex/layout.tex.erb +76 -361
- data/templates/latex/review-jlreq/README.md +22 -0
- data/templates/latex/review-jlreq/review-base.sty +178 -0
- data/templates/latex/review-jlreq/review-custom.sty +1 -0
- data/templates/latex/review-jlreq/review-jlreq.cls +141 -0
- data/templates/latex/review-jlreq/review-style.sty +149 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +8 -0
- data/templates/latex/review-jsbook/jumoline.sty +310 -0
- data/templates/latex/review-jsbook/plistings.sty +326 -0
- data/templates/latex/review-jsbook/review-base.sty +405 -0
- data/templates/latex/review-jsbook/review-custom.sty +1 -0
- data/templates/latex/review-jsbook/review-style.sty +38 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +8 -0
- data/templates/latex-compat2/layout.tex.erb +387 -0
- data/test/assets/test_template.tex +105 -235
- data/test/assets/test_template_backmatter.tex +133 -14
- data/test/book_test_helper.rb +1 -1
- data/test/run_test.rb +2 -0
- data/test/sample-book/src/Rakefile +11 -6
- data/test/sample-book/src/config.yml +2 -2
- data/test/sample-book/src/sty/reviewmacro.sty +1 -39
- data/test/sample-book/src/style.css +6 -0
- data/test/syntax-book/config.yml +1 -1
- data/test/test_book.rb +13 -16
- data/test/test_book_chapter.rb +4 -10
- data/test/test_book_part.rb +4 -3
- data/test/test_catalog.rb +15 -4
- data/test/test_helper.rb +2 -2
- data/test/test_htmlbuilder.rb +78 -10
- data/test/test_htmlutils.rb +12 -5
- data/test/test_idgxmlbuilder.rb +1 -1
- data/test/test_latexbuilder.rb +94 -49
- data/test/test_latexbuilder_v2.rb +1077 -0
- data/test/test_logger.rb +20 -0
- data/test/test_markdownbuilder.rb +10 -0
- data/test/test_pdfmaker.rb +6 -7
- data/test/test_plaintextbuilder.rb +1 -1
- data/test/test_review_ext.rb +0 -1
- data/test/test_rstbuilder.rb +1 -1
- data/test/test_topbuilder.rb +19 -7
- data/test/test_webtocprinter.rb +14 -14
- data/{test/sample-book/src/vendor → vendor}/jumoline/README +0 -0
- data/{test/sample-book/src/vendor → vendor}/jumoline/jumoline.dtx +0 -0
- data/{test/sample-book/src/vendor → vendor}/jumoline/jumoline.ins +0 -0
- data/{test/sample-book/src/vendor → vendor}/jumoline/lppl.txt +0 -0
- data/vendor/plistings/.gitignore +9 -0
- data/vendor/plistings/LICENSE +21 -0
- data/vendor/plistings/README.md +18 -0
- data/vendor/plistings/plistings.sty +326 -0
- data/vendor/plistings/test1.tex +174 -0
- data/vendor/plistings/test2.tex +54 -0
- metadata +48 -19
- data/lib/review/unfold.rb +0 -129
- data/test/CHAPS +0 -2
- data/test/bib.re +0 -13
- data/test/test.re +0 -43
data/test/test_book_chapter.rb
CHANGED
@@ -35,12 +35,6 @@ class ChapterTest < Test::Unit::TestCase
|
|
35
35
|
# assert_raises(TypeError) { ch.name } # XXX: OK?
|
36
36
|
end
|
37
37
|
|
38
|
-
def test_open
|
39
|
-
ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io)
|
40
|
-
assert_equal :io, ch.open
|
41
|
-
assert_equal [:io], (ch.open { |io| [io] })
|
42
|
-
end
|
43
|
-
|
44
38
|
def test_size
|
45
39
|
ch = Book::Chapter.new(nil, nil, nil, __FILE__, :io)
|
46
40
|
assert_equal File.size(__FILE__), ch.size
|
@@ -53,7 +47,7 @@ class ChapterTest < Test::Unit::TestCase
|
|
53
47
|
|
54
48
|
def test_title
|
55
49
|
io = StringIO.new
|
56
|
-
book = Book::Base.new
|
50
|
+
book = Book::Base.new
|
57
51
|
ch = Book::Chapter.new(book, nil, nil, nil, io)
|
58
52
|
assert_equal '', ch.title
|
59
53
|
|
@@ -68,7 +62,7 @@ class ChapterTest < Test::Unit::TestCase
|
|
68
62
|
tf.print lines.join
|
69
63
|
tf.close
|
70
64
|
|
71
|
-
book = Book::Base.new
|
65
|
+
book = Book::Base.new
|
72
66
|
ch = Book::Chapter.new(book, nil, nil, tf.path)
|
73
67
|
assert_equal lines, ch.lines
|
74
68
|
|
@@ -95,12 +89,12 @@ class ChapterTest < Test::Unit::TestCase
|
|
95
89
|
tf2.print content
|
96
90
|
tf2.close
|
97
91
|
|
98
|
-
book = Book::Base.new
|
92
|
+
book = Book::Base.new
|
99
93
|
ch = Book::Chapter.new(book, nil, nil, tf1.path)
|
100
94
|
assert ch.volume
|
101
95
|
assert_equal content.gsub(/\s/, '').size, ch.volume.bytes
|
102
96
|
|
103
|
-
book = Book::Base.new
|
97
|
+
book = Book::Base.new
|
104
98
|
ch = Book::Chapter.new(book, nil, nil, tf1.path, tf2)
|
105
99
|
assert ch.volume
|
106
100
|
assert_equal content.gsub(/\s/, '').size, ch.volume.bytes # XXX: OK?
|
data/test/test_book_part.rb
CHANGED
@@ -3,12 +3,13 @@ class PartTest < Test::Unit::TestCase
|
|
3
3
|
include BookTestHelper
|
4
4
|
|
5
5
|
def test_initialize
|
6
|
-
|
6
|
+
book = Book::Base.new
|
7
|
+
part = Book::Part.new(book, nil, nil)
|
7
8
|
assert_equal nil, part.number
|
8
9
|
assert_equal nil, part.chapters
|
9
10
|
assert_equal '', part.name
|
10
11
|
|
11
|
-
part = Book::Part.new(
|
12
|
+
part = Book::Part.new(book, 123, [], 'name')
|
12
13
|
assert_equal 123, part.number
|
13
14
|
assert_equal [], part.chapters
|
14
15
|
assert_equal 'name', part.name
|
@@ -23,7 +24,7 @@ class PartTest < Test::Unit::TestCase
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def test_volume
|
26
|
-
book = Book::Base.new
|
27
|
+
book = Book::Base.new
|
27
28
|
part = Book::Part.new(book, nil, [])
|
28
29
|
assert part.volume
|
29
30
|
assert_equal 0, part.volume.bytes
|
data/test/test_catalog.rb
CHANGED
@@ -97,7 +97,7 @@ ch02.re
|
|
97
97
|
FileUtils.touch(file)
|
98
98
|
end
|
99
99
|
cat = Catalog.new(yaml_hash)
|
100
|
-
cat.validate!(dir)
|
100
|
+
cat.validate!({ 'contentdir' => '.' }, dir)
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
@@ -107,7 +107,7 @@ ch02.re
|
|
107
107
|
FileUtils.touch(file)
|
108
108
|
end
|
109
109
|
cat = Catalog.new(yaml_with_parts)
|
110
|
-
cat.validate!(dir)
|
110
|
+
cat.validate!({ 'contentdir' => '.' }, dir)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -118,7 +118,7 @@ ch02.re
|
|
118
118
|
FileUtils.touch(file)
|
119
119
|
end
|
120
120
|
cat = Catalog.new(yaml_hash)
|
121
|
-
cat.validate!(dir)
|
121
|
+
cat.validate!({ 'contentdir' => '.' }, dir)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -130,11 +130,22 @@ ch02.re
|
|
130
130
|
FileUtils.touch(file)
|
131
131
|
end
|
132
132
|
cat = Catalog.new(yaml_hash)
|
133
|
-
cat.validate!(dir)
|
133
|
+
cat.validate!({ 'contentdir' => '.' }, dir)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
def test_validate_contentdir
|
139
|
+
mktmpbookdir do |dir, _book, _files|
|
140
|
+
Dir.mkdir('content')
|
141
|
+
%w[content/pre01.re content/pre02.re content/ch01.re content/ch02.re content/post01.re content/post02.re content/back01.re content/back02.re].each do |file|
|
142
|
+
FileUtils.touch(file)
|
143
|
+
end
|
144
|
+
cat = Catalog.new(yaml_hash)
|
145
|
+
cat.validate!({ 'contentdir' => 'content' }, dir)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
138
149
|
private
|
139
150
|
|
140
151
|
def yaml
|
data/test/test_helper.rb
CHANGED
data/test/test_htmlbuilder.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'book_test_helper'
|
2
3
|
require 'review'
|
3
4
|
|
4
5
|
class HTMLBuidlerTest < Test::Unit::TestCase
|
5
6
|
include ReVIEW
|
7
|
+
include BookTestHelper
|
6
8
|
|
7
9
|
def setup
|
8
10
|
ReVIEW::I18n.setup
|
@@ -297,6 +299,11 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
297
299
|
assert_equal 'test ① test2', actual
|
298
300
|
end
|
299
301
|
|
302
|
+
def test_inline_balloon
|
303
|
+
actual = compile_inline('test @<balloon>{①}')
|
304
|
+
assert_equal %Q(test <span class="balloon">①</span>), actual
|
305
|
+
end
|
306
|
+
|
300
307
|
def test_inline_ruby
|
301
308
|
actual = compile_inline('@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。')
|
302
309
|
assert_equal '<ruby>粗雑<rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby>繊細<rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。', actual
|
@@ -436,8 +443,7 @@ EOS
|
|
436
443
|
end
|
437
444
|
|
438
445
|
def test_noindent
|
439
|
-
|
440
|
-
actual = compile_block("foo\nbar\n\nfoo2\nbar2\n")
|
446
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
441
447
|
assert_equal %Q(<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n), actual
|
442
448
|
end
|
443
449
|
|
@@ -747,14 +753,6 @@ EOS
|
|
747
753
|
assert_equal %Q(<div id="samplelist" class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b><&>_</p>\n<pre class="list highlight">def foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n</pre>\n</div>\n), actual
|
748
754
|
end
|
749
755
|
|
750
|
-
def test_list_ext
|
751
|
-
def @chapter.list(_id)
|
752
|
-
Book::ListIndex::Item.new('samplelist.rb', 1)
|
753
|
-
end
|
754
|
-
actual = compile_block("//list[samplelist.rb][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
755
|
-
assert_equal %Q(<div id="samplelist.rb" class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b><&>_</p>\n<pre class="list language-rb">test1\ntest1.5\n\ntest<i>2</i>\n</pre>\n</div>\n), actual
|
756
|
-
end
|
757
|
-
|
758
756
|
def test_listnum
|
759
757
|
def @chapter.list(_id)
|
760
758
|
Book::ListIndex::Item.new('samplelist', 1)
|
@@ -1068,6 +1066,59 @@ EOS
|
|
1068
1066
|
assert_equal %Q(<div class="cmd-code">\n<p class="caption">cap1</p>\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n), actual
|
1069
1067
|
end
|
1070
1068
|
|
1069
|
+
def test_texequation
|
1070
|
+
return true if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
1071
|
+
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1072
|
+
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1073
|
+
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P} q\n//}\n") do |dir, book, _files|
|
1074
|
+
@book = book
|
1075
|
+
@book.config = @config
|
1076
|
+
@config['imgmath'] = true
|
1077
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1078
|
+
location = Location.new(nil, nil)
|
1079
|
+
@builder.bind(@compiler, @chapter, location)
|
1080
|
+
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1081
|
+
expected = <<-EOB
|
1082
|
+
<div class=\"equation\">
|
1083
|
+
<img src=\"././images/_review_math/_gen_XXX.png\" />
|
1084
|
+
</div>
|
1085
|
+
EOB
|
1086
|
+
tmpio = $stderr
|
1087
|
+
$stderr = StringIO.new
|
1088
|
+
begin
|
1089
|
+
result = compile_block("//texequation{\np \\land \\bm{P} q\n//}\n")
|
1090
|
+
ensure
|
1091
|
+
$stderr = tmpio
|
1092
|
+
end
|
1093
|
+
actual = result.gsub(/_gen_[0-9a-f]+\.png/, '_gen_XXX.png')
|
1094
|
+
assert_equal expected, actual
|
1095
|
+
end
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
def test_texequation_fail
|
1099
|
+
return true if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
1100
|
+
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1101
|
+
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1102
|
+
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P}} q\n//}\n") do |dir, book, _files|
|
1103
|
+
@book = book
|
1104
|
+
@book.config = @config
|
1105
|
+
@config['imgmath'] = true
|
1106
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1107
|
+
location = Location.new(nil, nil)
|
1108
|
+
@builder.bind(@compiler, @chapter, location)
|
1109
|
+
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1110
|
+
tmpio = $stderr
|
1111
|
+
$stderr = StringIO.new
|
1112
|
+
begin
|
1113
|
+
assert_raise(ReVIEW::ApplicationError) do
|
1114
|
+
_result = compile_block("//texequation{\np \\land \\bm{P}} q\n//}\n")
|
1115
|
+
end
|
1116
|
+
ensure
|
1117
|
+
$stderr = tmpio
|
1118
|
+
end
|
1119
|
+
end
|
1120
|
+
end
|
1121
|
+
|
1071
1122
|
def test_bib
|
1072
1123
|
def @chapter.bibpaper(_id)
|
1073
1124
|
Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
|
@@ -1692,6 +1743,23 @@ EOS
|
|
1692
1743
|
assert_equal 'test <code class="inline-code tt">@<code>{$サンプル$}</code>', actual
|
1693
1744
|
end
|
1694
1745
|
|
1746
|
+
def test_inline_w
|
1747
|
+
Dir.mktmpdir do |dir|
|
1748
|
+
File.open(File.join(dir, 'words.csv'), 'w') do |f|
|
1749
|
+
f.write <<EOB
|
1750
|
+
"F","foo"
|
1751
|
+
"B","bar""\\<>_@<b>{BAZ}"
|
1752
|
+
EOB
|
1753
|
+
end
|
1754
|
+
@book.config['words_file'] = File.join(dir, 'words.csv')
|
1755
|
+
io = StringIO.new
|
1756
|
+
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
1757
|
+
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
1758
|
+
assert_equal %Q(<p>foo bar"\\<>_@<b>{BAZ} <b>bar"\\<>_@<b>{BAZ}</b> [missing word: N]</p>\n), actual
|
1759
|
+
assert_match(/WARN -- : :1: word not bound: N/, io.string)
|
1760
|
+
end
|
1761
|
+
end
|
1762
|
+
|
1695
1763
|
def test_inline_unknown
|
1696
1764
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<img>{n}\n" }
|
1697
1765
|
assert_equal ':1: error: unknown image: n', e.message
|
data/test/test_htmlutils.rb
CHANGED
@@ -5,9 +5,16 @@ class HTMLUtilsTest < Test::Unit::TestCase
|
|
5
5
|
include ReVIEW::HTMLUtils
|
6
6
|
|
7
7
|
def test_escape_html
|
8
|
-
assert_equal '<',
|
9
|
-
assert_equal '<<',
|
10
|
-
assert_equal '_<_<_',
|
8
|
+
assert_equal '<', escape('<')
|
9
|
+
assert_equal '<<', escape('<<')
|
10
|
+
assert_equal '_<_<_', escape('_<_<_')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_unescape_html
|
14
|
+
assert_equal '<', unescape('<')
|
15
|
+
assert_equal '>', unescape('>')
|
16
|
+
assert_equal '&', unescape('&')
|
17
|
+
assert_equal '&', unescape('&amp;')
|
11
18
|
end
|
12
19
|
|
13
20
|
def test_escape_html_ex
|
@@ -15,9 +22,9 @@ class HTMLUtilsTest < Test::Unit::TestCase
|
|
15
22
|
ESC['.'] = 'X'
|
16
23
|
ESC.each_pair do |ch, ref|
|
17
24
|
if keys.include?(ch)
|
18
|
-
assert_equal ref,
|
25
|
+
assert_equal ref, escape(ch)
|
19
26
|
else
|
20
|
-
assert_equal ch,
|
27
|
+
assert_equal ch, escape(ch)
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
data/test/test_idgxmlbuilder.rb
CHANGED
@@ -12,7 +12,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
12
12
|
@config = ReVIEW::Configure.values
|
13
13
|
@config['secnolevel'] = 2
|
14
14
|
@config['tableopt'] = '10'
|
15
|
-
@book = Book::Base.new
|
15
|
+
@book = Book::Base.new
|
16
16
|
@book.config = @config
|
17
17
|
@compiler = ReVIEW::Compiler.new(@builder)
|
18
18
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|