review 4.0.0 → 5.1.1
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 +141 -38
- data/Dockerfile +21 -5
- data/NEWS.ja.md +338 -1
- data/NEWS.md +339 -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 +4 -4
- data/bin/review-check +8 -12
- data/bin/review-checkdep +2 -5
- data/bin/review-compile +11 -20
- 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 +3 -5
- data/bin/review-textmaker +1 -3
- data/bin/review-update +1 -4
- data/bin/review-validate +5 -5
- data/bin/review-vol +5 -82
- data/bin/review-webmaker +1 -3
- data/doc/config.yml.sample +55 -12
- data/doc/config.yml.sample-simple +4 -3
- data/doc/format.ja.md +119 -17
- data/doc/format.md +106 -17
- 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 +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 +69 -30
- 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 +39 -206
- data/lib/review/book/index/item.rb +8 -2
- 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 +124 -27
- data/lib/review/call_hook.rb +20 -0
- data/lib/review/catalog.rb +3 -2
- data/lib/review/compiler.rb +197 -91
- data/lib/review/configure.rb +95 -9
- data/lib/review/converter.rb +1 -1
- data/lib/review/epub2html.rb +6 -1
- data/lib/review/epubmaker.rb +116 -117
- 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 +132 -87
- data/lib/review/htmlutils.rb +8 -11
- data/lib/review/i18n.rb +2 -1
- data/lib/review/idgxmlbuilder.rb +156 -76
- data/lib/review/idgxmlmaker.rb +22 -18
- data/lib/review/img_math.rb +245 -0
- data/lib/review/index_builder.rb +654 -0
- data/lib/review/init.rb +17 -18
- data/lib/review/latexbox.rb +58 -0
- data/lib/review/latexbuilder.rb +173 -43
- data/lib/review/latexutils.rb +9 -1
- data/lib/review/lineinput.rb +112 -2
- data/lib/review/logger.rb +42 -3
- data/lib/review/makerhelper.rb +12 -187
- data/lib/review/markdownbuilder.rb +51 -2
- data/lib/review/pdfmaker.rb +78 -73
- data/lib/review/plaintextbuilder.rb +98 -14
- data/lib/review/preprocessor.rb +18 -12
- data/lib/review/rstbuilder.rb +28 -9
- data/lib/review/sec_counter.rb +14 -0
- data/lib/review/template.rb +6 -0
- data/lib/review/textmaker.rb +21 -19
- data/lib/review/textutils.rb +3 -12
- data/lib/review/tocprinter.rb +242 -97
- data/lib/review/topbuilder.rb +91 -24
- 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 +34 -33
- data/lib/review/webtocprinter.rb +39 -35
- data/lib/review/yamlloader.rb +2 -1
- data/review.gemspec +5 -3
- data/samples/sample-book/src/.gitignore +1 -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.yml +3 -3
- data/samples/sample-book/src/lib/tasks/review.rake +26 -6
- 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 +1 -1
- data/samples/syntax-book/config-jlreq-lualatex.yml +4 -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 +23 -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 +41 -29
- data/templates/latex/review-jlreq/README.md +3 -1
- data/templates/latex/review-jlreq/review-base.sty +47 -22
- data/templates/latex/review-jlreq/review-jlreq.cls +25 -24
- 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 +47 -21
- data/templates/latex/review-jsbook/review-jsbook.cls +12 -2
- 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 +12 -9
- data/test/assets/test_template_backmatter.tex +12 -9
- data/test/book_test_helper.rb +11 -5
- data/test/run_test.rb +1 -1
- data/test/test_book.rb +62 -63
- 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 +1 -0
- 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 +14 -7
- data/test/test_helper.rb +23 -11
- data/test/test_htmlbuilder.rb +956 -76
- data/test/test_htmlutils.rb +0 -12
- data/test/test_i18n.rb +33 -33
- data/test/test_idgxmlbuilder.rb +568 -10
- 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 +1056 -30
- data/test/test_latexbuilder_v2.rb +52 -12
- 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 +101 -7
- data/test/test_plaintextbuilder.rb +531 -25
- 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 +58 -0
- data/test/test_tocprinter.rb +46 -0
- data/test/test_topbuilder.rb +365 -10
- 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/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 +109 -20
- 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 -271
- data/samples/syntax-book/review-ext.rb +0 -14
- data/test/test_tocparser.rb +0 -25
data/test/test_epubmaker_cmd.rb
CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'rbconfig'
|
6
6
|
|
7
|
-
REVIEW_EPUBMAKER = File.expand_path('../bin/review-epubmaker',
|
7
|
+
REVIEW_EPUBMAKER = File.expand_path('../bin/review-epubmaker', __dir__)
|
8
8
|
|
9
9
|
class EPUBMakerCmdTest < Test::Unit::TestCase
|
10
10
|
def setup
|
@@ -12,7 +12,7 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
|
|
12
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
|
@@ -21,18 +21,25 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
|
|
21
21
|
ENV['RUBYLIB'] = @old_rubylib
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def common_buildepub(bookdir, configfile, targetepubfile)
|
25
25
|
if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
|
26
|
-
config = prepare_samplebook(@tmpdir1)
|
26
|
+
config = prepare_samplebook(@tmpdir1, bookdir, nil, configfile)
|
27
27
|
builddir = File.join(@tmpdir1, config['bookname'] + '-epub')
|
28
28
|
assert !File.exist?(builddir)
|
29
29
|
|
30
30
|
ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
|
31
31
|
Dir.chdir(@tmpdir1) do
|
32
|
-
system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER}
|
32
|
+
system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} #{configfile} 1>/dev/null 2>/dev/null")
|
33
33
|
end
|
34
|
-
|
35
|
-
assert File.exist?(builddir)
|
34
|
+
assert File.exist?(File.join(@tmpdir1, targetepubfile))
|
36
35
|
end
|
37
36
|
end
|
37
|
+
|
38
|
+
def test_epubmaker_cmd_samplebook
|
39
|
+
common_buildepub('sample-book/src', 'config.yml', 'book.epub')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_epubmaker_cmd_syntaxbook
|
43
|
+
common_buildepub('syntax-book', 'config.yml', 'syntax-book.epub')
|
44
|
+
end
|
38
45
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,22 +1,31 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.
|
1
|
+
$LOAD_PATH.unshift(File.realpath('../lib', __dir__))
|
2
|
+
|
2
3
|
require 'test/unit'
|
3
4
|
require 'fileutils'
|
5
|
+
require 'review/yamlloader'
|
6
|
+
require 'review/extentions'
|
4
7
|
|
5
8
|
def touch_file(path)
|
6
9
|
FileUtils.touch(path)
|
7
10
|
end
|
8
11
|
|
9
12
|
def assets_dir
|
10
|
-
File.join(
|
11
|
-
end
|
12
|
-
|
13
|
-
def prepare_samplebook(srcdir)
|
14
|
-
samplebook_dir = File.expand_path(
|
15
|
-
|
16
|
-
#
|
17
|
-
|
18
|
-
FileUtils.
|
19
|
-
|
13
|
+
File.join(__dir__, 'assets')
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare_samplebook(srcdir, bookdir, latextemplatedir, configfile)
|
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)
|
22
|
+
if latextemplatedir
|
23
|
+
# copy from review-jsbook or review-jlreq
|
24
|
+
template_dir = File.expand_path("../templates/latex/#{latextemplatedir}/", __dir__)
|
25
|
+
FileUtils.cp(Dir.glob(File.join(template_dir, '*')), File.join(srcdir, 'sty'))
|
26
|
+
end
|
27
|
+
loader = ReVIEW::YAMLLoader.new
|
28
|
+
loader.load_file(File.open(File.join(srcdir, configfile)))
|
20
29
|
end
|
21
30
|
|
22
31
|
def compile_inline(text)
|
@@ -31,11 +40,13 @@ end
|
|
31
40
|
|
32
41
|
def compile_block_default(text)
|
33
42
|
@chapter.content = text
|
43
|
+
@chapter.execute_indexer(force: true)
|
34
44
|
@compiler.compile(@chapter)
|
35
45
|
end
|
36
46
|
|
37
47
|
def compile_block_html(text)
|
38
48
|
@chapter.content = text
|
49
|
+
@chapter.execute_indexer(force: true)
|
39
50
|
matched = @compiler.compile(@chapter).match(Regexp.new(%Q(<body>\n(.+)</body>), Regexp::MULTILINE))
|
40
51
|
if matched && matched.size > 1
|
41
52
|
matched[1]
|
@@ -46,5 +57,6 @@ end
|
|
46
57
|
|
47
58
|
def compile_block_idgxml(text)
|
48
59
|
@chapter.content = text
|
60
|
+
@chapter.execute_indexer(force: true)
|
49
61
|
@compiler.compile(@chapter).gsub(Regexp.new(%Q(.*<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">), Regexp::MULTILINE), '').gsub("</doc>\n", '')
|
50
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,14 @@ 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
|
+
@builder = HTMLBuilder.new(img_math: img_math)
|
19
20
|
@compiler = ReVIEW::Compiler.new(@builder)
|
20
21
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
21
22
|
location = Location.new(nil, nil)
|
22
23
|
@builder.bind(@compiler, @chapter, location)
|
23
24
|
I18n.setup('ja')
|
25
|
+
@skip_pygments = true # temporary suppress pygments test
|
24
26
|
end
|
25
27
|
|
26
28
|
def test_xmlns_ops_prefix_epub3
|
@@ -61,7 +63,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
61
63
|
Dir.mktmpdir do |dir|
|
62
64
|
Dir.chdir(dir) do
|
63
65
|
file = File.join(dir, 'locale.yml')
|
64
|
-
File.
|
66
|
+
File.write(file, "locale: ja\nappendix: 付録%pR")
|
65
67
|
I18n.setup('ja')
|
66
68
|
@chapter.instance_eval do
|
67
69
|
def on_appendix?
|
@@ -82,7 +84,7 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
82
84
|
Dir.mktmpdir do |dir|
|
83
85
|
Dir.chdir(dir) do
|
84
86
|
file = File.join(dir, 'locale.yml')
|
85
|
-
File.
|
87
|
+
File.write(file, "locale: ja\nappendix: 付録%pA")
|
86
88
|
I18n.setup('ja')
|
87
89
|
@chapter.instance_eval do
|
88
90
|
def on_appendix?
|
@@ -106,8 +108,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
106
108
|
end
|
107
109
|
|
108
110
|
def test_headline_level1_with_tricky_id
|
109
|
-
actual = compile_block("={123
|
110
|
-
assert_equal %Q(<h1 id="
|
111
|
+
actual = compile_block("={123あ_} this is test.\n")
|
112
|
+
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
113
|
end
|
112
114
|
|
113
115
|
def test_headline_level1_with_inlinetag
|
@@ -137,8 +139,8 @@ class HTMLBuidlerTest < Test::Unit::TestCase
|
|
137
139
|
end
|
138
140
|
|
139
141
|
def test_label_with_tricky_id
|
140
|
-
actual = compile_block("//label[123
|
141
|
-
assert_equal %Q(<a id="
|
142
|
+
actual = compile_block("//label[123あ_]\n")
|
143
|
+
assert_equal %Q(<a id="id_123_E3_81_82__"></a>\n), actual
|
142
144
|
end
|
143
145
|
|
144
146
|
def test_href
|
@@ -244,10 +246,21 @@ EOS
|
|
244
246
|
|
245
247
|
def test_inline_hd_chap
|
246
248
|
def @chapter.headline_index
|
247
|
-
|
248
|
-
Book::HeadlineIndex.new(
|
249
|
+
item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
|
250
|
+
idx = Book::HeadlineIndex.new(self)
|
251
|
+
idx.add_item(item)
|
252
|
+
idx
|
249
253
|
end
|
250
254
|
|
255
|
+
@config['secnolevel'] = 2
|
256
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
257
|
+
assert_equal 'test <a href="-.html#h1-1-1">「te_st」</a> test2', actual
|
258
|
+
|
259
|
+
@config['secnolevel'] = 3
|
260
|
+
actual = compile_inline('test @<hd>{chap1|test} test2')
|
261
|
+
assert_equal 'test <a href="-.html#h1-1-1">「1.1.1 te_st」</a> test2', actual
|
262
|
+
|
263
|
+
@config['chapterlink'] = nil
|
251
264
|
@config['secnolevel'] = 2
|
252
265
|
actual = compile_inline('test @<hd>{chap1|test} test2')
|
253
266
|
assert_equal 'test 「te_st」 test2', actual
|
@@ -261,7 +274,7 @@ EOS
|
|
261
274
|
Dir.mktmpdir do |dir|
|
262
275
|
Dir.chdir(dir) do
|
263
276
|
file = File.join(dir, 'locale.yml')
|
264
|
-
File.
|
277
|
+
File.write(file, "locale: ja\nappendix: 付録%pR")
|
265
278
|
I18n.setup('ja')
|
266
279
|
@chapter.instance_eval do
|
267
280
|
def on_appendix?
|
@@ -270,10 +283,16 @@ EOS
|
|
270
283
|
end
|
271
284
|
|
272
285
|
def @chapter.headline_index
|
273
|
-
|
274
|
-
Book::HeadlineIndex.new(
|
286
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
287
|
+
idx = Book::HeadlineIndex.new(self)
|
288
|
+
idx.add_item(item)
|
289
|
+
idx
|
275
290
|
end
|
276
291
|
|
292
|
+
actual = compile_inline('test @<hd>{test} test2')
|
293
|
+
assert_equal 'test <a href="-.html#hI-1">「I.1 te_st」</a> test2', actual
|
294
|
+
|
295
|
+
@config['chapterlink'] = nil
|
277
296
|
actual = compile_inline('test @<hd>{test} test2')
|
278
297
|
assert_equal 'test 「I.1 te_st」 test2', actual
|
279
298
|
end
|
@@ -284,7 +303,7 @@ EOS
|
|
284
303
|
Dir.mktmpdir do |dir|
|
285
304
|
Dir.chdir(dir) do
|
286
305
|
file = File.join(dir, 'locale.yml')
|
287
|
-
File.
|
306
|
+
File.write(file, "locale: ja\nappendix: 付録%pA")
|
288
307
|
I18n.setup('ja')
|
289
308
|
@chapter.instance_eval do
|
290
309
|
def on_appendix?
|
@@ -293,10 +312,16 @@ EOS
|
|
293
312
|
end
|
294
313
|
|
295
314
|
def @chapter.headline_index
|
296
|
-
|
297
|
-
Book::HeadlineIndex.new(
|
315
|
+
item = Book::Index::Item.new('test', [1], 'te_st')
|
316
|
+
idx = Book::HeadlineIndex.new(self)
|
317
|
+
idx.add_item(item)
|
318
|
+
idx
|
298
319
|
end
|
299
320
|
|
321
|
+
actual = compile_inline('test @<hd>{test} test2')
|
322
|
+
assert_equal 'test <a href="-.html#hA-1">「A.1 te_st」</a> test2', actual
|
323
|
+
|
324
|
+
@config['chapterlink'] = nil
|
300
325
|
actual = compile_inline('test @<hd>{test} test2')
|
301
326
|
assert_equal 'test 「A.1 te_st」 test2', actual
|
302
327
|
end
|
@@ -335,12 +360,26 @@ EOS
|
|
335
360
|
rescue LoadError
|
336
361
|
return true
|
337
362
|
end
|
338
|
-
@config['
|
363
|
+
@config['math_format'] = 'mathml'
|
339
364
|
actual = compile_inline('@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}')
|
340
|
-
@config['mathml'] = nil
|
341
365
|
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
|
342
366
|
end
|
343
367
|
|
368
|
+
def test_inline_mathjax
|
369
|
+
@config['math_format'] = 'mathjax'
|
370
|
+
actual = compile_inline('@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}')
|
371
|
+
assert_equal %Q(<span class="equation">\\( \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a} \\)</span>), actual
|
372
|
+
|
373
|
+
content = <<-EOF
|
374
|
+
//texequation{
|
375
|
+
\\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}
|
376
|
+
//}
|
377
|
+
EOF
|
378
|
+
actual = compile_block(content)
|
379
|
+
expected = %Q(<div class="equation">\n$$\\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$$\n</div>\n)
|
380
|
+
assert_equal expected, actual
|
381
|
+
end
|
382
|
+
|
344
383
|
def test_inline_img
|
345
384
|
def @chapter.image(_id)
|
346
385
|
item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
|
@@ -348,6 +387,11 @@ EOS
|
|
348
387
|
item
|
349
388
|
end
|
350
389
|
|
390
|
+
actual = compile_block("@<img>{sampleimg}\n")
|
391
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
392
|
+
assert_equal expected, actual
|
393
|
+
|
394
|
+
@config['chapterlink'] = nil
|
351
395
|
actual = compile_block("@<img>{sampleimg}\n")
|
352
396
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
353
397
|
assert_equal expected, actual
|
@@ -360,6 +404,11 @@ EOS
|
|
360
404
|
item
|
361
405
|
end
|
362
406
|
|
407
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
408
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span>「sample photo」</p>\n)
|
409
|
+
assert_equal expected, actual
|
410
|
+
|
411
|
+
@config['chapterlink'] = nil
|
363
412
|
actual = compile_block("@<imgref>{sampleimg}\n")
|
364
413
|
expected = %Q(<p><span class="imgref">図1.1</span>「sample photo」</p>\n)
|
365
414
|
assert_equal expected, actual
|
@@ -372,6 +421,11 @@ EOS
|
|
372
421
|
item
|
373
422
|
end
|
374
423
|
|
424
|
+
actual = compile_block("@<imgref>{sampleimg}\n")
|
425
|
+
expected = %Q(<p><span class="imgref"><a href="./-.html#sampleimg">図1.1</a></span></p>\n)
|
426
|
+
assert_equal expected, actual
|
427
|
+
|
428
|
+
@config['chapterlink'] = nil
|
375
429
|
actual = compile_block("@<imgref>{sampleimg}\n")
|
376
430
|
expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
|
377
431
|
assert_equal expected, actual
|
@@ -383,20 +437,24 @@ EOS
|
|
383
437
|
file1 = File.join(dir, 'images', 'img1.png')
|
384
438
|
filet1 = File.join(dir, 'images', 'tbl1.png')
|
385
439
|
file2 = File.join(dir, 'images', 'img2.png')
|
440
|
+
file3 = File.join(dir, 'images', 'icon3.png')
|
386
441
|
re1 = File.join(dir, 'sample1.re')
|
387
442
|
cat = File.join(dir, 'catalog.yml')
|
388
443
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
389
|
-
File.
|
390
|
-
File.
|
391
|
-
File.
|
392
|
-
File.
|
393
|
-
File.
|
444
|
+
File.write(file1, '')
|
445
|
+
File.write(filet1, '')
|
446
|
+
File.write(file2, '')
|
447
|
+
File.write(file3, '')
|
448
|
+
File.write(cat, "CHAPS:\n - sample1.re\n")
|
449
|
+
File.write(re1, <<-EOF)
|
394
450
|
= test
|
395
451
|
|
396
452
|
tbl1 is @<table>{tbl1}.
|
397
453
|
|
398
454
|
img2 is @<img>{img2}.
|
399
455
|
|
456
|
+
icon3 is @<icon>{icon3}.
|
457
|
+
|
400
458
|
//image[img1][image 1]{
|
401
459
|
//}
|
402
460
|
|
@@ -411,8 +469,37 @@ EOF
|
|
411
469
|
|
412
470
|
expected = <<-EOS
|
413
471
|
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
472
|
+
<p>tbl1 is <span class="tableref"><a href="./-.html#tbl1">表1.1</a></span>.</p>
|
473
|
+
<p>img2 is <span class="imgref"><a href="./-.html#img2">図1.2</a></span>.</p>
|
474
|
+
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
475
|
+
<div id="img1" class="image">
|
476
|
+
<img src="images/img1.png" alt="image 1" />
|
477
|
+
<p class="caption">
|
478
|
+
図1.1: image 1
|
479
|
+
</p>
|
480
|
+
</div>
|
481
|
+
<div id="tbl1" class="imgtable image">
|
482
|
+
<p class="caption">表1.1: table 1</p>
|
483
|
+
<img src="images/tbl1.png" alt="table 1" />
|
484
|
+
</div>
|
485
|
+
<div id="img2" class="image">
|
486
|
+
<img src="images/img2.png" alt="image 2" />
|
487
|
+
<p class="caption">
|
488
|
+
図1.2: image 2
|
489
|
+
</p>
|
490
|
+
</div>
|
491
|
+
EOS
|
492
|
+
|
493
|
+
assert_equal expected, actual
|
494
|
+
|
495
|
+
@config['chapterlink'] = nil
|
496
|
+
actual = compile_block(content)
|
497
|
+
|
498
|
+
expected = <<-EOS
|
499
|
+
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
|
414
500
|
<p>tbl1 is <span class="tableref">表1.1</span>.</p>
|
415
501
|
<p>img2 is <span class="imgref">図1.2</span>.</p>
|
502
|
+
<p>icon3 is <img src="images/icon3.png" alt="[icon3]" />.</p>
|
416
503
|
<div id="img1" class="image">
|
417
504
|
<img src="images/img1.png" alt="image 1" />
|
418
505
|
<p class="caption">
|
@@ -540,6 +627,32 @@ EOS
|
|
540
627
|
図1.1: sample photo
|
541
628
|
</p>
|
542
629
|
</div>
|
630
|
+
EOS
|
631
|
+
assert_equal expected, actual
|
632
|
+
|
633
|
+
actual = compile_block("//image[sampleimg][]{\n//}\n")
|
634
|
+
expected = <<-EOS
|
635
|
+
<div id="sampleimg" class="image">
|
636
|
+
<img src="images/chap1-sampleimg.png" alt="" />
|
637
|
+
<p class="caption">
|
638
|
+
図1.1:
|
639
|
+
</p>
|
640
|
+
</div>
|
641
|
+
EOS
|
642
|
+
assert_equal expected, actual
|
643
|
+
|
644
|
+
actual = compile_block("//image[sampleimg][][]{\n//}\n")
|
645
|
+
assert_equal expected, actual
|
646
|
+
|
647
|
+
@config['caption_position']['image'] = 'top'
|
648
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
649
|
+
expected = <<-EOS
|
650
|
+
<div id="sampleimg" class="image">
|
651
|
+
<p class="caption">
|
652
|
+
図1.1: sample photo
|
653
|
+
</p>
|
654
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
655
|
+
</div>
|
543
656
|
EOS
|
544
657
|
assert_equal expected, actual
|
545
658
|
end
|
@@ -582,21 +695,22 @@ EOS
|
|
582
695
|
assert_equal expected, actual
|
583
696
|
end
|
584
697
|
|
585
|
-
def
|
698
|
+
def test_image_with_tricky_id_kana
|
586
699
|
def @chapter.image(_id)
|
587
|
-
item = Book::Index::Item.new('123
|
588
|
-
item.instance_eval { @path = './images/
|
700
|
+
item = Book::Index::Item.new('123あいう', 1)
|
701
|
+
item.instance_eval { @path = './images/123あいう.png' }
|
589
702
|
item
|
590
703
|
end
|
591
|
-
|
592
|
-
actual = compile_block("//image[123
|
704
|
+
@chapter.instance_eval { @name = 'ch01' }
|
705
|
+
actual = compile_block("//image[123あいう][sample photo]{\n//}\nimg: @<img>{123あいう}\n")
|
593
706
|
expected = <<-EOS
|
594
|
-
<div id="
|
595
|
-
<img src="images/
|
707
|
+
<div id="id_123_E3_81_82_E3_81_84_E3_81_86" class="image">
|
708
|
+
<img src="images/123あいう.png" alt="sample photo" />
|
596
709
|
<p class="caption">
|
597
710
|
図1.1: sample photo
|
598
711
|
</p>
|
599
712
|
</div>
|
713
|
+
<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>
|
600
714
|
EOS
|
601
715
|
assert_equal expected, actual
|
602
716
|
end
|
@@ -616,6 +730,18 @@ EOS
|
|
616
730
|
図: sample photo
|
617
731
|
</p>
|
618
732
|
</div>
|
733
|
+
EOS
|
734
|
+
assert_equal expected, actual
|
735
|
+
|
736
|
+
@config['caption_position']['image'] = 'top'
|
737
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
738
|
+
expected = <<-EOS
|
739
|
+
<div id="sampleimg" class="image">
|
740
|
+
<p class="caption">
|
741
|
+
図: sample photo
|
742
|
+
</p>
|
743
|
+
<img src="images/chap1-sampleimg.png" alt="sample photo" />
|
744
|
+
</div>
|
619
745
|
EOS
|
620
746
|
assert_equal expected, actual
|
621
747
|
end
|
@@ -634,6 +760,12 @@ EOS
|
|
634
760
|
</div>
|
635
761
|
EOS
|
636
762
|
assert_equal expected, actual
|
763
|
+
|
764
|
+
actual = compile_block("//indepimage[sampleimg][]\n")
|
765
|
+
assert_equal expected, actual
|
766
|
+
|
767
|
+
actual = compile_block("//indepimage[sampleimg][][]\n")
|
768
|
+
assert_equal expected, actual
|
637
769
|
end
|
638
770
|
|
639
771
|
def test_indepimage_with_metric
|
@@ -772,6 +904,19 @@ EOS
|
|
772
904
|
assert_equal expected, actual
|
773
905
|
end
|
774
906
|
|
907
|
+
def test_dt_inline
|
908
|
+
actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
|
909
|
+
|
910
|
+
expected = <<-EOS
|
911
|
+
<div class="footnote" epub:type="footnote" id="fn-bar"><p class="footnote">[*1] bar</p></div>
|
912
|
+
<dl>
|
913
|
+
<dt>foo<a id="fnb-bar" href="#fn-bar" class="noteref" epub:type="noteref">*1</a>[]<>&<span class="equation">\\alpha[]</span></dt>
|
914
|
+
<dd></dd>
|
915
|
+
</dl>
|
916
|
+
EOS
|
917
|
+
assert_equal expected, actual
|
918
|
+
end
|
919
|
+
|
775
920
|
def test_list
|
776
921
|
def @chapter.list(_id)
|
777
922
|
Book::Index::Item.new('samplelist', 1)
|
@@ -786,6 +931,20 @@ test1.5
|
|
786
931
|
test<i>2</i>
|
787
932
|
</pre>
|
788
933
|
</div>
|
934
|
+
EOS
|
935
|
+
assert_equal expected, actual
|
936
|
+
|
937
|
+
@config['caption_position']['list'] = 'bottom'
|
938
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
939
|
+
expected = <<-EOS
|
940
|
+
<div id="samplelist" class="caption-code">
|
941
|
+
<pre class="list">test1
|
942
|
+
test1.5
|
943
|
+
|
944
|
+
test<i>2</i>
|
945
|
+
</pre>
|
946
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
947
|
+
</div>
|
789
948
|
EOS
|
790
949
|
assert_equal expected, actual
|
791
950
|
end
|
@@ -794,27 +953,35 @@ EOS
|
|
794
953
|
def @chapter.list(_id)
|
795
954
|
Book::Index::Item.new('samplelist', 1)
|
796
955
|
end
|
797
|
-
actual = compile_block("@<list>{
|
956
|
+
actual = compile_block("@<list>{samplelist}\n")
|
957
|
+
assert_equal %Q(<p><span class="listref"><a href="./-.html#samplelist">リスト1.1</a></span></p>\n), actual
|
958
|
+
|
959
|
+
@config['chapterlink'] = nil
|
960
|
+
actual = compile_block("@<list>{samplelist}\n")
|
798
961
|
assert_equal %Q(<p><span class="listref">リスト1.1</span></p>\n), actual
|
799
962
|
end
|
800
963
|
|
801
964
|
def test_inline_list_href
|
802
|
-
book = ReVIEW::Book::Base.
|
965
|
+
book = ReVIEW::Book::Base.new
|
803
966
|
book.config['chapterlink'] = true
|
804
967
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
805
|
-
io1 = StringIO.new("//list[sampletest]{\nfoo\n//}\n")
|
968
|
+
io1 = StringIO.new("//list[sampletest][a]{\nfoo\n//}\n")
|
806
969
|
io2 = StringIO.new("= BAR\n")
|
807
970
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
808
971
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
809
|
-
book.parts = [ReVIEW::Book::Part.new(
|
972
|
+
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
810
973
|
builder = ReVIEW::HTMLBuilder.new
|
811
974
|
comp = ReVIEW::Compiler.new(builder)
|
812
975
|
builder.bind(comp, chap2, nil)
|
976
|
+
|
977
|
+
chap1.generate_indexes
|
813
978
|
actual = builder.inline_list('ch1|sampletest')
|
814
979
|
assert_equal %Q(<span class="listref"><a href="./ch1.html#sampletest">リスト1.1</a></span>), actual
|
815
980
|
end
|
816
981
|
|
817
982
|
def test_list_pygments
|
983
|
+
return true if @skip_pygments
|
984
|
+
|
818
985
|
def @chapter.list(_id)
|
819
986
|
Book::Index::Item.new('samplelist', 1)
|
820
987
|
end
|
@@ -842,6 +1009,8 @@ test<i>2</i>
|
|
842
1009
|
end
|
843
1010
|
|
844
1011
|
def test_list_pygments_lang
|
1012
|
+
return true if @skip_pygments
|
1013
|
+
|
845
1014
|
def @chapter.list(_id)
|
846
1015
|
Book::Index::Item.new('samplelist', 1)
|
847
1016
|
end
|
@@ -870,6 +1039,8 @@ EOS
|
|
870
1039
|
end
|
871
1040
|
|
872
1041
|
def test_list_pygments_nulllang
|
1042
|
+
return true if @skip_pygments
|
1043
|
+
|
873
1044
|
def @chapter.list(_id)
|
874
1045
|
Book::Index::Item.new('samplelist', 1)
|
875
1046
|
end
|
@@ -1003,6 +1174,29 @@ EOS
|
|
1003
1174
|
4: end
|
1004
1175
|
</pre>
|
1005
1176
|
</div>
|
1177
|
+
EOS
|
1178
|
+
|
1179
|
+
assert_equal expected, actual
|
1180
|
+
|
1181
|
+
@config['caption_position']['list'] = 'bottom'
|
1182
|
+
actual = compile_block(<<-EOS)
|
1183
|
+
//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
|
1184
|
+
def foo(a1, a2=:test)
|
1185
|
+
(1..3).times{|i| a.include?(:foo)}
|
1186
|
+
return true
|
1187
|
+
end
|
1188
|
+
//}
|
1189
|
+
EOS
|
1190
|
+
|
1191
|
+
expected = <<-EOS
|
1192
|
+
<div id="samplelist" class="code">
|
1193
|
+
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
|
1194
|
+
2: (1..3).times{|i| a.include?(:foo)}
|
1195
|
+
3: return true
|
1196
|
+
4: end
|
1197
|
+
</pre>
|
1198
|
+
<p class="caption">リスト1.1: this is <b>test</b><&>_</p>
|
1199
|
+
</div>
|
1006
1200
|
EOS
|
1007
1201
|
|
1008
1202
|
assert_equal expected, actual
|
@@ -1039,6 +1233,8 @@ EOS
|
|
1039
1233
|
end
|
1040
1234
|
|
1041
1235
|
def test_listnum_pygments_lang
|
1236
|
+
return true if @skip_pygments
|
1237
|
+
|
1042
1238
|
def @chapter.list(_id)
|
1043
1239
|
Book::Index::Item.new('samplelist', 1)
|
1044
1240
|
end
|
@@ -1066,6 +1262,8 @@ EOS
|
|
1066
1262
|
end
|
1067
1263
|
|
1068
1264
|
def test_listnum_pygments_lang_linenum
|
1265
|
+
return true if @skip_pygments
|
1266
|
+
|
1069
1267
|
def @chapter.list(_id)
|
1070
1268
|
Book::Index::Item.new('samplelist', 1)
|
1071
1269
|
end
|
@@ -1094,6 +1292,8 @@ EOS
|
|
1094
1292
|
end
|
1095
1293
|
|
1096
1294
|
def test_listnum_pygments_lang_without_lang
|
1295
|
+
return true if @skip_pygments
|
1296
|
+
|
1097
1297
|
def @chapter.list(_id)
|
1098
1298
|
Book::Index::Item.new('samplelist', 1)
|
1099
1299
|
end
|
@@ -1200,6 +1400,20 @@ bar
|
|
1200
1400
|
buz
|
1201
1401
|
</pre>
|
1202
1402
|
</div>
|
1403
|
+
EOS
|
1404
|
+
assert_equal expected, actual
|
1405
|
+
|
1406
|
+
@config['caption_position']['list'] = 'bottom'
|
1407
|
+
actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
|
1408
|
+
expected = <<-EOS
|
1409
|
+
<div class="source-code">
|
1410
|
+
<pre class="source">foo
|
1411
|
+
bar
|
1412
|
+
|
1413
|
+
buz
|
1414
|
+
</pre>
|
1415
|
+
<p class="caption">foo/bar/test.rb</p>
|
1416
|
+
</div>
|
1203
1417
|
EOS
|
1204
1418
|
assert_equal expected, actual
|
1205
1419
|
end
|
@@ -1237,6 +1451,18 @@ EOS
|
|
1237
1451
|
bar
|
1238
1452
|
</pre>
|
1239
1453
|
</div>
|
1454
|
+
EOS
|
1455
|
+
assert_equal expected, actual
|
1456
|
+
|
1457
|
+
@config['caption_position']['list'] = 'bottom'
|
1458
|
+
actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
|
1459
|
+
expected = <<-EOS
|
1460
|
+
<div class="syntax">
|
1461
|
+
<pre class="syntax">foo
|
1462
|
+
bar
|
1463
|
+
</pre>
|
1464
|
+
<p class="caption">FOO</p>
|
1465
|
+
</div>
|
1240
1466
|
EOS
|
1241
1467
|
assert_equal expected, actual
|
1242
1468
|
end
|
@@ -1254,6 +1480,8 @@ EOS
|
|
1254
1480
|
end
|
1255
1481
|
|
1256
1482
|
def test_emlist_pygments_lang
|
1483
|
+
return true if @skip_pygments
|
1484
|
+
|
1257
1485
|
begin
|
1258
1486
|
require 'pygments'
|
1259
1487
|
rescue LoadError
|
@@ -1281,6 +1509,18 @@ EOS
|
|
1281
1509
|
lineB
|
1282
1510
|
</pre>
|
1283
1511
|
</div>
|
1512
|
+
EOS
|
1513
|
+
assert_equal expected, actual
|
1514
|
+
|
1515
|
+
@config['caption_position']['list'] = 'bottom'
|
1516
|
+
actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
|
1517
|
+
expected = <<-EOS
|
1518
|
+
<div class="emlist-code">
|
1519
|
+
<pre class="emlist">lineA
|
1520
|
+
lineB
|
1521
|
+
</pre>
|
1522
|
+
<p class="caption">cap1</p>
|
1523
|
+
</div>
|
1284
1524
|
EOS
|
1285
1525
|
assert_equal expected, actual
|
1286
1526
|
end
|
@@ -1321,6 +1561,18 @@ EOS
|
|
1321
1561
|
2: lineB
|
1322
1562
|
</pre>
|
1323
1563
|
</div>
|
1564
|
+
EOS
|
1565
|
+
assert_equal expected, actual
|
1566
|
+
|
1567
|
+
@config['caption_position']['list'] = 'bottom'
|
1568
|
+
actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
|
1569
|
+
expected = <<-EOS
|
1570
|
+
<div class="emlistnum-code">
|
1571
|
+
<pre class="emlist language-text"> 1: lineA
|
1572
|
+
2: lineB
|
1573
|
+
</pre>
|
1574
|
+
<p class="caption">cap</p>
|
1575
|
+
</div>
|
1324
1576
|
EOS
|
1325
1577
|
assert_equal expected, actual
|
1326
1578
|
end
|
@@ -1366,6 +1618,8 @@ EOS
|
|
1366
1618
|
end
|
1367
1619
|
|
1368
1620
|
def test_cmd_pygments
|
1621
|
+
return true if @skip_pygments
|
1622
|
+
|
1369
1623
|
begin
|
1370
1624
|
require 'pygments'
|
1371
1625
|
rescue LoadError
|
@@ -1393,6 +1647,18 @@ EOS
|
|
1393
1647
|
lineB
|
1394
1648
|
</pre>
|
1395
1649
|
</div>
|
1650
|
+
EOS
|
1651
|
+
assert_equal expected, actual
|
1652
|
+
|
1653
|
+
@config['caption_position']['list'] = 'bottom'
|
1654
|
+
actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
|
1655
|
+
expected = <<-EOS
|
1656
|
+
<div class="cmd-code">
|
1657
|
+
<pre class="cmd">lineA
|
1658
|
+
lineB
|
1659
|
+
</pre>
|
1660
|
+
<p class="caption">cap1</p>
|
1661
|
+
</div>
|
1396
1662
|
EOS
|
1397
1663
|
assert_equal expected, actual
|
1398
1664
|
end
|
@@ -1400,13 +1666,16 @@ EOS
|
|
1400
1666
|
def test_texequation
|
1401
1667
|
return true if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
1402
1668
|
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1669
|
+
|
1403
1670
|
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1404
1671
|
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P} q\n//}\n") do |dir, book, _files|
|
1405
1672
|
@book = book
|
1406
1673
|
@book.config = @config
|
1407
|
-
@config['
|
1674
|
+
@config['math_format'] = 'imgmath'
|
1408
1675
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1409
1676
|
location = Location.new(nil, nil)
|
1677
|
+
img_math = ReVIEW::ImgMath.new(@config)
|
1678
|
+
@builder = HTMLBuilder.new(img_math: img_math)
|
1410
1679
|
@builder.bind(@compiler, @chapter, location)
|
1411
1680
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1412
1681
|
expected = <<-EOB
|
@@ -1430,14 +1699,17 @@ EOS
|
|
1430
1699
|
# Re:VIEW 3 never fail on defer mode. This test is only for Re:VIEW 2.
|
1431
1700
|
return true if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
1432
1701
|
return true unless system('latex -version 1>/dev/null 2>/dev/null')
|
1702
|
+
|
1433
1703
|
mktmpbookdir('catalog.yml' => "CHAPS:\n - ch01.re\n",
|
1434
1704
|
'ch01.re' => "= test\n\n//texequation{\np \\land \\bm{P}} q\n//}\n") do |dir, book, _files|
|
1435
1705
|
@book = book
|
1436
1706
|
@book.config = @config
|
1437
1707
|
@config['review_version'] = 2
|
1438
|
-
@config['
|
1708
|
+
@config['math_format'] = 'imgmath'
|
1439
1709
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
1440
1710
|
location = Location.new(nil, nil)
|
1711
|
+
img_math = ReVIEW::ImgMath.new(@config)
|
1712
|
+
@builder = HTMLBuilder.new(img_math: img_math)
|
1441
1713
|
@builder.bind(@compiler, @chapter, location)
|
1442
1714
|
FileUtils.mkdir_p(File.join(dir, 'images'))
|
1443
1715
|
tmpio = $stderr
|
@@ -1628,6 +1900,20 @@ EOS
|
|
1628
1900
|
<p>inside column</p>
|
1629
1901
|
</div>
|
1630
1902
|
|
1903
|
+
<h3><a id="h1-0-1"></a>next level</h3>
|
1904
|
+
<p>this is <a href="-.html#column-1" class="columnref">コラム「test」</a>.</p>
|
1905
|
+
EOS
|
1906
|
+
|
1907
|
+
assert_equal expected, column_helper(review)
|
1908
|
+
|
1909
|
+
@config['chapterlink'] = nil
|
1910
|
+
expected = <<-EOS
|
1911
|
+
<div class="column">
|
1912
|
+
|
1913
|
+
<h3 id="foo"><a id="column-1"></a>test</h3>
|
1914
|
+
<p>inside column</p>
|
1915
|
+
</div>
|
1916
|
+
|
1631
1917
|
<h3><a id="h1-0-1"></a>next level</h3>
|
1632
1918
|
<p>this is コラム「test」.</p>
|
1633
1919
|
EOS
|
@@ -1637,10 +1923,17 @@ EOS
|
|
1637
1923
|
|
1638
1924
|
def test_column_in_aother_chapter_ref
|
1639
1925
|
def @chapter.column_index
|
1640
|
-
|
1641
|
-
Book::ColumnIndex.new
|
1926
|
+
item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
|
1927
|
+
idx = Book::ColumnIndex.new
|
1928
|
+
idx.add_item(item)
|
1929
|
+
idx
|
1642
1930
|
end
|
1643
1931
|
|
1932
|
+
actual = compile_inline('test @<column>{chap1|column} test2')
|
1933
|
+
expected = 'test <a href="-.html#column-1" class="columnref">コラム「column_cap」</a> test2'
|
1934
|
+
assert_equal expected, actual
|
1935
|
+
|
1936
|
+
@config['chapterlink'] = nil
|
1644
1937
|
actual = compile_inline('test @<column>{chap1|column} test2')
|
1645
1938
|
expected = 'test コラム「column_cap」 test2'
|
1646
1939
|
assert_equal expected, actual
|
@@ -1938,8 +2231,6 @@ EOS
|
|
1938
2231
|
end
|
1939
2232
|
|
1940
2233
|
def test_footnote
|
1941
|
-
fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
|
1942
|
-
@chapter.instance_eval { @footnote_index = fn }
|
1943
2234
|
actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
|
1944
2235
|
expected = <<-'EOS'
|
1945
2236
|
<div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote">[*1] bar\a\$buz</p></div>
|
@@ -1964,58 +2255,69 @@ EOS
|
|
1964
2255
|
end
|
1965
2256
|
|
1966
2257
|
def test_footnote_with_tricky_id
|
1967
|
-
|
1968
|
-
@chapter.instance_eval { @footnote_index = fn }
|
1969
|
-
actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
|
2258
|
+
actual = compile_block("//footnote[123あ_;][bar\\a\\$buz]\n")
|
1970
2259
|
expected = <<-'EOS'
|
1971
|
-
<div class="footnote" epub:type="footnote" id="fn-
|
2260
|
+
<div class="footnote" epub:type="footnote" id="fn-id_123_E3_81_82___3B"><p class="footnote">[*1] bar\a\$buz</p></div>
|
1972
2261
|
EOS
|
1973
2262
|
assert_equal expected, actual
|
1974
2263
|
end
|
1975
2264
|
|
1976
2265
|
def test_inline_fn
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
comp = ReVIEW::Compiler.new(builder)
|
1984
|
-
builder.bind(comp, chap1, nil)
|
1985
|
-
fn = builder.inline_fn('foo')
|
1986
|
-
assert_equal '<a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a>', fn
|
2266
|
+
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2267
|
+
expected = <<-EOS
|
2268
|
+
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2269
|
+
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">*1</a></p>
|
2270
|
+
EOS
|
2271
|
+
assert_equal expected, fn
|
1987
2272
|
I18n.set('html_footnote_refmark', '+%s')
|
1988
|
-
fn =
|
1989
|
-
|
2273
|
+
fn = compile_block("//footnote[foo][bar]\n\n@<fn>{foo}\n")
|
2274
|
+
expected = <<-EOS
|
2275
|
+
<div class=\"footnote\" epub:type=\"footnote\" id=\"fn-foo\"><p class=\"footnote\">[*1] bar</p></div>
|
2276
|
+
<p><a id="fnb-foo" href="#fn-foo" class="noteref" epub:type="noteref">+1</a></p>
|
2277
|
+
EOS
|
2278
|
+
assert_equal expected, fn
|
1990
2279
|
end
|
1991
2280
|
|
1992
2281
|
def test_inline_hd
|
1993
|
-
book = ReVIEW::Book::Base.
|
2282
|
+
book = ReVIEW::Book::Base.new
|
1994
2283
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
1995
2284
|
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
1996
2285
|
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
1997
2286
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
1998
2287
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
1999
|
-
book.parts = [ReVIEW::Book::Part.new(
|
2288
|
+
book.parts = [ReVIEW::Book::Part.new(book, nil, [chap1, chap2])]
|
2000
2289
|
builder = ReVIEW::HTMLBuilder.new
|
2001
2290
|
comp = ReVIEW::Compiler.new(builder)
|
2002
2291
|
builder.bind(comp, chap2, nil)
|
2292
|
+
|
2293
|
+
chap1.generate_indexes
|
2294
|
+
chap2.generate_indexes
|
2295
|
+
hd = builder.inline_hd('ch1|test1-1')
|
2296
|
+
assert_equal '<a href="ch1.html#h1-1">「1.1 test1-1」</a>', hd
|
2297
|
+
|
2298
|
+
builder.instance_eval { @book.config['chapterlink'] = nil }
|
2003
2299
|
hd = builder.inline_hd('ch1|test1-1')
|
2004
2300
|
assert_equal '「1.1 test1-1」', hd
|
2005
2301
|
end
|
2006
2302
|
|
2007
2303
|
def test_inline_hd_for_part
|
2008
|
-
book = ReVIEW::Book::Base.
|
2304
|
+
book = ReVIEW::Book::Base.new
|
2009
2305
|
book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
|
2010
2306
|
io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
|
2011
2307
|
io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
|
2012
2308
|
io_p1 = StringIO.new("= part1\n\nfoo\n\n== part1-1\n\nbar\n\n== part1-2\n\nbar\n\n")
|
2013
2309
|
chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
|
2014
2310
|
chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
|
2015
|
-
book.parts = [ReVIEW::Book::Part.new(
|
2311
|
+
book.parts = [ReVIEW::Book::Part.new(book, 1, [chap1, chap2], 'part1.re', io_p1)]
|
2016
2312
|
builder = ReVIEW::HTMLBuilder.new
|
2017
2313
|
comp = ReVIEW::Compiler.new(builder)
|
2018
2314
|
builder.bind(comp, chap2, nil)
|
2315
|
+
book.generate_indexes
|
2316
|
+
|
2317
|
+
hd = builder.inline_hd('part1|part1-1')
|
2318
|
+
assert_equal '<a href="part1.html#h1-1">「1.1 part1-1」</a>', hd
|
2319
|
+
|
2320
|
+
builder.instance_eval { @book.config['chapterlink'] = nil }
|
2019
2321
|
hd = builder.inline_hd('part1|part1-1')
|
2020
2322
|
assert_equal '「1.1 part1-1」', hd
|
2021
2323
|
end
|
@@ -2026,7 +2328,12 @@ EOS
|
|
2026
2328
|
location = Location.new(nil, nil)
|
2027
2329
|
@builder.bind(@compiler, chap1, location)
|
2028
2330
|
hd = @builder.inline_hd('foo')
|
2331
|
+
assert_equal '<a href="-.html#h1-1">「1.1 foo」</a>', hd
|
2332
|
+
|
2333
|
+
@config['chapterlink'] = nil
|
2334
|
+
hd = @builder.inline_hd('foo')
|
2029
2335
|
assert_equal '「1.1 foo」', hd
|
2336
|
+
|
2030
2337
|
hd = @builder.inline_hd('bar')
|
2031
2338
|
assert_equal '「1.2 bar」', hd
|
2032
2339
|
end
|
@@ -2052,15 +2359,28 @@ EOS
|
|
2052
2359
|
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2053
2360
|
</table>
|
2054
2361
|
</div>
|
2362
|
+
EOS
|
2363
|
+
assert_equal expected, actual
|
2364
|
+
|
2365
|
+
@config['caption_position']['table'] = 'bottom'
|
2366
|
+
actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2367
|
+
expected = <<-EOS
|
2368
|
+
<div id="foo" class="table">
|
2369
|
+
<table>
|
2370
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2371
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2372
|
+
</table>
|
2373
|
+
<p class="caption">表1.1: FOO</p>
|
2374
|
+
</div>
|
2055
2375
|
EOS
|
2056
2376
|
assert_equal expected, actual
|
2057
2377
|
end
|
2058
2378
|
|
2059
2379
|
def test_empty_table
|
2060
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2380
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
|
2061
2381
|
assert_equal ':2: error: no rows in the table', e.message
|
2062
2382
|
|
2063
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2383
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
|
2064
2384
|
assert_equal ':3: error: no rows in the table', e.message
|
2065
2385
|
end
|
2066
2386
|
|
@@ -2069,6 +2389,10 @@ EOS
|
|
2069
2389
|
Book::Index::Item.new('sampletable', 1)
|
2070
2390
|
end
|
2071
2391
|
actual = compile_block("@<table>{sampletest}\n")
|
2392
|
+
assert_equal %Q(<p><span class="tableref"><a href="./-.html#sampletest">表1.1</a></span></p>\n), actual
|
2393
|
+
|
2394
|
+
@config['chapterlink'] = nil
|
2395
|
+
actual = compile_block("@<table>{sampletest}\n")
|
2072
2396
|
assert_equal %Q(<p><span class="tableref">表1.1</span></p>\n), actual
|
2073
2397
|
end
|
2074
2398
|
|
@@ -2090,21 +2414,100 @@ EOS
|
|
2090
2414
|
</div>
|
2091
2415
|
EOS
|
2092
2416
|
assert_equal expected, actual
|
2093
|
-
end
|
2094
2417
|
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2418
|
+
@config['caption_position']['table'] = 'bottom'
|
2419
|
+
actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
|
2420
|
+
expected = <<-EOS
|
2421
|
+
<div class="table">
|
2422
|
+
<table>
|
2423
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2424
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2425
|
+
</table>
|
2426
|
+
<p class="caption">foo</p>
|
2427
|
+
</div>
|
2428
|
+
<div class="table">
|
2429
|
+
<table>
|
2430
|
+
<tr><th>aaa</th><th>bbb</th></tr>
|
2431
|
+
<tr><td>ccc</td><td>ddd<>&</td></tr>
|
2432
|
+
</table>
|
2433
|
+
</div>
|
2434
|
+
EOS
|
2435
|
+
assert_equal expected, actual
|
2436
|
+
end
|
2437
|
+
|
2438
|
+
def test_imgtable
|
2439
|
+
def @chapter.image(_id)
|
2440
|
+
item = Book::Index::Item.new('sampleimg', 1, 'sample img')
|
2441
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
2442
|
+
item
|
2443
|
+
end
|
2444
|
+
|
2445
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
2103
2446
|
expected = <<-EOS
|
2104
2447
|
<div id="sampleimg" class="imgtable image">
|
2105
2448
|
<p class="caption">表1.1: test for imgtable</p>
|
2106
2449
|
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2107
2450
|
</div>
|
2451
|
+
EOS
|
2452
|
+
assert_equal expected, actual
|
2453
|
+
|
2454
|
+
@config['caption_position']['table'] = 'bottom'
|
2455
|
+
actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
|
2456
|
+
expected = <<-EOS
|
2457
|
+
<div id="sampleimg" class="imgtable image">
|
2458
|
+
<img src="images/chap1-sampleimg.png" alt="test for imgtable" />
|
2459
|
+
<p class="caption">表1.1: test for imgtable</p>
|
2460
|
+
</div>
|
2461
|
+
EOS
|
2462
|
+
assert_equal expected, actual
|
2463
|
+
end
|
2464
|
+
|
2465
|
+
def test_table_row_separator
|
2466
|
+
src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
|
2467
|
+
expected = <<-EOS
|
2468
|
+
<div class="table">
|
2469
|
+
<table>
|
2470
|
+
<tr><th>1</th><th>2</th><th>3 4| 5</th></tr>
|
2471
|
+
<tr><td>a b</td><td>c d |e</td><td></td></tr>
|
2472
|
+
</table>
|
2473
|
+
</div>
|
2474
|
+
EOS
|
2475
|
+
actual = compile_block(src)
|
2476
|
+
assert_equal expected, actual
|
2477
|
+
|
2478
|
+
@config['table_row_separator'] = 'singletab'
|
2479
|
+
actual = compile_block(src)
|
2480
|
+
expected = <<-EOS
|
2481
|
+
<div class="table">
|
2482
|
+
<table>
|
2483
|
+
<tr><th>1</th><th>2</th><th></th><th>3 4| 5</th></tr>
|
2484
|
+
<tr><td>a b</td><td>c d |e</td><td></td><td></td></tr>
|
2485
|
+
</table>
|
2486
|
+
</div>
|
2487
|
+
EOS
|
2488
|
+
assert_equal expected, actual
|
2489
|
+
|
2490
|
+
@config['table_row_separator'] = 'spaces'
|
2491
|
+
actual = compile_block(src)
|
2492
|
+
expected = <<-EOS
|
2493
|
+
<div class="table">
|
2494
|
+
<table>
|
2495
|
+
<tr><th>1</th><th>2</th><th>3</th><th>4|</th><th>5</th></tr>
|
2496
|
+
<tr><td>a</td><td>b</td><td>c</td><td>d</td><td>|e</td></tr>
|
2497
|
+
</table>
|
2498
|
+
</div>
|
2499
|
+
EOS
|
2500
|
+
assert_equal expected, actual
|
2501
|
+
|
2502
|
+
@config['table_row_separator'] = 'verticalbar'
|
2503
|
+
actual = compile_block(src)
|
2504
|
+
expected = <<-EOS
|
2505
|
+
<div class="table">
|
2506
|
+
<table>
|
2507
|
+
<tr><th>1 2 3 4</th><th>5</th></tr>
|
2508
|
+
<tr><td>a b c d</td><td>e</td></tr>
|
2509
|
+
</table>
|
2510
|
+
</div>
|
2108
2511
|
EOS
|
2109
2512
|
assert_equal expected, actual
|
2110
2513
|
end
|
@@ -2215,6 +2618,163 @@ EOS
|
|
2215
2618
|
assert_equal expected, actual
|
2216
2619
|
end
|
2217
2620
|
|
2621
|
+
def test_minicolumn_blocks
|
2622
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2623
|
+
src = <<-EOS
|
2624
|
+
//#{type}[#{type}1]{
|
2625
|
+
|
2626
|
+
//}
|
2627
|
+
|
2628
|
+
//#{type}[#{type}2]{
|
2629
|
+
//}
|
2630
|
+
EOS
|
2631
|
+
|
2632
|
+
expected = <<-EOS
|
2633
|
+
<div class="#{type}">
|
2634
|
+
<p class="caption">#{type}1</p>
|
2635
|
+
</div>
|
2636
|
+
<div class="#{type}">
|
2637
|
+
<p class="caption">#{type}2</p>
|
2638
|
+
</div>
|
2639
|
+
EOS
|
2640
|
+
assert_equal expected, compile_block(src)
|
2641
|
+
|
2642
|
+
src = <<-EOS
|
2643
|
+
//#{type}[#{type}2]{
|
2644
|
+
|
2645
|
+
//}
|
2646
|
+
|
2647
|
+
//#{type}[#{type}3]{
|
2648
|
+
|
2649
|
+
//}
|
2650
|
+
|
2651
|
+
//#{type}[#{type}4]{
|
2652
|
+
|
2653
|
+
//}
|
2654
|
+
|
2655
|
+
//#{type}[#{type}5]{
|
2656
|
+
|
2657
|
+
//}
|
2658
|
+
|
2659
|
+
//#{type}[#{type}6]{
|
2660
|
+
|
2661
|
+
//}
|
2662
|
+
EOS
|
2663
|
+
|
2664
|
+
expected = <<-EOS
|
2665
|
+
<div class="#{type}">
|
2666
|
+
<p class="caption">#{type}2</p>
|
2667
|
+
</div>
|
2668
|
+
<div class="#{type}">
|
2669
|
+
<p class="caption">#{type}3</p>
|
2670
|
+
</div>
|
2671
|
+
<div class="#{type}">
|
2672
|
+
<p class="caption">#{type}4</p>
|
2673
|
+
</div>
|
2674
|
+
<div class="#{type}">
|
2675
|
+
<p class="caption">#{type}5</p>
|
2676
|
+
</div>
|
2677
|
+
<div class="#{type}">
|
2678
|
+
<p class="caption">#{type}6</p>
|
2679
|
+
</div>
|
2680
|
+
EOS
|
2681
|
+
assert_equal expected, compile_block(src)
|
2682
|
+
|
2683
|
+
src = <<-EOS
|
2684
|
+
//#{type}{
|
2685
|
+
|
2686
|
+
* A
|
2687
|
+
|
2688
|
+
1. B
|
2689
|
+
|
2690
|
+
//}
|
2691
|
+
|
2692
|
+
//#{type}[OMITEND1]{
|
2693
|
+
|
2694
|
+
//emlist{
|
2695
|
+
LIST
|
2696
|
+
//}
|
2697
|
+
|
2698
|
+
//}
|
2699
|
+
|
2700
|
+
//#{type}[OMITEND2]{
|
2701
|
+
//}
|
2702
|
+
EOS
|
2703
|
+
|
2704
|
+
expected = <<-EOS
|
2705
|
+
<div class="#{type}">
|
2706
|
+
<ul>
|
2707
|
+
<li>A</li>
|
2708
|
+
</ul>
|
2709
|
+
<ol>
|
2710
|
+
<li>B</li>
|
2711
|
+
</ol>
|
2712
|
+
</div>
|
2713
|
+
<div class="#{type}">
|
2714
|
+
<p class="caption">OMITEND1</p>
|
2715
|
+
<div class="emlist-code">
|
2716
|
+
<pre class="emlist">LIST
|
2717
|
+
</pre>
|
2718
|
+
</div>
|
2719
|
+
</div>
|
2720
|
+
<div class="#{type}">
|
2721
|
+
<p class="caption">OMITEND2</p>
|
2722
|
+
</div>
|
2723
|
+
EOS
|
2724
|
+
assert_equal expected, compile_block(src)
|
2725
|
+
end
|
2726
|
+
end
|
2727
|
+
|
2728
|
+
def test_minicolumn_blocks_nest_error1
|
2729
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2730
|
+
@builder.doc_status.clear
|
2731
|
+
src = <<-EOS
|
2732
|
+
//#{type}{
|
2733
|
+
|
2734
|
+
//#{type}{
|
2735
|
+
//}
|
2736
|
+
|
2737
|
+
//}
|
2738
|
+
EOS
|
2739
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2740
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2741
|
+
end
|
2742
|
+
end
|
2743
|
+
|
2744
|
+
def test_minicolumn_blocks_nest_error2
|
2745
|
+
%w[note memo tip info warning important caution notice].each do |type|
|
2746
|
+
@builder.doc_status.clear
|
2747
|
+
src = <<-EOS
|
2748
|
+
//#{type}{
|
2749
|
+
|
2750
|
+
//#{type}{
|
2751
|
+
|
2752
|
+
//}
|
2753
|
+
|
2754
|
+
//}
|
2755
|
+
EOS
|
2756
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2757
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2758
|
+
end
|
2759
|
+
end
|
2760
|
+
|
2761
|
+
def test_minicolumn_blocks_nest_error3
|
2762
|
+
%w[memo tip info warning important caution notice].each do |type|
|
2763
|
+
@builder.doc_status.clear
|
2764
|
+
src = <<-EOS
|
2765
|
+
//#{type}{
|
2766
|
+
|
2767
|
+
//note{
|
2768
|
+
|
2769
|
+
//}
|
2770
|
+
|
2771
|
+
//}
|
2772
|
+
EOS
|
2773
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2774
|
+
assert_match(/minicolumn cannot be nested:/, e.message)
|
2775
|
+
end
|
2776
|
+
end
|
2777
|
+
|
2218
2778
|
def test_comment
|
2219
2779
|
actual = compile_block('//comment[コメント]')
|
2220
2780
|
assert_equal '', actual
|
@@ -2254,7 +2814,7 @@ EOB
|
|
2254
2814
|
end
|
2255
2815
|
@book.config['words_file'] = File.join(dir, 'words.csv')
|
2256
2816
|
io = StringIO.new
|
2257
|
-
@builder.instance_eval{ @logger = ReVIEW::Logger.new(io) }
|
2817
|
+
@builder.instance_eval { @logger = ReVIEW::Logger.new(io) }
|
2258
2818
|
actual = compile_block('@<w>{F} @<w>{B} @<wb>{B} @<w>{N}')
|
2259
2819
|
assert_equal %Q(<p>foo bar"\\<>_@<b>{BAZ} <b>bar"\\<>_@<b>{BAZ}</b> [missing word: N]</p>\n), actual
|
2260
2820
|
assert_match(/WARN --: :1: word not bound: N/, io.string)
|
@@ -2262,18 +2822,18 @@ EOB
|
|
2262
2822
|
end
|
2263
2823
|
|
2264
2824
|
def test_inline_unknown
|
2265
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2825
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
|
2266
2826
|
assert_equal ':1: error: unknown image: n', e.message
|
2267
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2827
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
|
2268
2828
|
assert_equal ':1: error: unknown footnote: n', e.message
|
2269
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2829
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
|
2270
2830
|
assert_equal ':1: error: unknown headline: n', e.message
|
2271
2831
|
%w[list table column].each do |name|
|
2272
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2832
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2273
2833
|
assert_equal ":1: error: unknown #{name}: n", e.message
|
2274
2834
|
end
|
2275
2835
|
%w[chap chapref title].each do |name|
|
2276
|
-
e = assert_raises(ReVIEW::ApplicationError) { compile_block
|
2836
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
|
2277
2837
|
assert_equal ':1: error: key not found: "n"', e.message
|
2278
2838
|
end
|
2279
2839
|
end
|
@@ -2303,6 +2863,20 @@ e=mc^2
|
|
2303
2863
|
//}
|
2304
2864
|
EOS
|
2305
2865
|
expected = <<-EOS
|
2866
|
+
<p><span class="eqref"><a href="./-.html#emc2">式1.1</a></span></p>
|
2867
|
+
<div id="emc2" class="caption-equation">
|
2868
|
+
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2869
|
+
<div class="equation">
|
2870
|
+
<pre>e=mc^2
|
2871
|
+
</pre>
|
2872
|
+
</div>
|
2873
|
+
</div>
|
2874
|
+
EOS
|
2875
|
+
actual = compile_block(src)
|
2876
|
+
assert_equal expected, actual
|
2877
|
+
|
2878
|
+
@config['chapterlink'] = nil
|
2879
|
+
expected = <<-EOS
|
2306
2880
|
<p><span class="eqref">式1.1</span></p>
|
2307
2881
|
<div id="emc2" class="caption-equation">
|
2308
2882
|
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
@@ -2314,5 +2888,311 @@ EOS
|
|
2314
2888
|
EOS
|
2315
2889
|
actual = compile_block(src)
|
2316
2890
|
assert_equal expected, actual
|
2891
|
+
|
2892
|
+
@config['caption_position']['equation'] = 'bottom'
|
2893
|
+
expected = <<-EOS
|
2894
|
+
<p><span class="eqref">式1.1</span></p>
|
2895
|
+
<div id="emc2" class="caption-equation">
|
2896
|
+
<div class="equation">
|
2897
|
+
<pre>e=mc^2
|
2898
|
+
</pre>
|
2899
|
+
</div>
|
2900
|
+
<p class="caption">式1.1: The Equivalence of Mass <i>and</i> Energy</p>
|
2901
|
+
</div>
|
2902
|
+
EOS
|
2903
|
+
actual = compile_block(src)
|
2904
|
+
assert_equal expected, actual
|
2905
|
+
end
|
2906
|
+
|
2907
|
+
def test_nest_error_close1
|
2908
|
+
src = <<-EOS
|
2909
|
+
//beginchild
|
2910
|
+
EOS
|
2911
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2912
|
+
assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
|
2913
|
+
end
|
2914
|
+
|
2915
|
+
def test_nest_error_close2
|
2916
|
+
src = <<-EOS
|
2917
|
+
* foo
|
2918
|
+
|
2919
|
+
//beginchild
|
2920
|
+
|
2921
|
+
1. foo
|
2922
|
+
|
2923
|
+
//beginchild
|
2924
|
+
|
2925
|
+
: foo
|
2926
|
+
|
2927
|
+
//beginchild
|
2928
|
+
EOS
|
2929
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2930
|
+
assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
|
2931
|
+
end
|
2932
|
+
|
2933
|
+
def test_nest_error_close3
|
2934
|
+
src = <<-EOS
|
2935
|
+
* foo
|
2936
|
+
|
2937
|
+
//beginchild
|
2938
|
+
|
2939
|
+
1. foo
|
2940
|
+
|
2941
|
+
//beginchild
|
2942
|
+
|
2943
|
+
: foo
|
2944
|
+
|
2945
|
+
//beginchild
|
2946
|
+
|
2947
|
+
//endchild
|
2948
|
+
EOS
|
2949
|
+
e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
|
2950
|
+
assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
|
2951
|
+
end
|
2952
|
+
|
2953
|
+
def test_nest_ul
|
2954
|
+
src = <<-EOS
|
2955
|
+
* UL1
|
2956
|
+
|
2957
|
+
//beginchild
|
2958
|
+
|
2959
|
+
1. UL1-OL1
|
2960
|
+
2. UL1-OL2
|
2961
|
+
|
2962
|
+
* UL1-UL1
|
2963
|
+
* UL1-UL2
|
2964
|
+
|
2965
|
+
: UL1-DL1
|
2966
|
+
UL1-DD1
|
2967
|
+
: UL1-DL2
|
2968
|
+
UL1-DD2
|
2969
|
+
|
2970
|
+
//endchild
|
2971
|
+
|
2972
|
+
* UL2
|
2973
|
+
|
2974
|
+
//beginchild
|
2975
|
+
|
2976
|
+
UL2-PARA
|
2977
|
+
|
2978
|
+
//endchild
|
2979
|
+
EOS
|
2980
|
+
|
2981
|
+
expected = <<-EOS
|
2982
|
+
<ul>
|
2983
|
+
<li>UL1
|
2984
|
+
<ol>
|
2985
|
+
<li>UL1-OL1</li>
|
2986
|
+
<li>UL1-OL2</li>
|
2987
|
+
</ol>
|
2988
|
+
<ul>
|
2989
|
+
<li>UL1-UL1</li>
|
2990
|
+
<li>UL1-UL2</li>
|
2991
|
+
</ul>
|
2992
|
+
<dl>
|
2993
|
+
<dt>UL1-DL1</dt>
|
2994
|
+
<dd>UL1-DD1</dd>
|
2995
|
+
<dt>UL1-DL2</dt>
|
2996
|
+
<dd>UL1-DD2</dd>
|
2997
|
+
</dl>
|
2998
|
+
</li>
|
2999
|
+
|
3000
|
+
<li>UL2
|
3001
|
+
<p>UL2-PARA</p>
|
3002
|
+
</li>
|
3003
|
+
</ul>
|
3004
|
+
EOS
|
3005
|
+
|
3006
|
+
actual = compile_block(src)
|
3007
|
+
assert_equal expected, actual
|
3008
|
+
end
|
3009
|
+
|
3010
|
+
def test_nest_ol
|
3011
|
+
src = <<-EOS
|
3012
|
+
1. OL1
|
3013
|
+
|
3014
|
+
//beginchild
|
3015
|
+
|
3016
|
+
1. OL1-OL1
|
3017
|
+
2. OL1-OL2
|
3018
|
+
|
3019
|
+
* OL1-UL1
|
3020
|
+
* OL1-UL2
|
3021
|
+
|
3022
|
+
: OL1-DL1
|
3023
|
+
OL1-DD1
|
3024
|
+
: OL1-DL2
|
3025
|
+
OL1-DD2
|
3026
|
+
|
3027
|
+
//endchild
|
3028
|
+
|
3029
|
+
2. OL2
|
3030
|
+
|
3031
|
+
//beginchild
|
3032
|
+
|
3033
|
+
OL2-PARA
|
3034
|
+
|
3035
|
+
//endchild
|
3036
|
+
EOS
|
3037
|
+
|
3038
|
+
expected = <<-EOS
|
3039
|
+
<ol>
|
3040
|
+
<li>OL1
|
3041
|
+
<ol>
|
3042
|
+
<li>OL1-OL1</li>
|
3043
|
+
<li>OL1-OL2</li>
|
3044
|
+
</ol>
|
3045
|
+
<ul>
|
3046
|
+
<li>OL1-UL1</li>
|
3047
|
+
<li>OL1-UL2</li>
|
3048
|
+
</ul>
|
3049
|
+
<dl>
|
3050
|
+
<dt>OL1-DL1</dt>
|
3051
|
+
<dd>OL1-DD1</dd>
|
3052
|
+
<dt>OL1-DL2</dt>
|
3053
|
+
<dd>OL1-DD2</dd>
|
3054
|
+
</dl>
|
3055
|
+
</li>
|
3056
|
+
|
3057
|
+
<li>OL2
|
3058
|
+
<p>OL2-PARA</p>
|
3059
|
+
</li>
|
3060
|
+
</ol>
|
3061
|
+
EOS
|
3062
|
+
|
3063
|
+
actual = compile_block(src)
|
3064
|
+
assert_equal expected, actual
|
3065
|
+
end
|
3066
|
+
|
3067
|
+
def test_nest_dl
|
3068
|
+
src = <<-EOS
|
3069
|
+
: DL1
|
3070
|
+
|
3071
|
+
//beginchild
|
3072
|
+
|
3073
|
+
1. DL1-OL1
|
3074
|
+
2. DL1-OL2
|
3075
|
+
|
3076
|
+
* DL1-UL1
|
3077
|
+
* DL1-UL2
|
3078
|
+
|
3079
|
+
: DL1-DL1
|
3080
|
+
DL1-DD1
|
3081
|
+
: DL1-DL2
|
3082
|
+
DL1-DD2
|
3083
|
+
|
3084
|
+
//endchild
|
3085
|
+
|
3086
|
+
: DL2
|
3087
|
+
DD2
|
3088
|
+
|
3089
|
+
//beginchild
|
3090
|
+
|
3091
|
+
* DD2-UL1
|
3092
|
+
* DD2-UL2
|
3093
|
+
|
3094
|
+
DD2-PARA
|
3095
|
+
|
3096
|
+
//endchild
|
3097
|
+
EOS
|
3098
|
+
|
3099
|
+
expected = <<-EOS
|
3100
|
+
<dl>
|
3101
|
+
<dt>DL1</dt>
|
3102
|
+
<dd>
|
3103
|
+
<ol>
|
3104
|
+
<li>DL1-OL1</li>
|
3105
|
+
<li>DL1-OL2</li>
|
3106
|
+
</ol>
|
3107
|
+
<ul>
|
3108
|
+
<li>DL1-UL1</li>
|
3109
|
+
<li>DL1-UL2</li>
|
3110
|
+
</ul>
|
3111
|
+
<dl>
|
3112
|
+
<dt>DL1-DL1</dt>
|
3113
|
+
<dd>DL1-DD1</dd>
|
3114
|
+
<dt>DL1-DL2</dt>
|
3115
|
+
<dd>DL1-DD2</dd>
|
3116
|
+
</dl>
|
3117
|
+
</dd>
|
3118
|
+
|
3119
|
+
<dt>DL2</dt>
|
3120
|
+
<dd>DD2
|
3121
|
+
<ul>
|
3122
|
+
<li>DD2-UL1</li>
|
3123
|
+
<li>DD2-UL2</li>
|
3124
|
+
</ul>
|
3125
|
+
<p>DD2-PARA</p>
|
3126
|
+
</dd>
|
3127
|
+
</dl>
|
3128
|
+
EOS
|
3129
|
+
|
3130
|
+
actual = compile_block(src)
|
3131
|
+
assert_equal expected, actual
|
3132
|
+
end
|
3133
|
+
|
3134
|
+
def test_nest_multi
|
3135
|
+
src = <<-EOS
|
3136
|
+
1. OL1
|
3137
|
+
|
3138
|
+
//beginchild
|
3139
|
+
|
3140
|
+
1. OL1-OL1
|
3141
|
+
|
3142
|
+
//beginchild
|
3143
|
+
|
3144
|
+
* OL1-OL1-UL1
|
3145
|
+
|
3146
|
+
OL1-OL1-PARA
|
3147
|
+
|
3148
|
+
//endchild
|
3149
|
+
|
3150
|
+
2. OL1-OL2
|
3151
|
+
|
3152
|
+
* OL1-UL1
|
3153
|
+
|
3154
|
+
//beginchild
|
3155
|
+
|
3156
|
+
: OL1-UL1-DL1
|
3157
|
+
OL1-UL1-DD1
|
3158
|
+
|
3159
|
+
OL1-UL1-PARA
|
3160
|
+
|
3161
|
+
//endchild
|
3162
|
+
|
3163
|
+
* OL1-UL2
|
3164
|
+
|
3165
|
+
//endchild
|
3166
|
+
EOS
|
3167
|
+
expected = <<-EOS
|
3168
|
+
<ol>
|
3169
|
+
<li>OL1
|
3170
|
+
<ol>
|
3171
|
+
<li>OL1-OL1
|
3172
|
+
<ul>
|
3173
|
+
<li>OL1-OL1-UL1</li>
|
3174
|
+
</ul>
|
3175
|
+
<p>OL1-OL1-PARA</p>
|
3176
|
+
</li>
|
3177
|
+
|
3178
|
+
<li>OL1-OL2</li>
|
3179
|
+
</ol>
|
3180
|
+
<ul>
|
3181
|
+
<li>OL1-UL1
|
3182
|
+
<dl>
|
3183
|
+
<dt>OL1-UL1-DL1</dt>
|
3184
|
+
<dd>OL1-UL1-DD1</dd>
|
3185
|
+
</dl>
|
3186
|
+
<p>OL1-UL1-PARA</p>
|
3187
|
+
</li>
|
3188
|
+
|
3189
|
+
<li>OL1-UL2</li>
|
3190
|
+
</ul>
|
3191
|
+
</li>
|
3192
|
+
</ol>
|
3193
|
+
EOS
|
3194
|
+
|
3195
|
+
actual = compile_block(src)
|
3196
|
+
assert_equal expected, actual
|
2317
3197
|
end
|
2318
3198
|
end
|