review 4.1.0 → 5.2.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 +19 -9
- data/.github/workflows/ruby.yml +7 -3
- data/.rubocop.yml +138 -34
- data/NEWS.ja.md +285 -0
- data/NEWS.md +285 -1
- data/README.md +7 -6
- data/Rakefile +7 -2
- data/bin/review +2 -4
- data/bin/review-catalog-converter +4 -4
- data/bin/review-check +8 -12
- data/bin/review-checkdep +2 -5
- data/bin/review-compile +18 -34
- data/bin/review-epub2html +1 -4
- data/bin/review-epubmaker +3 -4
- data/bin/review-idgxmlmaker +1 -3
- data/bin/review-index +5 -86
- 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 +4 -4
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +45 -11
- data/doc/config.yml.sample-simple +3 -3
- data/doc/format.ja.md +103 -13
- data/doc/format.md +104 -16
- data/doc/makeindex.ja.md +2 -2
- data/doc/pdfmaker.ja.md +42 -0
- data/doc/pdfmaker.md +41 -0
- data/doc/quickstart.ja.md +19 -6
- data/doc/quickstart.md +18 -6
- data/doc/writing_vertical.ja.md +6 -0
- data/lib/review.rb +1 -1
- data/lib/review/book.rb +2 -2
- data/lib/review/book/base.rb +67 -29
- data/lib/review/book/bib.rb +21 -0
- data/lib/review/book/book_unit.rb +158 -0
- data/lib/review/book/chapter.rb +33 -26
- data/lib/review/book/index.rb +24 -185
- data/lib/review/book/index/item.rb +7 -1
- data/lib/review/book/page_metric.rb +7 -7
- data/lib/review/book/part.rb +26 -11
- data/lib/review/book/volume.rb +5 -5
- data/lib/review/builder.rb +121 -52
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +3 -2
- data/lib/review/compiler.rb +230 -111
- data/lib/review/configure.rb +91 -7
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +124 -152
- 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/exception.rb +13 -0
- data/lib/review/htmlbuilder.rb +176 -89
- data/lib/review/htmlutils.rb +8 -11
- data/lib/review/i18n.rb +2 -1
- data/lib/review/idgxmlbuilder.rb +165 -75
- data/lib/review/idgxmlmaker.rb +24 -28
- data/lib/review/img_math.rb +238 -0
- data/lib/review/index_builder.rb +645 -0
- data/lib/review/init.rb +9 -17
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +193 -75
- 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 +90 -3
- data/lib/review/makerhelper.rb +17 -188
- data/lib/review/markdownbuilder.rb +54 -4
- data/lib/review/pdfmaker.rb +76 -84
- data/lib/review/plaintextbuilder.rb +106 -22
- data/lib/review/preprocessor.rb +107 -303
- 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/rstbuilder.rb +27 -8
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +11 -1
- data/lib/review/textmaker.rb +27 -32
- data/lib/review/textutils.rb +3 -12
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +98 -31
- data/lib/review/update.rb +12 -13
- data/lib/review/version.rb +1 -1
- data/lib/review/volumeprinter.rb +97 -0
- data/lib/review/webmaker.rb +40 -47
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +2 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/config-epub2.yml +1 -1
- data/samples/sample-book/src/config.yml +3 -3
- 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/Gemfile +1 -1
- data/samples/syntax-book/ch01.re +1 -1
- data/samples/syntax-book/ch02.re +21 -6
- data/samples/syntax-book/ch03.re +1 -1
- data/samples/syntax-book/config.yml +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 +35 -23
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +36 -23
- data/templates/latex/review-jlreq/review-jlreq.cls +18 -25
- 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/README.md +7 -5
- data/templates/latex/review-jsbook/review-base.sty +40 -24
- data/templates/latex/review-jsbook/review-jsbook.cls +13 -3
- 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 +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 +6 -3
- data/test/assets/test_template_backmatter.tex +6 -3
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +54 -63
- data/test/test_book_chapter.rb +95 -54
- data/test/test_book_part.rb +3 -3
- data/test/test_builder.rb +29 -20
- 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 +254 -129
- data/test/test_epubmaker_cmd.rb +15 -4
- data/test/test_helper.rb +12 -5
- data/test/test_htmlbuilder.rb +926 -76
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +531 -20
- data/test/test_idgxmlmaker_cmd.rb +7 -3
- 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 +891 -20
- data/test/test_latexbuilder_v2.rb +56 -10
- data/test/test_lineinput.rb +20 -93
- data/test/test_logger.rb +7 -7
- data/test/test_makerhelper.rb +0 -12
- data/test/test_markdownbuilder.rb +32 -0
- data/test/test_pdfmaker.rb +100 -11
- data/test/test_pdfmaker_cmd.rb +3 -3
- data/test/test_plaintextbuilder.rb +546 -32
- data/test/test_preprocessor.rb +188 -1
- data/test/test_review_ext.rb +2 -1
- data/test/test_reviewheaderlistener.rb +49 -0
- data/test/test_rstbuilder.rb +25 -1
- data/test/test_sec_counter.rb +156 -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 +324 -20
- data/test/test_update.rb +44 -44
- data/test/test_webtocprinter.rb +75 -43
- 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/Makefile +3 -2
- data/vendor/jsclasses/create_archive.sh +5 -5
- data/vendor/jsclasses/jis/Makefile +3 -2
- data/vendor/jsclasses/jis/jsarticle.cls +22 -18
- data/vendor/jsclasses/jis/jsbook.cls +22 -18
- data/vendor/jsclasses/jis/jsclasses.dtx +94 -13
- data/vendor/jsclasses/jis/jsclasses.ins +15 -5
- data/vendor/jsclasses/jis/jslogo.ins +9 -0
- data/vendor/jsclasses/jis/jslogo.sty +1 -13
- data/vendor/jsclasses/jis/jspf.cls +22 -18
- data/vendor/jsclasses/jis/jsreport.cls +22 -18
- data/vendor/jsclasses/jis/jsverb.ins +9 -0
- data/vendor/jsclasses/jis/jsverb.sty +1 -13
- data/vendor/jsclasses/jis/kiyou.cls +22 -18
- data/vendor/jsclasses/jis/minijs.sty +65 -22
- data/vendor/jsclasses/jis/okumacro.ins +9 -0
- data/vendor/jsclasses/jis/okumacro.sty +1 -13
- 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 +22 -18
- data/vendor/jsclasses/jsbook.cls +22 -18
- data/vendor/jsclasses/jsclasses.dtx +94 -13
- data/vendor/jsclasses/jsclasses.ins +15 -5
- data/vendor/jsclasses/jsclasses.pdf +0 -0
- data/vendor/jsclasses/jslogo.ins +9 -0
- data/vendor/jsclasses/jslogo.pdf +0 -0
- data/vendor/jsclasses/jslogo.sty +1 -13
- data/vendor/jsclasses/jspf.cls +22 -18
- data/vendor/jsclasses/jsreport.cls +22 -18
- 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 +22 -18
- data/vendor/jsclasses/minijs.sty +68 -22
- data/vendor/jsclasses/okumacro.ins +9 -0
- data/vendor/jsclasses/okumacro.pdf +0 -0
- data/vendor/jsclasses/okumacro.sty +1 -13
- 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 +106 -22
- 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 -178
- data/lib/review/tocparser.rb +0 -275
- data/test/test_tocparser.rb +0 -25
data/test/test_epubmaker_cmd.rb
CHANGED
@@ -3,21 +3,20 @@ require 'tmpdir'
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'yaml'
|
5
5
|
require 'rbconfig'
|
6
|
+
require 'zip'
|
6
7
|
|
7
|
-
REVIEW_EPUBMAKER = File.expand_path('../bin/review-epubmaker',
|
8
|
+
REVIEW_EPUBMAKER = File.expand_path('../bin/review-epubmaker', __dir__)
|
8
9
|
|
9
10
|
class EPUBMakerCmdTest < Test::Unit::TestCase
|
10
11
|
def setup
|
11
12
|
@tmpdir1 = Dir.mktmpdir
|
12
|
-
@tmpdir2 = Dir.mktmpdir
|
13
13
|
|
14
14
|
@old_rubylib = ENV['RUBYLIB']
|
15
|
-
ENV['RUBYLIB'] = File.expand_path('
|
15
|
+
ENV['RUBYLIB'] = File.expand_path('lib', __dir__)
|
16
16
|
end
|
17
17
|
|
18
18
|
def teardown
|
19
19
|
FileUtils.rm_rf(@tmpdir1)
|
20
|
-
FileUtils.rm_rf(@tmpdir2)
|
21
20
|
ENV['RUBYLIB'] = @old_rubylib
|
22
21
|
end
|
23
22
|
|
@@ -35,11 +34,23 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
37
|
+
def check_filesize(epubfile)
|
38
|
+
if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
|
39
|
+
Zip::File.open(epubfile) do |zio|
|
40
|
+
zio.each do |entry|
|
41
|
+
assert_not_equal(0, entry.size, "#{entry.name} is 0 byte.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
38
47
|
def test_epubmaker_cmd_samplebook
|
39
48
|
common_buildepub('sample-book/src', 'config.yml', 'book.epub')
|
49
|
+
check_filesize(File.join(@tmpdir1, 'book.epub'))
|
40
50
|
end
|
41
51
|
|
42
52
|
def test_epubmaker_cmd_syntaxbook
|
43
53
|
common_buildepub('syntax-book', 'config.yml', 'syntax-book.epub')
|
54
|
+
check_filesize(File.join(@tmpdir1, 'syntax-book.epub'))
|
44
55
|
end
|
45
56
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.
|
1
|
+
$LOAD_PATH.unshift(File.realpath('../lib', __dir__))
|
2
|
+
|
2
3
|
require 'test/unit'
|
3
4
|
require 'fileutils'
|
4
5
|
require 'review/yamlloader'
|
@@ -9,15 +10,18 @@ def touch_file(path)
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def assets_dir
|
12
|
-
File.join(
|
13
|
+
File.join(__dir__, 'assets')
|
13
14
|
end
|
14
15
|
|
15
16
|
def prepare_samplebook(srcdir, bookdir, latextemplatedir, configfile)
|
16
|
-
samplebook_dir = File.expand_path("../samples/#{bookdir}/",
|
17
|
-
|
17
|
+
samplebook_dir = File.expand_path("../samples/#{bookdir}/", __dir__)
|
18
|
+
files = Dir.glob(File.join(samplebook_dir, '*'))
|
19
|
+
# ignore temporary built files
|
20
|
+
files.delete_if { |file| file =~ /.*-(pdf|epub|text)/ || file == 'webroot' }
|
21
|
+
FileUtils.cp_r(files, srcdir)
|
18
22
|
if latextemplatedir
|
19
23
|
# copy from review-jsbook or review-jlreq
|
20
|
-
template_dir = File.expand_path("../templates/latex/#{latextemplatedir}/",
|
24
|
+
template_dir = File.expand_path("../templates/latex/#{latextemplatedir}/", __dir__)
|
21
25
|
FileUtils.cp(Dir.glob(File.join(template_dir, '*')), File.join(srcdir, 'sty'))
|
22
26
|
end
|
23
27
|
loader = ReVIEW::YAMLLoader.new
|
@@ -36,11 +40,13 @@ end
|
|
36
40
|
|
37
41
|
def compile_block_default(text)
|
38
42
|
@chapter.content = text
|
43
|
+
@chapter.execute_indexer(force: true)
|
39
44
|
@compiler.compile(@chapter)
|
40
45
|
end
|
41
46
|
|
42
47
|
def compile_block_html(text)
|
43
48
|
@chapter.content = text
|
49
|
+
@chapter.execute_indexer(force: true)
|
44
50
|
matched = @compiler.compile(@chapter).match(Regexp.new(%Q(<body>\n(.+)</body>), Regexp::MULTILINE))
|
45
51
|
if matched && matched.size > 1
|
46
52
|
matched[1]
|
@@ -51,5 +57,6 @@ end
|
|
51
57
|
|
52
58
|
def compile_block_idgxml(text)
|
53
59
|
@chapter.content = text
|
60
|
+
@chapter.execute_indexer(force: true)
|
54
61
|
@compiler.compile(@chapter).gsub(Regexp.new(%Q(.*<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">), Regexp::MULTILINE), '').gsub("</doc>\n", '')
|
55
62
|
end
|
data/test/test_htmlbuilder.rb
CHANGED
@@ -8,7 +8,6 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
def setup
|
10
10
|
ReVIEW::I18n.setup
|
11
|
-
@builder = HTMLBuilder.new
|
12
11
|
@config = ReVIEW::Configure.values
|
13
12
|
@config['secnolevel'] = 2
|
14
13
|
@config['stylesheet'] = nil
|
@@ -16,11 +15,16 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
16
15
|
@config['epubmaker'] = {}
|
17
16
|
@book = Book::Base.new('.')
|
18
17
|
@book.config = @config
|
18
|
+
img_math = ReVIEW::ImgMath.new(@config)
|
19
|
+
@log_io = StringIO.new
|
20
|
+
ReVIEW.logger = ReVIEW::Logger.new(@log_io)
|
21
|
+
@builder = HTMLBuilder.new(img_math: img_math)
|
19
22
|
@compiler = ReVIEW::Compiler.new(@builder)
|
20
23
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
21
24
|
location = Location.new(nil, nil)
|
22
25
|
@builder.bind(@compiler, @chapter, location)
|
23
26
|
I18n.setup('ja')
|
27
|
+
@skip_pygments = true # temporary suppress pygments test
|
24
28
|
end
|
25
29
|
|
26
30
|
def test_xmlns_ops_prefix_epub3
|
@@ -61,7 +65,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
61
65
|
Dir.mktmpdir do |dir|
|
62
66
|
Dir.chdir(dir) do
|
63
67
|
file = File.join(dir, 'locale.yml')
|
64
|
-
File.
|
68
|
+
File.write(file, "locale: ja\nappendix: 付録%pR")
|
65
69
|
I18n.setup('ja')
|
66
70
|
@chapter.instance_eval do
|
67
71
|
def on_appendix?
|
@@ -82,7 +86,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
82
86
|
Dir.mktmpdir do |dir|
|
83
87
|
Dir.chdir(dir) do
|
84
88
|
file = File.join(dir, 'locale.yml')
|
85
|
-
File.
|
89
|
+
File.write(file, "locale: ja\nappendix: 付録%pA")
|
86
90
|
I18n.setup('ja')
|
87
91
|
@chapter.instance_eval do
|
88
92
|
def on_appendix?
|
@@ -106,8 +110,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
106
110
|
end
|
107
111
|
|
108
112
|
def test_headline_level1_with_tricky_id
|
109
|
-
actual = compile_block("={123
|
110
|
-
assert_equal %Q(<h1 id="
|
113
|
+
actual = compile_block("={123あ_} this is test.\n")
|
114
|
+
assert_equal %Q(<h1 id="id_123_E3_81_82__"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n), actual
|
111
115
|
end
|
112
116
|
|
113
117
|
def test_headline_level1_with_inlinetag
|
@@ -131,14 +135,56 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
131
135
|
assert_equal %Q(\n<h3 id="test"><a id="h1-0-1"></a><span class="secno">1.0.1 </span>this is test.</h3>\n), actual
|
132
136
|
end
|
133
137
|
|
138
|
+
def test_headline_sections
|
139
|
+
@book.config['epubmaker']['use_section'] = true
|
140
|
+
actual = compile_block("= H1\n== H2\n== H2-2\n")
|
141
|
+
expected = <<-EOS
|
142
|
+
<section class="level1"><h1><a id="h1"></a><span class="secno">第1章 </span>H1</h1>
|
143
|
+
<section class="level2">
|
144
|
+
<h2><a id="h1-1"></a><span class="secno">1.1 </span>H2</h2>
|
145
|
+
</section>
|
146
|
+
<section class="level2">
|
147
|
+
<h2><a id="h1-2"></a><span class="secno">1.2 </span>H2-2</h2>
|
148
|
+
</section>
|
149
|
+
</section>
|
150
|
+
EOS
|
151
|
+
assert_equal expected, actual
|
152
|
+
|
153
|
+
actual = compile_block("= H1\n== H2\n==== H4\n== H2-2\n")
|
154
|
+
expected = <<-EOS
|
155
|
+
<section class="level1"><h1><a id="h1"></a><span class="secno">第1章 </span>H1</h1>
|
156
|
+
<section class="level2">
|
157
|
+
<h2><a id="h1-1"></a><span class="secno">1.1 </span>H2</h2>
|
158
|
+
<section class="level4">
|
159
|
+
<h4><a id="h1-1-0-1"></a>H4</h4>
|
160
|
+
</section>
|
161
|
+
</section>
|
162
|
+
<section class="level2">
|
163
|
+
<h2><a id="h1-2"></a><span class="secno">1.2 </span>H2-2</h2>
|
164
|
+
</section>
|
165
|
+
</section>
|
166
|
+
EOS
|
167
|
+
assert_equal expected, actual
|
168
|
+
|
169
|
+
actual = compile_block("===== H5\n= H1\n")
|
170
|
+
expected = <<-EOS
|
171
|
+
<section class="level5">
|
172
|
+
<h5><a id="h1-0-0-0-1"></a>H5</h5>
|
173
|
+
</section>
|
174
|
+
<section class="level1"><h1><a id="h1"></a><span class="secno">第1章 </span>H1</h1>
|
175
|
+
</section>
|
176
|
+
EOS
|
177
|
+
assert_equal expected, actual
|
178
|
+
end
|
179
|
+
|
134
180
|
def test_label
|
135
181
|
actual = compile_block("//label[label_test]\n")
|
136
182
|
assert_equal %Q(<a id="label_test"></a>\n), actual
|
137
183
|
end
|
138
184
|
|
139
185
|
def test_label_with_tricky_id
|
140
|
-
actual = compile_block("//label[123
|
141
|
-
assert_equal %Q(<a id="
|
186
|
+
actual = compile_block("//label[123あ_]\n")
|
187
|
+
assert_equal %Q(<a id="id_123_E3_81_82__"></a>\n), actual
|
142
188
|
end
|
143
189
|
|
144
190
|
def test_href
|
@@ -250,6 +296,15 @@ EOS
|
|
250
296
|
idx
|
251
297
|
end
|
252
298
|
|
299
|
+
@config['secnolevel'] = 2
|
300
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
301
|
+
assert_equal 'test <a href="-.html#h1-1-1">「te_st」</a> test2', actual
|
302
|
+
|
303
|
+
@config['secnolevel'] = 3
|
304
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
305
|
+
assert_equal 'test <a href="-.html#h1-1-1">「1.1.1 te_st」</a> test2', actual
|
306
|
+
|
307
|
+
@config['chapterlink'] = nil
|
253
308
|
@config['secnolevel'] = 2
|
254
309
|
actual = compile_inline('test @<hd>{chap1|test} test2')
|
255
310
|
assert_equal 'test 「te_st」 test2', actual
|
@@ -263,7 +318,7 @@ EOS
|
|
263
318
|
Dir.mktmpdir do |dir|
|
264
319
|
Dir.chdir(dir) do
|
265
320
|
file = File.join(dir, 'locale.yml')
|
266
|
-
File.
|
321
|
+
File.write(file, "locale: ja\nappendix: 付録%pR")
|
267
322
|
I18n.setup('ja')
|
268
323
|
@chapter.instance_eval do
|
269
324
|
def on_appendix?
|
@@ -278,6 +333,10 @@ EOS
|
|
278
333
|
idx
|
279
334
|
end
|
280
335
|
|
336
|
+
actual = compile_inline('test @<hd>{test} test2')
|
337
|
+
assert_equal 'test <a href="-.html#hI-1">「I.1 te_st」</a> test2', actual
|
338
|
+
|
339
|
+
@config['chapterlink'] = nil
|
281
340
|
actual = compile_inline('test @<hd>{test} test2')
|
282
341
|
assert_equal 'test 「I.1 te_st」 test2', actual
|
283
342
|
end
|
@@ -288,7 +347,7 @@ EOS
|
|
288
347
|
Dir.mktmpdir do |dir|
|
289
348
|
Dir.chdir(dir) do
|
290
349
|
file = File.join(dir, 'locale.yml')
|
291
|
-
File.
|
350
|
+
File.write(file, "locale: ja\nappendix: 付録%pA")
|
292
351
|
I18n.setup('ja')
|
293
352
|
@chapter.instance_eval do
|
294
353
|
def on_appendix?
|
@@ -303,6 +362,10 @@ EOS
|
|
303
362
|
idx
|
304
363
|
end
|
305
364
|
|
365
|
+
actual = compile_inline('test @<hd>{test} test2')
|
366
|
+
assert_equal 'test <a href="-.html#hA-1">「A.1 te_st」</a> test2', actual
|
367
|
+
|
368
|
+
@config['chapterlink'] = nil
|
306
369
|
actual = compile_inline('test @<hd>{test} test2')
|
307
370
|
assert_equal 'test 「A.1 te_st」 test2', actual
|
308
371
|
end
|
@@ -341,12 +404,26 @@ EOS
|
|
341
404
|
rescue LoadError
|
342
405
|
return true
|
343
406
|
end
|
344
|
-
@config['
|
407
|
+
@config['math_format'] = 'mathml'
|
345
408
|
actual = compile_inline('@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}')
|
346
|
-
@config['mathml'] = nil
|
347
409
|
assert_equal %Q(<span class="equation"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span>), actual
|
348
410
|
end
|
349
411
|
|
412
|
+
def test_inline_mathjax
|
413
|
+
@config['math_format'] = 'mathjax'
|
414
|
+
actual = compile_inline('@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}')
|
415
|
+
assert_equal %Q(<span class="equation">\\( \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a} \\)</span>), actual
|
416
|
+
|
417
|
+
content = <<-EOF
|
418
|
+
//texequation{
|
419
|
+
\\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}
|
420
|
+
//}
|
421
|
+
EOF
|
422
|
+
actual = compile_block(content)
|
423
|
+
expected = %Q(<div class="equation">\n$$\\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$$\n</div>\n)
|
424
|
+
assert_equal expected, actual
|
425
|
+
end
|
426
|
+
|
350
427
|
def test_inline_img
|
351
428
|
def @chapter.image(_id)
|
352
429
|
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
@@ -354,6 +431,11 @@ EOS
|
|
354
431
|
item
|
355
432
|
end
|
356
433
|
|
434
|
+
actual = compile_block("@<img>{sampleimg}\n")
|
435
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
436
|
+
assert_equal expected, actual
|
437
|
+
|
438
|
+
@config['chapterlink'] = nil
|
357
439
|
actual = compile_block("@<img>{sampleimg}\n")
|
358
440
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
359
441
|
assert_equal expected, actual
|
@@ -366,6 +448,11 @@ EOS
|
|
366
448
|
item
|
367
449
|
end
|
368
450
|
|
451
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
452
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span>「sample photo」</p>\n)
|
453
|
+
assert_equal expected, actual
|
454
|
+
|
455
|
+
@config['chapterlink'] = nil
|
369
456
|
actual = compile_block("@<imgref>{sampleimg}\n")
|
370
457
|
expected = %Q(<p><span class="imgref">図1.1</span>「sample photo」</p>\n)
|
371
458
|
assert_equal expected, actual
|
@@ -378,6 +465,11 @@ EOS
|
|
378
465
|
item
|
379
466
|
end
|
380
467
|
|
468
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
469
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
470
|
+
assert_equal expected, actual
|
471
|
+
|
472
|
+
@config['chapterlink'] = nil
|
381
473
|
actual = compile_block("@<imgref>{sampleimg}\n")
|
382
474
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
383
475
|
assert_equal expected, actual
|
@@ -389,20 +481,24 @@ EOS
|
|
389
481
|
file1 = File.join(dir, 'images', 'img1.png')
|
390
482
|
filet1 = File.join(dir, 'images', 'tbl1.png')
|
391
483
|
file2 = File.join(dir, 'images', 'img2.png')
|
484
|
+
file3 = File.join(dir, 'images', 'icon3.png')
|
392
485
|
re1 = File.join(dir, 'sample1.re')
|
393
486
|
cat = File.join(dir, 'catalog.yml')
|
394
487
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
395
|
-
File.
|
396
|
-
File.
|
397
|
-
File.
|
398
|
-
File.
|
399
|
-
File.
|
488
|
+
File.write(file1, '')
|
489
|
+
File.write(filet1, '')
|
490
|
+
File.write(file2, '')
|
491
|
+
File.write(file3, '')
|
492
|
+
File.write(cat, "CHAPS:\n - sample1.re\n")
|
493
|
+
File.write(re1, <<-EOF)
|
400
494
|
= test
|
401
495
|
|
402
496
|
tbl1 is @<table>{tbl1}.
|
403
497
|
|
404
498
|
img2 is @<img>{img2}.
|
405
499
|
|
500
|
+
icon3 is @<icon>{icon3}.
|
501
|
+
|
406
502
|
//image[img1][image 1]{
|
407
503
|
//}
|
408
504
|
|
@@ -417,8 +513,37 @@ EOF
|
|
417
513
|
|
418
514
|
expected = <<-EOS
|
419
515
|
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
516
|
+
<p>tbl1 is <span class="tableref"><a href="./-.html#tbl1">表1.1</a></span>.</p>
|
517
|
+
<p>img2 is <span class="imgref"><a href="./-.html#img2">図1.2</a></span>.</p>
|
518
|
+
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
519
|
+
<div id="img1" class="image">
|
520
|
+
<img src="images/img1.png" alt="image 1" />
|
521
|
+
<p class="caption">
|
522
|
+
図1.1: image 1
|
523
|
+
</p>
|
524
|
+
</div>
|
525
|
+
<div id="tbl1" class="imgtable image">
|
526
|
+
<p class="caption">表1.1: table 1</p>
|
527
|
+
<img src="images/tbl1.png" alt="table 1" />
|
528
|
+
</div>
|
529
|
+
<div id="img2" class="image">
|
530
|
+
<img src="images/img2.png" alt="image 2" />
|
531
|
+
<p class="caption">
|
532
|
+
図1.2: image 2
|
533
|
+
</p>
|
534
|
+
</div>
|
535
|
+
EOS
|
536
|
+
|
537
|
+
assert_equal expected, actual
|
538
|
+
|
539
|
+
@config['chapterlink'] = nil
|
540
|
+
actual = compile_block(content)
|
541
|
+
|
542
|
+
expected = <<-EOS
|
543
|
+
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
420
544
|
<p>tbl1 is <span class="tableref">表1.1</span>.</p>
|
421
545
|
<p>img2 is <span class="imgref">図1.2</span>.</p>
|
546
|
+
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
422
547
|
<div id="img1" class="image">
|
423
548
|
<img src="images/img1.png" alt="image 1" />
|
424
549
|
<p class="caption">
|
@@ -546,6 +671,32 @@ EOS
|
|
546
671
|
図1.1: sample photo
|
547
672
|
</p>
|
548
673
|
</div>
|
674
|
+
EOS
|
675
|
+
assert_equal expected, actual
|
676
|
+
|
677
|
+
actual = compile_block("//image[sampleimg][]{\n//}\n")
|
678
|
+
expected = <<-EOS
|
679
|
+
<div id="sampleimg" class="image">
|
680
|
+
<img src="images/chap1-sampleimg.png" alt="" />
|
681
|
+
<p class="caption">
|
682
|
+
図1.1:
|
683
|
+
</p>
|
684
|
+
</div>
|
685
|
+
EOS
|
686
|
+
assert_equal expected, actual
|
687
|
+
|
688
|
+
actual = compile_block("//image[sampleimg][][]{\n//}\n")
|
689
|
+
assert_equal expected, actual
|
690
|
+
|
691
|
+
@config['caption_position']['image'] = 'top'
|
692
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
693
|
+
expected = <<-EOS
|
694
|
+
<div id="sampleimg" class="image">
|
695
|
+
<p class="caption">
|
696
|
+
図1.1: sample photo
|
697
|
+
</p>
|
698
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
699
|
+
</div>
|
549
700
|
EOS
|
550
701
|
assert_equal expected, actual
|
551
702
|
end
|
@@ -588,21 +739,22 @@ EOS
|
|
588
739
|
assert_equal expected, actual
|
589
740
|
end
|
590
741
|
|
591
|
-
def
|
742
|
+
def test_image_with_tricky_id_kana
|
592
743
|
def @chapter.image(_id)
|
593
|
-
item = Book::Index::Item.new('123
|
594
|
-
item.instance_eval { @path = './images/
|
744
|
+
item = Book::Index::Item.new('123あいう', 1)
|
745
|
+
item.instance_eval { @path = './images/123あいう.png' }
|
595
746
|
item
|
596
747
|
end
|
597
|
-
|
598
|
-
actual = compile_block("//image[123
|
748
|
+
@chapter.instance_eval { @name = 'ch01' }
|
749
|
+
actual = compile_block("//image[123あいう][sample photo]{\n//}\nimg: @<img>{123あいう}\n")
|
599
750
|
expected = <<-EOS
|
600
|
-
<div id="
|
601
|
-
<img src="images/
|
751
|
+
<div id="id_123_E3_81_82_E3_81_84_E3_81_86" class="image">
|
752
|
+
<img src="images/123あいう.png" alt="sample photo" />
|
602
753
|
<p class="caption">
|
603
754
|
図1.1: sample photo
|
604
755
|
</p>
|
605
756
|
</div>
|
757
|
+
<p>img: <span class="imgref"><a href="./ch01.html#id_123_E3_81_82_E3_81_84_E3_81_86">図1.1</a></span></p>
|
606
758
|
EOS
|
607
759
|
assert_equal expected, actual
|
608
760
|
end
|
@@ -622,6 +774,18 @@ EOS
|
|
622
774
|
図: sample photo
|
623
775
|
</p>
|
624
776
|
</div>
|
777
|
+
EOS
|
778
|
+
assert_equal expected, actual
|
779
|
+
|
780
|
+
@config['caption_position']['image'] = 'top'
|
781
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
782
|
+
expected = <<-EOS
|
783
|
+
<div id="sampleimg" class="image">
|
784
|
+
<p class="caption">
|
785
|
+
図: sample photo
|
786
|
+
</p>
|
787
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
788
|
+
</div>
|
625
789
|
EOS
|
626
790
|
assert_equal expected, actual
|
627
791
|
end
|
@@ -640,6 +804,12 @@ EOS
|
|
640
804
|
</div>
|
641
805
|
EOS
|
642
806
|
assert_equal expected, actual
|
807
|
+
|
808
|
+
actual = compile_block("//indepimage[sampleimg][]\n")
|
809
|
+
assert_equal expected, actual
|
810
|
+
|
811
|
+
actual = compile_block("//indepimage[sampleimg][][]\n")
|
812
|
+
assert_equal expected, actual
|
643
813
|
end
|
644
814
|
|
645
815
|
def test_indepimage_with_metric
|
@@ -779,11 +949,10 @@ EOS
|
|
779
949
|
end
|
780
950
|
|
781
951
|
def test_dt_inline
|
782
|
-
|
783
|
-
@chapter.instance_eval { @footnote_index = fn }
|
784
|
-
actual = compile_block(" : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
952
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
785
953
|
|
786
954
|
expected = <<-EOS
|
955
|
+
<div class="footnote" epub:type="footnote" id="fn-bar"><p class="footnote">[*1] bar</p></div>
|
787
956
|
<dl>
|
788
957
|
<dt>foo<a id="fnb-bar" href="#fn-bar" class="noteref" epub:type="noteref">*1</a>[]<>&<span class="equation">\\alpha[]</span></dt>
|
789
958
|
<dd></dd>
|
@@ -806,6 +975,20 @@ test1.5
|
|
806
975
|
test<i>2</i>
|
807
976
|
</pre>
|
808
977
|
</div>
|
978
|
+
EOS
|
979
|
+
assert_equal expected, actual
|
980
|
+
|
981
|
+
@config['caption_position']['list'] = 'bottom'
|
982
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
983
|
+
expected = <<-EOS
|
984
|
+
<div id="samplelist" class="caption-code">
|
985
|
+
<pre class="list">test1
|
986
|
+
test1.5
|
987
|
+
|
988
|
+
test<i>2</i>
|
989
|
+
</pre>
|
990
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
991
|
+
</div>
|
809
992
|
EOS
|
810
993
|
assert_equal expected, actual
|
811
994
|
end
|
@@ -814,27 +997,35 @@ EOS
|
|
814
997
|
def @chapter.list(_id)
|
815
998
|
Book::Index::Item.new('samplelist', 1)
|
816
999
|
end
|
817
|
-
actual = compile_block("@<list>{
|
1000
|
+
actual = compile_block("@<list>{samplelist}\n")
|
1001
|
+
assert_equal %Q(<p><span class="listref"><a href="./-.html#samplelist">リスト1.1</a></span></p>\n), actual
|
1002
|
+
|
1003
|
+
@config['chapterlink'] = nil
|
1004
|
+
actual = compile_block("@<list>{samplelist}\n")
|
818
1005
|
assert_equal %Q(<p><span class="listref">リスト1.1</span></p>\n), actual
|
819
1006
|
end
|
820
1007
|
|
821
1008
|
def test_inline_list_href
|
822
|
-
book = ReVIEW::Book::Base.
|
1009
|
+
book = ReVIEW::Book::Base.new
|
823
1010
|
book.config['chapterlink'] = true
|
824
1011
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
825
|
-
io1 = StringIO.new("//list[sampletest]{\nfoo\n//}\n")
|
1012
|
+
io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
|
826
1013
|
io2 = StringIO.new("= BAR\n")
|
827
1014
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
828
1015
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
829
|
-
book.parts = [ReVIEW::Book::Part.new(
|
1016
|
+
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
830
1017
|
builder = ReVIEW::HTMLBuilder.new
|
831
1018
|
comp = ReVIEW::Compiler.new(builder)
|
832
1019
|
builder.bind(comp, chap2, nil)
|
1020
|
+
|
1021
|
+
chap1.generate_indexes
|
833
1022
|
actual = builder.inline_list('ch1|sampletest')
|
834
1023
|
assert_equal %Q(<span class="listref"><a href="./ch1.html#sampletest">リスト1.1</a></span>), actual
|
835
1024
|
end
|
836
1025
|
|
837
1026
|
def test_list_pygments
|
1027
|
+
return true if @skip_pygments
|
1028
|
+
|
838
1029
|
def @chapter.list(_id)
|
839
1030
|
Book::Index::Item.new('samplelist', 1)
|
840
1031
|
end
|
@@ -862,6 +1053,8 @@ test<i>2</i>
|
|
862
1053
|
end
|
863
1054
|
|
864
1055
|
def test_list_pygments_lang
|
1056
|
+
return true if @skip_pygments
|
1057
|
+
|
865
1058
|
def @chapter.list(_id)
|
866
1059
|
Book::Index::Item.new('samplelist', 1)
|
867
1060
|
end
|
@@ -890,6 +1083,8 @@ EOS
|
|
890
1083
|
end
|
891
1084
|
|
892
1085
|
def test_list_pygments_nulllang
|
1086
|
+
return true if @skip_pygments
|
1087
|
+
|
893
1088
|
def @chapter.list(_id)
|
894
1089
|
Book::Index::Item.new('samplelist', 1)
|
895
1090
|
end
|
@@ -1023,6 +1218,29 @@ EOS
|
|
1023
1218
|
4: end
|
1024
1219
|
</pre>
|
1025
1220
|
</div>
|
1221
|
+
EOS
|
1222
|
+
|
1223
|
+
assert_equal expected, actual
|
1224
|
+
|
1225
|
+
@config['caption_position']['list'] = 'bottom'
|
1226
|
+
actual = compile_block(<<-EOS)
|
1227
|
+
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
1228
|
+
def foo(a1, a2=:test)
|
1229
|
+
(1..3).times{|i| a.include?(:foo)}
|
1230
|
+
return true
|
1231
|
+
end
|
1232
|
+
//}
|
1233
|
+
EOS
|
1234
|
+
|
1235
|
+
expected = <<-EOS
|
1236
|
+
<div id="samplelist" class="code">
|
1237
|
+
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
|
1238
|
+
2: (1..3).times{|i| a.include?(:foo)}
|
1239
|
+
3: return true
|
1240
|
+
4: end
|
1241
|
+
</pre>
|
1242
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1243
|
+
</div>
|
1026
1244
|
EOS
|
1027
1245
|
|
1028
1246
|
assert_equal expected, actual
|
@@ -1059,6 +1277,8 @@ EOS
|
|
1059
1277
|
end
|
1060
1278
|
|
1061
1279
|
def test_listnum_pygments_lang
|
1280
|
+
return true if @skip_pygments
|
1281
|
+
|
1062
1282
|
def @chapter.list(_id)
|
1063
1283
|
Book::Index::Item.new('samplelist', 1)
|
1064
1284
|
end
|
@@ -1086,6 +1306,8 @@ EOS
|
|
1086
1306
|
end
|
1087
1307
|
|
1088
1308
|
def test_listnum_pygments_lang_linenum
|
1309
|
+
return true if @skip_pygments
|
1310
|
+
|
1089
1311
|
def @chapter.list(_id)
|
1090
1312
|
Book::Index::Item.new('samplelist', 1)
|
1091
1313
|
end
|
@@ -1114,6 +1336,8 @@ EOS
|
|
1114
1336
|
end
|
1115
1337
|
|
1116
1338
|
def test_listnum_pygments_lang_without_lang
|
1339
|
+
return true if @skip_pygments
|
1340
|
+
|
1117
1341
|
def @chapter.list(_id)
|
1118
1342
|
Book::Index::Item.new('samplelist', 1)
|
1119
1343
|
end
|
@@ -1220,6 +1444,20 @@ bar
|
|
1220
1444
|
buz
|
1221
1445
|
</pre>
|
1222
1446
|
</div>
|
1447
|
+
EOS
|
1448
|
+
assert_equal expected, actual
|
1449
|
+
|
1450
|
+
@config['caption_position']['list'] = 'bottom'
|
1451
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1452
|
+
expected = <<-EOS
|
1453
|
+
<div class="source-code">
|
1454
|
+
<pre class="source">foo
|
1455
|
+
bar
|
1456
|
+
|
1457
|
+
buz
|
1458
|
+
</pre>
|
1459
|
+
<p class="caption">foo/bar/test.rb</p>
|
1460
|
+
</div>
|
1223
1461
|
EOS
|
1224
1462
|
assert_equal expected, actual
|
1225
1463
|
end
|
@@ -1257,6 +1495,18 @@ EOS
|
|
1257
1495
|
bar
|
1258
1496
|
</pre>
|
1259
1497
|
</div>
|
1498
|
+
EOS
|
1499
|
+
assert_equal expected, actual
|
1500
|
+
|
1501
|
+
@config['caption_position']['list'] = 'bottom'
|
1502
|
+
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1503
|
+
expected = <<-EOS
|
1504
|
+
<div class="syntax">
|
1505
|
+
<pre class="syntax">foo
|
1506
|
+
bar
|
1507
|
+
</pre>
|
1508
|
+
<p class="caption">FOO</p>
|
1509
|
+
</div>
|
1260
1510
|
EOS
|
1261
1511
|
assert_equal expected, actual
|
1262
1512
|
end
|
@@ -1274,6 +1524,8 @@ EOS
|
|
1274
1524
|
end
|
1275
1525
|
|
1276
1526
|
def test_emlist_pygments_lang
|
1527
|
+
return true if @skip_pygments
|
1528
|
+
|
1277
1529
|
begin
|
1278
1530
|
require 'pygments'
|
1279
1531
|
rescue LoadError
|
@@ -1301,6 +1553,18 @@ EOS
|
|
1301
1553
|
lineB
|
1302
1554
|
</pre>
|
1303
1555
|
</div>
|
1556
|
+
EOS
|
1557
|
+
assert_equal expected, actual
|
1558
|
+
|
1559
|
+
@config['caption_position']['list'] = 'bottom'
|
1560
|
+
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
1561
|
+
expected = <<-EOS
|
1562
|
+
<div class="emlist-code">
|
1563
|
+
<pre class="emlist">lineA
|
1564
|
+
lineB
|
1565
|
+
</pre>
|
1566
|
+
<p class="caption">cap1</p>
|
1567
|
+
</div>
|
1304
1568
|
EOS
|
1305
1569
|
assert_equal expected, actual
|
1306
1570
|
end
|
@@ -1341,6 +1605,18 @@ EOS
|
|
1341
1605
|
2: lineB
|
1342
1606
|
</pre>
|
1343
1607
|
</div>
|
1608
|
+
EOS
|
1609
|
+
assert_equal expected, actual
|
1610
|
+
|
1611
|
+
@config['caption_position']['list'] = 'bottom'
|
1612
|
+
actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
1613
|
+
expected = <<-EOS
|
1614
|
+
<div class="emlistnum-code">
|
1615
|
+
<pre class="emlist language-text"> 1: lineA
|
1616
|
+
2: lineB
|
1617
|
+
</pre>
|
1618
|
+
<p class="caption">cap</p>
|
1619
|
+
</div>
|
1344
1620
|
EOS
|
1345
1621
|
assert_equal expected, actual
|
1346
1622
|
end
|
@@ -1386,6 +1662,8 @@ EOS
|
|
1386
1662
|
end
|
1387
1663
|
|
1388
1664
|
def test_cmd_pygments
|
1665
|
+
return true if @skip_pygments
|
1666
|
+
|
1389
1667
|
begin
|
1390
1668
|
require 'pygments'
|
1391
1669
|
rescue LoadError
|
@@ -1413,6 +1691,18 @@ EOS
|
|
1413
1691
|
lineB
|
1414
1692
|
</pre>
|
1415
1693
|
</div>
|
1694
|
+
EOS
|
1695
|
+
assert_equal expected, actual
|
1696
|
+
|
1697
|
+
@config['caption_position']['list'] = 'bottom'
|
1698
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1699
|
+
expected = <<-EOS
|
1700
|
+
<div class="cmd-code">
|
1701
|
+
<pre class="cmd">lineA
|
1702
|
+
lineB
|
1703
|
+
</pre>
|
1704
|
+
<p class="caption">cap1</p>
|
1705
|
+
</div>
|
1416
1706
|
EOS
|
1417
1707
|
assert_equal expected, actual
|
1418
1708
|
end
|
@@ -1420,13 +1710,16 @@ EOS
|
|
1420
1710
|
def test_texequation
|
1421
1711
|
return true if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
1422
1712
|
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1713
|
+
|
1423
1714
|
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1424
1715
|
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P} q\n//}\n") do |dir, book, _files|
|
1425
1716
|
@book = book
|
1426
1717
|
@book.config = @config
|
1427
|
-
@config['
|
1718
|
+
@config['math_format'] = 'imgmath'
|
1428
1719
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1429
1720
|
location = Location.new(nil, nil)
|
1721
|
+
img_math = ReVIEW::ImgMath.new(@config)
|
1722
|
+
@builder = HTMLBuilder.new(img_math: img_math)
|
1430
1723
|
@builder.bind(@compiler, @chapter, location)
|
1431
1724
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1432
1725
|
expected = <<-EOB
|
@@ -1450,14 +1743,17 @@ EOS
|
|
1450
1743
|
# Re:VIEW 3 never fail on defer mode. This test is only for Re:VIEW 2.
|
1451
1744
|
return true if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
1452
1745
|
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1746
|
+
|
1453
1747
|
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1454
1748
|
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P}} q\n//}\n") do |dir, book, _files|
|
1455
1749
|
@book = book
|
1456
1750
|
@book.config = @config
|
1457
1751
|
@config['review_version'] = 2
|
1458
|
-
@config['
|
1752
|
+
@config['math_format'] = 'imgmath'
|
1459
1753
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1460
1754
|
location = Location.new(nil, nil)
|
1755
|
+
img_math = ReVIEW::ImgMath.new(@config)
|
1756
|
+
@builder = HTMLBuilder.new(img_math: img_math)
|
1461
1757
|
@builder.bind(@compiler, @chapter, location)
|
1462
1758
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1463
1759
|
tmpio = $stderr
|
@@ -1648,6 +1944,20 @@ EOS
|
|
1648
1944
|
<p>inside column</p>
|
1649
1945
|
</div>
|
1650
1946
|
|
1947
|
+
<h3><a id="h1-0-1"></a>next level</h3>
|
1948
|
+
<p>this is <a href="-.html#column-1" class="columnref">コラム「test」</a>.</p>
|
1949
|
+
EOS
|
1950
|
+
|
1951
|
+
assert_equal expected, column_helper(review)
|
1952
|
+
|
1953
|
+
@config['chapterlink'] = nil
|
1954
|
+
expected = <<-EOS
|
1955
|
+
<div class="column">
|
1956
|
+
|
1957
|
+
<h3 id="foo"><a id="column-1"></a>test</h3>
|
1958
|
+
<p>inside column</p>
|
1959
|
+
</div>
|
1960
|
+
|
1651
1961
|
<h3><a id="h1-0-1"></a>next level</h3>
|
1652
1962
|
<p>this is コラム「test」.</p>
|
1653
1963
|
EOS
|
@@ -1663,6 +1973,11 @@ EOS
|
|
1663
1973
|
idx
|
1664
1974
|
end
|
1665
1975
|
|
1976
|
+
actual = compile_inline('test @<column>{chap1|column} test2')
|
1977
|
+
expected = 'test <a href="-.html#column-1" class="columnref">コラム「column_cap」</a> test2'
|
1978
|
+
assert_equal expected, actual
|
1979
|
+
|
1980
|
+
@config['chapterlink'] = nil
|
1666
1981
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
1667
1982
|
expected = 'test コラム「column_cap」 test2'
|
1668
1983
|
assert_equal expected, actual
|
@@ -1758,8 +2073,8 @@ EOS
|
|
1758
2073
|
* AA
|
1759
2074
|
EOS
|
1760
2075
|
|
1761
|
-
|
1762
|
-
|
2076
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2077
|
+
assert_match(/too many \*\./, @log_io.string)
|
1763
2078
|
end
|
1764
2079
|
|
1765
2080
|
def test_ul_nest4
|
@@ -1960,8 +2275,6 @@ EOS
|
|
1960
2275
|
end
|
1961
2276
|
|
1962
2277
|
def test_footnote
|
1963
|
-
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
|
1964
|
-
@chapter.instance_eval { @footnote_index = fn }
|
1965
2278
|
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
1966
2279
|
expected = <<-'EOS'
|
1967
2280
|
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote">[*1] bar\a\$buz</p></div>
|
@@ -1986,58 +2299,69 @@ EOS
|
|
1986
2299
|
end
|
1987
2300
|
|
1988
2301
|
def test_footnote_with_tricky_id
|
1989
|
-
|
1990
|
-
@chapter.instance_eval { @footnote_index = fn }
|
1991
|
-
actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
|
2302
|
+
actual = compile_block("//footnote[123あ_;][bar\\a\\$buz]\n")
|
1992
2303
|
expected = <<-'EOS'
|
1993
|
-
<div class="footnote" epub:type="footnote" id="fn-
|
2304
|
+
<div class="footnote" epub:type="footnote" id="fn-id_123_E3_81_82___3B"><p class="footnote">[*1] bar\a\$buz</p></div>
|
1994
2305
|
EOS
|
1995
2306
|
assert_equal expected, actual
|
1996
2307
|
end
|
1997
2308
|
|
1998
2309
|
def test_inline_fn
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
comp = ReVIEW::Compiler.new(builder)
|
2006
|
-
builder.bind(comp, chap1, nil)
|
2007
|
-
fn = builder.inline_fn('foo')
|
2008
|
-
assert_equal '<a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a>', fn
|
2310
|
+
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2311
|
+
expected = <<-EOS
|
2312
|
+
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2313
|
+
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a></p>
|
2314
|
+
EOS
|
2315
|
+
assert_equal expected, fn
|
2009
2316
|
I18n.set('html_footnote_refmark', '+%s')
|
2010
|
-
fn =
|
2011
|
-
|
2317
|
+
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2318
|
+
expected = <<-EOS
|
2319
|
+
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2320
|
+
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">+1</a></p>
|
2321
|
+
EOS
|
2322
|
+
assert_equal expected, fn
|
2012
2323
|
end
|
2013
2324
|
|
2014
2325
|
def test_inline_hd
|
2015
|
-
book = ReVIEW::Book::Base.
|
2326
|
+
book = ReVIEW::Book::Base.new
|
2016
2327
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
2017
2328
|
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
2018
2329
|
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
2019
2330
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
2020
2331
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
2021
|
-
book.parts = [ReVIEW::Book::Part.new(
|
2332
|
+
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
2022
2333
|
builder = ReVIEW::HTMLBuilder.new
|
2023
2334
|
comp = ReVIEW::Compiler.new(builder)
|
2024
2335
|
builder.bind(comp, chap2, nil)
|
2336
|
+
|
2337
|
+
chap1.generate_indexes
|
2338
|
+
chap2.generate_indexes
|
2339
|
+
hd = builder.inline_hd('ch1|test1-1')
|
2340
|
+
assert_equal '<a href="ch1.html#h1-1">「1.1 test1-1」</a>', hd
|
2341
|
+
|
2342
|
+
builder.instance_eval { @book.config['chapterlink'] = nil }
|
2025
2343
|
hd = builder.inline_hd('ch1|test1-1')
|
2026
2344
|
assert_equal '「1.1 test1-1」', hd
|
2027
2345
|
end
|
2028
2346
|
|
2029
2347
|
def test_inline_hd_for_part
|
2030
|
-
book = ReVIEW::Book::Base.
|
2348
|
+
book = ReVIEW::Book::Base.new
|
2031
2349
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
2032
2350
|
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
2033
2351
|
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
2034
2352
|
io_p1 = StringIO.new("= part1\n\nfoo\n\n== part1-1\n\nbar\n\n== part1-2\n\nbar\n\n")
|
2035
2353
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
2036
2354
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
2037
|
-
book.parts = [ReVIEW::Book::Part.new(
|
2355
|
+
book.parts = [ReVIEW::Book::Part.new(book, 1, [chap1, chap2], 'part1.re', io_p1)]
|
2038
2356
|
builder = ReVIEW::HTMLBuilder.new
|
2039
2357
|
comp = ReVIEW::Compiler.new(builder)
|
2040
2358
|
builder.bind(comp, chap2, nil)
|
2359
|
+
book.generate_indexes
|
2360
|
+
|
2361
|
+
hd = builder.inline_hd('part1|part1-1')
|
2362
|
+
assert_equal '<a href="part1.html#h1-1">「1.1 part1-1」</a>', hd
|
2363
|
+
|
2364
|
+
builder.instance_eval { @book.config['chapterlink'] = nil }
|
2041
2365
|
hd = builder.inline_hd('part1|part1-1')
|
2042
2366
|
assert_equal '「1.1 part1-1」', hd
|
2043
2367
|
end
|
@@ -2048,7 +2372,12 @@ EOS
|
|
2048
2372
|
location = Location.new(nil, nil)
|
2049
2373
|
@builder.bind(@compiler, chap1, location)
|
2050
2374
|
hd = @builder.inline_hd('foo')
|
2375
|
+
assert_equal '<a href="-.html#h1-1">「1.1 foo」</a>', hd
|
2376
|
+
|
2377
|
+
@config['chapterlink'] = nil
|
2378
|
+
hd = @builder.inline_hd('foo')
|
2051
2379
|
assert_equal '「1.1 foo」', hd
|
2380
|
+
|
2052
2381
|
hd = @builder.inline_hd('bar')
|
2053
2382
|
assert_equal '「1.2 bar」', hd
|
2054
2383
|
end
|
@@ -2074,16 +2403,29 @@ EOS
|
|
2074
2403
|
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2075
2404
|
</table>
|
2076
2405
|
</div>
|
2406
|
+
EOS
|
2407
|
+
assert_equal expected, actual
|
2408
|
+
|
2409
|
+
@config['caption_position']['table'] = 'bottom'
|
2410
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2411
|
+
expected = <<-EOS
|
2412
|
+
<div id="foo" class="table">
|
2413
|
+
<table>
|
2414
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2415
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2416
|
+
</table>
|
2417
|
+
<p class="caption">表1.1: FOO</p>
|
2418
|
+
</div>
|
2077
2419
|
EOS
|
2078
2420
|
assert_equal expected, actual
|
2079
2421
|
end
|
2080
2422
|
|
2081
2423
|
def test_empty_table
|
2082
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2083
|
-
assert_equal '
|
2424
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
2425
|
+
assert_equal 'no rows in the table', e.message
|
2084
2426
|
|
2085
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2086
|
-
assert_equal '
|
2427
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
2428
|
+
assert_equal 'no rows in the table', e.message
|
2087
2429
|
end
|
2088
2430
|
|
2089
2431
|
def test_inline_table
|
@@ -2091,6 +2433,10 @@ EOS
|
|
2091
2433
|
Book::Index::Item.new('sampletable', 1)
|
2092
2434
|
end
|
2093
2435
|
actual = compile_block("@<table>{sampletest}\n")
|
2436
|
+
assert_equal %Q(<p><span class="tableref"><a href="./-.html#sampletest">表1.1</a></span></p>\n), actual
|
2437
|
+
|
2438
|
+
@config['chapterlink'] = nil
|
2439
|
+
actual = compile_block("@<table>{sampletest}\n")
|
2094
2440
|
assert_equal %Q(<p><span class="tableref">表1.1</span></p>\n), actual
|
2095
2441
|
end
|
2096
2442
|
|
@@ -2112,10 +2458,29 @@ EOS
|
|
2112
2458
|
</div>
|
2113
2459
|
EOS
|
2114
2460
|
assert_equal expected, actual
|
2115
|
-
end
|
2116
2461
|
|
2117
|
-
|
2118
|
-
|
2462
|
+
@config['caption_position']['table'] = 'bottom'
|
2463
|
+
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2464
|
+
expected = <<-EOS
|
2465
|
+
<div class="table">
|
2466
|
+
<table>
|
2467
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2468
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2469
|
+
</table>
|
2470
|
+
<p class="caption">foo</p>
|
2471
|
+
</div>
|
2472
|
+
<div class="table">
|
2473
|
+
<table>
|
2474
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2475
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2476
|
+
</table>
|
2477
|
+
</div>
|
2478
|
+
EOS
|
2479
|
+
assert_equal expected, actual
|
2480
|
+
end
|
2481
|
+
|
2482
|
+
def test_imgtable
|
2483
|
+
def @chapter.image(_id)
|
2119
2484
|
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
|
2120
2485
|
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
2121
2486
|
item
|
@@ -2127,6 +2492,16 @@ EOS
|
|
2127
2492
|
<p class="caption">表1.1: test for imgtable</p>
|
2128
2493
|
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2129
2494
|
</div>
|
2495
|
+
EOS
|
2496
|
+
assert_equal expected, actual
|
2497
|
+
|
2498
|
+
@config['caption_position']['table'] = 'bottom'
|
2499
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
2500
|
+
expected = <<-EOS
|
2501
|
+
<div id="sampleimg" class="imgtable image">
|
2502
|
+
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2503
|
+
<p class="caption">表1.1: test for imgtable</p>
|
2504
|
+
</div>
|
2130
2505
|
EOS
|
2131
2506
|
assert_equal expected, actual
|
2132
2507
|
end
|
@@ -2287,6 +2662,163 @@ EOS
|
|
2287
2662
|
assert_equal expected, actual
|
2288
2663
|
end
|
2289
2664
|
|
2665
|
+
def test_minicolumn_blocks
|
2666
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2667
|
+
src = <<-EOS
|
2668
|
+
//#{type}[#{type}1]{
|
2669
|
+
|
2670
|
+
//}
|
2671
|
+
|
2672
|
+
//#{type}[#{type}2]{
|
2673
|
+
//}
|
2674
|
+
EOS
|
2675
|
+
|
2676
|
+
expected = <<-EOS
|
2677
|
+
<div class="#{type}">
|
2678
|
+
<p class="caption">#{type}1</p>
|
2679
|
+
</div>
|
2680
|
+
<div class="#{type}">
|
2681
|
+
<p class="caption">#{type}2</p>
|
2682
|
+
</div>
|
2683
|
+
EOS
|
2684
|
+
assert_equal expected, compile_block(src)
|
2685
|
+
|
2686
|
+
src = <<-EOS
|
2687
|
+
//#{type}[#{type}2]{
|
2688
|
+
|
2689
|
+
//}
|
2690
|
+
|
2691
|
+
//#{type}[#{type}3]{
|
2692
|
+
|
2693
|
+
//}
|
2694
|
+
|
2695
|
+
//#{type}[#{type}4]{
|
2696
|
+
|
2697
|
+
//}
|
2698
|
+
|
2699
|
+
//#{type}[#{type}5]{
|
2700
|
+
|
2701
|
+
//}
|
2702
|
+
|
2703
|
+
//#{type}[#{type}6]{
|
2704
|
+
|
2705
|
+
//}
|
2706
|
+
EOS
|
2707
|
+
|
2708
|
+
expected = <<-EOS
|
2709
|
+
<div class="#{type}">
|
2710
|
+
<p class="caption">#{type}2</p>
|
2711
|
+
</div>
|
2712
|
+
<div class="#{type}">
|
2713
|
+
<p class="caption">#{type}3</p>
|
2714
|
+
</div>
|
2715
|
+
<div class="#{type}">
|
2716
|
+
<p class="caption">#{type}4</p>
|
2717
|
+
</div>
|
2718
|
+
<div class="#{type}">
|
2719
|
+
<p class="caption">#{type}5</p>
|
2720
|
+
</div>
|
2721
|
+
<div class="#{type}">
|
2722
|
+
<p class="caption">#{type}6</p>
|
2723
|
+
</div>
|
2724
|
+
EOS
|
2725
|
+
assert_equal expected, compile_block(src)
|
2726
|
+
|
2727
|
+
src = <<-EOS
|
2728
|
+
//#{type}{
|
2729
|
+
|
2730
|
+
* A
|
2731
|
+
|
2732
|
+
1. B
|
2733
|
+
|
2734
|
+
//}
|
2735
|
+
|
2736
|
+
//#{type}[OMITEND1]{
|
2737
|
+
|
2738
|
+
//emlist{
|
2739
|
+
LIST
|
2740
|
+
//}
|
2741
|
+
|
2742
|
+
//}
|
2743
|
+
|
2744
|
+
//#{type}[OMITEND2]{
|
2745
|
+
//}
|
2746
|
+
EOS
|
2747
|
+
|
2748
|
+
expected = <<-EOS
|
2749
|
+
<div class="#{type}">
|
2750
|
+
<ul>
|
2751
|
+
<li>A</li>
|
2752
|
+
</ul>
|
2753
|
+
<ol>
|
2754
|
+
<li>B</li>
|
2755
|
+
</ol>
|
2756
|
+
</div>
|
2757
|
+
<div class="#{type}">
|
2758
|
+
<p class="caption">OMITEND1</p>
|
2759
|
+
<div class="emlist-code">
|
2760
|
+
<pre class="emlist">LIST
|
2761
|
+
</pre>
|
2762
|
+
</div>
|
2763
|
+
</div>
|
2764
|
+
<div class="#{type}">
|
2765
|
+
<p class="caption">OMITEND2</p>
|
2766
|
+
</div>
|
2767
|
+
EOS
|
2768
|
+
assert_equal expected, compile_block(src)
|
2769
|
+
end
|
2770
|
+
end
|
2771
|
+
|
2772
|
+
def test_minicolumn_blocks_nest_error1
|
2773
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2774
|
+
@builder.doc_status.clear
|
2775
|
+
src = <<-EOS
|
2776
|
+
//#{type}{
|
2777
|
+
|
2778
|
+
//#{type}{
|
2779
|
+
//}
|
2780
|
+
|
2781
|
+
//}
|
2782
|
+
EOS
|
2783
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2784
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2785
|
+
end
|
2786
|
+
end
|
2787
|
+
|
2788
|
+
def test_minicolumn_blocks_nest_error2
|
2789
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2790
|
+
@builder.doc_status.clear
|
2791
|
+
src = <<-EOS
|
2792
|
+
//#{type}{
|
2793
|
+
|
2794
|
+
//#{type}{
|
2795
|
+
|
2796
|
+
//}
|
2797
|
+
|
2798
|
+
//}
|
2799
|
+
EOS
|
2800
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2801
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2802
|
+
end
|
2803
|
+
end
|
2804
|
+
|
2805
|
+
def test_minicolumn_blocks_nest_error3
|
2806
|
+
%w[memo tip info warning important caution notice].each do |type|
|
2807
|
+
@builder.doc_status.clear
|
2808
|
+
src = <<-EOS
|
2809
|
+
//#{type}{
|
2810
|
+
|
2811
|
+
//note{
|
2812
|
+
|
2813
|
+
//}
|
2814
|
+
|
2815
|
+
//}
|
2816
|
+
EOS
|
2817
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2818
|
+
assert_match(/minicolumn cannot be nested:/, @log_io.string)
|
2819
|
+
end
|
2820
|
+
end
|
2821
|
+
|
2290
2822
|
def test_comment
|
2291
2823
|
actual = compile_block('//comment[コメント]')
|
2292
2824
|
assert_equal '', actual
|
@@ -2325,28 +2857,26 @@ EOS
|
|
2325
2857
|
EOB
|
2326
2858
|
end
|
2327
2859
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
2328
|
-
io = StringIO.new
|
2329
|
-
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
2330
2860
|
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
2331
2861
|
assert_equal %Q(<p>foo bar"\\<>_@<b>{BAZ} <b>bar"\\<>_@<b>{BAZ}</b> [missing word: N]</p>\n), actual
|
2332
|
-
assert_match(/WARN --: :1: word not bound: N/,
|
2862
|
+
assert_match(/WARN --: :1: word not bound: N/, @log_io.string)
|
2333
2863
|
end
|
2334
2864
|
end
|
2335
2865
|
|
2336
2866
|
def test_inline_unknown
|
2337
|
-
|
2338
|
-
|
2339
|
-
|
2340
|
-
|
2341
|
-
|
2342
|
-
|
2867
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
2868
|
+
assert_match(/unknown image: n/, @log_io.string)
|
2869
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
2870
|
+
assert_match(/unknown footnote: n/, @log_io.string)
|
2871
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
2872
|
+
assert_match(/unknown headline: n/, @log_io.string)
|
2343
2873
|
%w[list table column].each do |name|
|
2344
|
-
|
2345
|
-
|
2874
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2875
|
+
assert_match(/unknown #{name}: n/, @log_io.string)
|
2346
2876
|
end
|
2347
2877
|
%w[chap chapref title].each do |name|
|
2348
|
-
|
2349
|
-
|
2878
|
+
assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2879
|
+
assert_match(/key not found: "n"/, @log_io.string)
|
2350
2880
|
end
|
2351
2881
|
end
|
2352
2882
|
|
@@ -2375,6 +2905,20 @@ e=mc^2
|
|
2375
2905
|
//}
|
2376
2906
|
EOS
|
2377
2907
|
expected = <<-EOS
|
2908
|
+
<p><span class="eqref"><a href="./-.html#emc2">式1.1</a></span></p>
|
2909
|
+
<div id="emc2" class="caption-equation">
|
2910
|
+
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2911
|
+
<div class="equation">
|
2912
|
+
<pre>e=mc^2
|
2913
|
+
</pre>
|
2914
|
+
</div>
|
2915
|
+
</div>
|
2916
|
+
EOS
|
2917
|
+
actual = compile_block(src)
|
2918
|
+
assert_equal expected, actual
|
2919
|
+
|
2920
|
+
@config['chapterlink'] = nil
|
2921
|
+
expected = <<-EOS
|
2378
2922
|
<p><span class="eqref">式1.1</span></p>
|
2379
2923
|
<div id="emc2" class="caption-equation">
|
2380
2924
|
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
@@ -2386,5 +2930,311 @@ EOS
|
|
2386
2930
|
EOS
|
2387
2931
|
actual = compile_block(src)
|
2388
2932
|
assert_equal expected, actual
|
2933
|
+
|
2934
|
+
@config['caption_position']['equation'] = 'bottom'
|
2935
|
+
expected = <<-EOS
|
2936
|
+
<p><span class="eqref">式1.1</span></p>
|
2937
|
+
<div id="emc2" class="caption-equation">
|
2938
|
+
<div class="equation">
|
2939
|
+
<pre>e=mc^2
|
2940
|
+
</pre>
|
2941
|
+
</div>
|
2942
|
+
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2943
|
+
</div>
|
2944
|
+
EOS
|
2945
|
+
actual = compile_block(src)
|
2946
|
+
assert_equal expected, actual
|
2947
|
+
end
|
2948
|
+
|
2949
|
+
def test_nest_error_close1
|
2950
|
+
src = <<-EOS
|
2951
|
+
//beginchild
|
2952
|
+
EOS
|
2953
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2954
|
+
assert_equal "//beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
2955
|
+
end
|
2956
|
+
|
2957
|
+
def test_nest_error_close2
|
2958
|
+
src = <<-EOS
|
2959
|
+
* foo
|
2960
|
+
|
2961
|
+
//beginchild
|
2962
|
+
|
2963
|
+
1. foo
|
2964
|
+
|
2965
|
+
//beginchild
|
2966
|
+
|
2967
|
+
: foo
|
2968
|
+
|
2969
|
+
//beginchild
|
2970
|
+
EOS
|
2971
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2972
|
+
assert_equal '//beginchild of dl,ol,ul misses //endchild', e.message
|
2973
|
+
end
|
2974
|
+
|
2975
|
+
def test_nest_error_close3
|
2976
|
+
src = <<-EOS
|
2977
|
+
* foo
|
2978
|
+
|
2979
|
+
//beginchild
|
2980
|
+
|
2981
|
+
1. foo
|
2982
|
+
|
2983
|
+
//beginchild
|
2984
|
+
|
2985
|
+
: foo
|
2986
|
+
|
2987
|
+
//beginchild
|
2988
|
+
|
2989
|
+
//endchild
|
2990
|
+
EOS
|
2991
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2992
|
+
assert_equal '//beginchild of ol,ul misses //endchild', e.message
|
2993
|
+
end
|
2994
|
+
|
2995
|
+
def test_nest_ul
|
2996
|
+
src = <<-EOS
|
2997
|
+
* UL1
|
2998
|
+
|
2999
|
+
//beginchild
|
3000
|
+
|
3001
|
+
1. UL1-OL1
|
3002
|
+
2. UL1-OL2
|
3003
|
+
|
3004
|
+
* UL1-UL1
|
3005
|
+
* UL1-UL2
|
3006
|
+
|
3007
|
+
: UL1-DL1
|
3008
|
+
UL1-DD1
|
3009
|
+
: UL1-DL2
|
3010
|
+
UL1-DD2
|
3011
|
+
|
3012
|
+
//endchild
|
3013
|
+
|
3014
|
+
* UL2
|
3015
|
+
|
3016
|
+
//beginchild
|
3017
|
+
|
3018
|
+
UL2-PARA
|
3019
|
+
|
3020
|
+
//endchild
|
3021
|
+
EOS
|
3022
|
+
|
3023
|
+
expected = <<-EOS
|
3024
|
+
<ul>
|
3025
|
+
<li>UL1
|
3026
|
+
<ol>
|
3027
|
+
<li>UL1-OL1</li>
|
3028
|
+
<li>UL1-OL2</li>
|
3029
|
+
</ol>
|
3030
|
+
<ul>
|
3031
|
+
<li>UL1-UL1</li>
|
3032
|
+
<li>UL1-UL2</li>
|
3033
|
+
</ul>
|
3034
|
+
<dl>
|
3035
|
+
<dt>UL1-DL1</dt>
|
3036
|
+
<dd>UL1-DD1</dd>
|
3037
|
+
<dt>UL1-DL2</dt>
|
3038
|
+
<dd>UL1-DD2</dd>
|
3039
|
+
</dl>
|
3040
|
+
</li>
|
3041
|
+
|
3042
|
+
<li>UL2
|
3043
|
+
<p>UL2-PARA</p>
|
3044
|
+
</li>
|
3045
|
+
</ul>
|
3046
|
+
EOS
|
3047
|
+
|
3048
|
+
actual = compile_block(src)
|
3049
|
+
assert_equal expected, actual
|
3050
|
+
end
|
3051
|
+
|
3052
|
+
def test_nest_ol
|
3053
|
+
src = <<-EOS
|
3054
|
+
1. OL1
|
3055
|
+
|
3056
|
+
//beginchild
|
3057
|
+
|
3058
|
+
1. OL1-OL1
|
3059
|
+
2. OL1-OL2
|
3060
|
+
|
3061
|
+
* OL1-UL1
|
3062
|
+
* OL1-UL2
|
3063
|
+
|
3064
|
+
: OL1-DL1
|
3065
|
+
OL1-DD1
|
3066
|
+
: OL1-DL2
|
3067
|
+
OL1-DD2
|
3068
|
+
|
3069
|
+
//endchild
|
3070
|
+
|
3071
|
+
2. OL2
|
3072
|
+
|
3073
|
+
//beginchild
|
3074
|
+
|
3075
|
+
OL2-PARA
|
3076
|
+
|
3077
|
+
//endchild
|
3078
|
+
EOS
|
3079
|
+
|
3080
|
+
expected = <<-EOS
|
3081
|
+
<ol>
|
3082
|
+
<li>OL1
|
3083
|
+
<ol>
|
3084
|
+
<li>OL1-OL1</li>
|
3085
|
+
<li>OL1-OL2</li>
|
3086
|
+
</ol>
|
3087
|
+
<ul>
|
3088
|
+
<li>OL1-UL1</li>
|
3089
|
+
<li>OL1-UL2</li>
|
3090
|
+
</ul>
|
3091
|
+
<dl>
|
3092
|
+
<dt>OL1-DL1</dt>
|
3093
|
+
<dd>OL1-DD1</dd>
|
3094
|
+
<dt>OL1-DL2</dt>
|
3095
|
+
<dd>OL1-DD2</dd>
|
3096
|
+
</dl>
|
3097
|
+
</li>
|
3098
|
+
|
3099
|
+
<li>OL2
|
3100
|
+
<p>OL2-PARA</p>
|
3101
|
+
</li>
|
3102
|
+
</ol>
|
3103
|
+
EOS
|
3104
|
+
|
3105
|
+
actual = compile_block(src)
|
3106
|
+
assert_equal expected, actual
|
3107
|
+
end
|
3108
|
+
|
3109
|
+
def test_nest_dl
|
3110
|
+
src = <<-EOS
|
3111
|
+
: DL1
|
3112
|
+
|
3113
|
+
//beginchild
|
3114
|
+
|
3115
|
+
1. DL1-OL1
|
3116
|
+
2. DL1-OL2
|
3117
|
+
|
3118
|
+
* DL1-UL1
|
3119
|
+
* DL1-UL2
|
3120
|
+
|
3121
|
+
: DL1-DL1
|
3122
|
+
DL1-DD1
|
3123
|
+
: DL1-DL2
|
3124
|
+
DL1-DD2
|
3125
|
+
|
3126
|
+
//endchild
|
3127
|
+
|
3128
|
+
: DL2
|
3129
|
+
DD2
|
3130
|
+
|
3131
|
+
//beginchild
|
3132
|
+
|
3133
|
+
* DD2-UL1
|
3134
|
+
* DD2-UL2
|
3135
|
+
|
3136
|
+
DD2-PARA
|
3137
|
+
|
3138
|
+
//endchild
|
3139
|
+
EOS
|
3140
|
+
|
3141
|
+
expected = <<-EOS
|
3142
|
+
<dl>
|
3143
|
+
<dt>DL1</dt>
|
3144
|
+
<dd>
|
3145
|
+
<ol>
|
3146
|
+
<li>DL1-OL1</li>
|
3147
|
+
<li>DL1-OL2</li>
|
3148
|
+
</ol>
|
3149
|
+
<ul>
|
3150
|
+
<li>DL1-UL1</li>
|
3151
|
+
<li>DL1-UL2</li>
|
3152
|
+
</ul>
|
3153
|
+
<dl>
|
3154
|
+
<dt>DL1-DL1</dt>
|
3155
|
+
<dd>DL1-DD1</dd>
|
3156
|
+
<dt>DL1-DL2</dt>
|
3157
|
+
<dd>DL1-DD2</dd>
|
3158
|
+
</dl>
|
3159
|
+
</dd>
|
3160
|
+
|
3161
|
+
<dt>DL2</dt>
|
3162
|
+
<dd>DD2
|
3163
|
+
<ul>
|
3164
|
+
<li>DD2-UL1</li>
|
3165
|
+
<li>DD2-UL2</li>
|
3166
|
+
</ul>
|
3167
|
+
<p>DD2-PARA</p>
|
3168
|
+
</dd>
|
3169
|
+
</dl>
|
3170
|
+
EOS
|
3171
|
+
|
3172
|
+
actual = compile_block(src)
|
3173
|
+
assert_equal expected, actual
|
3174
|
+
end
|
3175
|
+
|
3176
|
+
def test_nest_multi
|
3177
|
+
src = <<-EOS
|
3178
|
+
1. OL1
|
3179
|
+
|
3180
|
+
//beginchild
|
3181
|
+
|
3182
|
+
1. OL1-OL1
|
3183
|
+
|
3184
|
+
//beginchild
|
3185
|
+
|
3186
|
+
* OL1-OL1-UL1
|
3187
|
+
|
3188
|
+
OL1-OL1-PARA
|
3189
|
+
|
3190
|
+
//endchild
|
3191
|
+
|
3192
|
+
2. OL1-OL2
|
3193
|
+
|
3194
|
+
* OL1-UL1
|
3195
|
+
|
3196
|
+
//beginchild
|
3197
|
+
|
3198
|
+
: OL1-UL1-DL1
|
3199
|
+
OL1-UL1-DD1
|
3200
|
+
|
3201
|
+
OL1-UL1-PARA
|
3202
|
+
|
3203
|
+
//endchild
|
3204
|
+
|
3205
|
+
* OL1-UL2
|
3206
|
+
|
3207
|
+
//endchild
|
3208
|
+
EOS
|
3209
|
+
expected = <<-EOS
|
3210
|
+
<ol>
|
3211
|
+
<li>OL1
|
3212
|
+
<ol>
|
3213
|
+
<li>OL1-OL1
|
3214
|
+
<ul>
|
3215
|
+
<li>OL1-OL1-UL1</li>
|
3216
|
+
</ul>
|
3217
|
+
<p>OL1-OL1-PARA</p>
|
3218
|
+
</li>
|
3219
|
+
|
3220
|
+
<li>OL1-OL2</li>
|
3221
|
+
</ol>
|
3222
|
+
<ul>
|
3223
|
+
<li>OL1-UL1
|
3224
|
+
<dl>
|
3225
|
+
<dt>OL1-UL1-DL1</dt>
|
3226
|
+
<dd>OL1-UL1-DD1</dd>
|
3227
|
+
</dl>
|
3228
|
+
<p>OL1-UL1-PARA</p>
|
3229
|
+
</li>
|
3230
|
+
|
3231
|
+
<li>OL1-UL2</li>
|
3232
|
+
</ul>
|
3233
|
+
</li>
|
3234
|
+
</ol>
|
3235
|
+
EOS
|
3236
|
+
|
3237
|
+
actual = compile_block(src)
|
3238
|
+
assert_equal expected, actual
|
2389
3239
|
end
|
2390
3240
|
end
|