review 5.5.0 → 5.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +31 -0
  3. data/.github/workflows/ruby-tex.yml +1 -1
  4. data/.github/workflows/ruby-win.yml +1 -1
  5. data/.github/workflows/ruby.yml +2 -2
  6. data/.rubocop.yml +13 -2
  7. data/NEWS.ja.md +40 -0
  8. data/NEWS.md +39 -0
  9. data/README.md +1 -1
  10. data/doc/format.ja.md +70 -33
  11. data/doc/format.md +69 -34
  12. data/doc/quickstart.ja.md +7 -1
  13. data/doc/quickstart.md +7 -1
  14. data/lib/review/book/base.rb +1 -1
  15. data/lib/review/builder.rb +6 -10
  16. data/lib/review/epubmaker/epubcommon.rb +13 -7
  17. data/lib/review/epubmaker/epubv2.rb +0 -5
  18. data/lib/review/epubmaker/epubv3.rb +9 -1
  19. data/lib/review/epubmaker/producer.rb +2 -3
  20. data/lib/review/epubmaker.rb +2 -4
  21. data/lib/review/htmlbuilder.rb +2 -2
  22. data/lib/review/i18n.yml +24 -2
  23. data/lib/review/idgxmlbuilder.rb +29 -10
  24. data/lib/review/idgxmlmaker.rb +11 -1
  25. data/lib/review/img_math.rb +9 -2
  26. data/lib/review/init.rb +10 -5
  27. data/lib/review/latexbuilder.rb +2 -2
  28. data/lib/review/lineinput.rb +2 -2
  29. data/lib/review/makerhelper.rb +2 -2
  30. data/lib/review/pdfmaker.rb +3 -5
  31. data/lib/review/update.rb +3 -7
  32. data/lib/review/version.rb +1 -1
  33. data/lib/review/yamlloader.rb +0 -3
  34. data/review.gemspec +3 -3
  35. data/samples/syntax-book/Gemfile +1 -1
  36. data/templates/latex/config.erb +6 -1
  37. data/templates/latex/review-jlreq/review-base.sty +11 -8
  38. data/templates/latex/review-jsbook/review-base.sty +15 -11
  39. data/templates/opf/epubv2.opf.erb +2 -0
  40. data/templates/opf/epubv3.opf.erb +2 -0
  41. data/templates/opf/opf_manifest_epubv2.opf.erb +2 -0
  42. data/templates/opf/opf_manifest_epubv3.opf.erb +2 -0
  43. data/templates/opf/opf_tocx_epubv3.opf.erb +2 -0
  44. metadata +24 -139
  45. data/test/assets/black.eps +0 -280
  46. data/test/assets/fit.png +0 -0
  47. data/test/assets/header_listener.html +0 -35
  48. data/test/assets/img_math/img1.png +0 -0
  49. data/test/assets/img_math/img2.png +0 -0
  50. data/test/assets/img_math/img3.png +0 -0
  51. data/test/assets/large.gif +0 -0
  52. data/test/assets/large.jpg +0 -0
  53. data/test/assets/large.png +0 -0
  54. data/test/assets/large.svg +0 -65
  55. data/test/assets/syntax_book_index_detail.txt +0 -60
  56. data/test/assets/test.xml.erb +0 -3
  57. data/test/assets/test_template.tex +0 -179
  58. data/test/assets/test_template_backmatter.tex +0 -190
  59. data/test/book_test_helper.rb +0 -44
  60. data/test/run_test.rb +0 -12
  61. data/test/test_book.rb +0 -588
  62. data/test/test_book_chapter.rb +0 -329
  63. data/test/test_book_part.rb +0 -53
  64. data/test/test_builder.rb +0 -126
  65. data/test/test_catalog.rb +0 -174
  66. data/test/test_catalog_converter_cmd.rb +0 -73
  67. data/test/test_compiler.rb +0 -52
  68. data/test/test_configure.rb +0 -91
  69. data/test/test_converter.rb +0 -21
  70. data/test/test_epub3maker.rb +0 -733
  71. data/test/test_epubmaker.rb +0 -931
  72. data/test/test_epubmaker_cmd.rb +0 -56
  73. data/test/test_extentions_hash.rb +0 -66
  74. data/test/test_helper.rb +0 -62
  75. data/test/test_htmlbuilder.rb +0 -3312
  76. data/test/test_htmltoc.rb +0 -29
  77. data/test/test_htmlutils.rb +0 -43
  78. data/test/test_i18n.rb +0 -300
  79. data/test/test_idgxmlbuilder.rb +0 -1487
  80. data/test/test_idgxmlmaker_cmd.rb +0 -50
  81. data/test/test_image_finder.rb +0 -81
  82. data/test/test_img_math.rb +0 -120
  83. data/test/test_index.rb +0 -287
  84. data/test/test_indexbuilder.rb +0 -52
  85. data/test/test_latexbuilder.rb +0 -2964
  86. data/test/test_latexbuilder_v2.rb +0 -1654
  87. data/test/test_lineinput.rb +0 -104
  88. data/test/test_location.rb +0 -30
  89. data/test/test_logger.rb +0 -33
  90. data/test/test_makerhelper.rb +0 -44
  91. data/test/test_markdownbuilder.rb +0 -371
  92. data/test/test_md2inaobuilder.rb +0 -90
  93. data/test/test_pdfmaker.rb +0 -354
  94. data/test/test_pdfmaker_cmd.rb +0 -130
  95. data/test/test_plaintextbuilder.rb +0 -1211
  96. data/test/test_preprocessor.rb +0 -196
  97. data/test/test_review_ext.rb +0 -30
  98. data/test/test_reviewheaderlistener.rb +0 -49
  99. data/test/test_rstbuilder.rb +0 -616
  100. data/test/test_sec_counter.rb +0 -156
  101. data/test/test_template.rb +0 -33
  102. data/test/test_textmaker_cmd.rb +0 -58
  103. data/test/test_textutils.rb +0 -187
  104. data/test/test_tocprinter.rb +0 -46
  105. data/test/test_topbuilder.rb +0 -1298
  106. data/test/test_update.rb +0 -473
  107. data/test/test_webtocprinter.rb +0 -195
  108. data/test/test_yamlloader.rb +0 -186
  109. data/test/test_zip_exporter.rb +0 -106
