review-peg 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/.rubocop.yml +47 -0
  4. data/.rubocop_todo.yml +605 -0
  5. data/.travis.yml +18 -0
  6. data/COPYING +515 -0
  7. data/ChangeLog +2449 -0
  8. data/Dockerfile +22 -0
  9. data/Gemfile +6 -0
  10. data/README.rdoc +81 -0
  11. data/Rakefile +51 -0
  12. data/bin/review-catalog-converter-peg +129 -0
  13. data/bin/review-check-peg +169 -0
  14. data/bin/review-checkdep-peg +63 -0
  15. data/bin/review-compile-peg +202 -0
  16. data/bin/review-epubmaker-legacy-peg +1024 -0
  17. data/bin/review-epubmaker-peg +44 -0
  18. data/bin/review-index-peg +110 -0
  19. data/bin/review-init-peg +151 -0
  20. data/bin/review-pdfmaker-peg +18 -0
  21. data/bin/review-preproc-peg +131 -0
  22. data/bin/review-validate-peg +51 -0
  23. data/bin/review-vol-peg +100 -0
  24. data/debian/README.Debian +12 -0
  25. data/debian/README.source +5 -0
  26. data/debian/changelog +5 -0
  27. data/debian/compat +1 -0
  28. data/debian/control +22 -0
  29. data/debian/copyright +62 -0
  30. data/debian/docs +6 -0
  31. data/debian/manpage.1.ex +59 -0
  32. data/debian/patches/path.diff +91 -0
  33. data/debian/patches/series +1 -0
  34. data/debian/review.install +13 -0
  35. data/debian/review.links +4 -0
  36. data/debian/rules +13 -0
  37. data/debian/source/format +1 -0
  38. data/doc/NEWS.ja.md +350 -0
  39. data/doc/NEWS.md +354 -0
  40. data/doc/catalog.ja.md +53 -0
  41. data/doc/catalog.md +52 -0
  42. data/doc/format.ja.md +734 -0
  43. data/doc/format.md +746 -0
  44. data/doc/format_idg.ja.md +203 -0
  45. data/doc/quickstart.ja.md +222 -0
  46. data/doc/quickstart.md +252 -0
  47. data/doc/ruby-uuid/README +11 -0
  48. data/doc/ruby-uuid/README.ja +34 -0
  49. data/doc/sample.css +108 -0
  50. data/doc/sample.yml +238 -0
  51. data/lib/epubmaker.rb +24 -0
  52. data/lib/epubmaker/content.rb +93 -0
  53. data/lib/epubmaker/epubcommon.rb +424 -0
  54. data/lib/epubmaker/epubv2.rb +139 -0
  55. data/lib/epubmaker/epubv3.rb +222 -0
  56. data/lib/epubmaker/producer.rb +330 -0
  57. data/lib/lineinput.rb +107 -0
  58. data/lib/review.rb +3 -0
  59. data/lib/review/book.rb +43 -0
  60. data/lib/review/book/base.rb +401 -0
  61. data/lib/review/book/chapter.rb +100 -0
  62. data/lib/review/book/compilable.rb +184 -0
  63. data/lib/review/book/image_finder.rb +71 -0
  64. data/lib/review/book/index.rb +413 -0
  65. data/lib/review/book/page_metric.rb +47 -0
  66. data/lib/review/book/part.rb +54 -0
  67. data/lib/review/book/volume.rb +67 -0
  68. data/lib/review/builder.rb +452 -0
  69. data/lib/review/catalog.rb +52 -0
  70. data/lib/review/compiler.rb +5183 -0
  71. data/lib/review/compiler/literals_1_9.kpeg +22 -0
  72. data/lib/review/compiler/literals_1_9.rb +435 -0
  73. data/lib/review/configure.rb +64 -0
  74. data/lib/review/epubbuilder.rb +18 -0
  75. data/lib/review/epubmaker.rb +480 -0
  76. data/lib/review/ewbbuilder.rb +381 -0
  77. data/lib/review/exception.rb +21 -0
  78. data/lib/review/extentions.rb +4 -0
  79. data/lib/review/extentions/array.rb +25 -0
  80. data/lib/review/extentions/object.rb +9 -0
  81. data/lib/review/extentions/string.rb +33 -0
  82. data/lib/review/htmlbuilder.rb +1166 -0
  83. data/lib/review/htmllayout.rb +41 -0
  84. data/lib/review/htmltoc.rb +45 -0
  85. data/lib/review/htmlutils.rb +90 -0
  86. data/lib/review/i18n.rb +96 -0
  87. data/lib/review/i18n.yml +169 -0
  88. data/lib/review/idgxmlbuilder.rb +1233 -0
  89. data/lib/review/inaobuilder.rb +357 -0
  90. data/lib/review/latexbuilder.rb +941 -0
  91. data/lib/review/latexindex.rb +35 -0
  92. data/lib/review/latexutils.rb +95 -0
  93. data/lib/review/layout.tex.erb +340 -0
  94. data/lib/review/lineinput.rb +17 -0
  95. data/lib/review/location.rb +24 -0
  96. data/lib/review/makerhelper.rb +67 -0
  97. data/lib/review/markdownbuilder.rb +339 -0
  98. data/lib/review/node.rb +288 -0
  99. data/lib/review/pdfmaker.rb +332 -0
  100. data/lib/review/preprocessor.rb +530 -0
  101. data/lib/review/review.kpeg +745 -0
  102. data/lib/review/sec_counter.rb +69 -0
  103. data/lib/review/template.rb +21 -0
  104. data/lib/review/textbuilder.rb +17 -0
  105. data/lib/review/textutils.rb +16 -0
  106. data/lib/review/tocparser.rb +348 -0
  107. data/lib/review/tocprinter.rb +205 -0
  108. data/lib/review/topbuilder.rb +796 -0
  109. data/lib/review/unfold.rb +138 -0
  110. data/lib/review/version.rb +3 -0
  111. data/lib/uuid.rb +312 -0
  112. data/review.gemspec +32 -0
  113. data/templates/html/layout-html5.html.erb +17 -0
  114. data/templates/html/layout-xhtml1.html.erb +20 -0
  115. data/templates/ncx/epubv2.ncx.erb +11 -0
  116. data/templates/opf/epubv2.opf.erb +21 -0
  117. data/templates/opf/epubv3.opf.erb +18 -0
  118. data/templates/xml/container.xml.erb +6 -0
  119. data/test/CHAPS +2 -0
  120. data/test/assets/test.xml.erb +3 -0
  121. data/test/assets/test_template.tex +255 -0
  122. data/test/assets/test_template_backmatter.tex +32 -0
  123. data/test/bib.re +13 -0
  124. data/test/book_test_helper.rb +35 -0
  125. data/test/sample-book/README.md +7 -0
  126. data/test/sample-book/src/Rakefile +58 -0
  127. data/test/sample-book/src/_cover.html +3 -0
  128. data/test/sample-book/src/catalog.yml +10 -0
  129. data/test/sample-book/src/ch01.re +71 -0
  130. data/test/sample-book/src/ch02.re +3 -0
  131. data/test/sample-book/src/config.yml +186 -0
  132. data/test/sample-book/src/images/ch01-imgsample.jpg +0 -0
  133. data/test/sample-book/src/images/cover.jpg +0 -0
  134. data/test/sample-book/src/preface.re +15 -0
  135. data/test/sample-book/src/sty/jumoline.sty +310 -0
  136. data/test/sample-book/src/sty/reviewmacro.sty +39 -0
  137. data/test/sample-book/src/style.css +251 -0
  138. data/test/sample-book/src/vendor/jumoline/README +29 -0
  139. data/test/sample-book/src/vendor/jumoline/jumoline.dtx +2988 -0
  140. data/test/sample-book/src/vendor/jumoline/jumoline.ins +6 -0
  141. data/test/test.re +43 -0
  142. data/test/test_book.rb +556 -0
  143. data/test/test_book_chapter.rb +280 -0
  144. data/test/test_book_part.rb +54 -0
  145. data/test/test_builder.rb +80 -0
  146. data/test/test_catalog.rb +119 -0
  147. data/test/test_catalog_converter_cmd.rb +73 -0
  148. data/test/test_compiler.rb +92 -0
  149. data/test/test_configure.rb +50 -0
  150. data/test/test_epub3maker.rb +529 -0
  151. data/test/test_epubmaker.rb +569 -0
  152. data/test/test_epubmaker_cmd.rb +40 -0
  153. data/test/test_helper.rb +92 -0
  154. data/test/test_htmlbuilder.rb +1114 -0
  155. data/test/test_htmltoc.rb +32 -0
  156. data/test/test_htmlutils.rb +50 -0
  157. data/test/test_i18n.rb +180 -0
  158. data/test/test_idgxmlbuilder.rb +608 -0
  159. data/test/test_image_finder.rb +82 -0
  160. data/test/test_inaobuilder.rb +245 -0
  161. data/test/test_index.rb +174 -0
  162. data/test/test_latexbuilder.rb +732 -0
  163. data/test/test_lineinput.rb +182 -0
  164. data/test/test_makerhelper.rb +66 -0
  165. data/test/test_markdownbuilder.rb +125 -0
  166. data/test/test_pdfmaker.rb +171 -0
  167. data/test/test_pdfmaker_cmd.rb +40 -0
  168. data/test/test_preprocessor.rb +23 -0
  169. data/test/test_review_ext.rb +31 -0
  170. data/test/test_template.rb +26 -0
  171. data/test/test_textutils.rb +32 -0
  172. data/test/test_topbuilder.rb +291 -0
  173. data/test/test_uuid.rb +157 -0
  174. metadata +357 -0
