review 5.0.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby-tex.yml +35 -0
- data/.github/workflows/ruby-win.yml +8 -4
- data/.github/workflows/ruby.yml +6 -2
- data/.rubocop.yml +24 -9
- data/NEWS.ja.md +215 -0
- data/NEWS.md +215 -1
- data/README.md +7 -6
- data/Rakefile +7 -2
- data/bin/review +2 -4
- data/bin/review-catalog-converter +3 -3
- data/bin/review-check +6 -8
- data/bin/review-checkdep +1 -4
- data/bin/review-compile +10 -20
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +11 -5
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +30 -38
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +3 -3
- data/bin/review-vol +1 -4
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +23 -5
- data/doc/config.yml.sample-simple +1 -1
- data/doc/format.ja.md +49 -12
- data/doc/format.md +52 -12
- data/doc/quickstart.ja.md +11 -1
- data/doc/quickstart.md +11 -2
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review/book/base.rb +4 -0
- data/lib/review/book/book_unit.rb +15 -2
- data/lib/review/book/chapter.rb +3 -0
- data/lib/review/book/index.rb +5 -1
- data/lib/review/book/volume.rb +1 -0
- data/lib/review/builder.rb +90 -54
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +2 -0
- data/lib/review/compiler.rb +88 -52
- data/lib/review/configure.rb +64 -7
- data/lib/review/epubmaker/content.rb +113 -0
- data/lib/review/epubmaker/epubcommon.rb +372 -0
- data/lib/review/epubmaker/epubv2.rb +178 -0
- data/lib/review/epubmaker/epubv3.rb +231 -0
- data/lib/review/epubmaker/producer.rb +167 -0
- data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
- data/lib/review/epubmaker/zip_exporter.rb +84 -0
- data/lib/review/epubmaker.rb +114 -129
- data/lib/review/exception.rb +13 -0
- data/lib/review/htmlbuilder.rb +109 -67
- data/lib/review/htmlutils.rb +1 -1
- data/lib/review/i18n.rb +1 -0
- data/lib/review/i18n.yml +6 -0
- data/lib/review/idgxmlbuilder.rb +72 -48
- data/lib/review/idgxmlmaker.rb +15 -14
- data/lib/review/img_math.rb +239 -0
- data/lib/review/index_builder.rb +90 -32
- data/lib/review/init.rb +4 -4
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +79 -58
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/loggable.rb +27 -0
- data/lib/review/logger.rb +89 -2
- data/lib/review/makerhelper.rb +7 -206
- data/lib/review/markdownbuilder.rb +44 -4
- data/lib/review/pdfmaker.rb +70 -51
- data/lib/review/plaintextbuilder.rb +20 -11
- data/lib/review/preprocessor/directive.rb +35 -0
- data/lib/review/preprocessor/line.rb +34 -0
- data/lib/review/preprocessor/repository.rb +177 -0
- data/lib/review/preprocessor.rb +105 -301
- data/lib/review/rstbuilder.rb +13 -4
- data/lib/review/sec_counter.rb +1 -0
- data/lib/review/template.rb +11 -1
- data/lib/review/textmaker.rb +23 -20
- data/lib/review/textutils.rb +10 -17
- data/lib/review/tocprinter.rb +93 -71
- data/lib/review/topbuilder.rb +44 -19
- data/lib/review/update.rb +5 -6
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +11 -12
- data/lib/review/webmaker.rb +31 -27
- data/lib/review/webtocprinter.rb +10 -9
- data/lib/review/yamlloader.rb +2 -1
- data/lib/review.rb +1 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config.yml +1 -1
- data/samples/sample-book/src/lib/tasks/review.rake +19 -1
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +2 -1
- data/samples/syntax-book/ch01.re +1 -1
- data/samples/syntax-book/ch02.re +30 -6
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/images/img3-2.png +0 -0
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +2 -1
- data/templates/html/_colophon.html.erb +23 -0
- data/templates/html/_colophon_history.html.erb +9 -0
- data/templates/html/_cover.html.erb +10 -0
- data/templates/html/_part_body.html.erb +6 -0
- data/templates/html/_titlepage.html.erb +20 -0
- data/templates/html/layout-html5.html.erb +6 -0
- data/templates/html/layout-xhtml1.html.erb +6 -0
- data/templates/latex/config.erb +11 -0
- data/templates/latex/review-jlreq/review-base.sty +7 -9
- data/templates/latex/review-jlreq/review-jlreq.cls +48 -6
- data/templates/latex/review-jlreq/review-style.sty +6 -1
- data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
- data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
- data/templates/latex/review-jsbook/review-base.sty +13 -9
- data/templates/latex/review-jsbook/review-jsbook.cls +41 -6
- data/templates/latex/review-jsbook/review-style.sty +6 -1
- data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
- data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
- data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
- data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
- data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
- data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
- data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
- data/templates/web/html/layout-html5.html.erb +6 -5
- data/templates/web/html/layout-xhtml1.html.erb +6 -0
- data/test/assets/header_listener.html +35 -0
- data/test/assets/img_math/img1.png +0 -0
- data/test/assets/img_math/img2.png +0 -0
- data/test/assets/img_math/img3.png +0 -0
- data/test/assets/syntax_book_index_detail.txt +60 -0
- data/test/assets/test_template.tex +7 -1
- data/test/assets/test_template_backmatter.tex +7 -1
- data/test/run_test.rb +1 -1
- data/test/test_book_chapter.rb +27 -4
- data/test/test_builder.rb +10 -8
- data/test/test_catalog_converter_cmd.rb +1 -1
- data/test/test_epub3maker.rb +168 -124
- data/test/test_epubmaker.rb +248 -131
- data/test/test_epubmaker_cmd.rb +15 -4
- data/test/test_helper.rb +5 -4
- data/test/test_htmlbuilder.rb +170 -31
- data/test/test_idgxmlbuilder.rb +44 -23
- data/test/test_idgxmlmaker_cmd.rb +7 -3
- data/test/test_img_math.rb +111 -0
- data/test/test_index.rb +30 -4
- data/test/test_indexbuilder.rb +5 -5
- data/test/test_latexbuilder.rb +151 -26
- data/test/test_latexbuilder_v2.rb +18 -10
- data/test/test_lineinput.rb +20 -93
- data/test/test_markdownbuilder.rb +42 -0
- data/test/test_pdfmaker.rb +90 -0
- data/test/test_pdfmaker_cmd.rb +2 -2
- data/test/test_plaintextbuilder.rb +56 -40
- data/test/test_preprocessor.rb +188 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +13 -0
- data/test/test_template.rb +12 -2
- data/test/test_textmaker_cmd.rb +5 -1
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +50 -19
- data/test/test_update.rb +34 -34
- data/test/test_zip_exporter.rb +5 -6
- metadata +95 -17
- data/lib/epubmaker/content.rb +0 -111
- data/lib/epubmaker/epubcommon.rb +0 -449
- data/lib/epubmaker/epubv2.rb +0 -142
- data/lib/epubmaker/epubv3.rb +0 -235
- data/lib/epubmaker/producer.rb +0 -375
- data/lib/epubmaker/zip_exporter.rb +0 -81
- data/lib/epubmaker.rb +0 -23
- data/lib/lineinput.rb +0 -155
data/test/test_preprocessor.rb
CHANGED
@@ -1,9 +1,196 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'review/preprocessor'
|
3
3
|
require 'stringio'
|
4
|
+
require 'book_test_helper'
|
4
5
|
|
5
6
|
class PreprocessorTest < Test::Unit::TestCase
|
6
7
|
include ReVIEW
|
8
|
+
include BookTestHelper
|
7
9
|
|
8
|
-
|
10
|
+
def test_mapfile
|
11
|
+
preproc = ReVIEW::Preprocessor.new({})
|
12
|
+
|
13
|
+
ch01_re = <<-'REFILE'
|
14
|
+
= test1
|
15
|
+
|
16
|
+
//list[hello.rb.1][hello.re]{
|
17
|
+
#@mapfile(hello.rb)
|
18
|
+
#@end
|
19
|
+
//}
|
20
|
+
REFILE
|
21
|
+
|
22
|
+
hello_rb = <<-'RBFILE'
|
23
|
+
#!/usr/bin/env ruby
|
24
|
+
|
25
|
+
class Hello
|
26
|
+
def hello(name)
|
27
|
+
print "hello, #{name}!\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if __FILE__ == $0
|
32
|
+
Hello.new.hello("world")
|
33
|
+
end
|
34
|
+
RBFILE
|
35
|
+
|
36
|
+
expected = <<-'EXPECTED'
|
37
|
+
= test1
|
38
|
+
|
39
|
+
//list[hello.rb.1][hello.re]{
|
40
|
+
#@mapfile(hello.rb)
|
41
|
+
#!/usr/bin/env ruby
|
42
|
+
|
43
|
+
class Hello
|
44
|
+
def hello(name)
|
45
|
+
print "hello, #{name}!\n"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if __FILE__ == $0
|
50
|
+
Hello.new.hello("world")
|
51
|
+
end
|
52
|
+
#@end
|
53
|
+
//}
|
54
|
+
EXPECTED
|
55
|
+
converted = mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
56
|
+
'ch01.re' => ch01_re,
|
57
|
+
'hello.rb' => hello_rb) do |_dir, _book, _files|
|
58
|
+
preproc.process('ch01.re')
|
59
|
+
end
|
60
|
+
assert_equal expected, converted
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_mapfile_tabwidth_is_4
|
64
|
+
param = { 'tabwidth' => 4 }
|
65
|
+
preproc = ReVIEW::Preprocessor.new(param)
|
66
|
+
|
67
|
+
ch01 = <<-'REFILE'
|
68
|
+
//emlist[test1][inc.txt]{
|
69
|
+
#@mapfile(inc.txt)
|
70
|
+
#@end
|
71
|
+
//}
|
72
|
+
REFILE
|
73
|
+
|
74
|
+
inc_txt = <<-'INC_TXT'
|
75
|
+
test.
|
76
|
+
test2.
|
77
|
+
|
78
|
+
test3.
|
79
|
+
|
80
|
+
test4.
|
81
|
+
|
82
|
+
test5.
|
83
|
+
INC_TXT
|
84
|
+
|
85
|
+
expected = <<-'EXPECTED'
|
86
|
+
//emlist[test1][inc.txt]{
|
87
|
+
#@mapfile(inc.txt)
|
88
|
+
test.
|
89
|
+
test2.
|
90
|
+
|
91
|
+
test3.
|
92
|
+
|
93
|
+
test4.
|
94
|
+
|
95
|
+
test5.
|
96
|
+
#@end
|
97
|
+
//}
|
98
|
+
EXPECTED
|
99
|
+
converted = nil
|
100
|
+
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
101
|
+
'inc.txt' => inc_txt,
|
102
|
+
'ch01.re' => ch01) do |_dir, _book, _files|
|
103
|
+
converted = preproc.process('ch01.re')
|
104
|
+
end
|
105
|
+
assert_equal expected, converted
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_maprange
|
109
|
+
preproc = ReVIEW::Preprocessor.new({})
|
110
|
+
|
111
|
+
ch01_re = <<-'REFILE'
|
112
|
+
//list[range.rb][range.rb(抜粋)]{
|
113
|
+
#@maprange(range.rb,sample)
|
114
|
+
#@end
|
115
|
+
//}
|
116
|
+
REFILE
|
117
|
+
|
118
|
+
range_rb = <<-'RBFILE'
|
119
|
+
#!/usr/bin/env ruby
|
120
|
+
|
121
|
+
class Hello
|
122
|
+
#@range_begin(sample)
|
123
|
+
def hello(name)
|
124
|
+
print "hello, #{name}!\n"
|
125
|
+
end
|
126
|
+
#@range_end(sample)
|
127
|
+
end
|
128
|
+
|
129
|
+
if __FILE__ == $0
|
130
|
+
Hello.new.hello("world")
|
131
|
+
end
|
132
|
+
RBFILE
|
133
|
+
|
134
|
+
expected = <<-'EXPECTED'
|
135
|
+
//list[range.rb][range.rb(抜粋)]{
|
136
|
+
#@maprange(range.rb,sample)
|
137
|
+
def hello(name)
|
138
|
+
print "hello, #{name}!\n"
|
139
|
+
end
|
140
|
+
#@end
|
141
|
+
//}
|
142
|
+
EXPECTED
|
143
|
+
converted = mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
144
|
+
'ch01.re' => ch01_re,
|
145
|
+
'range.rb' => range_rb) do |_dir, _book, _files|
|
146
|
+
preproc.process('ch01.re')
|
147
|
+
end
|
148
|
+
assert_equal expected, converted
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_at_at_maprange
|
152
|
+
preproc = ReVIEW::Preprocessor.new({})
|
153
|
+
|
154
|
+
ch01_re = <<-'REFILE'
|
155
|
+
//list[range.c][range.c(抜粋)]{
|
156
|
+
#@maprange(range.c,sample)
|
157
|
+
#@end
|
158
|
+
//}
|
159
|
+
REFILE
|
160
|
+
|
161
|
+
range_c = <<-'CFILE'
|
162
|
+
#include <stdio.h>
|
163
|
+
|
164
|
+
/* #@@range_begin(sample) */
|
165
|
+
void
|
166
|
+
put_hello(char *name)
|
167
|
+
{
|
168
|
+
printf("hello, %s!\n", name);
|
169
|
+
}
|
170
|
+
/* #@@range_end(sample) */
|
171
|
+
|
172
|
+
int main()
|
173
|
+
{
|
174
|
+
put_hello("world");
|
175
|
+
}
|
176
|
+
CFILE
|
177
|
+
|
178
|
+
expected = <<-'EXPECTED'
|
179
|
+
//list[range.c][range.c(抜粋)]{
|
180
|
+
#@maprange(range.c,sample)
|
181
|
+
void
|
182
|
+
put_hello(char *name)
|
183
|
+
{
|
184
|
+
printf("hello, %s!\n", name);
|
185
|
+
}
|
186
|
+
#@end
|
187
|
+
//}
|
188
|
+
EXPECTED
|
189
|
+
converted = mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
190
|
+
'ch01.re' => ch01_re,
|
191
|
+
'range.c' => range_c) do |_dir, _book, _files|
|
192
|
+
preproc.process('ch01.re')
|
193
|
+
end
|
194
|
+
assert_equal expected, converted
|
195
|
+
end
|
9
196
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rexml/document'
|
3
|
+
require 'rexml/streamlistener'
|
4
|
+
require 'review/epubmaker'
|
5
|
+
|
6
|
+
class ReVIEWHeaderListenerTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@epubmaker = ReVIEW::EPUBMaker.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_epubmaker_parse_headlines
|
15
|
+
# original Re:VIEW source:
|
16
|
+
#
|
17
|
+
# = first chapter
|
18
|
+
# == first section
|
19
|
+
# === first @<embed>{<img src="images/icon1.jpg" alt="subsection" />}
|
20
|
+
# == second section
|
21
|
+
# ==={dummy1} dummy subsection
|
22
|
+
# == third section
|
23
|
+
# ==[notoc] notoc section
|
24
|
+
# ==[notoc]{dummy2} notoc section
|
25
|
+
# ==[nodisp] nodisp section
|
26
|
+
# ==[nodisp]{dummy3} nodisp section
|
27
|
+
# ==[nonum] nonum section
|
28
|
+
# ==[nonum]{dummy4} nonum section
|
29
|
+
Dir.mktmpdir do |_dir|
|
30
|
+
path = File.join(assets_dir, 'header_listener.html')
|
31
|
+
headlines = @epubmaker.parse_headlines(path)
|
32
|
+
|
33
|
+
expected = [{ 'id' => 'h1', 'level' => 1, 'notoc' => nil, 'title' => '第1章 first chapter' },
|
34
|
+
{ 'id' => 'h1-1', 'level' => 2, 'notoc' => nil, 'title' => '1.1 first section' },
|
35
|
+
{ 'id' => 'h1-1-1', 'level' => 3, 'notoc' => nil, 'title' => 'first subsection' },
|
36
|
+
{ 'id' => 'h1-2', 'level' => 2, 'notoc' => nil, 'title' => '1.2 second section' },
|
37
|
+
{ 'id' => 'h1-2-1', 'level' => 3, 'notoc' => nil, 'title' => 'dummy subsection' },
|
38
|
+
{ 'id' => 'h1-3', 'level' => 2, 'notoc' => nil, 'title' => '1.3 third section' },
|
39
|
+
{ 'id' => 'ch01_nonum1', 'level' => 2, 'notoc' => 'true', 'title' => 'notoc section' },
|
40
|
+
{ 'id' => 'dummy2', 'level' => 2, 'notoc' => 'true', 'title' => 'notoc section' },
|
41
|
+
{ 'id' => 'ch01_nonum3', 'level' => 2, 'notoc' => nil, 'title' => 'nodisp section' },
|
42
|
+
{ 'id' => 'dummy3', 'level' => 2, 'notoc' => nil, 'title' => 'nodisp section' },
|
43
|
+
{ 'id' => 'ch01_nonum5', 'level' => 2, 'notoc' => nil, 'title' => 'nonum section' },
|
44
|
+
{ 'id' => 'dummy4', 'level' => 2, 'notoc' => nil, 'title' => 'nonum section' }]
|
45
|
+
|
46
|
+
assert_equal expected, headlines
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/test/test_rstbuilder.rb
CHANGED
@@ -513,6 +513,19 @@ EOS
|
|
513
513
|
|
514
514
|
\\sin 1^{2}
|
515
515
|
|
516
|
+
EOS
|
517
|
+
assert_equal expected, actual
|
518
|
+
end
|
519
|
+
|
520
|
+
def test_endnote
|
521
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
522
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
523
|
+
|
524
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
525
|
+
expected = <<-'EOS'
|
526
|
+
[(1)]_
|
527
|
+
|
528
|
+
.. [(1)] bar
|
516
529
|
EOS
|
517
530
|
assert_equal expected, actual
|
518
531
|
end
|
data/test/test_template.rb
CHANGED
@@ -9,15 +9,25 @@ class TemplateTest < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_load
|
12
|
-
tmplfile = File.expand_path('./assets/test.xml.erb',
|
12
|
+
tmplfile = File.expand_path('./assets/test.xml.erb', __dir__)
|
13
13
|
tmpl = ReVIEW::Template.load(tmplfile)
|
14
14
|
assert_equal("<test>\n<name></name>\n</test>\n", tmpl.result(binding))
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_open_with_value
|
18
|
-
tmplfile = File.expand_path('./assets/test.xml.erb',
|
18
|
+
tmplfile = File.expand_path('./assets/test.xml.erb', __dir__)
|
19
19
|
tmpl = ReVIEW::Template.load(tmplfile)
|
20
20
|
@name = 'test'
|
21
21
|
assert_equal("<test>\n<name>test</name>\n</test>\n", tmpl.result(binding))
|
22
22
|
end
|
23
|
+
|
24
|
+
def test_generate
|
25
|
+
result = ReVIEW::Template.generate(path: './assets/test.xml.erb', binding: binding, template_dir: __dir__)
|
26
|
+
assert_equal("<test>\n<name></name>\n</test>\n", result)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_generate_without_template_dir
|
30
|
+
result = ReVIEW::Template.generate(path: '../test/assets/test.xml.erb', binding: binding)
|
31
|
+
assert_equal("<test>\n<name></name>\n</test>\n", result)
|
32
|
+
end
|
23
33
|
end
|
data/test/test_textmaker_cmd.rb
CHANGED
@@ -29,7 +29,11 @@ class TEXTMakerCmdTest < Test::Unit::TestCase
|
|
29
29
|
ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
|
30
30
|
Dir.chdir(@tmpdir1) do
|
31
31
|
_o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_TEXTMAKER} #{option} #{configfile}")
|
32
|
-
|
32
|
+
if defined?(ReVIEW::TTYLogger)
|
33
|
+
assert_match(/SUCCESS/, e)
|
34
|
+
else
|
35
|
+
assert_equal '', e
|
36
|
+
end
|
33
37
|
assert s.success?
|
34
38
|
end
|
35
39
|
assert File.exist?(File.join(@tmpdir1, targetfile))
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'review/tocprinter'
|
3
|
+
require 'unicode/eaw'
|
4
|
+
|
5
|
+
class TOCPrinterTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@toc_printer = ReVIEW::TOCPrinter.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_calc_linesize
|
14
|
+
@toc_printer.calc_char_width = nil
|
15
|
+
size = @toc_printer.calc_linesize('あ いうえおABCD')
|
16
|
+
assert_equal 10, size
|
17
|
+
size = @toc_printer.calc_linesize("あ い\nうえ\nおAB\nCD\n")
|
18
|
+
assert_equal 14, size
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_calc_linesize_with_char_width
|
22
|
+
@toc_printer.calc_char_width = true
|
23
|
+
size = @toc_printer.calc_linesize('あ いうえおABCD')
|
24
|
+
assert_equal 7.5, size
|
25
|
+
size = @toc_printer.calc_linesize("あ い\nうえ\nおAB\nCD\n")
|
26
|
+
assert_equal 9.5, size
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_execute_syntax_book_detail
|
30
|
+
Dir.chdir('./samples/syntax-book') do
|
31
|
+
stdout = $stdout
|
32
|
+
tmp_io = StringIO.new
|
33
|
+
$stdout = tmp_io
|
34
|
+
begin
|
35
|
+
@toc_printer.execute('-d')
|
36
|
+
tmp_io.rewind
|
37
|
+
result = tmp_io.read
|
38
|
+
path = File.join(assets_dir, 'syntax_book_index_detail.txt')
|
39
|
+
expected = File.read(path)
|
40
|
+
assert_equal expected, result
|
41
|
+
ensure
|
42
|
+
$stdout = stdout
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/test/test_topbuilder.rb
CHANGED
@@ -14,6 +14,8 @@ class TOPBuidlerTest < Test::Unit::TestCase
|
|
14
14
|
@config['language'] = 'ja'
|
15
15
|
@book = Book::Base.new
|
16
16
|
@book.config = @config
|
17
|
+
@log_io = StringIO.new
|
18
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
17
19
|
@compiler = ReVIEW::Compiler.new(@builder)
|
18
20
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
19
21
|
location = Location.new(nil, nil)
|
@@ -119,6 +121,11 @@ class TOPBuidlerTest < Test::Unit::TestCase
|
|
119
121
|
assert_equal 'test ★inline test☆◆→等幅フォント太字←◆ test2', actual
|
120
122
|
end
|
121
123
|
|
124
|
+
def test_inline_tcy
|
125
|
+
actual = compile_inline('test @<tcy>{A} test2')
|
126
|
+
assert_equal 'test ◆→開始:回転←◆A◆→終了:縦回転←◆ test2', actual
|
127
|
+
end
|
128
|
+
|
122
129
|
def test_inline_uchar
|
123
130
|
actual = compile_inline('test @<uchar>{2460} test2')
|
124
131
|
assert_equal 'test ① test2', actual
|
@@ -534,10 +541,10 @@ EOS
|
|
534
541
|
|
535
542
|
def test_empty_table
|
536
543
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
537
|
-
assert_equal '
|
544
|
+
assert_equal 'no rows in the table', e.message
|
538
545
|
|
539
546
|
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
540
|
-
assert_equal '
|
547
|
+
assert_equal 'no rows in the table', e.message
|
541
548
|
end
|
542
549
|
|
543
550
|
def test_inline_table
|
@@ -874,8 +881,8 @@ EOS
|
|
874
881
|
|
875
882
|
//}
|
876
883
|
EOS
|
877
|
-
|
878
|
-
assert_match(/minicolumn cannot be nested:/,
|
884
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
885
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
879
886
|
end
|
880
887
|
end
|
881
888
|
|
@@ -891,8 +898,8 @@ EOS
|
|
891
898
|
|
892
899
|
//}
|
893
900
|
EOS
|
894
|
-
|
895
|
-
assert_match(/minicolumn cannot be nested:/,
|
901
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
902
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
896
903
|
end
|
897
904
|
end
|
898
905
|
|
@@ -907,8 +914,8 @@ EOS
|
|
907
914
|
|
908
915
|
//}
|
909
916
|
EOS
|
910
|
-
|
911
|
-
assert_match(/minicolumn cannot be nested:/,
|
917
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
918
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
912
919
|
end
|
913
920
|
end
|
914
921
|
|
@@ -985,27 +992,51 @@ EOB
|
|
985
992
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
986
993
|
|
987
994
|
io = StringIO.new
|
988
|
-
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
995
|
+
@builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
989
996
|
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
990
997
|
assert_equal %Q(foo bar"\\<>_@<b>{BAZ} ★bar"\\<>_@<b>{BAZ}☆ [missing word: N]\n), actual
|
991
998
|
assert_match(/WARN --: :1: word not bound: N/, io.string)
|
992
999
|
end
|
993
1000
|
end
|
994
1001
|
|
1002
|
+
def test_endnote
|
1003
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//endnote[foo][bar]\n\n@<endnote>{foo}\n") }
|
1004
|
+
assert_equal ':4: //endnote is found but //printendnotes is not found.', e.message
|
1005
|
+
|
1006
|
+
actual = compile_block("@<endnote>{foo}\n//endnote[foo][bar]\n//printendnotes\n")
|
1007
|
+
expected = <<-'EOS'
|
1008
|
+
【後注1】
|
1009
|
+
◆→開始:後注←◆
|
1010
|
+
【後注1】bar
|
1011
|
+
◆→終了:後注←◆
|
1012
|
+
EOS
|
1013
|
+
assert_equal expected, actual
|
1014
|
+
end
|
1015
|
+
|
995
1016
|
def test_inline_unknown
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1017
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
1018
|
+
assert_match(/unknown image: n/, @log_io.string)
|
1019
|
+
|
1020
|
+
@log_io.string = ''
|
1021
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
1022
|
+
assert_match(/unknown footnote: n/, @log_io.string)
|
1023
|
+
|
1024
|
+
@log_io.string = ''
|
1025
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<endnote>{n}\n") }
|
1026
|
+
assert_match(/unknown endnote: n/, @log_io.string)
|
1027
|
+
|
1028
|
+
@log_io.string = ''
|
1029
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
1030
|
+
assert_match(/unknown headline: n/, @log_io.string)
|
1002
1031
|
%w[list table column].each do |name|
|
1003
|
-
|
1004
|
-
|
1032
|
+
@log_io.string = ''
|
1033
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1034
|
+
assert_match(/unknown #{name}: n/, @log_io.string)
|
1005
1035
|
end
|
1006
1036
|
%w[chap chapref title].each do |name|
|
1007
|
-
|
1008
|
-
|
1037
|
+
@log_io.string = ''
|
1038
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
1039
|
+
assert_match(/key not found: "n"/, @log_io.string)
|
1009
1040
|
end
|
1010
1041
|
end
|
1011
1042
|
|