review-peg 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/.rubocop.yml +47 -0
- data/.rubocop_todo.yml +605 -0
- data/.travis.yml +18 -0
- data/COPYING +515 -0
- data/ChangeLog +2449 -0
- data/Dockerfile +22 -0
- data/Gemfile +6 -0
- data/README.rdoc +81 -0
- data/Rakefile +51 -0
- data/bin/review-catalog-converter-peg +129 -0
- data/bin/review-check-peg +169 -0
- data/bin/review-checkdep-peg +63 -0
- data/bin/review-compile-peg +202 -0
- data/bin/review-epubmaker-legacy-peg +1024 -0
- data/bin/review-epubmaker-peg +44 -0
- data/bin/review-index-peg +110 -0
- data/bin/review-init-peg +151 -0
- data/bin/review-pdfmaker-peg +18 -0
- data/bin/review-preproc-peg +131 -0
- data/bin/review-validate-peg +51 -0
- data/bin/review-vol-peg +100 -0
- data/debian/README.Debian +12 -0
- data/debian/README.source +5 -0
- data/debian/changelog +5 -0
- data/debian/compat +1 -0
- data/debian/control +22 -0
- data/debian/copyright +62 -0
- data/debian/docs +6 -0
- data/debian/manpage.1.ex +59 -0
- data/debian/patches/path.diff +91 -0
- data/debian/patches/series +1 -0
- data/debian/review.install +13 -0
- data/debian/review.links +4 -0
- data/debian/rules +13 -0
- data/debian/source/format +1 -0
- data/doc/NEWS.ja.md +350 -0
- data/doc/NEWS.md +354 -0
- data/doc/catalog.ja.md +53 -0
- data/doc/catalog.md +52 -0
- data/doc/format.ja.md +734 -0
- data/doc/format.md +746 -0
- data/doc/format_idg.ja.md +203 -0
- data/doc/quickstart.ja.md +222 -0
- data/doc/quickstart.md +252 -0
- data/doc/ruby-uuid/README +11 -0
- data/doc/ruby-uuid/README.ja +34 -0
- data/doc/sample.css +108 -0
- data/doc/sample.yml +238 -0
- data/lib/epubmaker.rb +24 -0
- data/lib/epubmaker/content.rb +93 -0
- data/lib/epubmaker/epubcommon.rb +424 -0
- data/lib/epubmaker/epubv2.rb +139 -0
- data/lib/epubmaker/epubv3.rb +222 -0
- data/lib/epubmaker/producer.rb +330 -0
- data/lib/lineinput.rb +107 -0
- data/lib/review.rb +3 -0
- data/lib/review/book.rb +43 -0
- data/lib/review/book/base.rb +401 -0
- data/lib/review/book/chapter.rb +100 -0
- data/lib/review/book/compilable.rb +184 -0
- data/lib/review/book/image_finder.rb +71 -0
- data/lib/review/book/index.rb +413 -0
- data/lib/review/book/page_metric.rb +47 -0
- data/lib/review/book/part.rb +54 -0
- data/lib/review/book/volume.rb +67 -0
- data/lib/review/builder.rb +452 -0
- data/lib/review/catalog.rb +52 -0
- data/lib/review/compiler.rb +5183 -0
- data/lib/review/compiler/literals_1_9.kpeg +22 -0
- data/lib/review/compiler/literals_1_9.rb +435 -0
- data/lib/review/configure.rb +64 -0
- data/lib/review/epubbuilder.rb +18 -0
- data/lib/review/epubmaker.rb +480 -0
- data/lib/review/ewbbuilder.rb +381 -0
- data/lib/review/exception.rb +21 -0
- data/lib/review/extentions.rb +4 -0
- data/lib/review/extentions/array.rb +25 -0
- data/lib/review/extentions/object.rb +9 -0
- data/lib/review/extentions/string.rb +33 -0
- data/lib/review/htmlbuilder.rb +1166 -0
- data/lib/review/htmllayout.rb +41 -0
- data/lib/review/htmltoc.rb +45 -0
- data/lib/review/htmlutils.rb +90 -0
- data/lib/review/i18n.rb +96 -0
- data/lib/review/i18n.yml +169 -0
- data/lib/review/idgxmlbuilder.rb +1233 -0
- data/lib/review/inaobuilder.rb +357 -0
- data/lib/review/latexbuilder.rb +941 -0
- data/lib/review/latexindex.rb +35 -0
- data/lib/review/latexutils.rb +95 -0
- data/lib/review/layout.tex.erb +340 -0
- data/lib/review/lineinput.rb +17 -0
- data/lib/review/location.rb +24 -0
- data/lib/review/makerhelper.rb +67 -0
- data/lib/review/markdownbuilder.rb +339 -0
- data/lib/review/node.rb +288 -0
- data/lib/review/pdfmaker.rb +332 -0
- data/lib/review/preprocessor.rb +530 -0
- data/lib/review/review.kpeg +745 -0
- data/lib/review/sec_counter.rb +69 -0
- data/lib/review/template.rb +21 -0
- data/lib/review/textbuilder.rb +17 -0
- data/lib/review/textutils.rb +16 -0
- data/lib/review/tocparser.rb +348 -0
- data/lib/review/tocprinter.rb +205 -0
- data/lib/review/topbuilder.rb +796 -0
- data/lib/review/unfold.rb +138 -0
- data/lib/review/version.rb +3 -0
- data/lib/uuid.rb +312 -0
- data/review.gemspec +32 -0
- data/templates/html/layout-html5.html.erb +17 -0
- data/templates/html/layout-xhtml1.html.erb +20 -0
- data/templates/ncx/epubv2.ncx.erb +11 -0
- data/templates/opf/epubv2.opf.erb +21 -0
- data/templates/opf/epubv3.opf.erb +18 -0
- data/templates/xml/container.xml.erb +6 -0
- data/test/CHAPS +2 -0
- data/test/assets/test.xml.erb +3 -0
- data/test/assets/test_template.tex +255 -0
- data/test/assets/test_template_backmatter.tex +32 -0
- data/test/bib.re +13 -0
- data/test/book_test_helper.rb +35 -0
- data/test/sample-book/README.md +7 -0
- data/test/sample-book/src/Rakefile +58 -0
- data/test/sample-book/src/_cover.html +3 -0
- data/test/sample-book/src/catalog.yml +10 -0
- data/test/sample-book/src/ch01.re +71 -0
- data/test/sample-book/src/ch02.re +3 -0
- data/test/sample-book/src/config.yml +186 -0
- data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
- data/test/sample-book/src/images/cover.jpg +0 -0
- data/test/sample-book/src/preface.re +15 -0
- data/test/sample-book/src/sty/jumoline.sty +310 -0
- data/test/sample-book/src/sty/reviewmacro.sty +39 -0
- data/test/sample-book/src/style.css +251 -0
- data/test/sample-book/src/vendor/jumoline/README +29 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
- data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
- data/test/test.re +43 -0
- data/test/test_book.rb +556 -0
- data/test/test_book_chapter.rb +280 -0
- data/test/test_book_part.rb +54 -0
- data/test/test_builder.rb +80 -0
- data/test/test_catalog.rb +119 -0
- data/test/test_catalog_converter_cmd.rb +73 -0
- data/test/test_compiler.rb +92 -0
- data/test/test_configure.rb +50 -0
- data/test/test_epub3maker.rb +529 -0
- data/test/test_epubmaker.rb +569 -0
- data/test/test_epubmaker_cmd.rb +40 -0
- data/test/test_helper.rb +92 -0
- data/test/test_htmlbuilder.rb +1114 -0
- data/test/test_htmltoc.rb +32 -0
- data/test/test_htmlutils.rb +50 -0
- data/test/test_i18n.rb +180 -0
- data/test/test_idgxmlbuilder.rb +608 -0
- data/test/test_image_finder.rb +82 -0
- data/test/test_inaobuilder.rb +245 -0
- data/test/test_index.rb +174 -0
- data/test/test_latexbuilder.rb +732 -0
- data/test/test_lineinput.rb +182 -0
- data/test/test_makerhelper.rb +66 -0
- data/test/test_markdownbuilder.rb +125 -0
- data/test/test_pdfmaker.rb +171 -0
- data/test/test_pdfmaker_cmd.rb +40 -0
- data/test/test_preprocessor.rb +23 -0
- data/test/test_review_ext.rb +31 -0
- data/test/test_template.rb +26 -0
- data/test/test_textutils.rb +32 -0
- data/test/test_topbuilder.rb +291 -0
- data/test/test_uuid.rb +157 -0
- metadata +357 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
require 'review/htmltoc'
|
|
5
|
+
|
|
6
|
+
class HTMLTocTest < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def teardown
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_tocfilename
|
|
15
|
+
toc = HTMLToc.new("/var/tmp")
|
|
16
|
+
assert_equal "/var/tmp/toc-html.txt", toc.tocfilename
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_encode_args
|
|
20
|
+
toc = HTMLToc.new("/var/tmp")
|
|
21
|
+
assert_equal "chaptype=pre", toc.encode_args({:chaptype => "pre"})
|
|
22
|
+
assert_equal "force_include=true,chaptype=body,properties=foo", toc.encode_args({:force_include => true, :chaptype => "body", "properties"=>"foo"})
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_decode_args
|
|
26
|
+
toc = HTMLToc.new("/var/tmp")
|
|
27
|
+
assert_equal({:chaptype => "pre"}, toc.decode_args("chaptype=pre"))
|
|
28
|
+
assert_equal({:force_include => "true", :chaptype => "body",:properties=>"foo"}, toc.decode_args("force_include=true,chaptype=body,properties=foo"))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
require 'review/htmlutils'
|
|
4
|
+
|
|
5
|
+
class HTMLUtilsTest < Test::Unit::TestCase
|
|
6
|
+
include ReVIEW::HTMLUtils
|
|
7
|
+
|
|
8
|
+
def test_escape_html
|
|
9
|
+
assert_equal '<', escape_html('<')
|
|
10
|
+
assert_equal '<<', escape_html('<<')
|
|
11
|
+
assert_equal '_<_<_', escape_html('_<_<_')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_escape_html_ex
|
|
15
|
+
keys = ESC.keys
|
|
16
|
+
ESC['.'] = 'X'
|
|
17
|
+
ESC.each_pair do |ch, ref|
|
|
18
|
+
if keys.include?(ch)
|
|
19
|
+
assert_equal ref, escape_html(ch)
|
|
20
|
+
else
|
|
21
|
+
assert_equal ch, escape_html(ch)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_strip_html
|
|
27
|
+
assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_escape_comment
|
|
31
|
+
assert_equal '<', escape_comment('<')
|
|
32
|
+
assert_equal '>', escape_comment('>')
|
|
33
|
+
assert_equal '&', escape_comment('&')
|
|
34
|
+
assert_equal '-', escape_comment('-')
|
|
35
|
+
assert_equal '--', escape_comment('--')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_normalize_id
|
|
39
|
+
assert_equal 'abcxyz', normalize_id('abcxyz')
|
|
40
|
+
assert_equal 'ABCXYZ', normalize_id('ABCXYZ')
|
|
41
|
+
assert_equal 'abc0123', normalize_id('abc0123')
|
|
42
|
+
assert_equal 'a-b-c_x.y.z', normalize_id('a-b-c_x.y.z')
|
|
43
|
+
assert_equal 'id_a_3Ab_3Ac', normalize_id('a:b:c')
|
|
44
|
+
assert_equal 'id_0123a-b-c_x.y.z', normalize_id('0123a-b-c_x.y.z')
|
|
45
|
+
assert_equal 'id_.', normalize_id('.')
|
|
46
|
+
assert_equal 'id__E3_81_82', normalize_id('あ')
|
|
47
|
+
assert_equal 'id_-___3B', normalize_id(' _;')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
data/test/test_i18n.rb
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
require 'review/i18n'
|
|
4
|
+
|
|
5
|
+
require 'review/compiler'
|
|
6
|
+
require 'review/book'
|
|
7
|
+
require 'review/htmlbuilder'
|
|
8
|
+
require 'tmpdir'
|
|
9
|
+
|
|
10
|
+
class I18nTest < Test::Unit::TestCase
|
|
11
|
+
include ReVIEW
|
|
12
|
+
|
|
13
|
+
if RUBY_VERSION !~ /^1.8/ ## to avoid Travis error :-(
|
|
14
|
+
def test_load_locale_yml
|
|
15
|
+
Dir.mktmpdir do |dir|
|
|
16
|
+
Dir.chdir(dir) do
|
|
17
|
+
file = File.join(dir, "locale.yml")
|
|
18
|
+
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
|
|
19
|
+
I18n.setup
|
|
20
|
+
assert_equal "bar", I18n.t("foo")
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_load_locale_yaml
|
|
26
|
+
Dir.mktmpdir do |dir|
|
|
27
|
+
Dir.chdir(dir) do
|
|
28
|
+
file = File.join(dir, "locale.yaml")
|
|
29
|
+
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
|
|
30
|
+
I18n.setup
|
|
31
|
+
assert_equal "bar", I18n.t("foo")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_load_foo_yaml
|
|
37
|
+
Dir.mktmpdir do |dir|
|
|
38
|
+
Dir.chdir(dir) do
|
|
39
|
+
file = File.join(dir, "foo.yml")
|
|
40
|
+
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
|
|
41
|
+
I18n.setup("ja","foo.yml")
|
|
42
|
+
assert_equal "bar", I18n.t("foo")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_update_foo_yaml
|
|
48
|
+
Dir.mktmpdir do |dir|
|
|
49
|
+
Dir.chdir(dir) do
|
|
50
|
+
file = File.join(dir, "foo.yml")
|
|
51
|
+
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
|
|
52
|
+
i18n = ReVIEW::I18n.new("ja")
|
|
53
|
+
i18n.update_localefile(File.join(Dir.pwd, "foo.yml"))
|
|
54
|
+
assert_equal "bar", i18n.t("foo")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_update_foo_yaml_i18nclass
|
|
60
|
+
Dir.mktmpdir do |dir|
|
|
61
|
+
Dir.chdir(dir) do
|
|
62
|
+
file = File.join(dir, "foo.yml")
|
|
63
|
+
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
|
|
64
|
+
I18n.setup("ja", "foo.yml")
|
|
65
|
+
assert_equal "bar", I18n.t("foo")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_load_locale_yml_i18n
|
|
71
|
+
Dir.mktmpdir do |dir|
|
|
72
|
+
Dir.chdir(dir) do
|
|
73
|
+
file = File.join(dir, "locale.yml")
|
|
74
|
+
File.open(file, "w"){|f| f.write("ja:\n foo: \"bar\"\nen:\n foo: \"buz\"\n")}
|
|
75
|
+
I18n.setup
|
|
76
|
+
assert_equal "bar", I18n.t("foo")
|
|
77
|
+
assert_equal "図", I18n.t("image")
|
|
78
|
+
I18n.setup("en")
|
|
79
|
+
assert_equal "buz", I18n.t("foo")
|
|
80
|
+
assert_equal "Figure ", I18n.t("image")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_load_locale_invalid_yml
|
|
86
|
+
Dir.mktmpdir do |dir|
|
|
87
|
+
Dir.chdir(dir) do
|
|
88
|
+
file = File.join(dir, "locale.yml")
|
|
89
|
+
File.open(file, "w"){|f| f.write("local: ja\nfoo: \"bar\"\n")}
|
|
90
|
+
assert_raises(ReVIEW::KeyError) do
|
|
91
|
+
I18n.setup
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def test_ja
|
|
99
|
+
I18n.setup("ja")
|
|
100
|
+
assert_equal "図", I18n.t("image")
|
|
101
|
+
assert_equal "表", I18n.t("table")
|
|
102
|
+
assert_equal "第1章", I18n.t("chapter", 1)
|
|
103
|
+
assert_equal "etc", I18n.t("etc")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_ja_with_user_i18n
|
|
107
|
+
i18n = I18n.new("ja")
|
|
108
|
+
i18n.update({"image" => "ず"}, "ja")
|
|
109
|
+
assert_equal "ず", i18n.t("image")
|
|
110
|
+
assert_equal "表", i18n.t("table")
|
|
111
|
+
assert_equal "第1章", i18n.t("chapter", 1)
|
|
112
|
+
assert_equal "etc", i18n.t("etc")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_en
|
|
116
|
+
I18n.setup "en"
|
|
117
|
+
assert_equal "Figure ", I18n.t("image")
|
|
118
|
+
assert_equal "Table ", I18n.t("table")
|
|
119
|
+
assert_equal "Chapter 1", I18n.t("chapter", 1)
|
|
120
|
+
assert_equal "etc", I18n.t("etc")
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_nil
|
|
124
|
+
I18n.setup "nil"
|
|
125
|
+
assert_equal "image", I18n.t("image")
|
|
126
|
+
assert_equal "table", I18n.t("table")
|
|
127
|
+
assert_equal "etc", I18n.t("etc")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def test_htmlbuilder
|
|
131
|
+
_setup_htmlbuilder
|
|
132
|
+
actual = compile_block("={test} this is test.\n")
|
|
133
|
+
assert_equal %Q|<h1 id="test"><a id="h1"></a><span class="secno">Chapter 1. </span>this is test.</h1>\n|, actual
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def _setup_htmlbuilder
|
|
137
|
+
I18n.setup "en"
|
|
138
|
+
@builder = HTMLBuilder.new()
|
|
139
|
+
@config = {
|
|
140
|
+
"secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
|
|
141
|
+
"stylesheet" => nil, # for HTMLBuilder
|
|
142
|
+
"ext" => ".re"
|
|
143
|
+
}
|
|
144
|
+
@book = Book::Base.new(".")
|
|
145
|
+
@book.config = @config
|
|
146
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
|
147
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
|
148
|
+
location = Location.new(nil, nil)
|
|
149
|
+
@builder.bind(@compiler, @chapter, location)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def test_update
|
|
153
|
+
i18n = ReVIEW::I18n.new("ja")
|
|
154
|
+
hash = {"foo"=>"bar"}
|
|
155
|
+
i18n.update(hash)
|
|
156
|
+
assert_equal "bar", i18n.t("foo")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def test_update_newlocale
|
|
160
|
+
i18n = ReVIEW::I18n.new("ja")
|
|
161
|
+
hash = {"foo"=>"bar"}
|
|
162
|
+
i18n.update(hash, "abc")
|
|
163
|
+
i18n.locale = "abc"
|
|
164
|
+
assert_equal "bar", i18n.t("foo")
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def test_i18n_error
|
|
168
|
+
I18n.setup
|
|
169
|
+
assert_raises NotImplementedError do
|
|
170
|
+
I18n.i18n("ja")
|
|
171
|
+
end
|
|
172
|
+
assert_raises NotImplementedError do
|
|
173
|
+
I18n.i18n("ja",{})
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def teardown
|
|
178
|
+
I18n.setup "ja"
|
|
179
|
+
end
|
|
180
|
+
end
|
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
require 'review/compiler'
|
|
5
|
+
require 'review/book'
|
|
6
|
+
require 'review/idgxmlbuilder'
|
|
7
|
+
require 'review/i18n'
|
|
8
|
+
|
|
9
|
+
class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
10
|
+
include ReVIEW
|
|
11
|
+
|
|
12
|
+
def setup
|
|
13
|
+
@builder = IDGXMLBuilder.new()
|
|
14
|
+
@config = ReVIEW::Configure.values
|
|
15
|
+
@config.merge!({
|
|
16
|
+
"secnolevel" => 2,
|
|
17
|
+
"nolf" => true,
|
|
18
|
+
"tableopt" => "10"
|
|
19
|
+
})
|
|
20
|
+
@book = Book::Base.new(nil)
|
|
21
|
+
@book.config = @config
|
|
22
|
+
@compiler = ReVIEW::Compiler.new(@builder)
|
|
23
|
+
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
|
24
|
+
location = Location.new(nil, nil)
|
|
25
|
+
@builder.bind(@compiler, @chapter, location)
|
|
26
|
+
I18n.setup("ja")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_headline_level1
|
|
30
|
+
actual = compile_block("={test} this is test.\n")
|
|
31
|
+
assert_equal %Q|<title id="test" aid:pstyle="h1">第1章 this is test.</title><?dtp level="1" section="第1章 this is test."?>|, actual
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_headline_level1_without_secno
|
|
35
|
+
@config["secnolevel"] = 0
|
|
36
|
+
actual = compile_block("={test} this is test.\n")
|
|
37
|
+
assert_equal %Q|<title id="test" aid:pstyle="h1">this is test.</title><?dtp level="1" section="this is test."?>|, actual
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_headline_level2
|
|
41
|
+
actual = compile_block("=={test} this is test.\n")
|
|
42
|
+
assert_equal %Q|<title id="test" aid:pstyle="h2">1.1 this is test.</title><?dtp level="2" section="1.1 this is test."?>|, actual
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_headline_level3
|
|
46
|
+
actual = compile_block("==={test} this is test.\n")
|
|
47
|
+
assert_equal %Q|<title id="test" aid:pstyle="h3">this is test.</title><?dtp level="3" section="this is test."?>|, actual
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_headline_level3_with_secno
|
|
52
|
+
@config["secnolevel"] = 3
|
|
53
|
+
actual = compile_block("==={test} this is test.\n")
|
|
54
|
+
assert_equal %Q|<title id="test" aid:pstyle="h3">1.0.1 this is test.</title><?dtp level="3" section="1.0.1 this is test."?>|, actual
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_label
|
|
58
|
+
actual = compile_block("//label[label_test]\n")
|
|
59
|
+
assert_equal %Q|<label id='label_test' />|, actual
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_inline_ref
|
|
63
|
+
actual = compile_inline("@<ref>{外部参照<>&}")
|
|
64
|
+
assert_equal %Q|<ref idref='外部参照<>&'>「●● 外部参照<>&」</ref>|, actual
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_href
|
|
68
|
+
actual = compile_inline("@<href>{http://github.com,GitHub}")
|
|
69
|
+
assert_equal %Q|<a linkurl='http://github.com'>GitHub</a>|, actual
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_href_without_label
|
|
73
|
+
actual = compile_inline("@<href>{http://github.com}")
|
|
74
|
+
assert_equal %Q|<a linkurl='http://github.com'>http://github.com</a>|, actual
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_inline_href
|
|
78
|
+
actual = compile_inline("@<href>{http://github.com, Git\\,Hub}")
|
|
79
|
+
assert_equal %Q|<a linkurl='http://github.com'>Git,Hub</a>|, actual
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_inline_raw
|
|
83
|
+
actual = compile_inline("@<raw>{@<tt>{inline\}}")
|
|
84
|
+
assert_equal %Q|@<tt>{inline}|, actual
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_inline_in_table
|
|
88
|
+
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
89
|
+
assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i><>&</td></tbody></table>|, actual
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def test_inline_in_table_without_header
|
|
93
|
+
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
94
|
+
assert_equal %Q|<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="2"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>1</b></td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>2</i></td><td xyh="1,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><b>3</b></td><td xyh="2,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.2450142450142"><i>4</i><>&</td></tbody></table>|, actual
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_inline_in_table_without_cellwidth
|
|
98
|
+
@config["tableopt"] = nil
|
|
99
|
+
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
100
|
+
assert_equal %Q|<table><tbody><tr type="header"><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i><>&</tr></tbody></table>|, actual
|
|
101
|
+
@config["tableopt"] = 10
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_inline_in_table_without_header_and_cellwidth
|
|
105
|
+
@config["tableopt"] = nil
|
|
106
|
+
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
107
|
+
assert_equal %Q|<table><tbody><tr><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i><>&</tr></tbody></table>|, actual
|
|
108
|
+
@config["tableopt"] = 10
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_inline_br
|
|
112
|
+
actual = compile_inline("@<br>{}")
|
|
113
|
+
assert_equal %Q|\n|, actual
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_inline_uchar
|
|
117
|
+
actual = compile_inline("test @<uchar>{2460} test2")
|
|
118
|
+
assert_equal %Q|test ① test2|, actual
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_inline_ruby
|
|
122
|
+
actual = compile_inline("@<ruby>{coffin, bed}")
|
|
123
|
+
assert_equal %Q|<GroupRuby><aid:ruby xmlns:aid="http://ns.adobe.com/AdobeInDesign/3.0/"><aid:rb>coffin</aid:rb><aid:rt>bed</aid:rt></aid:ruby></GroupRuby>|, actual
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_inline_kw
|
|
127
|
+
actual = compile_inline("@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}")
|
|
128
|
+
assert_equal %Q|<keyword>ISO(International Organization for Standardization)</keyword><index value="ISO" /><index value="International Organization for Standardization" /> <keyword>Ruby<></keyword><index value="Ruby<>" />|, actual
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def test_inline_maru
|
|
132
|
+
actual = compile_inline("@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}")
|
|
133
|
+
assert_equal %Q|①⑳Ⓐⓩ|, actual
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_inline_ttb
|
|
137
|
+
actual = compile_inline("@<ttb>{test * <>\"}")
|
|
138
|
+
assert_equal %Q|<tt style='bold'>test * <>"</tt>|, actual
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_inline_ttbold
|
|
142
|
+
actual = compile_inline("@<ttbold>{test * <>\"}")
|
|
143
|
+
assert_equal %Q|<tt style='bold'>test * <>"</tt>|, actual
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_inline_balloon
|
|
147
|
+
actual = compile_inline("@<balloon>{@maru[1]test}")
|
|
148
|
+
assert_equal %Q|<balloon>①test</balloon>|, actual
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def test_inline_m
|
|
152
|
+
actual = compile_inline("@<m>{\\sin} @<m>{\\frac{1\\}{2\\}}")
|
|
153
|
+
assert_equal %Q|<replace idref="texinline-1"><pre>\\sin</pre></replace> <replace idref="texinline-2"><pre>\\frac{1}{2}</pre></replace>|, actual
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_paragraph
|
|
157
|
+
actual = compile_block("foo\nbar\n")
|
|
158
|
+
assert_equal %Q|<p>foobar</p>|, actual
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def test_tabbed_paragraph
|
|
162
|
+
actual = compile_block("\tfoo\nbar\n")
|
|
163
|
+
assert_equal %Q|<p inlist="1">foobar</p>|, actual
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def test_quote
|
|
167
|
+
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
|
168
|
+
assert_equal %Q|<quote><p>foobar</p><p>buz</p></quote>|, actual
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_quote_deprecated
|
|
172
|
+
@book.config["deprecated-blocklines"] = true
|
|
173
|
+
actual = compile_block("//quote{\nfoo\n\nbuz\n//}\n")
|
|
174
|
+
@book.config["deprecated-blocklines"] = nil
|
|
175
|
+
assert_equal %Q|<quote>foo\n\nbuz</quote>|, actual
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
## XXX block content should be escaped.
|
|
179
|
+
def test_note
|
|
180
|
+
actual = compile_block("//note[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
181
|
+
assert_equal %Q|<note><title aid:pstyle='note-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></note>|, actual
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
## XXX block content should be escaped.
|
|
185
|
+
def test_memo
|
|
186
|
+
actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
187
|
+
assert_equal %Q|<memo><title aid:pstyle='memo-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></memo>|, actual
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def test_term
|
|
191
|
+
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
192
|
+
assert_equal %Q|<term><p>test1test1.5</p><p>test<i>2</i></p></term>|, actual
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def test_term_deprecated
|
|
196
|
+
@book.config["deprecated-blocklines"] = true
|
|
197
|
+
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
198
|
+
@book.config["deprecated-blocklines"] = nil
|
|
199
|
+
assert_equal %Q|<term>test1test1.5\n\ntest<i>2</i></term>|, actual
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def test_notice
|
|
203
|
+
actual = compile_block("//notice[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
204
|
+
assert_equal %Q|<notice-t><title aid:pstyle='notice-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></notice-t>|, actual
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def test_notice_without_caption
|
|
208
|
+
actual = compile_block("//notice{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
209
|
+
assert_equal %Q|<notice><p>test1test1.5</p><p>test<i>2</i></p></notice>|, actual
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def test_point
|
|
213
|
+
actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
214
|
+
assert_equal %Q|<point-t><title aid:pstyle='point-title'>this is <b>test</b><&>_</title><p>test1test1.5</p><p>test<i>2</i></p></point-t>|, actual
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def test_point_without_caption
|
|
218
|
+
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
219
|
+
assert_equal %Q|<point><p>test1test1.5</p><p>test<i>2</i></p></point>|, actual
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def test_emlist
|
|
223
|
+
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
224
|
+
assert_equal %Q|<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>|, actual
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def test_emlist_listinfo
|
|
228
|
+
@config["listinfo"] = true
|
|
229
|
+
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
230
|
+
assert_equal %Q|<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></pre></list>|, actual
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def test_emlist_with_tab
|
|
234
|
+
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
|
235
|
+
assert_equal %Q|<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1\n test1.5\n\n test<i>2</i>\n</pre></list>|, actual
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_emlist_with_4tab
|
|
239
|
+
@config["tabwidth"] = 4
|
|
240
|
+
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
|
241
|
+
assert_equal %Q|<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b><&>_</caption><pre> test1\n test1.5\n\n test<i>2</i>\n</pre></list>|, actual
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def test_list
|
|
245
|
+
def @chapter.list(id)
|
|
246
|
+
Book::ListIndex::Item.new("samplelist",1)
|
|
247
|
+
end
|
|
248
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
249
|
+
assert_equal %Q|<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></codelist>|, actual
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def test_list_listinfo
|
|
253
|
+
def @chapter.list(id)
|
|
254
|
+
Book::ListIndex::Item.new("samplelist",1)
|
|
255
|
+
end
|
|
256
|
+
@config["listinfo"] = true
|
|
257
|
+
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
258
|
+
assert_equal %Q|<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></pre></codelist>|, actual
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def test_insn
|
|
262
|
+
@config["listinfo"] = true
|
|
263
|
+
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
264
|
+
@config["listinfo"] = nil
|
|
265
|
+
assert_equal %Q|<insn><floattitle type="insn">this is <b>test</b><&>_</floattitle><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></insn>|, actual
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def test_box
|
|
269
|
+
@config["listinfo"] = true
|
|
270
|
+
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
271
|
+
@config["listinfo"] = nil
|
|
272
|
+
assert_equal %Q|<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption><listinfo line="1" begin="1">test1\n</listinfo><listinfo line="2">test1.5\n</listinfo><listinfo line="3">\n</listinfo><listinfo line="4" end="4">test<i>2</i>\n</listinfo></box>|, actual
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def test_flushright
|
|
276
|
+
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
|
277
|
+
assert_equal %Q|<p align='right'>foobar</p><p align='right'>buz</p>|, actual
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def test_centering
|
|
281
|
+
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
|
282
|
+
assert_equal %Q|<p align='center'>foobar</p><p align='center'>buz</p>|, actual
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def test_noindent
|
|
286
|
+
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
287
|
+
assert_equal %Q|<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>|, actual
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def test_image
|
|
291
|
+
def @chapter.image(id)
|
|
292
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
293
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
294
|
+
item
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
|
298
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>|, actual
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def test_image_with_metric
|
|
302
|
+
def @chapter.image(id)
|
|
303
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
304
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
305
|
+
item
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
|
309
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>|, actual
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def test_image_with_metric2
|
|
313
|
+
def @chapter.image(id)
|
|
314
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
315
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
316
|
+
item
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
actual = compile_block("//image[sampleimg][sample photo][scale=1.2, html::class=sample, latex::ignore=params, idgxml::ostyle=object]{\n//}\n")
|
|
320
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>図1.1 sample photo</caption></img>|, actual
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def test_indepimage
|
|
324
|
+
def @chapter.image(id)
|
|
325
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
326
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
327
|
+
item
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
|
331
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>|, actual
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def test_indepimage_without_caption
|
|
335
|
+
def @chapter.image(id)
|
|
336
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
337
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
338
|
+
item
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
actual = compile_block("//indepimage[sampleimg]\n")
|
|
342
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" /></img>|, actual
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
def test_indepimage_with_metric
|
|
346
|
+
def @chapter.image(id)
|
|
347
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
348
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
349
|
+
item
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
|
353
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>|, actual
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def test_indepimage_with_metric2
|
|
357
|
+
def @chapter.image(id)
|
|
358
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
359
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
360
|
+
item
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\", latex::ignore=params, idgxml::ostyle=\"object\"]\n")
|
|
364
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>sample photo</caption></img>|, actual
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def test_indepimage_without_caption_but_with_metric
|
|
368
|
+
def @chapter.image(id)
|
|
369
|
+
item = Book::ImageIndex::Item.new("sampleimg",1)
|
|
370
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
371
|
+
item
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
|
375
|
+
assert_equal %Q|<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /></img>|, actual
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
def column_helper(review)
|
|
379
|
+
compile_block(review)
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
def test_column_1
|
|
383
|
+
review =<<-EOS
|
|
384
|
+
===[column] prev column
|
|
385
|
+
|
|
386
|
+
inside prev column
|
|
387
|
+
|
|
388
|
+
===[column] test
|
|
389
|
+
|
|
390
|
+
inside column
|
|
391
|
+
|
|
392
|
+
===[/column]
|
|
393
|
+
EOS
|
|
394
|
+
expected =<<-EOS.chomp
|
|
395
|
+
<column id="column-1"><title aid:pstyle="column-title">prev column</title><p>inside prev column</p></column><column id="column-2"><title aid:pstyle="column-title">test</title><p>inside column</p></column>
|
|
396
|
+
EOS
|
|
397
|
+
assert_equal expected, column_helper(review)
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
def test_column_2
|
|
401
|
+
review =<<-EOS
|
|
402
|
+
===[column] test
|
|
403
|
+
|
|
404
|
+
inside column
|
|
405
|
+
|
|
406
|
+
=== next level
|
|
407
|
+
EOS
|
|
408
|
+
expected =<<-EOS.chomp
|
|
409
|
+
<column id="column-1"><title aid:pstyle="column-title">test</title><p>inside column</p></column><title aid:pstyle=\"h3\">next level</title><?dtp level="3" section="next level"?>
|
|
410
|
+
EOS
|
|
411
|
+
|
|
412
|
+
assert_equal expected, column_helper(review)
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
def test_column_3
|
|
416
|
+
review =<<-EOS
|
|
417
|
+
===[column] test
|
|
418
|
+
|
|
419
|
+
inside column
|
|
420
|
+
|
|
421
|
+
===[/column_dummy]
|
|
422
|
+
EOS
|
|
423
|
+
assert_raise(ReVIEW::CompileError) do
|
|
424
|
+
column_helper(review)
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def test_ul
|
|
429
|
+
src =<<-EOS
|
|
430
|
+
* AAA
|
|
431
|
+
* BBB
|
|
432
|
+
EOS
|
|
433
|
+
|
|
434
|
+
expected =<<-EOS.chomp
|
|
435
|
+
<ul><li aid:pstyle="ul-item">AAA</li><li aid:pstyle="ul-item">BBB</li></ul>
|
|
436
|
+
EOS
|
|
437
|
+
actual = compile_block(src)
|
|
438
|
+
assert_equal expected, actual
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
def test_ul_cont
|
|
442
|
+
src =<<-EOS
|
|
443
|
+
* AAA
|
|
444
|
+
-AA
|
|
445
|
+
* BBB
|
|
446
|
+
-BB
|
|
447
|
+
EOS
|
|
448
|
+
|
|
449
|
+
expected =<<-EOS.chomp
|
|
450
|
+
<ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
|
|
451
|
+
EOS
|
|
452
|
+
actual = compile_block(src)
|
|
453
|
+
assert_equal expected, actual
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
def test_ul_nest1
|
|
457
|
+
src =<<-EOS
|
|
458
|
+
* AAA
|
|
459
|
+
** AA
|
|
460
|
+
EOS
|
|
461
|
+
|
|
462
|
+
expected =<<-EOS.chomp
|
|
463
|
+
<ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li></ul>
|
|
464
|
+
EOS
|
|
465
|
+
actual = compile_block(src)
|
|
466
|
+
assert_equal expected, actual
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def test_ul_nest2
|
|
470
|
+
src =<<-EOS
|
|
471
|
+
* AAA
|
|
472
|
+
** AA
|
|
473
|
+
* BBB
|
|
474
|
+
** BB
|
|
475
|
+
EOS
|
|
476
|
+
|
|
477
|
+
expected =<<-EOS.chomp
|
|
478
|
+
<ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li><li aid:pstyle="ul-item">BBB<ul2><li aid:pstyle="ul-item">BB</li></ul2></li></ul>
|
|
479
|
+
EOS
|
|
480
|
+
actual = compile_block(src)
|
|
481
|
+
assert_equal expected, actual
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def test_ul_nest3
|
|
485
|
+
src =<<-EOS
|
|
486
|
+
** AAA
|
|
487
|
+
* AA
|
|
488
|
+
* BBB
|
|
489
|
+
** BB
|
|
490
|
+
EOS
|
|
491
|
+
|
|
492
|
+
expected =<<-EOS.chomp
|
|
493
|
+
<ul><li aid:pstyle="ul-item"><ul2><li aid:pstyle="ul-item">AAA</li></ul2></li><li aid:pstyle="ul-item">AA</li><li aid:pstyle="ul-item">BBB<ul2><li aid:pstyle="ul-item">BB</li></ul2></li></ul>
|
|
494
|
+
EOS
|
|
495
|
+
actual = compile_block(src)
|
|
496
|
+
assert_equal expected, actual
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
def test_ul_nest4
|
|
500
|
+
src =<<-EOS
|
|
501
|
+
* A
|
|
502
|
+
** B
|
|
503
|
+
** C
|
|
504
|
+
*** D
|
|
505
|
+
** E
|
|
506
|
+
* F
|
|
507
|
+
** G
|
|
508
|
+
EOS
|
|
509
|
+
|
|
510
|
+
expected =<<-EOS.chomp
|
|
511
|
+
<ul><li aid:pstyle="ul-item">A<ul2><li aid:pstyle="ul-item">B</li><li aid:pstyle="ul-item">C<ul3><li aid:pstyle="ul-item">D</li></ul3></li><li aid:pstyle="ul-item">E</li></ul2></li><li aid:pstyle="ul-item">F<ul2><li aid:pstyle="ul-item">G</li></ul2></li></ul>
|
|
512
|
+
EOS
|
|
513
|
+
actual = compile_block(src)
|
|
514
|
+
assert_equal expected, actual
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
def test_ol
|
|
518
|
+
src =<<-EOS
|
|
519
|
+
3. AAA
|
|
520
|
+
3. BBB
|
|
521
|
+
EOS
|
|
522
|
+
|
|
523
|
+
expected =<<-EOS.chomp
|
|
524
|
+
<ol><li aid:pstyle="ol-item" olnum="1" num="3">AAA</li><li aid:pstyle="ol-item" olnum="2" num="3">BBB</li></ol>
|
|
525
|
+
EOS
|
|
526
|
+
actual = compile_block(src)
|
|
527
|
+
assert_equal expected, actual
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
def test_inline_raw0
|
|
531
|
+
assert_equal "normal", compile_inline("@<raw>{normal}")
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
def test_inline_raw1
|
|
535
|
+
assert_equal "body", compile_inline("@<raw>{|idgxml|body}")
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
def test_inline_raw2
|
|
539
|
+
assert_equal "body", compile_inline("@<raw>{|idgxml, latex|body}")
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
def test_inline_raw3
|
|
543
|
+
assert_equal "", compile_inline("@<raw>{|latex, html|body}")
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
def test_inline_raw4
|
|
547
|
+
assert_equal "|idgxml body", compile_inline("@<raw>{|idgxml body}")
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
def test_inline_raw5
|
|
551
|
+
assert_equal "nor\nmal", compile_inline("@<raw>{|idgxml|nor\\nmal}")
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
def test_inline_imgref
|
|
555
|
+
def @chapter.image(id)
|
|
556
|
+
item = Book::ImageIndex::Item.new("sampleimg", 1, 'sample photo')
|
|
557
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
558
|
+
item
|
|
559
|
+
end
|
|
560
|
+
|
|
561
|
+
actual = compile_block "@<imgref>{sampleimg}\n"
|
|
562
|
+
expected = "<p><span type='image'>図1.1「sample photo」</span></p>"
|
|
563
|
+
assert_equal expected, actual
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
def test_inline_imgref2
|
|
567
|
+
def @chapter.image(id)
|
|
568
|
+
item = Book::NumberlessImageIndex::Item.new("sampleimg", 1)
|
|
569
|
+
item.instance_eval{@path="./images/chap1-sampleimg.png"}
|
|
570
|
+
item
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
actual = compile_block "@<imgref>{sampleimg}\n"
|
|
574
|
+
expected = "<p><span type='image'>図1.1</span></p>"
|
|
575
|
+
assert_equal expected, actual
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def test_block_raw0
|
|
580
|
+
actual = compile_block("//raw[<>!\"\\n& ]\n")
|
|
581
|
+
expected = %Q(<>!\"\n& )
|
|
582
|
+
assert_equal expected, actual
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
def test_block_raw1
|
|
586
|
+
actual = compile_block("//raw[|idgxml|<>!\"\\n& ]\n")
|
|
587
|
+
expected = %Q(<>!\"\n& )
|
|
588
|
+
assert_equal expected.chomp, actual
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
def test_block_raw2
|
|
592
|
+
actual = compile_block("//raw[|idgxml, latex|<>!\"\\n& ]\n")
|
|
593
|
+
expected = %Q(<>!\"\n& )
|
|
594
|
+
assert_equal expected.chomp, actual
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
def test_block_raw3
|
|
598
|
+
actual = compile_block("//raw[|latex, html|<>!\"\\n& ]\n")
|
|
599
|
+
expected = %Q()
|
|
600
|
+
assert_equal expected.chomp, actual
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
def test_block_raw4
|
|
604
|
+
actual = compile_block("//raw[|idgxml <>!\"\\n& ]\n")
|
|
605
|
+
expected = %Q(|idgxml <>!\"\n& )
|
|
606
|
+
assert_equal expected.chomp, actual
|
|
607
|
+
end
|
|
608
|
+
end
|