review 2.3.0 → 2.4.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 +4 -4
- data/.rubocop.yml +90 -66
- data/.travis.yml +1 -1
- data/Gemfile +0 -1
- data/NEWS.ja.md +82 -0
- data/NEWS.md +83 -0
- data/README.md +5 -3
- data/Rakefile +8 -8
- data/bin/review +1 -5
- data/bin/review-catalog-converter +22 -27
- data/bin/review-check +36 -43
- data/bin/review-checkdep +10 -15
- data/bin/review-compile +37 -55
- data/bin/review-epubmaker +4 -5
- data/bin/review-index +21 -29
- data/bin/review-init +26 -37
- data/bin/review-pdfmaker +0 -2
- data/bin/review-preproc +25 -45
- data/bin/review-validate +19 -18
- data/bin/review-vol +15 -27
- data/doc/config.yml.sample +5 -2
- data/doc/format.ja.md +20 -1
- data/doc/format.md +21 -5
- data/doc/images/review-generate.png +0 -0
- data/lib/epubmaker.rb +1 -3
- data/lib/epubmaker/content.rb +24 -27
- data/lib/epubmaker/epubcommon.rb +135 -148
- data/lib/epubmaker/epubv2.rb +39 -46
- data/lib/epubmaker/epubv3.rb +93 -103
- data/lib/epubmaker/producer.rb +138 -151
- data/lib/epubmaker/zip_exporter.rb +21 -26
- data/lib/review/book.rb +3 -6
- data/lib/review/book/base.rb +78 -103
- data/lib/review/book/chapter.rb +36 -40
- data/lib/review/book/compilable.rb +28 -31
- data/lib/review/book/image_finder.rb +6 -13
- data/lib/review/book/index.rb +100 -121
- data/lib/review/book/page_metric.rb +2 -7
- data/lib/review/book/part.rb +18 -20
- data/lib/review/book/volume.rb +9 -13
- data/lib/review/builder.rb +81 -116
- data/lib/review/catalog.rb +15 -19
- data/lib/review/compiler.rb +64 -83
- data/lib/review/configure.rb +87 -97
- data/lib/review/converter.rb +2 -7
- data/lib/review/epubbuilder.rb +1 -3
- data/lib/review/epubmaker.rb +213 -205
- data/lib/review/exception.rb +2 -4
- data/lib/review/extentions.rb +0 -1
- data/lib/review/extentions/hash.rb +2 -2
- data/lib/review/extentions/string.rb +5 -30
- data/lib/review/htmlbuilder.rb +320 -375
- data/lib/review/htmltoc.rb +4 -7
- data/lib/review/htmlutils.rb +29 -32
- data/lib/review/i18n.rb +33 -44
- data/lib/review/i18n.yml +3 -3
- data/lib/review/idgxmlbuilder.rb +309 -345
- data/lib/review/latexbuilder.rb +175 -212
- data/lib/review/latexindex.rb +2 -8
- data/lib/review/latexutils.rb +33 -43
- data/lib/review/lineinput.rb +1 -1
- data/lib/review/logger.rb +21 -0
- data/lib/review/makerhelper.rb +1 -4
- data/lib/review/markdownbuilder.rb +44 -53
- data/lib/review/md2inaobuilder.rb +6 -12
- data/lib/review/pdfmaker.rb +143 -173
- data/lib/review/preprocessor.rb +64 -101
- data/lib/review/rstbuilder.rb +126 -158
- data/lib/review/sec_counter.rb +18 -34
- data/lib/review/template.rb +4 -5
- data/lib/review/textbuilder.rb +2 -3
- data/lib/review/textutils.rb +7 -13
- data/lib/review/tocparser.rb +31 -56
- data/lib/review/tocprinter.rb +26 -52
- data/lib/review/topbuilder.rb +219 -247
- data/lib/review/unfold.rb +15 -24
- data/lib/review/version.rb +1 -1
- data/lib/review/webmaker.rb +75 -99
- data/lib/review/webtocprinter.rb +15 -20
- data/lib/review/yamlloader.rb +13 -15
- data/review.gemspec +20 -22
- data/templates/latex/layout.tex.erb +2 -2
- data/templates/opf/epubv2.opf.erb +7 -7
- data/templates/opf/epubv3.opf.erb +7 -7
- data/templates/web/html/layout-html5.html.erb +2 -2
- data/test/assets/black.eps +280 -0
- data/test/assets/fit.png +0 -0
- data/test/assets/large.gif +0 -0
- data/test/assets/large.jpg +0 -0
- data/test/assets/large.png +0 -0
- data/test/assets/large.svg +65 -0
- data/test/assets/test_template.tex +1 -1
- data/test/book_test_helper.rb +2 -2
- data/test/run_test.rb +4 -4
- data/test/sample-book/src/Rakefile +21 -22
- data/test/syntax-book/Gemfile +4 -0
- data/test/syntax-book/Rakefile +72 -0
- data/test/syntax-book/appA.re +22 -0
- data/test/syntax-book/bib.re +6 -0
- data/test/syntax-book/catalog.yml +15 -0
- data/test/syntax-book/ch01.re +136 -0
- data/test/syntax-book/ch02.re +351 -0
- data/test/syntax-book/ch03.re +82 -0
- data/test/syntax-book/config.yml +35 -0
- data/test/syntax-book/images/ball.png +0 -0
- data/test/syntax-book/images/cover.jpg +0 -0
- data/test/syntax-book/images/fractal.png +0 -0
- data/test/syntax-book/images/img3-1.png +0 -0
- data/test/syntax-book/images/inlineicon.jpg +0 -0
- data/test/syntax-book/images/logic.png +0 -0
- data/test/syntax-book/images/logic2.png +0 -0
- data/test/syntax-book/images/puzzle.jpg +0 -0
- data/test/syntax-book/images/table.jpg +0 -0
- data/test/syntax-book/part2.re +6 -0
- data/test/syntax-book/pre01.re +26 -0
- data/test/syntax-book/review-ext.rb +14 -0
- data/test/syntax-book/sty/jumoline.sty +310 -0
- data/test/syntax-book/sty/reviewmacro.sty +39 -0
- data/test/syntax-book/style.css +494 -0
- data/test/syntax-book/syntax.dic +2 -0
- data/test/test_book.rb +106 -111
- data/test/test_book_chapter.rb +21 -22
- data/test/test_book_part.rb +3 -5
- data/test/test_builder.rb +11 -22
- data/test/test_catalog.rb +17 -18
- data/test/test_catalog_converter_cmd.rb +5 -5
- data/test/test_compiler.rb +18 -16
- data/test/test_configure.rb +35 -38
- data/test/test_converter.rb +3 -4
- data/test/test_epub3maker.rb +136 -117
- data/test/test_epubmaker.rb +107 -114
- data/test/test_epubmaker_cmd.rb +2 -4
- data/test/test_extentions_hash.rb +32 -33
- data/test/test_helper.rb +9 -11
- data/test/test_htmlbuilder.rb +454 -420
- data/test/test_htmltoc.rb +8 -12
- data/test/test_htmlutils.rb +0 -2
- data/test/test_i18n.rb +159 -150
- data/test/test_idgxmlbuilder.rb +190 -197
- data/test/test_image_finder.rb +21 -22
- data/test/test_index.rb +24 -29
- data/test/test_latexbuilder.rb +274 -264
- data/test/test_lineinput.rb +7 -10
- data/test/test_location.rb +7 -7
- data/test/test_makerhelper.rb +13 -25
- data/test/test_markdownbuilder.rb +23 -26
- data/test/test_md2inaobuilder.rb +8 -11
- data/test/test_pdfmaker.rb +114 -123
- data/test/test_pdfmaker_cmd.rb +1 -3
- data/test/test_review_ext.rb +3 -5
- data/test/test_rstbuilder.rb +92 -97
- data/test/test_template.rb +3 -7
- data/test/test_textutils.rb +27 -27
- data/test/test_tocparser.rb +2 -2
- data/test/test_topbuilder.rb +98 -103
- data/test/test_webtocprinter.rb +5 -6
- data/test/test_yamlloader.rb +42 -42
- data/test/test_zip_exporter.rb +12 -18
- metadata +86 -9
- data/lib/review/ewbbuilder.rb +0 -382
data/test/test_idgxmlbuilder.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
1
|
require 'test_helper'
|
|
4
2
|
require 'review/compiler'
|
|
5
3
|
require 'review/book'
|
|
@@ -10,202 +8,199 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
|
10
8
|
include ReVIEW
|
|
11
9
|
|
|
12
10
|
def setup
|
|
13
|
-
@builder = IDGXMLBuilder.new
|
|
11
|
+
@builder = IDGXMLBuilder.new
|
|
14
12
|
@config = ReVIEW::Configure.values
|
|
15
|
-
@config
|
|
16
|
-
|
|
17
|
-
"tableopt" => "10"
|
|
18
|
-
})
|
|
13
|
+
@config['secnolevel'] = 2
|
|
14
|
+
@config['tableopt'] = '10'
|
|
19
15
|
@book = Book::Base.new(nil)
|
|
20
16
|
@book.config = @config
|
|
21
17
|
@compiler = ReVIEW::Compiler.new(@builder)
|
|
22
18
|
@chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
|
|
23
19
|
location = Location.new(nil, nil)
|
|
24
20
|
@builder.bind(@compiler, @chapter, location)
|
|
25
|
-
I18n.setup(
|
|
21
|
+
I18n.setup('ja')
|
|
26
22
|
end
|
|
27
23
|
|
|
28
24
|
def test_headline_level1
|
|
29
25
|
actual = compile_block("={test} this is test.\n")
|
|
30
|
-
assert_equal %Q
|
|
26
|
+
assert_equal %Q(<title id="test" aid:pstyle="h1">第1章 this is test.</title><?dtp level="1" section="第1章 this is test."?>), actual
|
|
31
27
|
end
|
|
32
28
|
|
|
33
29
|
def test_headline_level1_without_secno
|
|
34
|
-
@config[
|
|
30
|
+
@config['secnolevel'] = 0
|
|
35
31
|
actual = compile_block("={test} this is test.\n")
|
|
36
|
-
assert_equal %Q
|
|
32
|
+
assert_equal %Q(<title id="test" aid:pstyle="h1">this is test.</title><?dtp level="1" section="this is test."?>), actual
|
|
37
33
|
end
|
|
38
34
|
|
|
39
35
|
def test_headline_level2
|
|
40
36
|
actual = compile_block("=={test} this is test.\n")
|
|
41
|
-
assert_equal %Q
|
|
37
|
+
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
|
|
42
38
|
end
|
|
43
39
|
|
|
44
40
|
def test_headline_level3
|
|
45
41
|
actual = compile_block("==={test} this is test.\n")
|
|
46
|
-
assert_equal %Q
|
|
42
|
+
assert_equal %Q(<title id="test" aid:pstyle="h3">this is test.</title><?dtp level="3" section="this is test."?>), actual
|
|
47
43
|
end
|
|
48
44
|
|
|
49
45
|
def test_headline_level3_with_secno
|
|
50
|
-
@config[
|
|
46
|
+
@config['secnolevel'] = 3
|
|
51
47
|
actual = compile_block("==={test} this is test.\n")
|
|
52
|
-
assert_equal %Q
|
|
48
|
+
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
|
|
53
49
|
end
|
|
54
50
|
|
|
55
51
|
def test_label
|
|
56
52
|
actual = compile_block("//label[label_test]\n")
|
|
57
|
-
assert_equal %Q
|
|
53
|
+
assert_equal %Q(<label id='label_test' />), actual
|
|
58
54
|
end
|
|
59
55
|
|
|
60
56
|
def test_inline_ref
|
|
61
|
-
actual = compile_inline(
|
|
62
|
-
assert_equal %Q
|
|
57
|
+
actual = compile_inline('@<ref>{外部参照<>&}')
|
|
58
|
+
assert_equal %Q(<ref idref='外部参照<>&'>「●● 外部参照<>&」</ref>), actual
|
|
63
59
|
end
|
|
64
60
|
|
|
65
61
|
def test_href
|
|
66
|
-
actual = compile_inline(
|
|
67
|
-
assert_equal %Q
|
|
62
|
+
actual = compile_inline('@<href>{http://github.com,GitHub}')
|
|
63
|
+
assert_equal %Q(<a linkurl='http://github.com'>GitHub</a>), actual
|
|
68
64
|
end
|
|
69
65
|
|
|
70
66
|
def test_href_without_label
|
|
71
|
-
actual = compile_inline(
|
|
72
|
-
assert_equal %Q
|
|
67
|
+
actual = compile_inline('@<href>{http://github.com}')
|
|
68
|
+
assert_equal %Q(<a linkurl='http://github.com'>http://github.com</a>), actual
|
|
73
69
|
end
|
|
74
70
|
|
|
75
71
|
def test_inline_href
|
|
76
|
-
actual = compile_inline(
|
|
77
|
-
assert_equal %Q
|
|
72
|
+
actual = compile_inline('@<href>{http://github.com, Git\\,Hub}')
|
|
73
|
+
assert_equal %Q(<a linkurl='http://github.com'>Git,Hub</a>), actual
|
|
78
74
|
end
|
|
79
75
|
|
|
80
76
|
def test_inline_raw
|
|
81
|
-
actual = compile_inline(
|
|
82
|
-
assert_equal %Q
|
|
77
|
+
actual = compile_inline('@<raw>{@<tt>{inline\\}}')
|
|
78
|
+
assert_equal %Q(@<tt>{inline}), actual
|
|
83
79
|
end
|
|
84
80
|
|
|
85
81
|
def test_inline_in_table
|
|
86
82
|
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
87
|
-
assert_equal %Q
|
|
83
|
+
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.172"><b>1</b></td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>2</i></td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><b>3</b></td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>4</i><>&</td></tbody></table>), actual
|
|
88
84
|
end
|
|
89
85
|
|
|
90
86
|
def test_inline_in_table_without_header
|
|
91
87
|
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
92
|
-
assert_equal %Q
|
|
88
|
+
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.172"><b>1</b></td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>2</i></td><td xyh="1,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><b>3</b></td><td xyh="2,2,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172"><i>4</i><>&</td></tbody></table>), actual
|
|
93
89
|
end
|
|
94
90
|
|
|
95
91
|
def test_inline_in_table_without_cellwidth
|
|
96
|
-
@config[
|
|
92
|
+
@config['tableopt'] = nil
|
|
97
93
|
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
98
|
-
assert_equal %Q
|
|
94
|
+
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
|
|
99
95
|
end
|
|
100
96
|
|
|
101
97
|
def test_inline_in_table_without_header_and_cellwidth
|
|
102
|
-
@config[
|
|
98
|
+
@config['tableopt'] = nil
|
|
103
99
|
actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
|
|
104
|
-
assert_equal %Q
|
|
100
|
+
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
|
|
105
101
|
end
|
|
106
102
|
|
|
107
103
|
def test_customize_cellwidth
|
|
108
104
|
actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
|
|
109
|
-
assert_equal %Q
|
|
105
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="8.503">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">C</td></tbody></table>), actual
|
|
110
106
|
|
|
111
107
|
actual = compile_block("//tsize[2,3]\n//table{\nA\tB\tC\n//}\n")
|
|
112
|
-
assert_equal %Q
|
|
108
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="8.503">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">C</td></tbody></table>), actual
|
|
113
109
|
|
|
114
110
|
actual = compile_block("//tsize[2]\n//table{\nA\tB\tC\n//}\n")
|
|
115
|
-
assert_equal %Q
|
|
111
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">C</td></tbody></table>), actual
|
|
116
112
|
|
|
117
113
|
actual = compile_block("//tsize[|idgxml|2]\n//table{\nA\tB\tC\n//}\n")
|
|
118
|
-
assert_equal %Q
|
|
114
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">C</td></tbody></table>), actual
|
|
119
115
|
|
|
120
116
|
actual = compile_block("//tsize[|idgxml,html|2]\n//table{\nA\tB\tC\n//}\n")
|
|
121
|
-
assert_equal %Q
|
|
117
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="11.338">C</td></tbody></table>), actual
|
|
122
118
|
|
|
123
119
|
actual = compile_block("//tsize[|html|2]\n//table{\nA\tB\tC\n//}\n")
|
|
124
|
-
assert_equal %Q
|
|
120
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="3"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">A</td><td xyh="2,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">B</td><td xyh="3,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">C</td></tbody></table>), actual
|
|
125
121
|
end
|
|
126
122
|
|
|
127
123
|
def test_customize_mmtopt
|
|
128
124
|
actual = compile_block("//table{\nA\n//}\n")
|
|
129
|
-
assert_equal %Q
|
|
125
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>), actual
|
|
130
126
|
|
|
131
|
-
@config[
|
|
127
|
+
@config['pt_to_mm_unit'] = 0.3514
|
|
132
128
|
actual = compile_block("//table{\nA\n//}\n")
|
|
133
|
-
assert_equal %Q
|
|
129
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.458">A</td></tbody></table>), actual
|
|
134
130
|
|
|
135
|
-
@config[
|
|
131
|
+
@config['pt_to_mm_unit'] = '0.3514'
|
|
136
132
|
actual = compile_block("//table{\nA\n//}\n")
|
|
137
|
-
assert_equal %Q
|
|
133
|
+
assert_equal %Q(<table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.458">A</td></tbody></table>), actual
|
|
138
134
|
end
|
|
139
135
|
|
|
140
136
|
def test_emtable
|
|
141
137
|
actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
|
|
142
|
-
assert_equal %Q
|
|
143
|
-
actual
|
|
138
|
+
assert_equal %Q(<table><caption>foo</caption><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table><table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="1" aid:tcols="1"><td xyh="1,1,0" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="28.345">A</td></tbody></table>), actual
|
|
144
139
|
end
|
|
145
140
|
|
|
146
141
|
def test_inline_br
|
|
147
|
-
actual = compile_inline(
|
|
148
|
-
assert_equal
|
|
142
|
+
actual = compile_inline('@<br>{}')
|
|
143
|
+
assert_equal "\n", actual
|
|
149
144
|
end
|
|
150
145
|
|
|
151
146
|
def test_inline_uchar
|
|
152
|
-
actual = compile_inline(
|
|
153
|
-
assert_equal
|
|
147
|
+
actual = compile_inline('test @<uchar>{2460} test2')
|
|
148
|
+
assert_equal 'test ① test2', actual
|
|
154
149
|
end
|
|
155
150
|
|
|
156
151
|
def test_inline_ruby
|
|
157
|
-
actual = compile_inline(
|
|
158
|
-
assert_equal %Q
|
|
152
|
+
actual = compile_inline('@<ruby>{coffin, bed}')
|
|
153
|
+
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
|
|
159
154
|
end
|
|
160
155
|
|
|
161
156
|
def test_inline_kw
|
|
162
|
-
actual = compile_inline(
|
|
163
|
-
assert_equal %Q
|
|
157
|
+
actual = compile_inline('@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}')
|
|
158
|
+
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
|
|
164
159
|
end
|
|
165
160
|
|
|
166
161
|
def test_inline_maru
|
|
167
|
-
actual = compile_inline(
|
|
168
|
-
assert_equal
|
|
162
|
+
actual = compile_inline('@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}')
|
|
163
|
+
assert_equal '①⑳Ⓐⓩ', actual
|
|
169
164
|
end
|
|
170
165
|
|
|
171
166
|
def test_inline_ttb
|
|
172
|
-
actual = compile_inline(
|
|
173
|
-
assert_equal %Q
|
|
167
|
+
actual = compile_inline(%Q(@<ttb>{test * <>"}))
|
|
168
|
+
assert_equal %Q(<tt style='bold'>test * <>"</tt>), actual
|
|
174
169
|
end
|
|
175
170
|
|
|
176
171
|
def test_inline_ttbold
|
|
177
|
-
actual = compile_inline(
|
|
178
|
-
assert_equal %Q
|
|
172
|
+
actual = compile_inline(%Q(@<ttbold>{test * <>"}))
|
|
173
|
+
assert_equal %Q(<tt style='bold'>test * <>"</tt>), actual
|
|
179
174
|
end
|
|
180
175
|
|
|
181
176
|
def test_inline_balloon
|
|
182
|
-
actual = compile_inline(
|
|
183
|
-
assert_equal
|
|
177
|
+
actual = compile_inline('@<balloon>{@maru[1]test}')
|
|
178
|
+
assert_equal '<balloon>①test</balloon>', actual
|
|
184
179
|
end
|
|
185
180
|
|
|
186
181
|
def test_inline_m
|
|
187
|
-
actual = compile_inline(
|
|
188
|
-
assert_equal %Q
|
|
182
|
+
actual = compile_inline('@<m>{\\sin} @<m>{\\frac{1\\}{2\\}}')
|
|
183
|
+
assert_equal %Q(<replace idref="texinline-1"><pre>\\sin</pre></replace> <replace idref="texinline-2"><pre>\\frac{1}{2}</pre></replace>), actual
|
|
189
184
|
end
|
|
190
185
|
|
|
191
186
|
def test_dlist_beforeulol
|
|
192
187
|
actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
|
|
193
|
-
assert_equal %Q
|
|
188
|
+
assert_equal %Q(<dl><dt>foo</dt><dd>foo.</dd></dl><p>para</p><dl><dt>foo</dt><dd>foo.</dd></dl><ol><li aid:pstyle="ol-item" olnum="1" num="1">bar</li></ol><dl><dt>foo</dt><dd>foo.</dd></dl><ul><li aid:pstyle="ul-item">bar</li></ul>), actual
|
|
194
189
|
end
|
|
195
190
|
|
|
196
191
|
def test_paragraph
|
|
197
192
|
actual = compile_block("foo\nbar\n")
|
|
198
|
-
assert_equal
|
|
193
|
+
assert_equal '<p>foobar</p>', actual
|
|
199
194
|
end
|
|
200
195
|
|
|
201
196
|
def test_tabbed_paragraph
|
|
202
197
|
actual = compile_block("\tfoo\nbar\n")
|
|
203
|
-
assert_equal %Q
|
|
198
|
+
assert_equal %Q(<p inlist="1">foobar</p>), actual
|
|
204
199
|
end
|
|
205
200
|
|
|
206
201
|
def test_quote
|
|
207
202
|
actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
|
|
208
|
-
assert_equal
|
|
203
|
+
assert_equal '<quote><p>foobar</p><p>buz</p></quote>', actual
|
|
209
204
|
end
|
|
210
205
|
|
|
211
206
|
def test_major_blocks
|
|
@@ -245,200 +240,198 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
|
245
240
|
|
|
246
241
|
def test_term
|
|
247
242
|
actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
248
|
-
assert_equal
|
|
243
|
+
assert_equal '<term><p>test1test1.5</p><p>test<i>2</i></p></term>', actual
|
|
249
244
|
end
|
|
250
245
|
|
|
251
246
|
def test_point
|
|
252
247
|
actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
253
|
-
assert_equal %Q
|
|
248
|
+
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
|
|
254
249
|
end
|
|
255
250
|
|
|
256
251
|
def test_point_without_caption
|
|
257
252
|
actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
258
|
-
assert_equal
|
|
253
|
+
assert_equal '<point><p>test1test1.5</p><p>test<i>2</i></p></point>', actual
|
|
259
254
|
end
|
|
260
255
|
|
|
261
256
|
def test_emlist
|
|
262
257
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
263
|
-
assert_equal %Q
|
|
258
|
+
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
|
|
264
259
|
end
|
|
265
260
|
|
|
266
261
|
def test_emlistnum
|
|
267
262
|
actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
268
|
-
assert_equal %Q
|
|
263
|
+
assert_equal %Q(<list type='emlistnum'><caption aid:pstyle='emlistnum-title'>this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre></list>), actual
|
|
269
264
|
end
|
|
270
265
|
|
|
271
266
|
def test_emlist_listinfo
|
|
272
|
-
@config[
|
|
267
|
+
@config['listinfo'] = true
|
|
273
268
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
274
|
-
assert_equal %Q
|
|
269
|
+
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
|
|
275
270
|
end
|
|
276
271
|
|
|
277
272
|
def test_emlist_with_tab
|
|
278
273
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
|
279
|
-
assert_equal %Q
|
|
274
|
+
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
|
|
280
275
|
end
|
|
281
276
|
|
|
282
277
|
def test_emlist_with_4tab
|
|
283
|
-
@config[
|
|
278
|
+
@config['tabwidth'] = 4
|
|
284
279
|
actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
|
|
285
|
-
assert_equal %Q
|
|
280
|
+
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
|
|
286
281
|
end
|
|
287
282
|
|
|
288
283
|
def test_list
|
|
289
|
-
def @chapter.list(
|
|
290
|
-
Book::ListIndex::Item.new(
|
|
284
|
+
def @chapter.list(_id)
|
|
285
|
+
Book::ListIndex::Item.new('samplelist', 1)
|
|
291
286
|
end
|
|
292
287
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
293
|
-
assert_equal %Q
|
|
288
|
+
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
|
|
294
289
|
end
|
|
295
290
|
|
|
296
291
|
def test_listnum
|
|
297
|
-
def @chapter.list(
|
|
298
|
-
Book::ListIndex::Item.new(
|
|
292
|
+
def @chapter.list(_id)
|
|
293
|
+
Book::ListIndex::Item.new('samplelist', 1)
|
|
299
294
|
end
|
|
300
295
|
actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
301
|
-
assert_equal %Q
|
|
296
|
+
assert_equal %Q(<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'> 1: </span>test1\n<span type='lineno'> 2: </span>test1.5\n<span type='lineno'> 3: </span>\n<span type='lineno'> 4: </span>test<i>2</i>\n</pre></codelist>), actual
|
|
302
297
|
end
|
|
303
298
|
|
|
304
299
|
def test_listnum_linenum
|
|
305
|
-
def @chapter.list(
|
|
306
|
-
Book::ListIndex::Item.new(
|
|
300
|
+
def @chapter.list(_id)
|
|
301
|
+
Book::ListIndex::Item.new('samplelist', 1)
|
|
307
302
|
end
|
|
308
303
|
actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
309
|
-
assert_equal %Q
|
|
304
|
+
assert_equal %Q(<codelist><caption>リスト1.1 this is <b>test</b><&>_</caption><pre><span type='lineno'>100: </span>test1\n<span type='lineno'>101: </span>test1.5\n<span type='lineno'>102: </span>\n<span type='lineno'>103: </span>test<i>2</i>\n</pre></codelist>), actual
|
|
310
305
|
end
|
|
311
306
|
|
|
312
307
|
def test_list_listinfo
|
|
313
|
-
def @chapter.list(
|
|
314
|
-
Book::ListIndex::Item.new(
|
|
308
|
+
def @chapter.list(_id)
|
|
309
|
+
Book::ListIndex::Item.new('samplelist', 1)
|
|
315
310
|
end
|
|
316
|
-
@config[
|
|
311
|
+
@config['listinfo'] = true
|
|
317
312
|
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
318
|
-
assert_equal %Q
|
|
313
|
+
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
|
|
319
314
|
end
|
|
320
315
|
|
|
321
316
|
def test_insn
|
|
322
|
-
@config[
|
|
317
|
+
@config['listinfo'] = true
|
|
323
318
|
actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
324
|
-
|
|
325
|
-
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
|
|
319
|
+
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
|
|
326
320
|
end
|
|
327
321
|
|
|
328
322
|
def test_box
|
|
329
|
-
@config[
|
|
323
|
+
@config['listinfo'] = true
|
|
330
324
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
331
|
-
|
|
332
|
-
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
|
|
325
|
+
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
|
|
333
326
|
end
|
|
334
327
|
|
|
335
328
|
def test_box_non_listinfo
|
|
336
|
-
@config[
|
|
329
|
+
@config['listinfo'] = nil
|
|
337
330
|
actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
|
|
338
|
-
assert_equal %Q
|
|
331
|
+
assert_equal %Q(<box><caption aid:pstyle="box-title">this is <b>test</b><&>_</caption>test1\ntest1.5\n\ntest<i>2</i>\n</box>), actual
|
|
339
332
|
end
|
|
340
333
|
|
|
341
334
|
def test_flushright
|
|
342
335
|
actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
|
|
343
|
-
assert_equal %Q
|
|
336
|
+
assert_equal %Q(<p align='right'>foobar</p><p align='right'>buz</p>), actual
|
|
344
337
|
end
|
|
345
338
|
|
|
346
339
|
def test_centering
|
|
347
340
|
actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
|
|
348
|
-
assert_equal %Q
|
|
341
|
+
assert_equal %Q(<p align='center'>foobar</p><p align='center'>buz</p>), actual
|
|
349
342
|
end
|
|
350
343
|
|
|
351
344
|
def test_noindent
|
|
352
345
|
actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
|
|
353
|
-
assert_equal %Q
|
|
346
|
+
assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>), actual
|
|
354
347
|
end
|
|
355
348
|
|
|
356
349
|
def test_image
|
|
357
|
-
def @chapter.image(
|
|
358
|
-
item = Book::ImageIndex::Item.new(
|
|
359
|
-
item.instance_eval{@path=
|
|
350
|
+
def @chapter.image(_id)
|
|
351
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
352
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
360
353
|
item
|
|
361
354
|
end
|
|
362
355
|
|
|
363
356
|
actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
|
|
364
|
-
assert_equal %Q
|
|
357
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>), actual
|
|
365
358
|
end
|
|
366
359
|
|
|
367
360
|
def test_image_with_metric
|
|
368
|
-
def @chapter.image(
|
|
369
|
-
item = Book::ImageIndex::Item.new(
|
|
370
|
-
item.instance_eval{@path=
|
|
361
|
+
def @chapter.image(_id)
|
|
362
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
363
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
371
364
|
item
|
|
372
365
|
end
|
|
373
366
|
|
|
374
367
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
|
|
375
|
-
assert_equal %Q
|
|
368
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>), actual
|
|
376
369
|
end
|
|
377
370
|
|
|
378
371
|
def test_image_with_metric2
|
|
379
|
-
def @chapter.image(
|
|
380
|
-
item = Book::ImageIndex::Item.new(
|
|
381
|
-
item.instance_eval{@path=
|
|
372
|
+
def @chapter.image(_id)
|
|
373
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
374
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
382
375
|
item
|
|
383
376
|
end
|
|
384
377
|
|
|
385
378
|
actual = compile_block("//image[sampleimg][sample photo][scale=1.2, html::class=sample, latex::ignore=params, idgxml::ostyle=object]{\n//}\n")
|
|
386
|
-
assert_equal %Q
|
|
379
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>図1.1 sample photo</caption></img>), actual
|
|
387
380
|
end
|
|
388
381
|
|
|
389
382
|
def test_indepimage
|
|
390
|
-
def @chapter.image(
|
|
391
|
-
item = Book::ImageIndex::Item.new(
|
|
392
|
-
item.instance_eval{@path=
|
|
383
|
+
def @chapter.image(_id)
|
|
384
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
385
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
393
386
|
item
|
|
394
387
|
end
|
|
395
388
|
|
|
396
389
|
actual = compile_block("//indepimage[sampleimg][sample photo]\n")
|
|
397
|
-
assert_equal %Q
|
|
390
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>), actual
|
|
398
391
|
end
|
|
399
392
|
|
|
400
393
|
def test_indepimage_without_caption
|
|
401
|
-
def @chapter.image(
|
|
402
|
-
item = Book::ImageIndex::Item.new(
|
|
403
|
-
item.instance_eval{@path=
|
|
394
|
+
def @chapter.image(_id)
|
|
395
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
396
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
404
397
|
item
|
|
405
398
|
end
|
|
406
399
|
|
|
407
400
|
actual = compile_block("//indepimage[sampleimg]\n")
|
|
408
|
-
assert_equal %Q
|
|
401
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /></img>), actual
|
|
409
402
|
end
|
|
410
403
|
|
|
411
404
|
def test_indepimage_with_metric
|
|
412
|
-
def @chapter.image(
|
|
413
|
-
item = Book::ImageIndex::Item.new(
|
|
414
|
-
item.instance_eval{@path=
|
|
405
|
+
def @chapter.image(_id)
|
|
406
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
407
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
415
408
|
item
|
|
416
409
|
end
|
|
417
410
|
|
|
418
411
|
actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
|
|
419
|
-
assert_equal %Q
|
|
412
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>), actual
|
|
420
413
|
end
|
|
421
414
|
|
|
422
415
|
def test_indepimage_with_metric2
|
|
423
|
-
def @chapter.image(
|
|
424
|
-
item = Book::ImageIndex::Item.new(
|
|
425
|
-
item.instance_eval{@path=
|
|
416
|
+
def @chapter.image(_id)
|
|
417
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
418
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
426
419
|
item
|
|
427
420
|
end
|
|
428
421
|
|
|
429
|
-
actual = compile_block(
|
|
430
|
-
assert_equal %Q
|
|
422
|
+
actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample", latex::ignore=params, idgxml::ostyle="object"]\n))
|
|
423
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>sample photo</caption></img>), actual
|
|
431
424
|
end
|
|
432
425
|
|
|
433
426
|
def test_indepimage_without_caption_but_with_metric
|
|
434
|
-
def @chapter.image(
|
|
435
|
-
item = Book::ImageIndex::Item.new(
|
|
436
|
-
item.instance_eval{@path=
|
|
427
|
+
def @chapter.image(_id)
|
|
428
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1)
|
|
429
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
437
430
|
item
|
|
438
431
|
end
|
|
439
432
|
|
|
440
433
|
actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
|
|
441
|
-
assert_equal %Q
|
|
434
|
+
assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /></img>), actual
|
|
442
435
|
end
|
|
443
436
|
|
|
444
437
|
def column_helper(review)
|
|
@@ -446,7 +439,7 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
|
|
|
446
439
|
end
|
|
447
440
|
|
|
448
441
|
def test_column_1
|
|
449
|
-
review
|
|
442
|
+
review = <<-EOS
|
|
450
443
|
===[column] prev column
|
|
451
444
|
|
|
452
445
|
inside prev column
|
|
@@ -457,42 +450,42 @@ inside column
|
|
|
457
450
|
|
|
458
451
|
===[/column]
|
|
459
452
|
EOS
|
|
460
|
-
expected
|
|
453
|
+
expected = <<-EOS.chomp
|
|
461
454
|
<column id="column-1"><title aid:pstyle="column-title">prev column</title><?dtp level="9" section="prev column"?><p>inside prev column</p></column><column id="column-2"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column>
|
|
462
455
|
EOS
|
|
463
456
|
assert_equal expected, column_helper(review)
|
|
464
457
|
end
|
|
465
458
|
|
|
466
459
|
def test_column_2
|
|
467
|
-
review
|
|
460
|
+
review = <<-EOS
|
|
468
461
|
===[column] test
|
|
469
462
|
|
|
470
463
|
inside column
|
|
471
464
|
|
|
472
465
|
=== next level
|
|
473
466
|
EOS
|
|
474
|
-
expected
|
|
475
|
-
<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle
|
|
467
|
+
expected = <<-EOS.chomp
|
|
468
|
+
<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle="h3">next level</title><?dtp level="3" section="next level"?>
|
|
476
469
|
EOS
|
|
477
470
|
|
|
478
471
|
assert_equal expected, column_helper(review)
|
|
479
472
|
end
|
|
480
473
|
|
|
481
474
|
def test_column_3
|
|
482
|
-
review
|
|
475
|
+
review = <<-EOS
|
|
483
476
|
===[column] test
|
|
484
477
|
|
|
485
478
|
inside column
|
|
486
479
|
|
|
487
480
|
===[/column_dummy]
|
|
488
481
|
EOS
|
|
489
|
-
assert_raise(ReVIEW::
|
|
482
|
+
assert_raise(ReVIEW::ApplicationError) do
|
|
490
483
|
column_helper(review)
|
|
491
484
|
end
|
|
492
485
|
end
|
|
493
486
|
|
|
494
487
|
def test_column_ref
|
|
495
|
-
review
|
|
488
|
+
review = <<-EOS
|
|
496
489
|
===[column]{foo} test
|
|
497
490
|
|
|
498
491
|
inside column
|
|
@@ -501,7 +494,7 @@ inside column
|
|
|
501
494
|
|
|
502
495
|
this is @<column>{foo}.
|
|
503
496
|
EOS
|
|
504
|
-
expected
|
|
497
|
+
expected = <<-EOS.chomp
|
|
505
498
|
<column id="column-1"><title aid:pstyle="column-title">test</title><?dtp level="9" section="test"?><p>inside column</p></column><title aid:pstyle="h3">next level</title><?dtp level="3" section="next level"?><p>this is コラム「test」.</p>
|
|
506
499
|
EOS
|
|
507
500
|
|
|
@@ -510,22 +503,22 @@ EOS
|
|
|
510
503
|
|
|
511
504
|
def test_column_in_aother_chapter_ref
|
|
512
505
|
def @chapter.column_index
|
|
513
|
-
items = [Book::ColumnIndex::Item.new(
|
|
506
|
+
items = [Book::ColumnIndex::Item.new('chap1|column', 1, 'column_cap')]
|
|
514
507
|
Book::ColumnIndex.new(items)
|
|
515
508
|
end
|
|
516
509
|
|
|
517
|
-
actual = compile_inline(
|
|
518
|
-
expected =
|
|
510
|
+
actual = compile_inline('test @<column>{chap1|column} test2')
|
|
511
|
+
expected = 'test コラム「column_cap」 test2'
|
|
519
512
|
assert_equal expected, actual
|
|
520
513
|
end
|
|
521
514
|
|
|
522
515
|
def test_ul
|
|
523
|
-
src
|
|
516
|
+
src = <<-EOS
|
|
524
517
|
* AAA
|
|
525
518
|
* BBB
|
|
526
519
|
EOS
|
|
527
520
|
|
|
528
|
-
expected
|
|
521
|
+
expected = <<-EOS.chomp
|
|
529
522
|
<ul><li aid:pstyle="ul-item">AAA</li><li aid:pstyle="ul-item">BBB</li></ul>
|
|
530
523
|
EOS
|
|
531
524
|
actual = compile_block(src)
|
|
@@ -533,14 +526,14 @@ EOS
|
|
|
533
526
|
end
|
|
534
527
|
|
|
535
528
|
def test_ul_cont
|
|
536
|
-
src
|
|
529
|
+
src = <<-EOS
|
|
537
530
|
* AAA
|
|
538
531
|
-AA
|
|
539
532
|
* BBB
|
|
540
533
|
-BB
|
|
541
534
|
EOS
|
|
542
535
|
|
|
543
|
-
expected
|
|
536
|
+
expected = <<-EOS.chomp
|
|
544
537
|
<ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
|
|
545
538
|
EOS
|
|
546
539
|
actual = compile_block(src)
|
|
@@ -548,12 +541,12 @@ EOS
|
|
|
548
541
|
end
|
|
549
542
|
|
|
550
543
|
def test_ul_nest1
|
|
551
|
-
src
|
|
544
|
+
src = <<-EOS
|
|
552
545
|
* AAA
|
|
553
546
|
** AA
|
|
554
547
|
EOS
|
|
555
548
|
|
|
556
|
-
expected
|
|
549
|
+
expected = <<-EOS.chomp
|
|
557
550
|
<ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li></ul>
|
|
558
551
|
EOS
|
|
559
552
|
actual = compile_block(src)
|
|
@@ -561,14 +554,14 @@ EOS
|
|
|
561
554
|
end
|
|
562
555
|
|
|
563
556
|
def test_ul_nest2
|
|
564
|
-
src
|
|
557
|
+
src = <<-EOS
|
|
565
558
|
* AAA
|
|
566
559
|
** AA
|
|
567
560
|
* BBB
|
|
568
561
|
** BB
|
|
569
562
|
EOS
|
|
570
563
|
|
|
571
|
-
expected
|
|
564
|
+
expected = <<-EOS.chomp
|
|
572
565
|
<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>
|
|
573
566
|
EOS
|
|
574
567
|
actual = compile_block(src)
|
|
@@ -576,14 +569,14 @@ EOS
|
|
|
576
569
|
end
|
|
577
570
|
|
|
578
571
|
def test_ul_nest3
|
|
579
|
-
src
|
|
572
|
+
src = <<-EOS
|
|
580
573
|
** AAA
|
|
581
574
|
* AA
|
|
582
575
|
* BBB
|
|
583
576
|
** BB
|
|
584
577
|
EOS
|
|
585
578
|
|
|
586
|
-
expected
|
|
579
|
+
expected = <<-EOS.chomp
|
|
587
580
|
<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>
|
|
588
581
|
EOS
|
|
589
582
|
actual = compile_block(src)
|
|
@@ -591,7 +584,7 @@ EOS
|
|
|
591
584
|
end
|
|
592
585
|
|
|
593
586
|
def test_ul_nest4
|
|
594
|
-
src
|
|
587
|
+
src = <<-EOS
|
|
595
588
|
* A
|
|
596
589
|
** B
|
|
597
590
|
** C
|
|
@@ -601,7 +594,7 @@ EOS
|
|
|
601
594
|
** G
|
|
602
595
|
EOS
|
|
603
596
|
|
|
604
|
-
expected
|
|
597
|
+
expected = <<-EOS.chomp
|
|
605
598
|
<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>
|
|
606
599
|
EOS
|
|
607
600
|
actual = compile_block(src)
|
|
@@ -609,12 +602,12 @@ EOS
|
|
|
609
602
|
end
|
|
610
603
|
|
|
611
604
|
def test_ol
|
|
612
|
-
src
|
|
605
|
+
src = <<-EOS
|
|
613
606
|
3. AAA
|
|
614
607
|
3. BBB
|
|
615
608
|
EOS
|
|
616
609
|
|
|
617
|
-
expected
|
|
610
|
+
expected = <<-EOS.chomp
|
|
618
611
|
<ol><li aid:pstyle="ol-item" olnum="1" num="3">AAA</li><li aid:pstyle="ol-item" olnum="2" num="3">BBB</li></ol>
|
|
619
612
|
EOS
|
|
620
613
|
actual = compile_block(src)
|
|
@@ -622,102 +615,102 @@ EOS
|
|
|
622
615
|
end
|
|
623
616
|
|
|
624
617
|
def test_inline_raw0
|
|
625
|
-
assert_equal
|
|
618
|
+
assert_equal 'normal', compile_inline('@<raw>{normal}')
|
|
626
619
|
end
|
|
627
620
|
|
|
628
621
|
def test_inline_raw1
|
|
629
|
-
assert_equal
|
|
622
|
+
assert_equal 'body', compile_inline('@<raw>{|idgxml|body}')
|
|
630
623
|
end
|
|
631
624
|
|
|
632
625
|
def test_inline_raw2
|
|
633
|
-
assert_equal
|
|
626
|
+
assert_equal 'body', compile_inline('@<raw>{|idgxml, latex|body}')
|
|
634
627
|
end
|
|
635
628
|
|
|
636
629
|
def test_inline_raw3
|
|
637
|
-
assert_equal
|
|
630
|
+
assert_equal '', compile_inline('@<raw>{|latex, html|body}')
|
|
638
631
|
end
|
|
639
632
|
|
|
640
633
|
def test_inline_raw4
|
|
641
|
-
assert_equal
|
|
634
|
+
assert_equal '|idgxml body', compile_inline('@<raw>{|idgxml body}')
|
|
642
635
|
end
|
|
643
636
|
|
|
644
637
|
def test_inline_raw5
|
|
645
|
-
assert_equal "nor\nmal", compile_inline(
|
|
638
|
+
assert_equal "nor\nmal", compile_inline('@<raw>{|idgxml|nor\\nmal}')
|
|
646
639
|
end
|
|
647
640
|
|
|
648
641
|
def test_inline_imgref
|
|
649
|
-
def @chapter.image(
|
|
650
|
-
item = Book::ImageIndex::Item.new(
|
|
651
|
-
item.instance_eval{@path=
|
|
642
|
+
def @chapter.image(_id)
|
|
643
|
+
item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
|
|
644
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
652
645
|
item
|
|
653
646
|
end
|
|
654
647
|
|
|
655
648
|
actual = compile_block "@<imgref>{sampleimg}\n"
|
|
656
|
-
expected =
|
|
649
|
+
expected = %Q(<p><span type='image'>図1.1「sample photo」</span></p>)
|
|
657
650
|
assert_equal expected, actual
|
|
658
651
|
end
|
|
659
652
|
|
|
660
653
|
def test_inline_imgref2
|
|
661
|
-
def @chapter.image(
|
|
662
|
-
item = Book::NumberlessImageIndex::Item.new(
|
|
663
|
-
item.instance_eval{@path=
|
|
654
|
+
def @chapter.image(_id)
|
|
655
|
+
item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
|
|
656
|
+
item.instance_eval { @path = './images/chap1-sampleimg.png' }
|
|
664
657
|
item
|
|
665
658
|
end
|
|
666
659
|
|
|
667
660
|
actual = compile_block "@<imgref>{sampleimg}\n"
|
|
668
|
-
expected =
|
|
661
|
+
expected = %Q(<p><span type='image'>図1.1</span></p>)
|
|
669
662
|
assert_equal expected, actual
|
|
670
663
|
end
|
|
671
664
|
|
|
672
665
|
def test_block_raw0
|
|
673
|
-
actual = compile_block(
|
|
674
|
-
expected = %Q(
|
|
666
|
+
actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
|
|
667
|
+
expected = %Q(<>!"\n& )
|
|
675
668
|
assert_equal expected, actual
|
|
676
669
|
end
|
|
677
670
|
|
|
678
671
|
def test_block_raw1
|
|
679
|
-
actual = compile_block(
|
|
680
|
-
expected = %Q(
|
|
681
|
-
assert_equal expected
|
|
672
|
+
actual = compile_block(%Q(//raw[|idgxml|<>!"\\n& ]\n))
|
|
673
|
+
expected = %Q(<>!"\n& )
|
|
674
|
+
assert_equal expected, actual
|
|
682
675
|
end
|
|
683
676
|
|
|
684
677
|
def test_block_raw2
|
|
685
|
-
actual = compile_block(
|
|
686
|
-
expected = %Q(
|
|
687
|
-
assert_equal expected
|
|
678
|
+
actual = compile_block(%Q(//raw[|idgxml, latex|<>!"\\n& ]\n))
|
|
679
|
+
expected = %Q(<>!"\n& )
|
|
680
|
+
assert_equal expected, actual
|
|
688
681
|
end
|
|
689
682
|
|
|
690
683
|
def test_block_raw3
|
|
691
|
-
actual = compile_block(
|
|
692
|
-
expected =
|
|
693
|
-
assert_equal expected
|
|
684
|
+
actual = compile_block(%Q(//raw[|latex, html|<>!"\\n& ]\n))
|
|
685
|
+
expected = ''
|
|
686
|
+
assert_equal expected, actual
|
|
694
687
|
end
|
|
695
688
|
|
|
696
689
|
def test_block_raw4
|
|
697
|
-
actual = compile_block(
|
|
698
|
-
expected = %Q(|idgxml
|
|
690
|
+
actual = compile_block(%Q(//raw[|idgxml <>!"\\n& ]\n))
|
|
691
|
+
expected = %Q(|idgxml <>!"\n& )
|
|
699
692
|
assert_equal expected.chomp, actual
|
|
700
693
|
end
|
|
701
694
|
|
|
702
695
|
def test_comment
|
|
703
|
-
actual = compile_block(
|
|
704
|
-
assert_equal
|
|
696
|
+
actual = compile_block('//comment[コメント]')
|
|
697
|
+
assert_equal '', actual
|
|
705
698
|
end
|
|
706
699
|
|
|
707
700
|
def test_comment_for_draft
|
|
708
|
-
@config[
|
|
709
|
-
actual = compile_block(
|
|
710
|
-
assert_equal
|
|
701
|
+
@config['draft'] = true
|
|
702
|
+
actual = compile_block('//comment[コメント]')
|
|
703
|
+
assert_equal '<msg>コメント</msg>', actual
|
|
711
704
|
end
|
|
712
705
|
|
|
713
706
|
def test_inline_comment
|
|
714
|
-
actual = compile_inline(
|
|
715
|
-
assert_equal
|
|
707
|
+
actual = compile_inline('test @<comment>{コメント} test2')
|
|
708
|
+
assert_equal 'test test2', actual
|
|
716
709
|
end
|
|
717
710
|
|
|
718
711
|
def test_inline_comment_for_draft
|
|
719
|
-
@config[
|
|
720
|
-
actual = compile_inline(
|
|
721
|
-
assert_equal
|
|
712
|
+
@config['draft'] = true
|
|
713
|
+
actual = compile_inline('test @<comment>{コメント} test2')
|
|
714
|
+
assert_equal 'test <msg>コメント</msg> test2', actual
|
|
722
715
|
end
|
|
723
716
|
end
|