@@ -1,1487 +0,0 @@
1
- require 'test_helper'
2
- require 'review/compiler'
3
- require 'review/book'
4
- require 'review/idgxmlbuilder'
5
- require 'review/i18n'
6
-
7
- class IDGXMLBuidlerTest < Test::Unit::TestCase
8
- include ReVIEW
9
-
10
- def setup
11
- @builder = IDGXMLBuilder.new
12
- @config = ReVIEW::Configure.values
13
- @config['secnolevel'] = 2
14
- @config['tableopt'] = '10'
15
- @book = Book::Base.new
16
- @book.config = @config
17
- @log_io = StringIO.new
18
- ReVIEW.logger = ReVIEW::Logger.new(@log_io)
19
- @compiler = ReVIEW::Compiler.new(@builder)
20
- @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
21
- location = Location.new(nil, nil)
22
- @builder.bind(@compiler, @chapter, location)
23
- I18n.setup('ja')
24
- end
25
-
26
- def test_headline_level1
27
- actual = compile_block("={test} this is test.\n")
28
- assert_equal %Q(<title id="test" aid:pstyle="h1">第1章 this is test.</title><?dtp level="1" section="第1章 this is test."?>), actual
29
- end
30
-
31
- def test_headline_level1_without_secno
32
- @config['secnolevel'] = 0
33
- actual = compile_block("={test} this is test.\n")
34
- assert_equal %Q(<title id="test" aid:pstyle="h1">this is test.</title><?dtp level="1" section="this is test."?>), actual
35
- end
36
-
37
- def test_headline_level2
38
- actual = compile_block("=={test} this is test.\n")
39
- 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
40
- end
41
-
42
- def test_headline_level3
43
- actual = compile_block("==={test} this is test.\n")
44
- assert_equal %Q(<title id="test" aid:pstyle="h3">this is test.</title><?dtp level="3" section="this is test."?>), actual
45
- end
46
-
47
- def test_headline_level3_with_secno
48
- @config['secnolevel'] = 3
49
- actual = compile_block("==={test} this is test.\n")
50
- 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
51
- end
52
-
53
- def test_headline_secttags
54
- @config['structuredxml'] = true
55
- actual = compile_block("= HEAD1\n== HEAD1-1\n\n=== HEAD1-1-1\n\n== HEAD1-2\n\n==== HEAD1-2-0-1\n\n===== HEAD1-2-0-1-1\n\n== HEAD1-3\n")
56
- expected = '<chapter id="chap:1"><title aid:pstyle="h1">第1章 HEAD1</title><?dtp level="1" section="第1章 HEAD1"?>' +
57
- '<sect id="sect:1.1"><title aid:pstyle="h2">1.1 HEAD1-1</title><?dtp level="2" section="1.1 HEAD1-1"?>' +
58
- '<sect2 id="sect:1.1.1"><title aid:pstyle="h3">HEAD1-1-1</title><?dtp level="3" section="HEAD1-1-1"?></sect2></sect>' +
59
- '<sect id="sect:1.2"><title aid:pstyle="h2">1.2 HEAD1-2</title><?dtp level="2" section="1.2 HEAD1-2"?>' +
60
- '<sect3 id="sect:1.2.0.1"><title aid:pstyle="h4">HEAD1-2-0-1</title><?dtp level="4" section="HEAD1-2-0-1"?>' +
61
- '<sect4 id="sect:1.2.0.1.1"><title aid:pstyle="h5">HEAD1-2-0-1-1</title><?dtp level="5" section="HEAD1-2-0-1-1"?></sect4></sect3></sect>' +
62
- '<sect id="sect:1.3"><title aid:pstyle="h2">1.3 HEAD1-3</title><?dtp level="2" section="1.3 HEAD1-3"?></sect></chapter>'
63
- assert_equal expected, actual
64
- end
65
-
66
- def test_label
67
- actual = compile_block("//label[label_test]\n")
68
- assert_equal %Q(<label id='label_test' />), actual
69
- end
70
-
71
- def test_inline_ref
72
- actual = compile_inline('@<ref>{外部参照<>&}')
73
- assert_equal %Q(<ref idref='外部参照&lt;&gt;&amp;'>「●● 外部参照&lt;&gt;&amp;」</ref>), actual
74
- end
75
-
76
- def test_href
77
- actual = compile_inline('@<href>{http://github.com,GitHub}')
78
- assert_equal %Q(<a linkurl='http://github.com'>GitHub</a>), actual
79
- end
80
-
81
- def test_href_without_label
82
- actual = compile_inline('@<href>{http://github.com}')
83
- assert_equal %Q(<a linkurl='http://github.com'>http://github.com</a>), actual
84
- end
85
-
86
- def test_inline_href
87
- actual = compile_inline('@<href>{http://github.com, Git\\,Hub}')
88
- assert_equal %Q(<a linkurl='http://github.com'>Git,Hub</a>), actual
89
- end
90
-
91
- def test_inline_raw
92
- actual = compile_inline('@<raw>{@<tt>{inline\\}}')
93
- assert_equal %Q(@<tt>{inline}), actual
94
- end
95
-
96
- def test_inline_in_table
97
- actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
98
- 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>&lt;&gt;&amp;</td></tbody></table>), actual
99
- end
100
-
101
- def test_inline_in_table_without_header
102
- actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
103
- 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>&lt;&gt;&amp;</td></tbody></table>), actual
104
- end
105
-
106
- def test_inline_in_table_without_cellwidth
107
- @config['tableopt'] = nil
108
- actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
109
- 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>&lt;&gt;&amp;</tr></tbody></table>), actual
110
- end
111
-
112
- def test_inline_in_table_without_header_and_cellwidth
113
- @config['tableopt'] = nil
114
- actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n@<b>{3}\t@<i>{4}<>&\n//}\n")
115
- assert_equal %Q(<table><tbody><tr><b>1</b>\t<i>2</i></tr><tr type="lastline"><b>3</b>\t<i>4</i>&lt;&gt;&amp;</tr></tbody></table>), actual
116
- end
117
-
118
- def test_table
119
- actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
120
- expected = <<-EOS.chomp
121
- <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">aaa</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">bbb</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ccc</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ddd&lt;&gt;&amp;</td></tbody></table>
122
- EOS
123
- assert_equal expected, actual
124
-
125
- actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
126
- expected = <<-EOS.chomp
127
- <table><caption>表1.1 FOO</caption><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">aaa</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">bbb</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ccc</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ddd&lt;&gt;&amp;</td></tbody></table>
128
- EOS
129
- assert_equal expected, actual
130
-
131
- @config['caption_position']['table'] = 'bottom'
132
- actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
133
- expected = <<-EOS.chomp
134
- <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">aaa</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">bbb</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ccc</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">ddd&lt;&gt;&amp;</td></tbody><caption>表1.1 FOO</caption></table>
135
- EOS
136
- assert_equal expected, actual
137
- end
138
-
139
- def test_customize_cellwidth
140
- actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
141
- 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
142
-
143
- actual = compile_block("//tsize[2,3]\n//table{\nA\tB\tC\n//}\n")
144
- 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
145
-
146
- actual = compile_block("//tsize[2]\n//table{\nA\tB\tC\n//}\n")
147
- 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
148
-
149
- actual = compile_block("//tsize[|idgxml|2]\n//table{\nA\tB\tC\n//}\n")
150
- 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
151
-
152
- actual = compile_block("//tsize[|idgxml,html|2]\n//table{\nA\tB\tC\n//}\n")
153
- 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
154
-
155
- actual = compile_block("//tsize[|html|2]\n//table{\nA\tB\tC\n//}\n")
156
- 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
157
- end
158
-
159
- def test_customize_mmtopt
160
- actual = compile_block("//table{\nA\n//}\n")
161
- 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
162
-
163
- @config['pt_to_mm_unit'] = 0.3514
164
- actual = compile_block("//table{\nA\n//}\n")
165
- 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
166
-
167
- @config['pt_to_mm_unit'] = '0.3514'
168
- actual = compile_block("//table{\nA\n//}\n")
169
- 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
170
- end
171
-
172
- def test_empty_table
173
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
174
- assert_equal 'no rows in the table', e.message
175
-
176
- e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
177
- assert_equal 'no rows in the table', e.message
178
- end
179
-
180
- def test_emtable
181
- actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
182
- 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
183
-
184
- @config['caption_position']['table'] = 'bottom'
185
- actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
186
- 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><caption>foo</caption></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
187
- end
188
-
189
- def test_table_row_separator
190
- src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
191
- expected = <<-EOS.chomp
192
- <table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="3"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="9.448">c d |e</td></tbody></table>
193
- EOS
194
- actual = compile_block(src)
195
- assert_equal expected, actual
196
-
197
- @config['table_row_separator'] = 'singletab'
198
- actual = compile_block(src)
199
- expected = <<-EOS.chomp
200
- <table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="4"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086"></td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">3 4| 5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">a b</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="7.086">c d |e</td></tbody></table>
201
- EOS
202
- assert_equal expected, actual
203
-
204
- @config['table_row_separator'] = 'spaces'
205
- actual = compile_block(src)
206
- expected = <<-EOS.chomp
207
- <table><tbody xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="2" aid:tcols="5"><td xyh="1,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">1</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">2</td><td xyh="3,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">3</td><td xyh="4,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">4|</td><td xyh="5,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">a</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">b</td><td xyh="3,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">c</td><td xyh="4,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">d</td><td xyh="5,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="5.669">|e</td></tbody></table>
208
- EOS
209
- assert_equal expected, actual
210
-
211
- @config['table_row_separator'] = 'verticalbar'
212
- actual = compile_block(src)
213
- expected = <<-EOS.chomp
214
- <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">1 2 3 4</td><td xyh="2,1,1" aid:table="cell" aid:theader="1" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">5</td><td xyh="1,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">a b c d</td><td xyh="2,2,1" aid:table="cell" aid:crows="1" aid:ccols="1" aid:ccolwidth="14.172">e</td></tbody></table>
215
- EOS
216
- assert_equal expected, actual
217
- end
218
-
219
- def test_inline_br
220
- actual = compile_inline('@<br>{}')
221
- assert_equal "\n", actual
222
- end
223
-
224
- def test_inline_uchar
225
- actual = compile_inline('test @<uchar>{2460} test2')
226
- assert_equal 'test &#x2460; test2', actual
227
- end
228
-
229
- def test_inline_ruby
230
- actual = compile_inline('@<ruby>{coffin, bed}')
231
- 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
232
- end
233
-
234
- def test_inline_kw
235
- actual = compile_inline('@<kw>{ISO, International Organization for Standardization } @<kw>{Ruby<>}')
236
- assert_equal %Q(<keyword>ISO(International Organization for Standardization)</keyword><index value="ISO" /><index value="International Organization for Standardization" /> <keyword>Ruby&lt;&gt;</keyword><index value="Ruby&lt;&gt;" />), actual
237
- end
238
-
239
- def test_inline_maru
240
- actual = compile_inline('@<maru>{1}@<maru>{20}@<maru>{A}@<maru>{z}')
241
- assert_equal '&#x2460;&#x2473;&#x24b6;&#x24e9;', actual
242
- end
243
-
244
- def test_inline_ttb
245
- actual = compile_inline(%Q(@<ttb>{test * <>"}))
246
- assert_equal %Q(<tt style='bold'>test * &lt;&gt;&quot;</tt>), actual
247
- end
248
-
249
- def test_inline_ttbold
250
- actual = compile_inline(%Q(@<ttbold>{test * <>"}))
251
- assert_equal %Q(<tt style='bold'>test * &lt;&gt;&quot;</tt>), actual
252
- end
253
-
254
- def test_inline_balloon
255
- actual = compile_inline('@<balloon>{@maru[1]test}')
256
- assert_equal '<balloon>&#x2460;test</balloon>', actual
257
- end
258
-
259
- def test_inline_m
260
- actual = compile_inline('@<m>{\\sin} @<m>{\\frac{1\\}{2\\}}')
261
- assert_equal %Q(<replace idref="texinline-1"><pre>\\sin</pre></replace> <replace idref="texinline-2"><pre>\\frac{1}{2}</pre></replace>), actual
262
- end
263
-
264
- def test_dlist_beforeulol
265
- 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")
266
- 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
267
- end
268
-
269
- def test_dt_inline
270
- actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
271
-
272
- expected = <<-EOS.chomp
273
- <dl><dt>foo<footnote>bar</footnote>[]&lt;&gt;&amp;<replace idref="texinline-1"><pre>\\alpha[]</pre></replace></dt><dd></dd></dl>
274
- EOS
275
- assert_equal expected, actual
276
- end
277
-
278
- def test_paragraph
279
- actual = compile_block("foo\nbar\n")
280
- assert_equal '<p>foobar</p>', actual
281
-
282
- @book.config['join_lines_by_lang'] = true
283
- actual = compile_block("foo\nbar\n")
284
- assert_equal '<p>foo bar</p>', actual
285
- end
286
-
287
- def test_tabbed_paragraph
288
- actual = compile_block("\tfoo\nbar\n")
289
- assert_equal %Q(<p inlist="1">foobar</p>), actual
290
-
291
- @book.config['join_lines_by_lang'] = true
292
- actual = compile_block("\tfoo\nbar\n")
293
- assert_equal %Q(<p inlist="1">foo bar</p>), actual
294
- end
295
-
296
- def test_quote
297
- actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
298
- assert_equal '<quote><p>foobar</p><p>buz</p></quote>', actual
299
-
300
- @book.config['join_lines_by_lang'] = true
301
- actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
302
- assert_equal '<quote><p>foo bar</p><p>buz</p></quote>', actual
303
- end
304
-
305
- def test_major_blocks
306
- actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
307
- expected = %Q(<note><p>A</p><p>B</p></note><note><title aid:pstyle='note-title'>caption</title><p>A</p></note>)
308
- assert_equal expected, actual
309
-
310
- actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
311
- expected = %Q(<memo><p>A</p><p>B</p></memo><memo><title aid:pstyle='memo-title'>caption</title><p>A</p></memo>)
312
- assert_equal expected, actual
313
-
314
- actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
315
- expected = %Q(<info><p>A</p><p>B</p></info><info><title aid:pstyle='info-title'>caption</title><p>A</p></info>)
316
- assert_equal expected, actual
317
-
318
- actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
319
- expected = %Q(<important><p>A</p><p>B</p></important><important><title aid:pstyle='important-title'>caption</title><p>A</p></important>)
320
- assert_equal expected, actual
321
-
322
- actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
323
- expected = %Q(<caution><p>A</p><p>B</p></caution><caution><title aid:pstyle='caution-title'>caption</title><p>A</p></caution>)
324
- assert_equal expected, actual
325
-
326
- # notice uses special tag notice-t if it includes caption
327
- actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
328
- expected = %Q(<notice><p>A</p><p>B</p></notice><notice-t><title aid:pstyle='notice-title'>caption</title><p>A</p></notice-t>)
329
- assert_equal expected, actual
330
-
331
- actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
332
- expected = %Q(<warning><p>A</p><p>B</p></warning><warning><title aid:pstyle='warning-title'>caption</title><p>A</p></warning>)
333
- assert_equal expected, actual
334
-
335
- actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
336
- expected = %Q(<tip><p>A</p><p>B</p></tip><tip><title aid:pstyle='tip-title'>caption</title><p>A</p></tip>)
337
- assert_equal expected, actual
338
- end
339
-
340
- def test_minicolumn_blocks
341
- %w[note memo tip info warning important caution notice].each do |type|
342
- src = <<-EOS
343
- //#{type}[#{type}1]{
344
-
345
- //}
346
-
347
- //#{type}[#{type}2]{
348
- //}
349
- EOS
350
-
351
- expected = if type == 'notice' # exception pattern
352
- <<-EOS.chomp
353
- <#{type}-t><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}-t>
354
- EOS
355
- else
356
- <<-EOS.chomp
357
- <#{type}><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}>
358
- EOS
359
- end
360
- assert_equal expected, compile_block(src)
361
-
362
- src = <<-EOS
363
- //#{type}[#{type}2]{
364
-
365
- //}
366
-
367
- //#{type}[#{type}3]{
368
-
369
- //}
370
-
371
- //#{type}[#{type}4]{
372
-
373
- //}
374
-
375
- //#{type}[#{type}5]{
376
-
377
- //}
378
-
379
- //#{type}[#{type}6]{
380
-
381
- //}
382
- EOS
383
-
384
- if type == 'notice' # exception pattern
385
- expected = <<-EOS.chomp
386
- <#{type}-t><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}3</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}4</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}5</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}6</title></#{type}-t>
387
- EOS
388
- else
389
- expected = <<-EOS.chomp
390
- <#{type}><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}3</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}4</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}5</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}6</title></#{type}>
391
- EOS
392
- end
393
- assert_equal expected, compile_block(src)
394
-
395
- src = <<-EOS
396
- //#{type}{
397
-
398
- * A
399
-
400
- 1. B
401
-
402
- //}
403
-
404
- //#{type}[OMITEND1]{
405
-
406
- //emlist{
407
- LIST
408
- //}
409
-
410
- //}
411
- //#{type}[OMITEND2]{
412
- //}
413
- EOS
414
-
415
- expected = if type == 'notice' # exception pattern
416
- <<-EOS.chomp
417
- <#{type}><ul><li aid:pstyle="ul-item">A</li></ul><ol><li aid:pstyle="ol-item" olnum="1" num="1">B</li></ol></#{type}><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND1</title><list type='emlist'><pre>LIST
418
- </pre></list></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}-t>
419
- EOS
420
- else
421
- <<-EOS.chomp
422
- <#{type}><ul><li aid:pstyle="ul-item">A</li></ul><ol><li aid:pstyle="ol-item" olnum="1" num="1">B</li></ol></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND1</title><list type='emlist'><pre>LIST
423
- </pre></list></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}>
424
- EOS
425
- end
426
- assert_equal expected, compile_block(src)
427
- end
428
- end
429
-
430
- def test_minicolumn_blocks_nest_error1
431
- %w[note memo tip info warning important caution notice].each do |type|
432
- @builder.doc_status.clear
433
- src = <<-EOS
434
- //#{type}{
435
-
436
- //#{type}{
437
- //}
438
-
439
- //}
440
- EOS
441
- assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
442
- assert_match(/minicolumn cannot be nested:/, @log_io.string)
443
- end
444
- end
445
-
446
- def test_minicolumn_blocks_nest_error2
447
- %w[note memo tip info warning important caution notice].each do |type|
448
- @builder.doc_status.clear
449
- src = <<-EOS
450
- //#{type}{
451
-
452
- //#{type}{
453
-
454
- //}
455
-
456
- //}
457
- EOS
458
- assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
459
- assert_match(/minicolumn cannot be nested:/, @log_io.string)
460
- end
461
- end
462
-
463
- def test_minicolumn_blocks_nest_error3
464
- %w[memo tip info warning important caution notice].each do |type|
465
- @builder.doc_status.clear
466
- src = <<-EOS
467
- //#{type}{
468
-
469
- //note{
470
- //}
471
-
472
- //}
473
- EOS
474
- assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
475
- assert_match(/minicolumn cannot be nested:/, @log_io.string)
476
- end
477
- end
478
-
479
- def test_term
480
- actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
481
- assert_equal '<term><p>test1test1.5</p><p>test<i>2</i></p></term>', actual
482
-
483
- @book.config['join_lines_by_lang'] = true
484
- actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
485
- assert_equal '<term><p>test1 test1.5</p><p>test<i>2</i></p></term>', actual
486
- end
487
-
488
- def test_point
489
- actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
490
- assert_equal %Q(<point-t><title aid:pstyle='point-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1test1.5</p><p>test<i>2</i></p></point-t>), actual
491
-
492
- @book.config['join_lines_by_lang'] = true
493
- actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
494
- assert_equal %Q(<point-t><title aid:pstyle='point-title'>this is <b>test</b>&lt;&amp;&gt;_</title><p>test1 test1.5</p><p>test<i>2</i></p></point-t>), actual
495
- end
496
-
497
- def test_point_without_caption
498
- actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
499
- assert_equal '<point><p>test1test1.5</p><p>test<i>2</i></p></point>', actual
500
-
501
- @book.config['join_lines_by_lang'] = true
502
- actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
503
- assert_equal '<point><p>test1 test1.5</p><p>test<i>2</i></p></point>', actual
504
- end
505
-
506
- def test_emlist
507
- actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
508
- assert_equal %Q(<list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre></list>), actual
509
-
510
- @config['caption_position']['list'] = 'bottom'
511
- actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
512
- assert_equal %Q(<list type='emlist'><pre>test1\ntest1.5\n\ntest<i>2</i>\n</pre><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption></list>), actual
513
- end
514
-
515
- def test_emlistnum
516
- actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
517
- assert_equal %Q(<list type='emlistnum'><caption aid:pstyle='emlistnum-title'>this is <b>test</b>&lt;&amp;&gt;_</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
518
-
519
- @config['caption_position']['list'] = 'bottom'
520
- actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
521
- assert_equal %Q(<list type='emlistnum'><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><caption aid:pstyle='emlistnum-title'>this is <b>test</b>&lt;&amp;&gt;_</caption></list>), actual
522
- end
523
-
524
- def test_emlist_listinfo
525
- @config['listinfo'] = true
526
- actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
527
- expected = <<-EOS.chomp
528
- <list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre><listinfo line="1" begin="1">test1
529
- </listinfo><listinfo line="2">test1.5
530
- </listinfo><listinfo line="3">
531
- </listinfo><listinfo line="4" end="4">test<i>2</i>
532
- </listinfo></pre></list>
533
- EOS
534
- assert_equal expected, actual
535
- end
536
-
537
- def test_emlist_with_tab
538
- actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
539
- expected = <<-EOS.chomp
540
- <list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre> test1
541
- test1.5
542
-
543
- test<i>2</i>
544
- </pre></list>
545
- EOS
546
- assert_equal expected, actual
547
- end
548
-
549
- def test_emlist_with_4tab
550
- @config['tabwidth'] = 4
551
- actual = compile_block("//emlist[this is @<b>{test}<&>_]{\n\ttest1\n\t\ttest1.5\n\n\ttest@<i>{2}\n//}\n")
552
- expected = <<-EOS.chomp
553
- <list type='emlist'><caption aid:pstyle='emlist-title'>this is <b>test</b>&lt;&amp;&gt;_</caption><pre> test1
554
- test1.5
555
-
556
- test<i>2</i>
557
- </pre></list>
558
- EOS
559
- assert_equal expected, actual
560
- end
561
-
562
- def test_list
563
- def @chapter.list(_id)
564
- Book::Index::Item.new('samplelist', 1)
565
- end
566
- actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
567
- expected = <<-EOS.chomp
568
- <codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre>test1
569
- test1.5
570
-
571
- test<i>2</i>
572
- </pre></codelist>
573
- EOS
574
- assert_equal expected, actual
575
-
576
- @config['caption_position']['list'] = 'bottom'
577
- actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
578
- expected = <<-EOS.chomp
579
- <codelist><pre>test1
580
- test1.5
581
-
582
- test<i>2</i>
583
- </pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
584
- EOS
585
- assert_equal expected, actual
586
- end
587
-
588
- def test_listnum
589
- def @chapter.list(_id)
590
- Book::Index::Item.new('samplelist', 1)
591
- end
592
- actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
593
- expected = <<-EOS.chomp
594
- <codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre><span type='lineno'> 1: </span>test1
595
- <span type='lineno'> 2: </span>test1.5
596
- <span type='lineno'> 3: </span>
597
- <span type='lineno'> 4: </span>test<i>2</i>
598
- </pre></codelist>
599
- EOS
600
- assert_equal expected, actual
601
-
602
- @config['caption_position']['list'] = 'bottom'
603
- actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
604
- expected = <<-EOS.chomp
605
- <codelist><pre><span type='lineno'> 1: </span>test1
606
- <span type='lineno'> 2: </span>test1.5
607
- <span type='lineno'> 3: </span>
608
- <span type='lineno'> 4: </span>test<i>2</i>
609
- </pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
610
- EOS
611
- assert_equal expected, actual
612
- end
613
-
614
- def test_listnum_linenum
615
- def @chapter.list(_id)
616
- Book::Index::Item.new('samplelist', 1)
617
- end
618
- actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
619
- expected = <<-EOS.chomp
620
- <codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre><span type='lineno'>100: </span>test1
621
- <span type='lineno'>101: </span>test1.5
622
- <span type='lineno'>102: </span>
623
- <span type='lineno'>103: </span>test<i>2</i>
624
- </pre></codelist>
625
- EOS
626
- assert_equal expected, actual
627
-
628
- @config['caption_position']['list'] = 'bottom'
629
- actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
630
- expected = <<-EOS.chomp
631
- <codelist><pre><span type='lineno'>100: </span>test1
632
- <span type='lineno'>101: </span>test1.5
633
- <span type='lineno'>102: </span>
634
- <span type='lineno'>103: </span>test<i>2</i>
635
- </pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
636
- EOS
637
- assert_equal expected, actual
638
- end
639
-
640
- def test_list_listinfo
641
- def @chapter.list(_id)
642
- Book::Index::Item.new('samplelist', 1)
643
- end
644
- @config['listinfo'] = true
645
- actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
646
- expected = <<-EOS.chomp
647
- <codelist><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption><pre><listinfo line="1" begin="1">test1
648
- </listinfo><listinfo line="2">test1.5
649
- </listinfo><listinfo line="3">
650
- </listinfo><listinfo line="4" end="4">test<i>2</i>
651
- </listinfo></pre></codelist>
652
- EOS
653
- assert_equal expected, actual
654
-
655
- @config['caption_position']['list'] = 'bottom'
656
- actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
657
- expected = <<-EOS.chomp
658
- <codelist><pre><listinfo line="1" begin="1">test1
659
- </listinfo><listinfo line="2">test1.5
660
- </listinfo><listinfo line="3">
661
- </listinfo><listinfo line="4" end="4">test<i>2</i>
662
- </listinfo></pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
663
- EOS
664
- assert_equal expected, actual
665
- end
666
-
667
- def test_cmd
668
- actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
669
- expected = <<-EOS.chomp
670
- <list type='cmd'><pre>lineA
671
- lineB
672
- </pre></list>
673
- EOS
674
- assert_equal expected, actual
675
-
676
- actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
677
- expected = <<-EOS.chomp
678
- <list type='cmd'><caption aid:pstyle='cmd-title'>cap1</caption><pre>lineA
679
- lineB
680
- </pre></list>
681
- EOS
682
- assert_equal expected, actual
683
-
684
- @config['caption_position']['list'] = 'bottom'
685
- actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
686
- expected = <<-EOS.chomp
687
- <list type='cmd'><pre>lineA
688
- lineB
689
- </pre><caption aid:pstyle='cmd-title'>cap1</caption></list>
690
- EOS
691
- assert_equal expected, actual
692
- end
693
-
694
- def test_source
695
- actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
696
- expected = <<-EOS.chomp
697
- <source><caption>foo/bar/test.rb</caption><pre>foo
698
- bar
699
-
700
- buz
701
- </pre></source>
702
- EOS
703
- assert_equal expected, actual
704
-
705
- @config['caption_position']['list'] = 'bottom'
706
- actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
707
- expected = <<-EOS.chomp
708
- <source><pre>foo
709
- bar
710
-
711
- buz
712
- </pre><caption>foo/bar/test.rb</caption></source>
713
- EOS
714
- assert_equal expected, actual
715
- end
716
-
717
- def test_source_empty_caption
718
- actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
719
- expected = <<-EOS.chomp
720
- <source><pre>foo
721
- bar
722
-
723
- buz
724
- </pre></source>
725
- EOS
726
- assert_equal expected, actual
727
- end
728
-
729
- def test_source_nil_caption
730
- actual = compile_block("//source{\nfoo\nbar\n\nbuz\n//}\n")
731
- expected = <<-EOS.chomp
732
- <source><pre>foo
733
- bar
734
-
735
- buz
736
- </pre></source>
737
- EOS
738
- assert_equal expected, actual
739
- end
740
-
741
- def test_insn
742
- @config['listinfo'] = true
743
- actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
744
- expected = <<-EOS.chomp
745
- <insn><floattitle type="insn">this is <b>test</b>&lt;&amp;&gt;_</floattitle><listinfo line="1" begin="1">test1
746
- </listinfo><listinfo line="2">test1.5
747
- </listinfo><listinfo line="3">
748
- </listinfo><listinfo line="4" end="4">test<i>2</i>
749
- </listinfo></insn>
750
- EOS
751
- assert_equal expected, actual
752
-
753
- @config['caption_position']['list'] = 'bottom'
754
- actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
755
- expected = <<-EOS.chomp
756
- <insn><listinfo line="1" begin="1">test1
757
- </listinfo><listinfo line="2">test1.5
758
- </listinfo><listinfo line="3">
759
- </listinfo><listinfo line="4" end="4">test<i>2</i>
760
- </listinfo><floattitle type="insn">this is <b>test</b>&lt;&amp;&gt;_</floattitle></insn>
761
- EOS
762
- assert_equal expected, actual
763
- end
764
-
765
- def test_box
766
- @config['listinfo'] = true
767
- actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
768
- expected = <<-EOS.chomp
769
- <box><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption><listinfo line="1" begin="1">test1
770
- </listinfo><listinfo line="2">test1.5
771
- </listinfo><listinfo line="3">
772
- </listinfo><listinfo line="4" end="4">test<i>2</i>
773
- </listinfo></box>
774
- EOS
775
- assert_equal expected, actual
776
-
777
- @config['caption_position']['list'] = 'bottom'
778
- actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
779
- expected = <<-EOS.chomp
780
- <box><listinfo line="1" begin="1">test1
781
- </listinfo><listinfo line="2">test1.5
782
- </listinfo><listinfo line="3">
783
- </listinfo><listinfo line="4" end="4">test<i>2</i>
784
- </listinfo><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption></box>
785
- EOS
786
- assert_equal expected, actual
787
- end
788
-
789
- def test_box_non_listinfo
790
- @config['listinfo'] = nil
791
- actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
792
- expected = <<-EOS.chomp
793
- <box><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption>test1
794
- test1.5
795
-
796
- test<i>2</i>
797
- </box>
798
- EOS
799
- assert_equal expected, actual
800
-
801
- @config['caption_position']['list'] = 'bottom'
802
- actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
803
- expected = <<-EOS.chomp
804
- <box>test1
805
- test1.5
806
-
807
- test<i>2</i>
808
- <caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption></box>
809
- EOS
810
- assert_equal expected, actual
811
- end
812
-
813
- def test_flushright
814
- actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
815
- assert_equal %Q(<p align='right'>foobar</p><p align='right'>buz</p>), actual
816
-
817
- @book.config['join_lines_by_lang'] = true
818
- actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
819
- assert_equal %Q(<p align='right'>foo bar</p><p align='right'>buz</p>), actual
820
- end
821
-
822
- def test_centering
823
- actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
824
- assert_equal %Q(<p align='center'>foobar</p><p align='center'>buz</p>), actual
825
-
826
- @book.config['join_lines_by_lang'] = true
827
- actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
828
- assert_equal %Q(<p align='center'>foo bar</p><p align='center'>buz</p>), actual
829
- end
830
-
831
- def test_blankline
832
- actual = compile_block("//blankline\nfoo\n")
833
- assert_equal %Q(<p/><p>foo</p>), actual
834
- end
835
-
836
- def test_noindent
837
- actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
838
- assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>), actual
839
-
840
- @book.config['join_lines_by_lang'] = true
841
- actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
842
- assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foo bar</p><p>foo2 bar2</p>), actual
843
- end
844
-
845
- def test_image
846
- def @chapter.image(_id)
847
- item = Book::Index::Item.new('sampleimg', 1)
848
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
849
- item
850
- end
851
-
852
- actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
853
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>), actual
854
-
855
- @config['caption_position']['image'] = 'top'
856
- actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
857
- assert_equal %Q(<img><caption>図1.1 sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
858
- end
859
-
860
- def test_image_with_metric
861
- def @chapter.image(_id)
862
- item = Book::Index::Item.new('sampleimg', 1)
863
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
864
- item
865
- end
866
-
867
- actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
868
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>図1.1 sample photo</caption></img>), actual
869
- end
870
-
871
- def test_image_with_metric2
872
- def @chapter.image(_id)
873
- item = Book::Index::Item.new('sampleimg', 1)
874
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
875
- item
876
- end
877
-
878
- actual = compile_block("//image[sampleimg][sample photo][scale=1.2, html::class=sample, latex::ignore=params, idgxml::ostyle=object]{\n//}\n")
879
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>図1.1 sample photo</caption></img>), actual
880
- end
881
-
882
- def test_indepimage
883
- def @chapter.image(_id)
884
- item = Book::Index::Item.new('sampleimg', 1)
885
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
886
- item
887
- end
888
-
889
- actual = compile_block("//indepimage[sampleimg][sample photo]\n")
890
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>), actual
891
-
892
- @config['caption_position']['image'] = 'top'
893
- actual = compile_block("//indepimage[sampleimg][sample photo]\n")
894
- assert_equal %Q(<img><caption>sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
895
- end
896
-
897
- def test_indepimage_without_caption
898
- def @chapter.image(_id)
899
- item = Book::Index::Item.new('sampleimg', 1)
900
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
901
- item
902
- end
903
-
904
- actual = compile_block("//indepimage[sampleimg]\n")
905
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /></img>), actual
906
- end
907
-
908
- def test_indepimage_with_metric
909
- def @chapter.image(_id)
910
- item = Book::Index::Item.new('sampleimg', 1)
911
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
912
- item
913
- end
914
-
915
- actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
916
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /><caption>sample photo</caption></img>), actual
917
- end
918
-
919
- def test_indepimage_with_metric2
920
- def @chapter.image(_id)
921
- item = Book::Index::Item.new('sampleimg', 1)
922
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
923
- item
924
- end
925
-
926
- actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample", latex::ignore=params, idgxml::ostyle="object"]\n))
927
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" ostyle="object" /><caption>sample photo</caption></img>), actual
928
- end
929
-
930
- def test_indepimage_without_caption_but_with_metric
931
- def @chapter.image(_id)
932
- item = Book::Index::Item.new('sampleimg', 1)
933
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
934
- item
935
- end
936
-
937
- actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
938
- assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" scale="1.2" /></img>), actual
939
- end
940
-
941
- def column_helper(review)
942
- compile_block(review)
943
- end
944
-
945
- def test_column_1
946
- review = <<-EOS
947
- ===[column] prev column
948
-
949
- inside prev column
950
-
951
- ===[column] test
952
-
953
- inside column
954
-
955
- ===[/column]
956
- EOS
957
- expected = <<-EOS.chomp
958
- <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>
959
- EOS
960
- assert_equal expected, column_helper(review)
961
- end
962
-
963
- def test_column_2
964
- review = <<-EOS
965
- ===[column] test
966
-
967
- inside column
968
-
969
- === next level
970
- EOS
971
- expected = <<-EOS.chomp
972
- <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"?>
973
- EOS
974
-
975
- assert_equal expected, column_helper(review)
976
- end
977
-
978
- def test_column_3
979
- review = <<-EOS
980
- ===[column] test
981
-
982
- inside column
983
-
984
- ===[/column_dummy]
985
- EOS
986
- assert_raise(ReVIEW::ApplicationError) do
987
- column_helper(review)
988
- end
989
- end
990
-
991
- def test_column_ref
992
- review = <<-EOS
993
- ===[column]{foo} test
994
-
995
- inside column
996
-
997
- === next level
998
-
999
- this is @<column>{foo}.
1000
- EOS
1001
- expected = <<-EOS.chomp
1002
- <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 <link href="column-1">コラム「test」</link>.</p>
1003
- EOS
1004
-
1005
- assert_equal expected, column_helper(review)
1006
-
1007
- @config['chapterlink'] = nil
1008
- expected = <<-EOS.chomp
1009
- <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>
1010
- EOS
1011
- assert_equal expected, column_helper(review)
1012
- end
1013
-
1014
- def test_column_in_aother_chapter_ref
1015
- def @chapter.column_index
1016
- item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
1017
- idx = Book::ColumnIndex.new
1018
- idx.add_item(item)
1019
- idx
1020
- end
1021
-
1022
- actual = compile_inline('test @<column>{chap1|column} test2')
1023
- expected = 'test <link href="column-1">コラム「column_cap」</link> test2'
1024
- assert_equal expected, actual
1025
-
1026
- @config['chapterlink'] = nil
1027
- actual = compile_inline('test @<column>{chap1|column} test2')
1028
- expected = 'test コラム「column_cap」 test2'
1029
- assert_equal expected, actual
1030
- end
1031
-
1032
- def test_ul
1033
- src = <<-EOS
1034
- * AAA
1035
- * BBB
1036
- EOS
1037
-
1038
- expected = <<-EOS.chomp
1039
- <ul><li aid:pstyle="ul-item">AAA</li><li aid:pstyle="ul-item">BBB</li></ul>
1040
- EOS
1041
- actual = compile_block(src)
1042
- assert_equal expected, actual
1043
- end
1044
-
1045
- def test_ul_cont
1046
- src = <<-EOS
1047
- * AAA
1048
- -AA
1049
- * BBB
1050
- -BB
1051
- EOS
1052
- expected = <<-EOS.chomp
1053
- <ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
1054
- EOS
1055
- actual = compile_block(src)
1056
- assert_equal expected, actual
1057
-
1058
- @book.config['join_lines_by_lang'] = true
1059
- expected = <<-EOS.chomp
1060
- <ul><li aid:pstyle="ul-item">AAA -AA</li><li aid:pstyle="ul-item">BBB -BB</li></ul>
1061
- EOS
1062
- actual = compile_block(src)
1063
- assert_equal expected, actual
1064
- end
1065
-
1066
- def test_ul_nest1
1067
- src = <<-EOS
1068
- * AAA
1069
- ** AA
1070
- EOS
1071
-
1072
- expected = <<-EOS.chomp
1073
- <ul><li aid:pstyle="ul-item">AAA<ul2><li aid:pstyle="ul-item">AA</li></ul2></li></ul>
1074
- EOS
1075
- actual = compile_block(src)
1076
- assert_equal expected, actual
1077
- end
1078
-
1079
- def test_ul_nest2
1080
- src = <<-EOS
1081
- * AAA
1082
- ** AA
1083
- * BBB
1084
- ** BB
1085
- EOS
1086
-
1087
- expected = <<-EOS.chomp
1088
- <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>
1089
- EOS
1090
- actual = compile_block(src)
1091
- assert_equal expected, actual
1092
- end
1093
-
1094
- def test_ul_nest3
1095
- src = <<-EOS
1096
- ** AAA
1097
- * AA
1098
- EOS
1099
-
1100
- assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1101
- assert_match(/too many \*\./, @log_io.string)
1102
- end
1103
-
1104
- def test_ul_nest4
1105
- src = <<-EOS
1106
- * A
1107
- ** B
1108
- ** C
1109
- *** D
1110
- ** E
1111
- * F
1112
- ** G
1113
- EOS
1114
-
1115
- expected = <<-EOS.chomp
1116
- <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>
1117
- EOS
1118
- actual = compile_block(src)
1119
- assert_equal expected, actual
1120
- end
1121
-
1122
- def test_ol
1123
- src = <<-EOS
1124
- 3. AAA
1125
- 3. BBB
1126
- EOS
1127
-
1128
- expected = <<-EOS.chomp
1129
- <ol><li aid:pstyle="ol-item" olnum="1" num="3">AAA</li><li aid:pstyle="ol-item" olnum="2" num="3">BBB</li></ol>
1130
- EOS
1131
- actual = compile_block(src)
1132
- assert_equal expected, actual
1133
- end
1134
-
1135
- def test_inline_unknown
1136
- assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
1137
- assert_match(/unknown image: n/, @log_io.string)
1138
-
1139
- @log_io.string = ''
1140
- assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
1141
- assert_match(/unknown footnote: n/, @log_io.string)
1142
-
1143
- @log_io.string = ''
1144
- assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
1145
- assert_match(/unknown headline: n/, @log_io.string)
1146
- %w[list table column].each do |name|
1147
- @log_io.string = ''
1148
- assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
1149
- assert_match(/unknown #{name}: n/, @log_io.string)
1150
- end
1151
- %w[chap chapref title].each do |name|
1152
- @log_io.string = ''
1153
- assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
1154
- assert_match(/key not found: "n"/, @log_io.string)
1155
- end
1156
- end
1157
-
1158
- def test_inline_raw0
1159
- assert_equal 'normal', compile_inline('@<raw>{normal}')
1160
- end
1161
-
1162
- def test_inline_raw1
1163
- assert_equal 'body', compile_inline('@<raw>{|idgxml|body}')
1164
- end
1165
-
1166
- def test_inline_raw2
1167
- assert_equal 'body', compile_inline('@<raw>{|idgxml, latex|body}')
1168
- end
1169
-
1170
- def test_inline_raw3
1171
- assert_equal '', compile_inline('@<raw>{|latex, html|body}')
1172
- end
1173
-
1174
- def test_inline_raw4
1175
- assert_equal '|idgxml body', compile_inline('@<raw>{|idgxml body}')
1176
- end
1177
-
1178
- def test_inline_raw5
1179
- assert_equal "nor\nmal", compile_inline('@<raw>{|idgxml|nor\\nmal}')
1180
- end
1181
-
1182
- def test_inline_imgref
1183
- def @chapter.image(_id)
1184
- item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
1185
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
1186
- item
1187
- end
1188
-
1189
- actual = compile_block("@<imgref>{sampleimg}\n")
1190
- expected = %Q(<p><span type='image'>図1.1「sample photo」</span></p>)
1191
- assert_equal expected, actual
1192
- end
1193
-
1194
- def test_inline_imgref2
1195
- def @chapter.image(_id)
1196
- item = Book::Index::Item.new('sampleimg', 1)
1197
- item.instance_eval { @path = './images/chap1-sampleimg.png' }
1198
- item
1199
- end
1200
-
1201
- actual = compile_block("@<imgref>{sampleimg}\n")
1202
- expected = %Q(<p><span type='image'>図1.1</span></p>)
1203
- assert_equal expected, actual
1204
- end
1205
-
1206
- def test_block_raw0
1207
- actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
1208
- expected = %Q(<>!"\n& )
1209
- assert_equal expected, actual
1210
- end
1211
-
1212
- def test_block_raw1
1213
- actual = compile_block(%Q(//raw[|idgxml|<>!"\\n& ]\n))
1214
- expected = %Q(<>!"\n& )
1215
- assert_equal expected, actual
1216
- end
1217
-
1218
- def test_block_raw2
1219
- actual = compile_block(%Q(//raw[|idgxml, latex|<>!"\\n& ]\n))
1220
- expected = %Q(<>!"\n& )
1221
- assert_equal expected, actual
1222
- end
1223
-
1224
- def test_block_raw3
1225
- actual = compile_block(%Q(//raw[|latex, html|<>!"\\n& ]\n))
1226
- expected = ''
1227
- assert_equal expected, actual
1228
- end
1229
-
1230
- def test_block_raw4
1231
- actual = compile_block(%Q(//raw[|idgxml <>!"\\n& ]\n))
1232
- expected = %Q(|idgxml <>!"\n& )
1233
- assert_equal expected.chomp, actual
1234
- end
1235
-
1236
- def test_comment
1237
- actual = compile_block('//comment[コメント]')
1238
- assert_equal '', actual
1239
- end
1240
-
1241
- def test_comment_for_draft
1242
- @config['draft'] = true
1243
- actual = compile_block('//comment[コメント<]')
1244
- assert_equal '<msg>コメント&lt;</msg>', actual
1245
- actual = compile_block("//comment{\nA<>\nB&\n//}")
1246
- assert_equal %Q(<msg>A&lt;&gt;\nB&amp;</msg>), actual
1247
- end
1248
-
1249
- def test_inline_comment
1250
- actual = compile_inline('test @<comment>{コメント} test2')
1251
- assert_equal 'test test2', actual
1252
- end
1253
-
1254
- def test_inline_comment_for_draft
1255
- @config['draft'] = true
1256
- actual = compile_inline('test @<comment>{コメント} test2')
1257
- assert_equal 'test <msg>コメント</msg> test2', actual
1258
- end
1259
-
1260
- def test_texequation
1261
- src = <<-EOS
1262
- //texequation{
1263
- e=mc^2
1264
- //}
1265
- EOS
1266
- expected = %Q(<replace idref="texblock-1"><pre>e=mc^2</pre></replace>)
1267
- actual = compile_block(src)
1268
- assert_equal expected, actual
1269
- end
1270
-
1271
- def test_texequation_with_caption
1272
- src = <<-EOS
1273
- @<eq>{emc2}
1274
-
1275
- //texequation[emc2][The Equivalence of Mass @<i>{and} Energy]{
1276
- e=mc^2
1277
- //}
1278
- EOS
1279
- expected = %Q(<p><span type='eq'>式1.1</span></p><equationblock><caption>式1.1 The Equivalence of Mass <i>and</i> Energy</caption><replace idref="texblock-1"><pre>e=mc^2</pre></replace></equationblock>)
1280
- actual = compile_block(src)
1281
- assert_equal expected, actual
1282
-
1283
- @config['caption_position']['equation'] = 'bottom'
1284
- expected = %Q(<p><span type='eq'>式1.1</span></p><equationblock><replace idref="texblock-1"><pre>e=mc^2</pre></replace><caption>式1.1 The Equivalence of Mass <i>and</i> Energy</caption></equationblock>)
1285
- actual = compile_block(src)
1286
- assert_equal expected, actual
1287
- end
1288
-
1289
- def test_nest_error_close1
1290
- src = <<-EOS
1291
- //beginchild
1292
- EOS
1293
- e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1294
- assert_equal ":1: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
1295
- end
1296
-
1297
- def test_nest_error_close2
1298
- src = <<-EOS
1299
- * foo
1300
-
1301
- //beginchild
1302
-
1303
- 1. foo
1304
-
1305
- //beginchild
1306
-
1307
- : foo
1308
-
1309
- //beginchild
1310
- EOS
1311
- e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1312
- assert_equal ':12: //beginchild of dl,ol,ul misses //endchild', e.message
1313
- end
1314
-
1315
- def test_nest_error_close3
1316
- src = <<-EOS
1317
- * foo
1318
-
1319
- //beginchild
1320
-
1321
- 1. foo
1322
-
1323
- //beginchild
1324
-
1325
- : foo
1326
-
1327
- //beginchild
1328
-
1329
- //endchild
1330
- EOS
1331
- e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1332
- assert_equal ':14: //beginchild of ol,ul misses //endchild', e.message
1333
- end
1334
-
1335
- def test_nest_ul
1336
- src = <<-EOS
1337
- * UL1
1338
-
1339
- //beginchild
1340
-
1341
- 1. UL1-OL1
1342
- 2. UL1-OL2
1343
-
1344
- * UL1-UL1
1345
- * UL1-UL2
1346
-
1347
- : UL1-DL1
1348
- UL1-DD1
1349
- : UL1-DL2
1350
- UL1-DD2
1351
-
1352
- //endchild
1353
-
1354
- * UL2
1355
-
1356
- //beginchild
1357
-
1358
- UL2-PARA
1359
-
1360
- //endchild
1361
- EOS
1362
-
1363
- expected = <<-EOS.chomp
1364
- <ul><li aid:pstyle="ul-item">UL1<ol><li aid:pstyle="ol-item" olnum="1" num="1">UL1-OL1</li><li aid:pstyle="ol-item" olnum="2" num="2">UL1-OL2</li></ol><ul><li aid:pstyle="ul-item">UL1-UL1</li><li aid:pstyle="ul-item">UL1-UL2</li></ul><dl><dt>UL1-DL1</dt><dd>UL1-DD1</dd><dt>UL1-DL2</dt><dd>UL1-DD2</dd></dl></li><li aid:pstyle="ul-item">UL2<p>UL2-PARA</p></li></ul>
1365
- EOS
1366
-
1367
- actual = compile_block(src)
1368
- assert_equal expected, actual
1369
- end
1370
-
1371
- def test_nest_ol
1372
- src = <<-EOS
1373
- 1. OL1
1374
-
1375
- //beginchild
1376
-
1377
- 1. OL1-OL1
1378
- 2. OL1-OL2
1379
-
1380
- * OL1-UL1
1381
- * OL1-UL2
1382
-
1383
- : OL1-DL1
1384
- OL1-DD1
1385
- : OL1-DL2
1386
- OL1-DD2
1387
-
1388
- //endchild
1389
-
1390
- 2. OL2
1391
-
1392
- //beginchild
1393
-
1394
- OL2-PARA
1395
-
1396
- //endchild
1397
- EOS
1398
-
1399
- expected = <<-EOS.chomp
1400
- <ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1<ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1-OL1</li><li aid:pstyle="ol-item" olnum="2" num="2">OL1-OL2</li></ol><ul><li aid:pstyle="ul-item">OL1-UL1</li><li aid:pstyle="ul-item">OL1-UL2</li></ul><dl><dt>OL1-DL1</dt><dd>OL1-DD1</dd><dt>OL1-DL2</dt><dd>OL1-DD2</dd></dl></li><li aid:pstyle="ol-item" olnum="1" num="2">OL2<p>OL2-PARA</p></li></ol>
1401
- EOS
1402
-
1403
- actual = compile_block(src)
1404
- assert_equal expected, actual
1405
- end
1406
-
1407
- def test_nest_dl
1408
- src = <<-EOS
1409
- : DL1
1410
-
1411
- //beginchild
1412
-
1413
- 1. DL1-OL1
1414
- 2. DL1-OL2
1415
-
1416
- * DL1-UL1
1417
- * DL1-UL2
1418
-
1419
- : DL1-DL1
1420
- DL1-DD1
1421
- : DL1-DL2
1422
- DL1-DD2
1423
-
1424
- //endchild
1425
-
1426
- : DL2
1427
- DD2
1428
-
1429
- //beginchild
1430
-
1431
- * DD2-UL1
1432
- * DD2-UL2
1433
-
1434
- DD2-PARA
1435
-
1436
- //endchild
1437
- EOS
1438
-
1439
- expected = <<-EOS.chomp
1440
- <dl><dt>DL1</dt><dd><ol><li aid:pstyle="ol-item" olnum="1" num="1">DL1-OL1</li><li aid:pstyle="ol-item" olnum="2" num="2">DL1-OL2</li></ol><ul><li aid:pstyle="ul-item">DL1-UL1</li><li aid:pstyle="ul-item">DL1-UL2</li></ul><dl><dt>DL1-DL1</dt><dd>DL1-DD1</dd><dt>DL1-DL2</dt><dd>DL1-DD2</dd></dl></dd><dt>DL2</dt><dd>DD2<ul><li aid:pstyle="ul-item">DD2-UL1</li><li aid:pstyle="ul-item">DD2-UL2</li></ul><p>DD2-PARA</p></dd></dl>
1441
- EOS
1442
-
1443
- actual = compile_block(src)
1444
- assert_equal expected, actual
1445
- end
1446
-
1447
- def test_nest_multi
1448
- src = <<-EOS
1449
- 1. OL1
1450
-
1451
- //beginchild
1452
-
1453
- 1. OL1-OL1
1454
-
1455
- //beginchild
1456
-
1457
- * OL1-OL1-UL1
1458
-
1459
- OL1-OL1-PARA
1460
-
1461
- //endchild
1462
-
1463
- 2. OL1-OL2
1464
-
1465
- * OL1-UL1
1466
-
1467
- //beginchild
1468
-
1469
- : OL1-UL1-DL1
1470
- OL1-UL1-DD1
1471
-
1472
- OL1-UL1-PARA
1473
-
1474
- //endchild
1475
-
1476
- * OL1-UL2
1477
-
1478
- //endchild
1479
- EOS
1480
- expected = <<-EOS.chomp
1481
- <ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1<ol><li aid:pstyle="ol-item" olnum="1" num="1">OL1-OL1<ul><li aid:pstyle="ul-item">OL1-OL1-UL1</li></ul><p>OL1-OL1-PARA</p></li><li aid:pstyle="ol-item" olnum="1" num="2">OL1-OL2</li></ol><ul><li aid:pstyle="ul-item">OL1-UL1<dl><dt>OL1-UL1-DL1</dt><dd>OL1-UL1-DD1</dd></dl><p>OL1-UL1-PARA</p></li><li aid:pstyle="ul-item">OL1-UL2</li></ul></li></ol>
1482
- EOS
1483
-
1484
- actual = compile_block(src)
1485
- assert_equal expected, actual
1486
- end
1487
- end