review 3.2.0 → 5.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-tex.yml +31 -0
- data/.github/workflows/ruby-win.yml +45 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.rubocop.yml +167 -42
- data/.travis.yml +1 -1
- data/Dockerfile +21 -5
- data/NEWS.ja.md +428 -1
- data/NEWS.md +429 -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 +5 -5
- data/bin/review-check +13 -17
- data/bin/review-checkdep +3 -6
- data/bin/review-compile +13 -22
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +14 -0
- data/bin/review-index +5 -86
- data/bin/review-init +1 -4
- data/bin/review-pdfmaker +1 -3
- data/bin/review-preproc +11 -13
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +7 -7
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +67 -16
- data/doc/config.yml.sample-simple +4 -3
- data/doc/format.ja.md +133 -21
- data/doc/format.md +135 -34
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +43 -1
- data/doc/pdfmaker.md +42 -1
- 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 +89 -90
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +51 -29
- data/lib/review/book/index.rb +42 -248
- data/lib/review/book/index/item.rb +46 -0
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +45 -10
- data/lib/review/book/volume.rb +5 -5
- data/lib/review/builder.rb +171 -54
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +15 -17
- data/lib/review/compiler.rb +240 -102
- data/lib/review/configure.rb +101 -12
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +120 -118
- 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 +147 -149
- data/lib/review/htmlutils.rb +10 -14
- data/lib/review/i18n.rb +4 -3
- data/lib/review/idgxmlbuilder.rb +229 -103
- data/lib/review/idgxmlmaker.rb +188 -0
- data/lib/review/img_math.rb +245 -0
- data/lib/review/index_builder.rb +654 -0
- data/lib/review/init-web/finish.html +10 -0
- data/lib/review/init-web/index.html +190 -0
- data/lib/review/init-web/review-layout-design.js +691 -0
- data/lib/review/init.rb +124 -41
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +249 -97
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +113 -3
- data/lib/review/logger.rb +43 -8
- data/lib/review/makerhelper.rb +13 -186
- data/lib/review/markdownbuilder.rb +75 -39
- data/lib/review/md2inaobuilder.rb +3 -5
- data/lib/review/pdfmaker.rb +88 -83
- data/lib/review/plaintextbuilder.rb +158 -83
- data/lib/review/preprocessor.rb +30 -24
- data/lib/review/rstbuilder.rb +58 -39
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +6 -0
- data/lib/review/textmaker.rb +29 -17
- data/lib/review/textutils.rb +68 -2
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +147 -61
- data/lib/review/update.rb +27 -28
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +36 -35
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +4 -0
- data/review.gemspec +8 -5
- data/samples/sample-book/README.md +7 -2
- data/samples/sample-book/src/.gitignore +154 -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-jlreq.yml +6 -0
- data/samples/sample-book/src/config.yml +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +45 -14
- data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
- 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 +4 -7
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
- data/samples/syntax-book/config-jlreq.yml +5 -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 +30 -15
- data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -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 +45 -27
- data/templates/latex/layout.tex.erb +1 -0
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +124 -37
- data/templates/latex/review-jlreq/review-jlreq.cls +29 -22
- data/templates/latex/review-jlreq/review-style.sty +9 -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 +46 -5
- data/templates/latex/review-jsbook/review-base.sty +111 -30
- data/templates/latex/review-jsbook/review-jsbook.cls +16 -2
- data/templates/latex/review-jsbook/review-style.sty +10 -2
- 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 +20 -9
- data/test/assets/test_template_backmatter.tex +20 -9
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +123 -78
- 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 +19 -42
- 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 +16 -9
- data/test/test_helper.rb +23 -11
- data/test/test_htmlbuilder.rb +1083 -114
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +37 -37
- data/test/test_idgxmlbuilder.rb +627 -27
- 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 +1189 -59
- data/test/test_latexbuilder_v2.rb +74 -34
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +17 -4
- data/test/test_makerhelper.rb +2 -14
- data/test/test_markdownbuilder.rb +77 -4
- data/test/test_md2inaobuilder.rb +12 -2
- data/test/test_pdfmaker.rb +101 -12
- data/test/test_pdfmaker_cmd.rb +102 -8
- data/test/test_plaintextbuilder.rb +562 -31
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +58 -5
- 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_textutils.rb +109 -2
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +400 -17
- data/test/test_update.rb +53 -44
- data/test/test_webtocprinter.rb +75 -43
- data/test/test_yamlloader.rb +13 -0
- 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 +136 -23
- 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 -173
- 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,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'yaml'
|
5
|
+
require 'rbconfig'
|
6
|
+
require 'open3'
|
7
|
+
|
8
|
+
REVIEW_TEXTMAKER = File.expand_path('../bin/review-textmaker', File.dirname(__FILE__))
|
9
|
+
|
10
|
+
class TEXTMakerCmdTest < 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_buildtext(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'] + '-text')
|
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_TEXTMAKER} #{option} #{configfile}")
|
32
|
+
if defined?(ReVIEW::TTYLogger)
|
33
|
+
assert_match(/SUCCESS/, e)
|
34
|
+
else
|
35
|
+
assert_equal '', e
|
36
|
+
end
|
37
|
+
assert s.success?
|
38
|
+
end
|
39
|
+
assert File.exist?(File.join(@tmpdir1, targetfile))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_textmaker_cmd_samplebook
|
44
|
+
common_buildtext('sample-book/src', 'config.yml', 'book-text/ch01.txt', nil)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_textmaker_cmd_samplebook_plain
|
48
|
+
common_buildtext('sample-book/src', 'config.yml', 'book-text/ch01.txt', '-n')
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_textmaker_cmd_syntaxbook
|
52
|
+
common_buildtext('syntax-book', 'config.yml', 'syntax-book-text/ch01.txt', nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_textmaker_cmd_syntaxbook_plain
|
56
|
+
common_buildtext('syntax-book', 'config.yml', 'syntax-book-text/ch01.txt', '-n')
|
57
|
+
end
|
58
|
+
end
|
data/test/test_textutils.rb
CHANGED
@@ -6,7 +6,12 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
@tu_nil = Object.new
|
9
|
-
@tu_nil.extend
|
9
|
+
@tu_nil.extend(ReVIEW::TextUtils)
|
10
|
+
@tu_nil.instance_eval { @book = Book::Base.new('.') }
|
11
|
+
def @tu_nil.config
|
12
|
+
@book.config
|
13
|
+
end
|
14
|
+
|
10
15
|
def @tu_nil.pre_paragraph
|
11
16
|
nil
|
12
17
|
end
|
@@ -16,7 +21,12 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
16
21
|
end
|
17
22
|
|
18
23
|
@tu_p = Object.new
|
19
|
-
@tu_p.extend
|
24
|
+
@tu_p.extend(ReVIEW::TextUtils)
|
25
|
+
@tu_p.instance_eval { @book = Book::Base.new('.') }
|
26
|
+
def @tu_p.config
|
27
|
+
@book.config
|
28
|
+
end
|
29
|
+
|
20
30
|
def @tu_p.pre_paragraph
|
21
31
|
'<p>'
|
22
32
|
end
|
@@ -63,6 +73,20 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
63
73
|
assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
|
64
74
|
ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
|
65
75
|
assert_equal ['<p>abc</p>', '<p>defghi</p>'], ret
|
76
|
+
|
77
|
+
@tu_p.config['join_lines_by_lang'] = true
|
78
|
+
ret = @tu_p.split_paragraph(['abc'])
|
79
|
+
assert_equal ['<p>abc</p>'], ret
|
80
|
+
ret = @tu_p.split_paragraph(['abc', 'def'])
|
81
|
+
assert_equal ['<p>abc def</p>'], ret
|
82
|
+
ret = @tu_p.split_paragraph(['abc', '', 'def'])
|
83
|
+
assert_equal ['<p>abc</p>', '<p>def</p>'], ret
|
84
|
+
ret = @tu_p.split_paragraph(['abc', '', '', 'def'])
|
85
|
+
assert_equal ['<p>abc</p>', '<p>def</p>'], ret
|
86
|
+
ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi'])
|
87
|
+
assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
|
88
|
+
ret = @tu_p.split_paragraph(['abc', '', '', 'def', 'ghi', '', ''])
|
89
|
+
assert_equal ['<p>abc</p>', '<p>def ghi</p>'], ret
|
66
90
|
end
|
67
91
|
|
68
92
|
def test_split_paragraph_nil
|
@@ -76,5 +100,88 @@ class TextUtilsTest < Test::Unit::TestCase
|
|
76
100
|
assert_equal ['abc', 'def'], ret
|
77
101
|
ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
|
78
102
|
assert_equal ['abc', 'defghi'], ret
|
103
|
+
|
104
|
+
@tu_nil.config['join_lines_by_lang'] = true
|
105
|
+
ret = @tu_nil.split_paragraph(['abc'])
|
106
|
+
assert_equal ['abc'], ret
|
107
|
+
ret = @tu_nil.split_paragraph(['abc', 'def'])
|
108
|
+
assert_equal ['abc def'], ret
|
109
|
+
ret = @tu_nil.split_paragraph(['abc', '', 'def'])
|
110
|
+
assert_equal ['abc', 'def'], ret
|
111
|
+
ret = @tu_nil.split_paragraph(['abc', '', '', 'def'])
|
112
|
+
assert_equal ['abc', 'def'], ret
|
113
|
+
ret = @tu_nil.split_paragraph(['abc', '', '', 'def', 'ghi'])
|
114
|
+
assert_equal ['abc', 'def ghi'], ret
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_split_paragraph_p_lang
|
118
|
+
ret = @tu_p.split_paragraph(['I', 'have.'])
|
119
|
+
assert_equal ['<p>Ihave.</p>'], ret
|
120
|
+
ret = @tu_p.split_paragraph(['I', 'have', '.'])
|
121
|
+
assert_equal ['<p>Ihave.</p>'], ret
|
122
|
+
ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
|
123
|
+
assert_equal ['<p>0123a4</p>'], ret
|
124
|
+
ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
|
125
|
+
assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
|
126
|
+
ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
|
127
|
+
assert_equal ['<p>こんにちは0814日</p>'], ret
|
128
|
+
ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
|
129
|
+
assert_equal ['<p>あaい?a</p>'], ret
|
130
|
+
ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
|
131
|
+
assert_equal ['<p>안녕하세요こんにちは</p>'], ret
|
132
|
+
ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
|
133
|
+
assert_equal ['<p>Hello안녕하세요처음뵙겠습니다</p>'], ret
|
134
|
+
ret = @tu_p.split_paragraph([''])
|
135
|
+
assert_equal ['<p></p>'], ret
|
136
|
+
# LaTeX
|
137
|
+
ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
|
138
|
+
assert_equal ['<p>\tag{a}A\tag{b}B</p>'], ret
|
139
|
+
ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
|
140
|
+
assert_equal ['<p>\tag{あ}い\tag{う}A\tag{え}\tag{b}\tag{お}\tag{か}</p>'], ret
|
141
|
+
# HTML/IDGXML
|
142
|
+
ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
|
143
|
+
assert_equal ['<p><b>a</b>A<b>b</b>B</p>'], ret
|
144
|
+
ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
|
145
|
+
assert_equal ['<p><b>あ</b>い<b>う</b>A<b>え</b><b>b</b><b>お</b><b>か</b></p>'], ret
|
146
|
+
# Text
|
147
|
+
ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
|
148
|
+
assert_equal ['<p>★a☆A★b☆B</p>'], ret
|
149
|
+
ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
|
150
|
+
assert_equal ['<p>★あ☆い★う☆A★え☆★b☆★お☆★か☆</p>'], ret
|
151
|
+
|
152
|
+
@tu_p.config['join_lines_by_lang'] = true
|
153
|
+
ret = @tu_p.split_paragraph(['I', 'have.'])
|
154
|
+
assert_equal ['<p>I have.</p>'], ret
|
155
|
+
ret = @tu_p.split_paragraph(['I', 'have', '.'])
|
156
|
+
assert_equal ['<p>I have .</p>'], ret # ...OK? (I have. ?)
|
157
|
+
ret = @tu_p.split_paragraph(['01', '23', 'a', '4'])
|
158
|
+
assert_equal ['<p>01 23 a 4</p>'], ret
|
159
|
+
ret = @tu_p.split_paragraph(['こんにちは', '漢字', 'α', 'アルファ?', '!'])
|
160
|
+
assert_equal ['<p>こんにちは漢字αアルファ?!</p>'], ret
|
161
|
+
ret = @tu_p.split_paragraph(['こんにちは', '0814', '日'])
|
162
|
+
assert_equal ['<p>こんにちは0814日</p>'], ret
|
163
|
+
ret = @tu_p.split_paragraph(['あ', 'a', 'い', '?', 'a'])
|
164
|
+
assert_equal ['<p>あaい? a</p>'], ret
|
165
|
+
ret = @tu_p.split_paragraph(['안녕하세요', 'こんにちは'])
|
166
|
+
assert_equal ['<p>안녕하세요こんにちは</p>'], ret
|
167
|
+
ret = @tu_p.split_paragraph(['Hello', '안녕하세요', '처음뵙겠습니다'])
|
168
|
+
assert_equal ['<p>Hello 안녕하세요 처음뵙겠습니다</p>'], ret
|
169
|
+
ret = @tu_p.split_paragraph([''])
|
170
|
+
assert_equal ['<p></p>'], ret
|
171
|
+
# LaTeX
|
172
|
+
ret = @tu_p.split_paragraph(['\tag{a}', 'A', '\tag{b}', 'B'])
|
173
|
+
assert_equal ['<p>\tag{a} A \tag{b} B</p>'], ret
|
174
|
+
ret = @tu_p.split_paragraph(['\tag{あ}', 'い', '\tag{う}', 'A', '\tag{え}', '\tag{b}', '\tag{お}', '\tag{か}'])
|
175
|
+
assert_equal ['<p>\tag{あ}い\tag{う} A \tag{え} \tag{b} \tag{お} \tag{か}</p>'], ret # ...OK? (\tag{お}\tag{か}?)
|
176
|
+
# HTML/IDGXML
|
177
|
+
ret = @tu_p.split_paragraph(['<b>a</b>', 'A', '<b>b</b>', 'B'])
|
178
|
+
assert_equal ['<p><b>a</b> A <b>b</b> B</p>'], ret
|
179
|
+
ret = @tu_p.split_paragraph(['<b>あ</b>', 'い', '<b>う</b>', 'A', '<b>え</b>', '<b>b</b>', '<b>お</b>', '<b>か</b>'])
|
180
|
+
assert_equal ['<p><b>あ</b>い<b>う</b> A <b>え</b> <b>b</b> <b>お</b> <b>か</b></p>'], ret # ...OK? (<b>お</b><b>か</b>?)
|
181
|
+
# Text
|
182
|
+
ret = @tu_p.split_paragraph(['★a☆', 'A', '★b☆', 'B'])
|
183
|
+
assert_equal ['<p>★a☆ A ★b☆ B</p>'], ret
|
184
|
+
ret = @tu_p.split_paragraph(['★あ☆', 'い', '★う☆', 'A', '★え☆', '★b☆', '★お☆', '★か☆'])
|
185
|
+
assert_equal ['<p>★あ☆い★う☆ A ★え☆ ★b☆ ★お☆ ★か☆</p>'], ret # ...OK? (★お☆★か☆?)
|
79
186
|
end
|
80
187
|
end
|
@@ -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
@@ -119,6 +119,11 @@ class TOPBuidlerTest < Test::Unit::TestCase
|
|
119
119
|
assert_equal 'test ★inline test☆◆→等幅フォント太字←◆ test2', actual
|
120
120
|
end
|
121
121
|
|
122
|
+
def test_inline_tcy
|
123
|
+
actual = compile_inline('test @<tcy>{A} test2')
|
124
|
+
assert_equal 'test ◆→開始:回転←◆A◆→終了:縦回転←◆ test2', actual
|
125
|
+
end
|
126
|
+
|
122
127
|
def test_inline_uchar
|
123
128
|
actual = compile_inline('test @<uchar>{2460} test2')
|
124
129
|
assert_equal 'test ① test2', actual
|
@@ -170,6 +175,19 @@ para
|
|
170
175
|
|
171
176
|
●\tbar
|
172
177
|
|
178
|
+
EOS
|
179
|
+
assert_equal expected, actual
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_dt_inline
|
183
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
184
|
+
|
185
|
+
expected = <<-EOS
|
186
|
+
【注1】bar
|
187
|
+
|
188
|
+
★foo【注1】[]<>&◆→TeX式ここから←◆\\alpha[]◆→TeX式ここまで←◆☆
|
189
|
+
|
190
|
+
|
173
191
|
EOS
|
174
192
|
assert_equal expected, actual
|
175
193
|
end
|
@@ -177,11 +195,19 @@ EOS
|
|
177
195
|
def test_paragraph
|
178
196
|
actual = compile_block("foo\nbar\n")
|
179
197
|
assert_equal %Q(foobar\n), actual
|
198
|
+
|
199
|
+
@book.config['join_lines_by_lang'] = true
|
200
|
+
actual = compile_block("foo\nbar\n")
|
201
|
+
assert_equal %Q(foo bar\n), actual
|
180
202
|
end
|
181
203
|
|
182
204
|
def test_tabbed_paragraph
|
183
205
|
actual = compile_block("\tfoo\nbar\n")
|
184
206
|
assert_equal %Q(\tfoobar\n), actual
|
207
|
+
|
208
|
+
@book.config['join_lines_by_lang'] = true
|
209
|
+
actual = compile_block("\tfoo\nbar\n")
|
210
|
+
assert_equal %Q(\tfoo bar\n), actual
|
185
211
|
end
|
186
212
|
|
187
213
|
def test_flushright
|
@@ -192,6 +218,17 @@ foobar
|
|
192
218
|
buz
|
193
219
|
◆→終了:右寄せ←◆
|
194
220
|
|
221
|
+
EOS
|
222
|
+
assert_equal expected, actual
|
223
|
+
|
224
|
+
@book.config['join_lines_by_lang'] = true
|
225
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
226
|
+
expected = <<-EOS
|
227
|
+
◆→開始:右寄せ←◆
|
228
|
+
foo bar
|
229
|
+
buz
|
230
|
+
◆→終了:右寄せ←◆
|
231
|
+
|
195
232
|
EOS
|
196
233
|
assert_equal expected, actual
|
197
234
|
end
|
@@ -207,6 +244,15 @@ EOS
|
|
207
244
|
◆→DTP連絡:次の1行インデントなし←◆
|
208
245
|
foobar
|
209
246
|
foo2bar2
|
247
|
+
EOS
|
248
|
+
assert_equal expected, actual
|
249
|
+
|
250
|
+
@book.config['join_lines_by_lang'] = true
|
251
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
252
|
+
expected = <<-EOS
|
253
|
+
◆→DTP連絡:次の1行インデントなし←◆
|
254
|
+
foo bar
|
255
|
+
foo2 bar2
|
210
256
|
EOS
|
211
257
|
assert_equal expected, actual
|
212
258
|
end
|
@@ -226,7 +272,7 @@ EOS
|
|
226
272
|
|
227
273
|
def test_list
|
228
274
|
def @chapter.list(_id)
|
229
|
-
Book::
|
275
|
+
Book::Index::Item.new('test', 1)
|
230
276
|
end
|
231
277
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
232
278
|
expected = <<-EOS
|
@@ -243,7 +289,7 @@ EOS
|
|
243
289
|
|
244
290
|
def test_listnum
|
245
291
|
def @chapter.list(_id)
|
246
|
-
Book::
|
292
|
+
Book::Index::Item.new('test', 1)
|
247
293
|
end
|
248
294
|
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
249
295
|
expected = <<-EOS
|
@@ -254,6 +300,19 @@ EOS
|
|
254
300
|
2: bar
|
255
301
|
◆→終了:リスト←◆
|
256
302
|
|
303
|
+
EOS
|
304
|
+
assert_equal expected, actual
|
305
|
+
|
306
|
+
@config['caption_position']['list'] = 'bottom'
|
307
|
+
actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
308
|
+
expected = <<-EOS
|
309
|
+
◆→開始:リスト←◆
|
310
|
+
1: foo
|
311
|
+
2: bar
|
312
|
+
|
313
|
+
リスト1.1 this is ★test☆<&>_
|
314
|
+
◆→終了:リスト←◆
|
315
|
+
|
257
316
|
EOS
|
258
317
|
assert_equal expected, actual
|
259
318
|
end
|
@@ -269,6 +328,20 @@ bar
|
|
269
328
|
buz
|
270
329
|
◆→終了:ソースコードリスト←◆
|
271
330
|
|
331
|
+
EOS
|
332
|
+
assert_equal expected, actual
|
333
|
+
|
334
|
+
@config['caption_position']['list'] = 'bottom'
|
335
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
336
|
+
expected = <<-EOS
|
337
|
+
◆→開始:ソースコードリスト←◆
|
338
|
+
foo
|
339
|
+
bar
|
340
|
+
|
341
|
+
buz
|
342
|
+
■foo/bar/test.rb
|
343
|
+
◆→終了:ソースコードリスト←◆
|
344
|
+
|
272
345
|
EOS
|
273
346
|
assert_equal expected, actual
|
274
347
|
end
|
@@ -306,6 +379,18 @@ foo
|
|
306
379
|
bar
|
307
380
|
◆→終了:書式←◆
|
308
381
|
|
382
|
+
EOS
|
383
|
+
assert_equal expected, actual
|
384
|
+
|
385
|
+
@config['caption_position']['list'] = 'bottom'
|
386
|
+
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
387
|
+
expected = <<-EOS
|
388
|
+
◆→開始:書式←◆
|
389
|
+
foo
|
390
|
+
bar
|
391
|
+
■FOO
|
392
|
+
◆→終了:書式←◆
|
393
|
+
|
309
394
|
EOS
|
310
395
|
assert_equal expected, actual
|
311
396
|
end
|
@@ -329,6 +414,18 @@ lineA
|
|
329
414
|
lineB
|
330
415
|
◆→終了:コマンド←◆
|
331
416
|
|
417
|
+
EOS
|
418
|
+
assert_equal expected, actual
|
419
|
+
|
420
|
+
@config['caption_position']['list'] = 'bottom'
|
421
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
422
|
+
expected = <<-EOS
|
423
|
+
◆→開始:コマンド←◆
|
424
|
+
lineA
|
425
|
+
lineB
|
426
|
+
■cap1
|
427
|
+
◆→終了:コマンド←◆
|
428
|
+
|
332
429
|
EOS
|
333
430
|
assert_equal expected, actual
|
334
431
|
end
|
@@ -354,6 +451,18 @@ lineA
|
|
354
451
|
lineB
|
355
452
|
◆→終了:インラインリスト←◆
|
356
453
|
|
454
|
+
EOS
|
455
|
+
assert_equal expected, actual
|
456
|
+
|
457
|
+
@config['caption_position']['list'] = 'bottom'
|
458
|
+
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
459
|
+
expected = <<-EOS
|
460
|
+
◆→開始:インラインリスト←◆
|
461
|
+
lineA
|
462
|
+
lineB
|
463
|
+
■cap1
|
464
|
+
◆→終了:インラインリスト←◆
|
465
|
+
|
357
466
|
EOS
|
358
467
|
assert_equal expected, actual
|
359
468
|
end
|
@@ -367,13 +476,25 @@ EOS
|
|
367
476
|
2: bar
|
368
477
|
◆→終了:インラインリスト←◆
|
369
478
|
|
479
|
+
EOS
|
480
|
+
assert_equal expected, actual
|
481
|
+
|
482
|
+
@config['caption_position']['list'] = 'bottom'
|
483
|
+
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
|
484
|
+
expected = <<-EOS
|
485
|
+
◆→開始:インラインリスト←◆
|
486
|
+
1: foo
|
487
|
+
2: bar
|
488
|
+
■this is ★test☆<&>_
|
489
|
+
◆→終了:インラインリスト←◆
|
490
|
+
|
370
491
|
EOS
|
371
492
|
assert_equal expected, actual
|
372
493
|
end
|
373
494
|
|
374
495
|
def test_bib
|
375
496
|
def @chapter.bibpaper(_id)
|
376
|
-
Book::
|
497
|
+
Book::Index::Item.new('samplebib', 1, 'sample bib')
|
377
498
|
end
|
378
499
|
|
379
500
|
assert_equal '[1]', compile_inline('@<bib>{samplebib}')
|
@@ -399,21 +520,34 @@ EOS
|
|
399
520
|
ccc\tddd<>&
|
400
521
|
◆→終了:表←◆
|
401
522
|
|
523
|
+
EOS
|
524
|
+
assert_equal expected, actual
|
525
|
+
|
526
|
+
@config['caption_position']['table'] = 'bottom'
|
527
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
528
|
+
expected = <<-EOS
|
529
|
+
◆→開始:表←◆
|
530
|
+
★aaa☆\t★bbb☆
|
531
|
+
ccc\tddd<>&
|
532
|
+
|
533
|
+
表1.1 FOO
|
534
|
+
◆→終了:表←◆
|
535
|
+
|
402
536
|
EOS
|
403
537
|
assert_equal expected, actual
|
404
538
|
end
|
405
539
|
|
406
540
|
def test_empty_table
|
407
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
541
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
408
542
|
assert_equal ':2: error: no rows in the table', e.message
|
409
543
|
|
410
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
544
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
411
545
|
assert_equal ':3: error: no rows in the table', e.message
|
412
546
|
end
|
413
547
|
|
414
548
|
def test_inline_table
|
415
549
|
def @chapter.table(_id)
|
416
|
-
Book::
|
550
|
+
Book::Index::Item.new('sampletable', 1)
|
417
551
|
end
|
418
552
|
actual = compile_block("@<table>{sampletest}\n")
|
419
553
|
assert_equal "表1.1\n", actual
|
@@ -434,6 +568,52 @@ ccc\tddd<>&
|
|
434
568
|
ccc\tddd<>&
|
435
569
|
◆→終了:表←◆
|
436
570
|
|
571
|
+
EOS
|
572
|
+
assert_equal expected, actual
|
573
|
+
end
|
574
|
+
|
575
|
+
def test_table_row_separator
|
576
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
577
|
+
expected = <<-EOS
|
578
|
+
◆→開始:表←◆
|
579
|
+
★1☆ ★2☆ ★3 4| 5☆
|
580
|
+
a b c d |e
|
581
|
+
◆→終了:表←◆
|
582
|
+
|
583
|
+
EOS
|
584
|
+
actual = compile_block(src)
|
585
|
+
assert_equal expected, actual
|
586
|
+
|
587
|
+
@config['table_row_separator'] = 'singletab'
|
588
|
+
actual = compile_block(src)
|
589
|
+
expected = <<-EOS
|
590
|
+
◆→開始:表←◆
|
591
|
+
★1☆ ★2☆ ★☆ ★3 4| 5☆
|
592
|
+
a b c d |e
|
593
|
+
◆→終了:表←◆
|
594
|
+
|
595
|
+
EOS
|
596
|
+
assert_equal expected, actual
|
597
|
+
|
598
|
+
@config['table_row_separator'] = 'spaces'
|
599
|
+
actual = compile_block(src)
|
600
|
+
expected = <<-EOS
|
601
|
+
◆→開始:表←◆
|
602
|
+
★1☆ ★2☆ ★3☆ ★4|☆ ★5☆
|
603
|
+
a b c d |e
|
604
|
+
◆→終了:表←◆
|
605
|
+
|
606
|
+
EOS
|
607
|
+
assert_equal expected, actual
|
608
|
+
|
609
|
+
@config['table_row_separator'] = 'verticalbar'
|
610
|
+
actual = compile_block(src)
|
611
|
+
expected = <<-EOS
|
612
|
+
◆→開始:表←◆
|
613
|
+
★1 2 3 4☆ ★5☆
|
614
|
+
a b c d e
|
615
|
+
◆→終了:表←◆
|
616
|
+
|
437
617
|
EOS
|
438
618
|
assert_equal expected, actual
|
439
619
|
end
|
@@ -560,9 +740,186 @@ EOS
|
|
560
740
|
assert_equal expected, actual
|
561
741
|
end
|
562
742
|
|
743
|
+
def test_minicolumn_blocks
|
744
|
+
titles = {
|
745
|
+
'note' => 'ノート',
|
746
|
+
'memo' => 'メモ',
|
747
|
+
'important' => '重要',
|
748
|
+
'info' => '情報',
|
749
|
+
'notice' => '注意',
|
750
|
+
'caution' => '警告',
|
751
|
+
'warning' => '危険',
|
752
|
+
'tip' => 'TIP'
|
753
|
+
}
|
754
|
+
|
755
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
756
|
+
@builder.doc_status.clear
|
757
|
+
src = <<-EOS
|
758
|
+
//#{type}[#{type}1]{
|
759
|
+
|
760
|
+
//}
|
761
|
+
|
762
|
+
//#{type}[#{type}2]{
|
763
|
+
//}
|
764
|
+
EOS
|
765
|
+
|
766
|
+
expected = <<-EOS
|
767
|
+
◆→開始:#{titles[type]}←◆
|
768
|
+
■#{type}1
|
769
|
+
◆→終了:#{titles[type]}←◆
|
770
|
+
|
771
|
+
◆→開始:#{titles[type]}←◆
|
772
|
+
■#{type}2
|
773
|
+
◆→終了:#{titles[type]}←◆
|
774
|
+
|
775
|
+
EOS
|
776
|
+
assert_equal expected, compile_block(src)
|
777
|
+
|
778
|
+
src = <<-EOS
|
779
|
+
//#{type}[#{type}2]{
|
780
|
+
|
781
|
+
//}
|
782
|
+
|
783
|
+
//#{type}[#{type}3]{
|
784
|
+
|
785
|
+
//}
|
786
|
+
|
787
|
+
//#{type}[#{type}4]{
|
788
|
+
|
789
|
+
//}
|
790
|
+
|
791
|
+
//#{type}[#{type}5]{
|
792
|
+
|
793
|
+
//}
|
794
|
+
|
795
|
+
//#{type}[#{type}6]{
|
796
|
+
|
797
|
+
//}
|
798
|
+
EOS
|
799
|
+
|
800
|
+
expected = <<-EOS
|
801
|
+
◆→開始:#{titles[type]}←◆
|
802
|
+
■#{type}2
|
803
|
+
◆→終了:#{titles[type]}←◆
|
804
|
+
|
805
|
+
◆→開始:#{titles[type]}←◆
|
806
|
+
■#{type}3
|
807
|
+
◆→終了:#{titles[type]}←◆
|
808
|
+
|
809
|
+
◆→開始:#{titles[type]}←◆
|
810
|
+
■#{type}4
|
811
|
+
◆→終了:#{titles[type]}←◆
|
812
|
+
|
813
|
+
◆→開始:#{titles[type]}←◆
|
814
|
+
■#{type}5
|
815
|
+
◆→終了:#{titles[type]}←◆
|
816
|
+
|
817
|
+
◆→開始:#{titles[type]}←◆
|
818
|
+
■#{type}6
|
819
|
+
◆→終了:#{titles[type]}←◆
|
820
|
+
|
821
|
+
EOS
|
822
|
+
assert_equal expected, compile_block(src)
|
823
|
+
|
824
|
+
src = <<-EOS
|
825
|
+
//#{type}{
|
826
|
+
|
827
|
+
* A
|
828
|
+
|
829
|
+
1. B
|
830
|
+
|
831
|
+
//}
|
832
|
+
|
833
|
+
//#{type}[OMITEND1]{
|
834
|
+
|
835
|
+
//emlist{
|
836
|
+
LIST
|
837
|
+
//}
|
838
|
+
|
839
|
+
//}
|
840
|
+
//#{type}[OMITEND2]{
|
841
|
+
//}
|
842
|
+
EOS
|
843
|
+
|
844
|
+
expected = <<-EOS
|
845
|
+
◆→開始:#{titles[type]}←◆
|
846
|
+
|
847
|
+
● A
|
848
|
+
|
849
|
+
1 B
|
850
|
+
|
851
|
+
◆→終了:#{titles[type]}←◆
|
852
|
+
|
853
|
+
◆→開始:#{titles[type]}←◆
|
854
|
+
■OMITEND1
|
855
|
+
|
856
|
+
◆→開始:インラインリスト←◆
|
857
|
+
LIST
|
858
|
+
◆→終了:インラインリスト←◆
|
859
|
+
|
860
|
+
◆→終了:#{titles[type]}←◆
|
861
|
+
|
862
|
+
◆→開始:#{titles[type]}←◆
|
863
|
+
■OMITEND2
|
864
|
+
◆→終了:#{titles[type]}←◆
|
865
|
+
|
866
|
+
EOS
|
867
|
+
assert_equal expected, compile_block(src)
|
868
|
+
end
|
869
|
+
end
|
870
|
+
|
871
|
+
def test_minicolumn_blocks_nest_error1
|
872
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
873
|
+
@builder.doc_status.clear
|
874
|
+
src = <<-EOS
|
875
|
+
//#{type}{
|
876
|
+
|
877
|
+
//#{type}{
|
878
|
+
//}
|
879
|
+
|
880
|
+
//}
|
881
|
+
EOS
|
882
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
883
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
884
|
+
end
|
885
|
+
end
|
886
|
+
|
887
|
+
def test_minicolumn_blocks_nest_error2
|
888
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
889
|
+
@builder.doc_status.clear
|
890
|
+
src = <<-EOS
|
891
|
+
//#{type}{
|
892
|
+
|
893
|
+
//#{type}{
|
894
|
+
|
895
|
+
//}
|
896
|
+
|
897
|
+
//}
|
898
|
+
EOS
|
899
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
900
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
901
|
+
end
|
902
|
+
end
|
903
|
+
|
904
|
+
def test_minicolumn_blocks_nest_error3
|
905
|
+
%w[memo tip info warning important caution notice].each do |type|
|
906
|
+
@builder.doc_status.clear
|
907
|
+
src = <<-EOS
|
908
|
+
//#{type}{
|
909
|
+
|
910
|
+
//note{
|
911
|
+
//}
|
912
|
+
|
913
|
+
//}
|
914
|
+
EOS
|
915
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
916
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
563
920
|
def test_image
|
564
921
|
def @chapter.image(_id)
|
565
|
-
item = Book::
|
922
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
566
923
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
567
924
|
item
|
568
925
|
end
|
@@ -570,6 +927,18 @@ EOS
|
|
570
927
|
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
|
571
928
|
expected = <<-EOS
|
572
929
|
◆→開始:図←◆
|
930
|
+
◆→./images/chap1-sampleimg.png←◆
|
931
|
+
|
932
|
+
図1.1 sample photo
|
933
|
+
◆→終了:図←◆
|
934
|
+
|
935
|
+
EOS
|
936
|
+
assert_equal expected, actual
|
937
|
+
|
938
|
+
@config['caption_position']['image'] = 'top'
|
939
|
+
actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
|
940
|
+
expected = <<-EOS
|
941
|
+
◆→開始:図←◆
|
573
942
|
図1.1 sample photo
|
574
943
|
|
575
944
|
◆→./images/chap1-sampleimg.png←◆
|
@@ -581,7 +950,7 @@ EOS
|
|
581
950
|
|
582
951
|
def test_image_with_metric
|
583
952
|
def @chapter.image(_id)
|
584
|
-
item = Book::
|
953
|
+
item = Book::Index::Item.new('sampleimg', 1)
|
585
954
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
586
955
|
item
|
587
956
|
end
|
@@ -589,9 +958,9 @@ EOS
|
|
589
958
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\nfoo\n//}\n")
|
590
959
|
expected = <<-EOS
|
591
960
|
◆→開始:図←◆
|
592
|
-
図1.1 sample photo
|
593
|
-
|
594
961
|
◆→./images/chap1-sampleimg.png scale=1.2←◆
|
962
|
+
|
963
|
+
図1.1 sample photo
|
595
964
|
◆→終了:図←◆
|
596
965
|
|
597
966
|
EOS
|
@@ -621,26 +990,26 @@ EOB
|
|
621
990
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
622
991
|
|
623
992
|
io = StringIO.new
|
624
|
-
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
993
|
+
@builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
625
994
|
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
626
995
|
assert_equal %Q(foo bar"\\<>_@<b>{BAZ} ★bar"\\<>_@<b>{BAZ}☆ [missing word: N]\n), actual
|
627
|
-
assert_match(/WARN
|
996
|
+
assert_match(/WARN --: :1: word not bound: N/, io.string)
|
628
997
|
end
|
629
998
|
end
|
630
999
|
|
631
1000
|
def test_inline_unknown
|
632
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1001
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
633
1002
|
assert_equal ':1: error: unknown image: n', e.message
|
634
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1003
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
635
1004
|
assert_equal ':1: error: unknown footnote: n', e.message
|
636
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1005
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
637
1006
|
assert_equal ':1: error: unknown headline: n', e.message
|
638
1007
|
%w[list table column].each do |name|
|
639
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1008
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
640
1009
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
641
1010
|
end
|
642
1011
|
%w[chap chapref title].each do |name|
|
643
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
1012
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
644
1013
|
assert_equal ':1: error: key not found: "n"', e.message
|
645
1014
|
end
|
646
1015
|
end
|
@@ -742,6 +1111,20 @@ EOS
|
|
742
1111
|
e=mc^2
|
743
1112
|
◆→終了:TeX式←◆
|
744
1113
|
|
1114
|
+
EOS
|
1115
|
+
actual = compile_block(src)
|
1116
|
+
assert_equal expected, actual
|
1117
|
+
|
1118
|
+
@config['caption_position']['equation'] = 'bottom'
|
1119
|
+
|
1120
|
+
expected = <<-EOS
|
1121
|
+
式1.1
|
1122
|
+
|
1123
|
+
◆→開始:TeX式←◆
|
1124
|
+
e=mc^2
|
1125
|
+
式1.1 The Equivalence of Mass ▲and☆ Energy
|
1126
|
+
◆→終了:TeX式←◆
|
1127
|
+
|
745
1128
|
EOS
|
746
1129
|
actual = compile_block(src)
|
747
1130
|
assert_equal expected, actual
|