review 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +43 -1
- data/.rubocop_todo.yml +605 -0
- data/.travis.yml +9 -0
- data/ChangeLog +4 -0
- data/Dockerfile +22 -0
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/bin/review-check +8 -21
- data/bin/review-compile +9 -15
- data/bin/review-epubmaker-legacy +6 -6
- data/bin/review-index +2 -13
- data/bin/review-preproc +1 -14
- data/bin/review-validate +1 -1
- data/bin/review-vol +1 -13
- data/doc/NEWS.ja.md +22 -0
- data/doc/NEWS.md +22 -0
- data/doc/quickstart.ja.md +1 -1
- data/doc/quickstart.md +1 -1
- data/lib/epubmaker/content.rb +3 -3
- data/lib/epubmaker/epubcommon.rb +91 -108
- data/lib/epubmaker/epubv2.rb +14 -67
- data/lib/epubmaker/epubv3.rb +25 -59
- data/lib/epubmaker/producer.rb +12 -0
- data/lib/review/book/base.rb +12 -4
- data/lib/review/book/compilable.rb +1 -3
- data/lib/review/book/index.rb +4 -4
- data/lib/review/builder.rb +6 -11
- data/lib/review/compiler.rb +7 -7
- data/lib/review/configure.rb +20 -8
- data/lib/review/epubbuilder.rb +1 -1
- data/lib/review/epubmaker.rb +52 -122
- data/lib/review/ewbbuilder.rb +4 -4
- data/lib/review/exception.rb +1 -1
- data/lib/review/htmlbuilder.rb +49 -54
- data/lib/review/htmltoc.rb +45 -0
- data/lib/review/htmlutils.rb +3 -3
- data/lib/review/i18n.rb +6 -2
- data/lib/review/i18n.yml +1 -1
- data/lib/review/idgxmlbuilder.rb +4 -5
- data/lib/review/inaobuilder.rb +1 -1
- data/lib/review/latexbuilder.rb +2 -2
- data/lib/review/latexutils.rb +6 -6
- data/lib/review/markdownbuilder.rb +4 -3
- data/lib/review/pdfmaker.rb +92 -92
- data/lib/review/preprocessor.rb +14 -51
- data/lib/review/template.rb +21 -0
- data/lib/review/textbuilder.rb +1 -1
- data/lib/review/textutils.rb +0 -28
- data/lib/review/tocparser.rb +3 -3
- data/lib/review/tocprinter.rb +8 -31
- data/lib/review/topbuilder.rb +2 -3
- data/lib/review/unfold.rb +2 -2
- data/lib/review/version.rb +1 -1
- data/review.gemspec +2 -1
- data/templates/html/layout-html5.html.erb +17 -0
- data/templates/html/layout-xhtml1.html.erb +20 -0
- data/templates/ncx/epubv2.ncx.erb +11 -0
- data/templates/opf/epubv2.opf.erb +21 -0
- data/templates/opf/epubv3.opf.erb +18 -0
- data/templates/xml/container.xml.erb +6 -0
- data/test/assets/test.xml.erb +3 -0
- data/test/test.re +1 -1
- data/test/test_book.rb +4 -4
- data/test/test_book_chapter.rb +0 -76
- data/test/test_book_part.rb +1 -1
- data/test/test_builder.rb +0 -49
- data/test/test_configure.rb +50 -0
- data/test/test_htmlbuilder.rb +54 -4
- data/test/test_htmltoc.rb +32 -0
- data/test/test_i18n.rb +3 -5
- data/test/test_idgxmlbuilder.rb +0 -2
- data/test/test_inaobuilder.rb +2 -4
- data/test/test_latexbuilder.rb +2 -4
- data/test/test_lineinput.rb +0 -18
- data/test/test_markdownbuilder.rb +5 -4
- data/test/test_pdfmaker.rb +11 -10
- data/test/test_template.rb +26 -0
- data/test/test_topbuilder.rb +0 -2
- metadata +35 -4
- data/rubocop-todo.yml +0 -456
data/lib/review/textbuilder.rb
CHANGED
data/lib/review/textutils.rb
CHANGED
@@ -34,33 +34,5 @@ module ReVIEW
|
|
34
34
|
|
35
35
|
blocked_lines.map{|l| l.join("")}
|
36
36
|
end
|
37
|
-
|
38
|
-
def convert_inencoding(str, enc)
|
39
|
-
case enc
|
40
|
-
when /^EUC$/i
|
41
|
-
NKF.nkf("-E -w -m0x", str)
|
42
|
-
when /^SJIS$/i
|
43
|
-
NKF.nkf("-S -w -m0x", str)
|
44
|
-
when /^JIS$/i
|
45
|
-
NKF.nkf("-J -w -m0x", str)
|
46
|
-
when /^UTF-8$/i
|
47
|
-
NKF.nkf("-W -w -m0x", str)
|
48
|
-
else
|
49
|
-
NKF.nkf("-w -m0 -m0x", str)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def convert_outencoding(str, enc)
|
54
|
-
case enc
|
55
|
-
when /^EUC$/i
|
56
|
-
NKF.nkf("-W -e -m0x", str)
|
57
|
-
when /^SJIS$/i
|
58
|
-
NKF.nkf("-W -s -m0x", str)
|
59
|
-
when /^JIS$/i
|
60
|
-
NKF.nkf("-W -j -m0x", str)
|
61
|
-
else
|
62
|
-
str
|
63
|
-
end
|
64
|
-
end
|
65
37
|
end
|
66
38
|
end
|
data/lib/review/tocparser.rb
CHANGED
@@ -323,11 +323,11 @@ module ReVIEW
|
|
323
323
|
end
|
324
324
|
end
|
325
325
|
|
326
|
-
class Book::Base
|
326
|
+
class Book::Base # reopen
|
327
327
|
include TOCRoot
|
328
328
|
end
|
329
329
|
|
330
|
-
class Book::ChapterSet
|
330
|
+
class Book::ChapterSet # reopen
|
331
331
|
include TOCRoot
|
332
332
|
end
|
333
333
|
|
@@ -335,7 +335,7 @@ module ReVIEW
|
|
335
335
|
include TOCRoot
|
336
336
|
end
|
337
337
|
|
338
|
-
class Book::Chapter
|
338
|
+
class Book::Chapter # reopen
|
339
339
|
def toc
|
340
340
|
@toc ||= TOCParser.parse(self)
|
341
341
|
unless @toc.size == 1
|
data/lib/review/tocprinter.rb
CHANGED
@@ -13,14 +13,13 @@
|
|
13
13
|
|
14
14
|
require 'review/htmlutils'
|
15
15
|
require 'review/htmllayout'
|
16
|
-
require 'nkf'
|
17
16
|
|
18
17
|
module ReVIEW
|
19
18
|
|
20
19
|
class TOCPrinter
|
21
20
|
|
22
21
|
def TOCPrinter.default_upper_level
|
23
|
-
99
|
22
|
+
99 # no one use 99 level nest
|
24
23
|
end
|
25
24
|
|
26
25
|
def initialize(print_upper, param)
|
@@ -31,28 +30,6 @@ module ReVIEW
|
|
31
30
|
def print?(level)
|
32
31
|
level <= @print_upper
|
33
32
|
end
|
34
|
-
|
35
|
-
def nkffilter(line)
|
36
|
-
inc = ""
|
37
|
-
outc = "-w"
|
38
|
-
if @config["inencoding"] =~ /^EUC$/
|
39
|
-
inc = "-E"
|
40
|
-
elsif @config["inencoding"] =~ /^SJIS$/
|
41
|
-
inc = "-S"
|
42
|
-
elsif @config["inencoding"] =~ /^JIS$/
|
43
|
-
inc = "-J"
|
44
|
-
end
|
45
|
-
|
46
|
-
if @config["outencoding"] =~ /^EUC$/
|
47
|
-
outc = "-e"
|
48
|
-
elsif @config["outencoding"] =~ /^SJIS$/
|
49
|
-
outc = "-s"
|
50
|
-
elsif @config["outencoding"] =~ /^JIS$/
|
51
|
-
outc = "-j"
|
52
|
-
end
|
53
|
-
|
54
|
-
NKF.nkf("#{inc} #{outc}", line)
|
55
|
-
end
|
56
33
|
end
|
57
34
|
|
58
35
|
|
@@ -79,11 +56,11 @@ module ReVIEW
|
|
79
56
|
printf "%3s %3dKB %6dC %5dL %s (%s)\n",
|
80
57
|
chapnumstr(node.number),
|
81
58
|
vol.kbytes, vol.chars, vol.lines,
|
82
|
-
|
59
|
+
node.label, node.chapter_id
|
83
60
|
else
|
84
61
|
printf "%17s %5dL %s\n",
|
85
62
|
'', node.estimated_lines,
|
86
|
-
|
63
|
+
" #{' ' * (node.level - 1)}#{number} #{node.label}"
|
87
64
|
end
|
88
65
|
end
|
89
66
|
|
@@ -94,7 +71,7 @@ module ReVIEW
|
|
94
71
|
def volume_columns(level, volstr)
|
95
72
|
cols = ["", "", "", nil]
|
96
73
|
cols[level - 1] = volstr
|
97
|
-
cols[0, 3]
|
74
|
+
cols[0, 3] # does not display volume of level-4 section
|
98
75
|
end
|
99
76
|
|
100
77
|
end
|
@@ -186,7 +163,7 @@ module ReVIEW
|
|
186
163
|
class IDGTOCPrinter < TOCPrinter
|
187
164
|
def print_book(book)
|
188
165
|
puts %Q(<?xml version="1.0" encoding="UTF-8"?>)
|
189
|
-
puts
|
166
|
+
puts %Q(<doc xmlns:aid='http://ns.adobe.com/AdobeInDesign/4.0/'><title aid:pstyle="h0">1 パート1</title><?dtp level="0" section="第1部 パート1"?>) # FIXME: 部タイトルを取るには? & 部ごとに結果を分けるには?
|
190
167
|
puts %Q(<ul aid:pstyle='ul-partblock'>)
|
191
168
|
print_children book
|
192
169
|
puts %Q(</ul></doc>)
|
@@ -208,15 +185,15 @@ module ReVIEW
|
|
208
185
|
if node.chapter?
|
209
186
|
vol = node.volume
|
210
187
|
printf "<li aid:pstyle='ul-part'>%s</li>\n",
|
211
|
-
|
188
|
+
"#{chapnumstr(node.number)}#{node.label}"
|
212
189
|
else
|
213
190
|
printf "<li>%-#{LABEL_LEN}s\n",
|
214
|
-
|
191
|
+
" #{' ' * (node.level - 1)}#{seq} #{node.label}</li>"
|
215
192
|
end
|
216
193
|
end
|
217
194
|
|
218
195
|
def chapnumstr(n)
|
219
|
-
n ?
|
196
|
+
n ? sprintf('第%d章 ', n) : ''
|
220
197
|
end
|
221
198
|
|
222
199
|
def volume_columns(level, volstr)
|
data/lib/review/topbuilder.rb
CHANGED
@@ -741,8 +741,7 @@ module ReVIEW
|
|
741
741
|
def inline_chapref(id)
|
742
742
|
chs = ["", "「", "」"]
|
743
743
|
unless @book.config["chapref"].nil?
|
744
|
-
_chs =
|
745
|
-
@book.config["inencoding"]).split(",")
|
744
|
+
_chs = @book.config["chapref"].split(",")
|
746
745
|
if _chs.size != 3
|
747
746
|
error "--chapsplitter must have exactly 3 parameters with comma."
|
748
747
|
else
|
@@ -787,4 +786,4 @@ module ReVIEW
|
|
787
786
|
|
788
787
|
end
|
789
788
|
|
790
|
-
end
|
789
|
+
end # module ReVIEW
|
data/lib/review/unfold.rb
CHANGED
@@ -47,7 +47,7 @@ module ReVIEW
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
ZSPACE = "\241\241"
|
50
|
+
ZSPACE = "\241\241" # EUC-JP zen-kaku space
|
51
51
|
|
52
52
|
def do_unfold(input)
|
53
53
|
@blank_needed = false
|
@@ -135,4 +135,4 @@ module ReVIEW
|
|
135
135
|
|
136
136
|
end
|
137
137
|
|
138
|
-
end
|
138
|
+
end # module ReVIEW
|
data/lib/review/version.rb
CHANGED
data/review.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.summary = "Re:VIEW: a easy-to-use digital publishing system"
|
14
14
|
gem.description = "Re:VIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX."
|
15
15
|
gem.required_rubygems_version = Gem::Requirement.new(">= 0") if gem.respond_to? :required_rubygems_version=
|
16
|
-
gem.date = "2015-
|
16
|
+
gem.date = "2015-10-29"
|
17
17
|
|
18
18
|
gem.files = `git ls-files`.split("\n")
|
19
19
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -27,5 +27,6 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_development_dependency("rake")
|
28
28
|
gem.add_development_dependency("test-unit")
|
29
29
|
gem.add_development_dependency("pygments.rb")
|
30
|
+
gem.add_development_dependency("rubocop")
|
30
31
|
end
|
31
32
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html>
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="<%= @language %>">
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8" />
|
6
|
+
<% if @stylesheets.present? %>
|
7
|
+
<% @stylesheets.each do |style| %>
|
8
|
+
<link rel="stylesheet" type="text/css" href="<%= style %>" />
|
9
|
+
<% end %>
|
10
|
+
<% end%>
|
11
|
+
<meta name="generator" content="Re:VIEW" />
|
12
|
+
<title><%= @title %></title>
|
13
|
+
</head>
|
14
|
+
<body<%= @body_ext %>>
|
15
|
+
<%= @body %>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="<%= @language %>">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
6
|
+
<meta http-equiv="Content-Style-Type" content="text/css"/>
|
7
|
+
<% if @stylesheets.present? %>
|
8
|
+
<% @stylesheets.each do |style| %>
|
9
|
+
<link rel="stylesheet" type="text/css" href="<%= style %>" />
|
10
|
+
<% end %>
|
11
|
+
<% end%>
|
12
|
+
<meta name="generator" content="Re:VIEW"/>
|
13
|
+
<title><%= @title %></title>
|
14
|
+
</head>
|
15
|
+
<body<%= @body_ext %>>
|
16
|
+
<% if @error_messages %><%= @error_messages %><% end %>
|
17
|
+
<% if @warning_messages %><%= @warning_messages %><% end %>
|
18
|
+
<%= @body %>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
3
|
+
<head>
|
4
|
+
<meta name="dtb:depth" content="1"/>
|
5
|
+
<meta name="dtb:totalPageCount" content="0"/>
|
6
|
+
<meta name="dtb:maxPageNumber" content="0"/>
|
7
|
+
<%= @ncx_isbn %>
|
8
|
+
</head>
|
9
|
+
<%= @ncx_doctitle %>
|
10
|
+
<%= @ncx_navmap %>
|
11
|
+
</ncx>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
|
3
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
4
|
+
<%= @opf_metainfo %>
|
5
|
+
<%= @opf_coverimage %>
|
6
|
+
</metadata>
|
7
|
+
<%= @opf_manifest %>
|
8
|
+
<%= @opf_toc %>
|
9
|
+
<guide>
|
10
|
+
<reference type="cover" title="<%= @producer.res.v("covertitle") %>" href="<%= @producer.params["cover"] %>"/>
|
11
|
+
<% if @producer.params["titlepage"].present? %>
|
12
|
+
<reference type="title-page" title="<%= @producer.res.v("titlepagetitle") %>" href="titlepage.<%= @producer.params["htmlext"] %>"/>
|
13
|
+
<% end %>
|
14
|
+
<% if @producer.params["mytoc"].present? %>
|
15
|
+
<reference type="toc" title="<%= @producer.res.v("toctitle") %>" href="<%= @producer.params["bookname"] %>-toc.<%= @producer.params["htmlext"] %>"/>
|
16
|
+
<% end %>
|
17
|
+
<% if @producer.params["colophon"].present? %>
|
18
|
+
<reference type="colophon" title="<%= @producer.res.v("colophontitle") %>" href="colophon.<%= @producer.params["htmlext"] %>"/>
|
19
|
+
<% end %>
|
20
|
+
</guide>
|
21
|
+
</package>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="<%= @producer.params["language"] %>">
|
3
|
+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
4
|
+
<%= @opf_metainfo %>
|
5
|
+
</metadata>
|
6
|
+
<%= @opf_manifest %>
|
7
|
+
<%= @opf_toc %>
|
8
|
+
<guide>
|
9
|
+
<reference type="cover" title="<%= @producer.res.v("covertitle") %>" href="<%= @producer.params["cover"] %>"/>
|
10
|
+
<% if @producer.params["titlepage"].present? %>
|
11
|
+
<reference type="title-page" title="<%= @producer.res.v("titlepagetitle") %>" href="titlepage.<%= @producer.params["htmlext"] %>"/>
|
12
|
+
<% end %>
|
13
|
+
<reference type="toc" title="<%= @producer.res.v("toctitle") %>" href="<%= @producer.params["bookname"] %>-toc.<%= @producer.params["htmlext"] %>"/>
|
14
|
+
<% if @producer.params["colophon"].present? %>
|
15
|
+
<reference type="colophon" title="<%= @producer.res.v("colophontitle") %>" href="colophon.<%= @producer.params["htmlext"] %>"/>
|
16
|
+
<% end %>
|
17
|
+
</guide>
|
18
|
+
</package>
|
data/test/test.re
CHANGED
data/test/test_book.rb
CHANGED
@@ -158,14 +158,14 @@ class BookTest < Test::Unit::TestCase
|
|
158
158
|
def test_setParameter
|
159
159
|
book = Book::Base.new(File.dirname(__FILE__))
|
160
160
|
book.param = :test
|
161
|
-
assert_equal :test, book.param
|
161
|
+
assert_equal :test, book.param # old way
|
162
162
|
assert_equal :test, book.config # new way
|
163
163
|
end
|
164
164
|
|
165
165
|
def test_setConfig
|
166
166
|
book = Book::Base.new(File.dirname(__FILE__))
|
167
167
|
book.config = :test
|
168
|
-
assert_equal :test, book.param
|
168
|
+
assert_equal :test, book.param # old way
|
169
169
|
assert_equal :test, book.config # new way
|
170
170
|
end
|
171
171
|
|
@@ -391,7 +391,7 @@ EOC
|
|
391
391
|
end
|
392
392
|
|
393
393
|
mktmpbookdir 'catalog.yml' => "APPENDIX:\n - p01.re",
|
394
|
-
'p01.re' => '= appendix'
|
394
|
+
'p01.re' => '= appendix' do |dir, book, files|
|
395
395
|
assert_equal 'appendix', book.appendix.chapters.first.title
|
396
396
|
assert_equal 1, book.appendix.chapters.first.number
|
397
397
|
end
|
@@ -399,7 +399,7 @@ EOC
|
|
399
399
|
|
400
400
|
def test_postscripts
|
401
401
|
mktmpbookdir 'catalog.yml' => "POSTDEF:\n - b01.re",
|
402
|
-
'b01.re' => '= back'
|
402
|
+
'b01.re' => '= back' do |dir, book, files|
|
403
403
|
assert_kind_of Book::Part, book.postscripts
|
404
404
|
assert_equal 1, book.postscripts.chapters.size
|
405
405
|
assert_equal 'back', book.postscripts.chapters.first.title
|
data/test/test_book_chapter.rb
CHANGED
@@ -3,27 +3,6 @@ require 'book_test_helper'
|
|
3
3
|
class ChapterTest < Test::Unit::TestCase
|
4
4
|
include BookTestHelper
|
5
5
|
|
6
|
-
def setup
|
7
|
-
|
8
|
-
if "".respond_to?(:encode)
|
9
|
-
@utf8_str = "あいうえお"
|
10
|
-
@eucjp_str = "あいうえお".encode("EUC-JP")
|
11
|
-
@sjis_str = "あいうえお".encode("Shift_JIS")
|
12
|
-
@jis_str = "あいうえお".encode("ISO-2022-JP")
|
13
|
-
else
|
14
|
-
@utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお"
|
15
|
-
@eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"
|
16
|
-
@sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"
|
17
|
-
@jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42"
|
18
|
-
end
|
19
|
-
=begin
|
20
|
-
@utf8_str = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a" # "あいうえお"
|
21
|
-
@eucjp_str = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"
|
22
|
-
@sjis_str = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"
|
23
|
-
@jis_str = "\x1b\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2a\x1b\x28\x42"
|
24
|
-
=end
|
25
|
-
end
|
26
|
-
|
27
6
|
def test_initialize
|
28
7
|
ch = Book::Chapter.new(:book, :number, :name, '/foo/bar', :io)
|
29
8
|
assert_equal :book, ch.book
|
@@ -88,60 +67,6 @@ class ChapterTest < Test::Unit::TestCase
|
|
88
67
|
io = StringIO.new("=1\n=2\n")
|
89
68
|
ch = Book::Chapter.new(book, nil, nil, nil, io)
|
90
69
|
assert_equal '1', ch.title
|
91
|
-
|
92
|
-
|
93
|
-
[
|
94
|
-
['EUC', @eucjp_str],
|
95
|
-
['SJIS', @sjis_str],
|
96
|
-
# ['JIS', @jis_str],
|
97
|
-
['XYZ', @eucjp_str],
|
98
|
-
].each do |enc, instr|
|
99
|
-
io = StringIO.new("= #{instr}\n")
|
100
|
-
ch = Book::Chapter.new(book, nil, nil, nil, io)
|
101
|
-
book.config['inencoding'] = enc
|
102
|
-
assert_equal @utf8_str, ch.title
|
103
|
-
assert_equal @utf8_str, ch.instance_eval { @title }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_content
|
108
|
-
[
|
109
|
-
['EUC', @eucjp_str],
|
110
|
-
['SJIS', @sjis_str],
|
111
|
-
['JIS', @jis_str],
|
112
|
-
['XYZ', @eucjp_str],
|
113
|
-
].each do |enc, instr|
|
114
|
-
tf = Tempfile.new('chapter_test')
|
115
|
-
book = Book::Base.new(nil)
|
116
|
-
begin
|
117
|
-
tf.print instr
|
118
|
-
tf.close
|
119
|
-
|
120
|
-
ch = Book::Chapter.new(book, nil, nil, tf.path)
|
121
|
-
book.config['inencoding'] = enc
|
122
|
-
assert_equal @utf8_str, ch.content
|
123
|
-
assert_equal @utf8_str, ch.instance_eval { @content }
|
124
|
-
ensure
|
125
|
-
tf.close(true)
|
126
|
-
end
|
127
|
-
|
128
|
-
tf1 = Tempfile.new('chapter_test1')
|
129
|
-
tf2 = Tempfile.new('chapter_test2')
|
130
|
-
begin
|
131
|
-
tf1.puts instr
|
132
|
-
tf1.puts instr
|
133
|
-
tf1.close
|
134
|
-
tf2.puts instr
|
135
|
-
tf1.close
|
136
|
-
|
137
|
-
ch = Book::Chapter.new(book, nil, nil, tf1.path, tf2)
|
138
|
-
book.config['inencoding'] = enc
|
139
|
-
assert_equal "#{@utf8_str}\n#{@utf8_str}\n", ch.content # XXX: OK?
|
140
|
-
ensure
|
141
|
-
tf1.close(true)
|
142
|
-
tf2.close(true)
|
143
|
-
end
|
144
|
-
end
|
145
70
|
end
|
146
71
|
|
147
72
|
def test_lines
|
@@ -282,7 +207,6 @@ E
|
|
282
207
|
|
283
208
|
def test_column_index
|
284
209
|
book = Book::Base.new(nil)
|
285
|
-
book.config["inencoding"] = "utf-8"
|
286
210
|
do_test_index(<<E, Book::ColumnIndex, :column_index, :column, :propagate => false)
|
287
211
|
= dummy1
|
288
212
|
===[column]{abc} aaaa
|