review 5.6.0 → 5.8.0

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