@@ -0,0 +1,82 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test_helper'
3
+ require 'review'
4
+ require 'review/book/image_finder'
5
+ require 'fileutils'
6
+
7
+ class ImageFinderTest < Test::Unit::TestCase
8
+ include ReVIEW
9
+
10
+ def setup
11
+ end
12
+
13
+ def test_find_path_pattern1
14
+ dir = Dir.mktmpdir
15
+ begin
16
+ path = dir+"/builder/ch01/foo.jpg"
17
+ FileUtils.mkdir_p(File.dirname(path))
18
+ FileUtils.touch(path)
19
+
20
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
21
+ assert_equal(path, finder.find_path("foo"))
22
+ ensure
23
+ FileUtils.remove_entry_secure dir
24
+ end
25
+ end
26
+
27
+ def test_find_path_pattern2
28
+ dir = Dir.mktmpdir
29
+ begin
30
+ path = dir+"/builder/ch01-foo.jpg"
31
+ FileUtils.mkdir_p(File.dirname(path))
32
+ FileUtils.touch(path)
33
+
34
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
35
+ assert_equal(path, finder.find_path("foo"))
36
+ ensure
37
+ FileUtils.remove_entry_secure dir
38
+ end
39
+ end
40
+
41
+ def test_find_path_pattern3
42
+ dir = Dir.mktmpdir
43
+ begin
44
+ path = dir+"/builder/foo.jpg"
45
+ FileUtils.mkdir_p(File.dirname(path))
46
+ FileUtils.touch(path)
47
+
48
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
49
+ assert_equal(path, finder.find_path("foo"))
50
+ ensure
51
+ FileUtils.remove_entry_secure dir
52
+ end
53
+ end
54
+
55
+ def test_find_path_pattern4
56
+ dir = Dir.mktmpdir
57
+ begin
58
+ path = dir+"/ch01/foo.jpg"
59
+ FileUtils.mkdir_p(File.dirname(path))
60
+ FileUtils.touch(path)
61
+
62
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
63
+ assert_equal(path, finder.find_path("foo"))
64
+ ensure
65
+ FileUtils.remove_entry_secure dir
66
+ end
67
+ end
68
+
69
+ def test_find_path_pattern5
70
+ dir = Dir.mktmpdir
71
+ begin
72
+ path = dir+"/ch01-foo.jpg"
73
+ FileUtils.mkdir_p(File.dirname(path))
74
+ FileUtils.touch(path)
75
+
76
+ finder = ReVIEW::Book::ImageFinder.new(dir, "ch01", "builder", [".jpg"])
77
+ assert_equal(path, finder.find_path("foo"))
78
+ ensure
79
+ FileUtils.remove_entry_secure dir
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,245 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test_helper'
3
+ require 'book_test_helper'
4
+ require 'review'
5
+
6
+ class INAOBuidlerTest < Test::Unit::TestCase
7
+ include ReVIEW
8
+ include BookTestHelper
9
+
10
+ def setup
11
+ @param = {
12
+ "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
13
+ "stylesheet" => nil, # for HTMLBuilder
14
+ }
15
+ end
16
+
17
+ def test_all
18
+ compiler = Compiler.new(INAOBuilder.new)
19
+ mktmpbookdir do |dir, book, files|
20
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
21
+ chapter.content = <<-EOS
22
+ = 見出し1(大見出し、節)
23
+ == 見出し2(中見出し、項)
24
+ === 見出し3(小見出し、目)
25
+ 段落冒頭の字下げは、自動で行われます。
26
+ 改行は、(改行)
27
+ このように自動で取り除かれます。
28
+
29
+ 通常の本文@<b>{強調(ボールド)}通常の本文@<i>{斜体(イタリック)}通常の本文@<tt>{インラインのコード}通常の本文@<fn>{1}通常の本文@<kbd>{Enter}(←キーボードフォント)通常の本文@<ruby>{外村,ほかむら}(←ルビ)。
30
+
31
+ //footnote[1][脚注]
32
+
33
+ //quote{
34
+ 引用です
35
+ //}
36
+
37
+ ====[column]コラム見出し
38
+ 本文コラム
39
+
40
+ ===== コラム小見出し
41
+ 本文コラム
42
+
43
+ ====[/column]
44
+
45
+ == 箇条書き
46
+ === 通常の箇条書き
47
+ * 連番箇条書き
48
+ * 連番箇条書き
49
+ === 連番箇条書き
50
+ 1. 連番箇条書き
51
+ 2. 連番箇条書き
52
+
53
+ == コマンド
54
+ //cmd[コマンドのタイトル]{
55
+ $ command foo
56
+ //}
57
+
58
+ === 本文埋め込みコマンド(本文埋め込み版はWEB+DB PRESSでは未使用)
59
+ //cmd{
60
+ $ command foo
61
+ //}
62
+
63
+ == 表
64
+ //table[id][表のタイトル]{
65
+ 項目1 項目2
66
+ -------------
67
+ 内容1 内容2
68
+ 内容1 内容2
69
+ //}
70
+
71
+ EOS
72
+
73
+ expected = <<-EOS
74
+ ■見出し1(大見出し、節)
75
+ ■■見出し2(中見出し、項)
76
+ ■■■見出し3(小見出し、目)
77
+  段落冒頭の字下げは、自動で行われます。改行は、(改行)このように自動で取り除かれます。
78
+  通常の本文◆b/◆強調(ボールド)◆/b◆通常の本文◆i/◆斜体(イタリック)◆/i◆通常の本文◆cmd/◆インラインのコード◆/cmd◆通常の本文◆注/◆脚注◆/注◆通常の本文Enter▲(←キーボードフォント)通常の本文◆ルビ/◆外村◆ほかむら◆/ルビ◆(←ルビ)。
79
+ ◆quote/◆
80
+ 引用です
81
+ ◆/quote◆
82
+
83
+ ◆column/◆
84
+ ■■■■コラム見出し
85
+  本文コラム
86
+ ■■■■■コラム小見出し
87
+  本文コラム
88
+ ◆/column◆
89
+ ■■箇条書き
90
+ ■■■通常の箇条書き
91
+ ・連番箇条書き
92
+ ・連番箇条書き
93
+ ■■■連番箇条書き
94
+ (1)連番箇条書き
95
+ (2)連番箇条書き
96
+ ■■コマンド
97
+ ◆list-white/◆
98
+ ●コマンドのタイトル
99
+ $ command foo
100
+ ◆/list-white◆
101
+ ■■■本文埋め込みコマンド(本文埋め込み版はWEB+DB PRESSでは未使用)
102
+ ◆list-white/◆
103
+ $ command foo
104
+ ◆/list-white◆
105
+ ■■表
106
+ ◆table/◆
107
+ ●表1.1 表のタイトル
108
+ ◆table-title◆項目1 項目2
109
+ 内容1 内容2
110
+ 内容1 内容2
111
+ ◆/table◆
112
+ EOS
113
+ assert_equal expected, compiler.compile(chapter)
114
+ end
115
+ end
116
+
117
+ def test_list
118
+ compiler = Compiler.new(INAOBuilder.new)
119
+ mktmpbookdir do |dir, book, files|
120
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
121
+ chapter.content = <<-EOS
122
+ == リスト
123
+ @<list>{id}
124
+ //list[id][キャプション(コードのタイトル)]{
125
+ function hoge() {
126
+ alert(foo);
127
+ alert(bar);
128
+ }
129
+ //}
130
+
131
+ === 本文埋め込みリスト
132
+ 本文中で流れでコードを掲載するときに使用します。
133
+
134
+ //emlist{
135
+ function hoge() {
136
+ alert(foo);@<comment>{こんな風にコメントがつけられます}
137
+ }
138
+ //}
139
+
140
+ このように、上下に本文が入ります。
141
+
142
+ 本文から一連の流れで読んでもらうことができますが、コードがページをまたぐ可能性がございます。
143
+ EOS
144
+ expected = <<-EOS
145
+ ■■リスト
146
+  リスト1.1
147
+ ◆list/◆
148
+ ●リスト1.1 キャプション(コードのタイトル)
149
+ function hoge() {
150
+ alert(foo);
151
+ alert(bar);
152
+ }
153
+ ◆/list◆
154
+ ■■■本文埋め込みリスト
155
+  本文中で流れでコードを掲載するときに使用します。
156
+ ◆list/◆
157
+ function hoge() {
158
+ alert(foo);◆comment/◆こんな風にコメントがつけられます◆/comment◆
159
+ }
160
+ ◆/list◆
161
+  このように、上下に本文が入ります。
162
+  本文から一連の流れで読んでもらうことができますが、コードがページをまたぐ可能性がございます。
163
+ EOS
164
+ assert_equal expected, compiler.compile(chapter)
165
+ end
166
+ end
167
+
168
+ def test_image
169
+ compiler = Compiler.new(INAOBuilder.new)
170
+ mktmpbookdir do |dir, book, files|
171
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
172
+ chapter.content = <<-EOS
173
+ = 図
174
+ @<img>{id}
175
+ //image[id][図のタイトル]{
176
+ ダミー
177
+ //}
178
+ EOS
179
+ expected = <<-EOS
180
+ ■図
181
+  図1.1
182
+ ●図1.1 図のタイトル
183
+ ダミー
184
+ EOS
185
+ assert_equal expected, compiler.compile(chapter)
186
+ end
187
+ end
188
+
189
+ def test_table
190
+ compiler = Compiler.new(INAOBuilder.new)
191
+ mktmpbookdir do |dir, book, files|
192
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
193
+ chapter.content = <<-EOS
194
+ == 表
195
+ @<table>{id}
196
+ //table[id][表のタイトル]{
197
+ 項目1 項目2
198
+ -------------
199
+ 内容1 内容2
200
+ 内容1 内容2
201
+ //}
202
+ EOS
203
+ expected = <<-EOS
204
+ ■■表
205
+  表1.1
206
+ ◆table/◆
207
+ ●表1.1 表のタイトル
208
+ ◆table-title◆項目1 項目2
209
+ 内容1 内容2
210
+ 内容1 内容2
211
+ ◆/table◆
212
+ EOS
213
+ assert_equal expected, compiler.compile(chapter)
214
+ end
215
+ end
216
+
217
+ def test_listnum
218
+ compiler = Compiler.new(INAOBuilder.new)
219
+ mktmpbookdir do |dir, book, files|
220
+ chapter = Book::Chapter.new(book, 1, "chap1", nil, StringIO.new)
221
+ chapter.content = <<-EOS
222
+ == リスト
223
+ @<list>{id}
224
+ //listnum[id][キャプション(コードのタイトル)]{
225
+ function hoge() {
226
+ alert(foo);
227
+ alert(bar);
228
+ }
229
+ //}
230
+ EOS
231
+ expected = <<-EOS
232
+ ■■リスト
233
+  リスト1.1
234
+ ◆list/◆
235
+ ●リスト1.1 キャプション(コードのタイトル)
236
+ 1 function hoge() {
237
+ 2 alert(foo);
238
+ 3 alert(bar);
239
+ 4 }
240
+ ◆/list◆
241
+ EOS
242
+ assert_equal expected, compiler.compile(chapter)
243
+ end
244
+ end
245
+ end
@@ -0,0 +1,174 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+ require 'review/book'
5
+ require 'review/book/index'
6
+
7
+ class IndexTest < Test::Unit::TestCase
8
+ include ReVIEW
9
+ def test_footnote_index
10
+ fn = Book::FootnoteIndex.parse(['//footnote[foo][bar]'])
11
+ items = fn.to_a
12
+ item = items[0]
13
+ assert_equal 'foo', item.id
14
+ assert_equal 'bar', item.content
15
+ end
16
+ def test_footnote_index_with_escape
17
+ fn = Book::FootnoteIndex.parse(['//footnote[foo][bar[\]buz]'])
18
+ items = fn.to_a
19
+ item = items[0]
20
+ assert_equal 'foo', item.id
21
+ assert_equal 'bar[]buz', item.content
22
+ end
23
+ def test_footnote_index_with_escape2
24
+ fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
25
+ items = fn.to_a
26
+ item = items[0]
27
+ assert_equal 'foo', item.id
28
+ assert_equal 'bar\\a\\$buz', item.content
29
+ end
30
+
31
+ def test_HeadelineIndex
32
+ src = <<-EOB
33
+ = chap1
34
+ == sec1-1
35
+ == sec1-2
36
+ === sec1-2-1
37
+ ===[column] column1
38
+ ==== inside_column
39
+ ===[/column]
40
+ ===[column] column2
41
+ === sec1-2-2
42
+ == sec1-3
43
+ ==== sec1-3-0-1
44
+ EOB
45
+ book = Book::Base.load
46
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
47
+ index = Book::HeadlineIndex.parse(src, chap)
48
+ assert_equal [2,2], index['sec1-2|sec1-2-2'].number
49
+ assert_equal "1.2.2", index.number('sec1-2|sec1-2-2')
50
+ end
51
+
52
+ def test_HeadelineIndex2
53
+ src = <<-EOB
54
+ = chap1
55
+ == sec1-1
56
+ == sec1-2
57
+ === sec1-2-1
58
+ ===[column] column1
59
+ == sec1-3
60
+ === sec1-3-1
61
+ EOB
62
+ book = Book::Base.load
63
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
64
+ index = Book::HeadlineIndex.parse(src, chap)
65
+ assert_equal [3,1], index['sec1-3|sec1-3-1'].number
66
+ assert_equal "1.3.1", index.number('sec1-3|sec1-3-1')
67
+ end
68
+
69
+ def test_HeadelineIndex3
70
+ src = <<-EOB
71
+ = chap1
72
+ == sec1-1
73
+ == sec1-2
74
+ === sec1-2-1
75
+ ===[column] column1
76
+ === sec1-2-2
77
+ == sec1-3
78
+ === sec1-3-1
79
+ EOB
80
+ book = Book::Base.load
81
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
82
+ index = Book::HeadlineIndex.parse(src, chap)
83
+ assert_equal [2,2], index['sec1-2|sec1-2-2'].number
84
+ assert_equal "1.2.2", index.number('sec1-2|sec1-2-2')
85
+
86
+ assert_equal [3,1], index['sec1-3|sec1-3-1'].number
87
+ assert_equal "1.3.1", index.number('sec1-3|sec1-3-1')
88
+ end
89
+
90
+ def test_HeadelineIndex4
91
+ src = <<-EOB
92
+ = chap1
93
+ ====[column] c1
94
+ == sec1-1
95
+ == sec1-2
96
+ === sec1-2-1
97
+ === sec1-2-2
98
+ EOB
99
+ book = Book::Base.load
100
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
101
+ index = Book::HeadlineIndex.parse(src, chap)
102
+ assert_equal [2,2], index['sec1-2|sec1-2-2'].number
103
+ assert_equal "1.2.2", index.number('sec1-2|sec1-2-2')
104
+ end
105
+
106
+ def test_HeadelineIndex5
107
+ src = <<-EOB
108
+ = chap1
109
+ ====[column] c1
110
+ == sec1-1
111
+ == sec1-2
112
+ === sec1-2-1
113
+ === sec1-2-2
114
+ EOB
115
+ book = Book::Base.load
116
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
117
+ index = Book::HeadlineIndex.parse(src, chap)
118
+ assert_equal [2,2], index['sec1-2-2'].number
119
+ assert_equal "1.2.2", index.number('sec1-2-2')
120
+ end
121
+
122
+ def test_HeadelineIndex6
123
+ src = <<-EOB
124
+ = chap1
125
+ == sec1
126
+ === target
127
+ == sec2
128
+
129
+ EOB
130
+ book = Book::Base.load
131
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
132
+ index = Book::HeadlineIndex.parse(src, chap)
133
+ assert_equal [1,1], index['target'].number
134
+ assert_equal "1.1.1", index.number('target')
135
+ end
136
+
137
+
138
+ def test_HeadelineIndex7
139
+ src = <<-EOB
140
+ = chap1
141
+ == sec1
142
+ === target
143
+ ^-- dummy target
144
+ == sec2
145
+ === target
146
+ ^-- real target but it cannot be detected, because there is another one.
147
+
148
+ EOB
149
+ book = Book::Base.load
150
+ chap = Book::Chapter.new(book, 1, '-', nil) # dummy
151
+ index = Book::HeadlineIndex.parse(src, chap)
152
+
153
+ assert_raise ReVIEW::KeyError do
154
+ assert_equal [1,1], index['target'].number
155
+ end
156
+ end
157
+
158
+ def test_HeadelineIndex8
159
+ src = <<-EOB
160
+ = chap1
161
+ == sec1
162
+ === sec1-1
163
+ ==== sec1-1-1
164
+
165
+ EOB
166
+ book = Book::Base.load
167
+ chap = Book::Chapter.new(book, 1, '-', nil)
168
+ index = Book::HeadlineIndex.parse(src, chap)
169
+ assert_equal "1.1.1", index.number('sec1-1')
170
+ end
171
+
172
+
173
+ end
174
+