review 3.2.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-tex.yml +31 -0
  3. data/.github/workflows/ruby-win.yml +45 -0
  4. data/.github/workflows/ruby.yml +27 -0
  5. data/.rubocop.yml +167 -42
  6. data/.travis.yml +1 -1
  7. data/Dockerfile +21 -5
  8. data/NEWS.ja.md +428 -1
  9. data/NEWS.md +429 -2
  10. data/README.md +11 -7
  11. data/Rakefile +7 -2
  12. data/appveyor.yml +0 -20
  13. data/bin/review +2 -4
  14. data/bin/review-catalog-converter +5 -5
  15. data/bin/review-check +13 -17
  16. data/bin/review-checkdep +3 -6
  17. data/bin/review-compile +13 -22
  18. data/bin/review-epub2html +1 -4
  19. data/bin/review-epubmaker +3 -4
  20. data/bin/review-idgxmlmaker +14 -0
  21. data/bin/review-index +5 -86
  22. data/bin/review-init +1 -4
  23. data/bin/review-pdfmaker +1 -3
  24. data/bin/review-preproc +11 -13
  25. data/bin/review-textmaker +1 -3
  26. data/bin/review-update +1 -4
  27. data/bin/review-validate +7 -7
  28. data/bin/review-vol +5 -82
  29. data/bin/review-webmaker +1 -3
  30. data/doc/config.yml.sample +67 -16
  31. data/doc/config.yml.sample-simple +4 -3
  32. data/doc/format.ja.md +133 -21
  33. data/doc/format.md +135 -34
  34. data/doc/makeindex.ja.md +2 -2
  35. data/doc/pdfmaker.ja.md +43 -1
  36. data/doc/pdfmaker.md +42 -1
  37. data/doc/quickstart.ja.md +55 -25
  38. data/doc/quickstart.md +47 -17
  39. data/lib/review.rb +1 -1
  40. data/lib/review/book.rb +2 -2
  41. data/lib/review/book/base.rb +89 -90
  42. data/lib/review/book/bib.rb +21 -0
  43. data/lib/review/book/book_unit.rb +158 -0
  44. data/lib/review/book/chapter.rb +51 -29
  45. data/lib/review/book/index.rb +42 -248
  46. data/lib/review/book/index/item.rb +46 -0
  47. data/lib/review/book/page_metric.rb +7 -7
  48. data/lib/review/book/part.rb +45 -10
  49. data/lib/review/book/volume.rb +5 -5
  50. data/lib/review/builder.rb +171 -54
  51. data/lib/review/call_hook.rb +20 -0
  52. data/lib/review/catalog.rb +15 -17
  53. data/lib/review/compiler.rb +240 -102
  54. data/lib/review/configure.rb +101 -12
  55. data/lib/review/converter.rb +1 -1
  56. data/lib/review/epub2html.rb +6 -1
  57. data/lib/review/epubmaker.rb +120 -118
  58. data/lib/review/epubmaker/content.rb +113 -0
  59. data/lib/review/epubmaker/epubcommon.rb +372 -0
  60. data/lib/review/epubmaker/epubv2.rb +178 -0
  61. data/lib/review/epubmaker/epubv3.rb +231 -0
  62. data/lib/review/epubmaker/producer.rb +168 -0
  63. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  64. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  65. data/lib/review/exception.rb +6 -0
  66. data/lib/review/extentions/string.rb +0 -4
  67. data/lib/review/htmlbuilder.rb +147 -149
  68. data/lib/review/htmlutils.rb +10 -14
  69. data/lib/review/i18n.rb +4 -3
  70. data/lib/review/idgxmlbuilder.rb +229 -103
  71. data/lib/review/idgxmlmaker.rb +188 -0
  72. data/lib/review/img_math.rb +245 -0
  73. data/lib/review/index_builder.rb +654 -0
  74. data/lib/review/init-web/finish.html +10 -0
  75. data/lib/review/init-web/index.html +190 -0
  76. data/lib/review/init-web/review-layout-design.js +691 -0
  77. data/lib/review/init.rb +124 -41
  78. data/lib/review/latexbox.rb +58 -0
  79. data/lib/review/latexbuilder.rb +249 -97
  80. data/lib/review/latexutils.rb +9 -1
  81. data/lib/review/lineinput.rb +113 -3
  82. data/lib/review/logger.rb +43 -8
  83. data/lib/review/makerhelper.rb +13 -186
  84. data/lib/review/markdownbuilder.rb +75 -39
  85. data/lib/review/md2inaobuilder.rb +3 -5
  86. data/lib/review/pdfmaker.rb +88 -83
  87. data/lib/review/plaintextbuilder.rb +158 -83
  88. data/lib/review/preprocessor.rb +30 -24
  89. data/lib/review/rstbuilder.rb +58 -39
  90. data/lib/review/sec_counter.rb +14 -0
  91. data/lib/review/template.rb +6 -0
  92. data/lib/review/textmaker.rb +29 -17
  93. data/lib/review/textutils.rb +68 -2
  94. data/lib/review/tocprinter.rb +242 -97
  95. data/lib/review/topbuilder.rb +147 -61
  96. data/lib/review/update.rb +27 -28
  97. data/lib/review/version.rb +1 -1
  98. data/lib/review/volumeprinter.rb +97 -0
  99. data/lib/review/webmaker.rb +36 -35
  100. data/lib/review/webtocprinter.rb +39 -35
  101. data/lib/review/yamlloader.rb +4 -0
  102. data/review.gemspec +8 -5
  103. data/samples/sample-book/README.md +7 -2
  104. data/samples/sample-book/src/.gitignore +154 -0
  105. data/samples/sample-book/src/config-ebook.yml +4 -0
  106. data/samples/sample-book/src/config-epub2.yml +1 -1
  107. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  108. data/samples/sample-book/src/config-jlreq.yml +6 -0
  109. data/samples/sample-book/src/config.yml +3 -3
  110. data/samples/sample-book/src/lib/tasks/review.rake +45 -14
  111. data/samples/sample-book/src/lib/tasks/z01_copy_sty.rake +14 -8
  112. data/samples/syntax-book/Gemfile +1 -1
  113. data/samples/syntax-book/ch01.re +3 -1
  114. data/samples/syntax-book/ch02.re +28 -21
  115. data/samples/syntax-book/ch03.re +4 -7
  116. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  117. data/samples/syntax-book/config-jlreq.yml +5 -0
  118. data/samples/syntax-book/config-print.yml +3 -0
  119. data/samples/syntax-book/config.yml +1 -1
  120. data/samples/syntax-book/images/img3-2.png +0 -0
  121. data/samples/syntax-book/lib/tasks/review.rake +30 -15
  122. data/samples/syntax-book/lib/tasks/z01_copy_sty.rake +14 -8
  123. data/templates/html/_colophon.html.erb +23 -0
  124. data/templates/html/_colophon_history.html.erb +9 -0
  125. data/templates/html/_cover.html.erb +10 -0
  126. data/templates/html/_part_body.html.erb +6 -0
  127. data/templates/html/_titlepage.html.erb +20 -0
  128. data/templates/html/layout-html5.html.erb +6 -0
  129. data/templates/html/layout-xhtml1.html.erb +6 -0
  130. data/templates/latex/config.erb +45 -27
  131. data/templates/latex/layout.tex.erb +1 -0
  132. data/templates/latex/review-jlreq/README.md +3 -1
  133. data/templates/latex/review-jlreq/review-base.sty +124 -37
  134. data/templates/latex/review-jlreq/review-jlreq.cls +29 -22
  135. data/templates/latex/review-jlreq/review-style.sty +9 -1
  136. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  137. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  138. data/templates/latex/review-jsbook/README.md +46 -5
  139. data/templates/latex/review-jsbook/review-base.sty +111 -30
  140. data/templates/latex/review-jsbook/review-jsbook.cls +16 -2
  141. data/templates/latex/review-jsbook/review-style.sty +10 -2
  142. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  143. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  144. data/templates/opf/epubv2.opf.erb +7 -7
  145. data/templates/opf/epubv3.opf.erb +7 -7
  146. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  147. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  148. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  149. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  150. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  151. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  152. data/templates/web/html/layout-html5.html.erb +9 -8
  153. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  154. data/test/assets/header_listener.html +35 -0
  155. data/test/assets/img_math/img1.png +0 -0
  156. data/test/assets/img_math/img2.png +0 -0
  157. data/test/assets/img_math/img3.png +0 -0
  158. data/test/assets/syntax_book_index_detail.txt +58 -0
  159. data/test/assets/test_template.tex +20 -9
  160. data/test/assets/test_template_backmatter.tex +20 -9
  161. data/test/book_test_helper.rb +11 -5
  162. data/test/run_test.rb +1 -1
  163. data/test/test_book.rb +123 -78
  164. data/test/test_book_chapter.rb +99 -56
  165. data/test/test_book_part.rb +3 -3
  166. data/test/test_builder.rb +24 -15
  167. data/test/test_catalog.rb +19 -42
  168. data/test/test_catalog_converter_cmd.rb +1 -1
  169. data/test/test_converter.rb +1 -0
  170. data/test/test_epub3maker.rb +170 -126
  171. data/test/test_epubmaker.rb +249 -129
  172. data/test/test_epubmaker_cmd.rb +16 -9
  173. data/test/test_helper.rb +23 -11
  174. data/test/test_htmlbuilder.rb +1083 -114
  175. data/test/test_htmlutils.rb +0 -12
  176. data/test/test_i18n.rb +37 -37
  177. data/test/test_idgxmlbuilder.rb +627 -27
  178. data/test/test_idgxmlmaker_cmd.rb +50 -0
  179. data/test/test_image_finder.rb +52 -70
  180. data/test/test_img_math.rb +111 -0
  181. data/test/test_index.rb +62 -52
  182. data/test/test_indexbuilder.rb +52 -0
  183. data/test/test_latexbuilder.rb +1189 -59
  184. data/test/test_latexbuilder_v2.rb +74 -34
  185. data/test/test_lineinput.rb +20 -93
  186. data/test/test_logger.rb +17 -4
  187. data/test/test_makerhelper.rb +2 -14
  188. data/test/test_markdownbuilder.rb +77 -4
  189. data/test/test_md2inaobuilder.rb +12 -2
  190. data/test/test_pdfmaker.rb +101 -12
  191. data/test/test_pdfmaker_cmd.rb +102 -8
  192. data/test/test_plaintextbuilder.rb +562 -31
  193. data/test/test_review_ext.rb +2 -1
  194. data/test/test_reviewheaderlistener.rb +49 -0
  195. data/test/test_rstbuilder.rb +58 -5
  196. data/test/test_sec_counter.rb +156 -0
  197. data/test/test_template.rb +12 -2
  198. data/test/test_textmaker_cmd.rb +58 -0
  199. data/test/test_textutils.rb +109 -2
  200. data/test/test_tocprinter.rb +46 -0
  201. data/test/test_topbuilder.rb +400 -17
  202. data/test/test_update.rb +53 -44
  203. data/test/test_webtocprinter.rb +75 -43
  204. data/test/test_yamlloader.rb +13 -0
  205. data/test/test_zip_exporter.rb +5 -6
  206. data/vendor/gentombow/LICENSE +1 -1
  207. data/vendor/gentombow/Makefile +0 -1
  208. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  209. data/vendor/gentombow/bounddvi-en.tex +1 -0
  210. data/vendor/gentombow/bounddvi.pdf +0 -0
  211. data/vendor/gentombow/bounddvi.sty +30 -7
  212. data/vendor/gentombow/bounddvi.tex +1 -0
  213. data/vendor/gentombow/create_archive.sh +1 -0
  214. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  215. data/vendor/gentombow/gentombow-ja.tex +9 -0
  216. data/vendor/gentombow/gentombow.pdf +0 -0
  217. data/vendor/gentombow/gentombow.sty +32 -10
  218. data/vendor/gentombow/gentombow.tex +8 -0
  219. data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
  220. data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
  221. data/vendor/jsclasses/LICENSE +1 -1
  222. data/vendor/jsclasses/Makefile +3 -2
  223. data/vendor/jsclasses/create_archive.sh +5 -5
  224. data/vendor/jsclasses/jis/Makefile +3 -2
  225. data/vendor/jsclasses/jis/jsarticle.cls +74 -31
  226. data/vendor/jsclasses/jis/jsbook.cls +74 -31
  227. data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
  228. data/vendor/jsclasses/jis/jsclasses.ins +15 -5
  229. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  230. data/vendor/jsclasses/jis/jslogo.ins +9 -0
  231. data/vendor/jsclasses/jis/jslogo.sty +4 -16
  232. data/vendor/jsclasses/jis/jspf.cls +73 -30
  233. data/vendor/jsclasses/jis/jsreport.cls +74 -31
  234. data/vendor/jsclasses/jis/jsverb.ins +9 -0
  235. data/vendor/jsclasses/jis/jsverb.sty +1 -13
  236. data/vendor/jsclasses/jis/kiyou.cls +74 -31
  237. data/vendor/jsclasses/jis/minijs.sty +65 -22
  238. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  239. data/vendor/jsclasses/jis/okumacro.ins +9 -0
  240. data/vendor/jsclasses/jis/okumacro.sty +4 -17
  241. data/vendor/jsclasses/jis/okuverb.ins +9 -0
  242. data/vendor/jsclasses/jis/okuverb.sty +1 -13
  243. data/vendor/jsclasses/jis/winjis.sty +23 -19
  244. data/vendor/jsclasses/jsarticle.cls +74 -31
  245. data/vendor/jsclasses/jsbook.cls +74 -31
  246. data/vendor/jsclasses/jsclasses.dtx +176 -36
  247. data/vendor/jsclasses/jsclasses.ins +15 -5
  248. data/vendor/jsclasses/jsclasses.pdf +0 -0
  249. data/vendor/jsclasses/jslogo.dtx +4 -4
  250. data/vendor/jsclasses/jslogo.ins +9 -0
  251. data/vendor/jsclasses/jslogo.pdf +0 -0
  252. data/vendor/jsclasses/jslogo.sty +4 -16
  253. data/vendor/jsclasses/jspf.cls +73 -30
  254. data/vendor/jsclasses/jsreport.cls +74 -31
  255. data/vendor/jsclasses/jsverb.ins +9 -0
  256. data/vendor/jsclasses/jsverb.pdf +0 -0
  257. data/vendor/jsclasses/jsverb.sty +1 -13
  258. data/vendor/jsclasses/kiyou.cls +74 -31
  259. data/vendor/jsclasses/minijs.sty +68 -22
  260. data/vendor/jsclasses/okumacro.dtx +4 -5
  261. data/vendor/jsclasses/okumacro.ins +9 -0
  262. data/vendor/jsclasses/okumacro.pdf +0 -0
  263. data/vendor/jsclasses/okumacro.sty +4 -17
  264. data/vendor/jsclasses/okuverb.ins +9 -0
  265. data/vendor/jsclasses/okuverb.pdf +0 -0
  266. data/vendor/jsclasses/okuverb.sty +1 -13
  267. data/vendor/jsclasses/tests/relfont.tex +10 -0
  268. data/vendor/jsclasses/winjis.sty +23 -19
  269. metadata +136 -23
  270. data/.rubocop_todo.yml +0 -7
  271. data/lib/epubmaker.rb +0 -23
  272. data/lib/epubmaker/content.rb +0 -110
  273. data/lib/epubmaker/epubcommon.rb +0 -441
  274. data/lib/epubmaker/epubv2.rb +0 -143
  275. data/lib/epubmaker/epubv3.rb +0 -233
  276. data/lib/epubmaker/producer.rb +0 -375
  277. data/lib/epubmaker/zip_exporter.rb +0 -81
  278. data/lib/lineinput.rb +0 -155
  279. data/lib/review/book/compilable.rb +0 -173
  280. data/lib/review/tocparser.rb +0 -271
  281. data/samples/syntax-book/review-ext.rb +0 -14
  282. data/test/test_tocparser.rb +0 -25
@@ -17,18 +17,6 @@ class HTMLUtilsTest < Test::Unit::TestCase
17
17
  assert_equal '&amp;', unescape('&amp;amp;')
18
18
  end
19
19
 
20
- def test_escape_html_ex
21
- keys = ESC.keys
22
- ESC['.'] = 'X'
23
- ESC.each_pair do |ch, ref|
24
- if keys.include?(ch)
25
- assert_equal ref, escape(ch)
26
- else
27
- assert_equal ch, escape(ch)
28
- end
29
- end
30
- end
31
-
32
20
  def test_strip_html
33
21
  assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
34
22
  end
data/test/test_i18n.rb CHANGED
@@ -9,7 +9,7 @@ class I18nTest < Test::Unit::TestCase
9
9
  Dir.mktmpdir do |dir|
10
10
  Dir.chdir(dir) do
11
11
  file = File.join(dir, 'locale.yml')
12
- File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
12
+ File.write(file, %Q(locale: ja\nfoo: "bar"\n))
13
13
  I18n.setup
14
14
  assert_equal 'bar', I18n.t('foo')
15
15
  end
@@ -20,7 +20,7 @@ class I18nTest < Test::Unit::TestCase
20
20
  Dir.mktmpdir do |dir|
21
21
  Dir.chdir(dir) do
22
22
  file = File.join(dir, 'locale.yaml')
23
- File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
23
+ File.write(file, %Q(locale: ja\nfoo: "bar"\n))
24
24
  assert_raise ReVIEW::ConfigError do
25
25
  I18n.setup
26
26
  end
@@ -32,7 +32,7 @@ class I18nTest < Test::Unit::TestCase
32
32
  Dir.mktmpdir do |dir|
33
33
  Dir.chdir(dir) do
34
34
  file = File.join(dir, 'foo.yml')
35
- File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
35
+ File.write(file, %Q(locale: ja\nfoo: "bar"\n))
36
36
  I18n.setup('ja', 'foo.yml')
37
37
  assert_equal 'bar', I18n.t('foo')
38
38
  end
@@ -43,7 +43,7 @@ class I18nTest < Test::Unit::TestCase
43
43
  Dir.mktmpdir do |dir|
44
44
  Dir.chdir(dir) do
45
45
  file = File.join(dir, 'foo.yml')
46
- File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
46
+ File.write(file, %Q(locale: ja\nfoo: "bar"\n))
47
47
  i18n = ReVIEW::I18n.new('ja')
48
48
  i18n.update_localefile(File.join(Dir.pwd, 'foo.yml'))
49
49
  assert_equal 'bar', i18n.t('foo')
@@ -55,7 +55,7 @@ class I18nTest < Test::Unit::TestCase
55
55
  Dir.mktmpdir do |dir|
56
56
  Dir.chdir(dir) do
57
57
  file = File.join(dir, 'foo.yml')
58
- File.open(file, 'w') { |f| f.write(%Q(locale: ja\nfoo: "bar"\n)) }
58
+ File.write(file, %Q(locale: ja\nfoo: "bar"\n))
59
59
  I18n.setup('ja', 'foo.yml')
60
60
  assert_equal 'bar', I18n.t('foo')
61
61
  end
@@ -66,7 +66,7 @@ class I18nTest < Test::Unit::TestCase
66
66
  Dir.mktmpdir do |dir|
67
67
  Dir.chdir(dir) do
68
68
  file = File.join(dir, 'locale.yml')
69
- File.open(file, 'w') { |f| f.write(%Q(ja:\n foo: "bar"\nen:\n foo: "buz"\n)) }
69
+ File.write(file, %Q(ja:\n foo: "bar"\nen:\n foo: "buz"\n))
70
70
  I18n.setup
71
71
  assert_equal 'bar', I18n.t('foo')
72
72
  assert_equal '図', I18n.t('image')
@@ -81,7 +81,7 @@ class I18nTest < Test::Unit::TestCase
81
81
  Dir.mktmpdir do |dir|
82
82
  Dir.chdir(dir) do
83
83
  file = File.join(dir, 'locale.yml')
84
- File.open(file, 'w') { |f| f.write(%Q(local: ja\nfoo: "bar"\n)) }
84
+ File.write(file, %Q(local: ja\nfoo: "bar"\n))
85
85
  assert_raises(ReVIEW::KeyError) do
86
86
  I18n.setup
87
87
  end
@@ -93,59 +93,59 @@ class I18nTest < Test::Unit::TestCase
93
93
  Dir.mktmpdir do |dir|
94
94
  Dir.chdir(dir) do
95
95
  file = File.join(dir, 'locale.yml')
96
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pa章") }
96
+ File.write(file, "locale: ja\nchapter: 第%pa章")
97
97
  I18n.setup('ja')
98
98
  assert_equal '第a章', I18n.t('chapter', 1)
99
99
 
100
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pA章") }
100
+ File.write(file, "locale: ja\nchapter: 第%pA章")
101
101
  I18n.setup('ja')
102
102
  assert_equal '第B章', I18n.t('chapter', 2)
103
103
 
104
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pAW章") }
104
+ File.write(file, "locale: ja\nchapter: 第%pAW章")
105
105
  I18n.setup('ja')
106
106
  assert_equal '第B章', I18n.t('chapter', 2)
107
107
 
108
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%paW章") }
108
+ File.write(file, "locale: ja\nchapter: 第%paW章")
109
109
  I18n.setup('ja')
110
110
  assert_equal '第b章', I18n.t('chapter', 2)
111
111
 
112
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pR章") }
112
+ File.write(file, "locale: ja\nchapter: 第%pR章")
113
113
  I18n.setup('ja')
114
114
  assert_equal '第I章', I18n.t('chapter', 1)
115
115
 
116
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pr章") }
116
+ File.write(file, "locale: ja\nchapter: 第%pr章")
117
117
  I18n.setup('ja')
118
118
  assert_equal '第ii章', I18n.t('chapter', 2)
119
119
 
120
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pRW章") }
120
+ File.write(file, "locale: ja\nchapter: 第%pRW章")
121
121
  I18n.setup('ja')
122
122
  assert_equal '第Ⅻ章', I18n.t('chapter', 12)
123
123
 
124
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pJ章") }
124
+ File.write(file, "locale: ja\nchapter: 第%pJ章")
125
125
  I18n.setup('ja')
126
126
  assert_equal '第二十七章', I18n.t('chapter', 27)
127
127
 
128
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pdW章") }
128
+ File.write(file, "locale: ja\nchapter: 第%pdW章")
129
129
  I18n.setup('ja')
130
130
  assert_equal '第1章', I18n.t('chapter', 1)
131
131
 
132
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pdW章") }
132
+ File.write(file, "locale: ja\nchapter: 第%pdW章")
133
133
  I18n.setup('ja')
134
134
  assert_equal '第27章', I18n.t('chapter', 27)
135
135
 
136
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pDW章") }
136
+ File.write(file, "locale: ja\nchapter: 第%pDW章")
137
137
  I18n.setup('ja')
138
138
  assert_equal '第1章', I18n.t('chapter', 1)
139
139
 
140
- File.open(file, 'w') { |f| f.write("locale: ja\nchapter: 第%pDW章") }
140
+ File.write(file, "locale: ja\nchapter: 第%pDW章")
141
141
  I18n.setup('ja')
142
142
  assert_equal '第27章', I18n.t('chapter', 27)
143
143
 
144
- File.open(file, 'w') { |f| f.write("locale: ja\npart: Part %pRW") }
144
+ File.write(file, "locale: ja\npart: Part %pRW")
145
145
  I18n.setup('ja')
146
146
  assert_equal 'Part 0', I18n.t('part', 0)
147
147
 
148
- File.open(file, 'w') { |f| f.write("locale: ja\npart: 第%pJ部") }
148
+ File.write(file, "locale: ja\npart: 第%pJ部")
149
149
  I18n.setup('ja')
150
150
  assert_equal '第一部', I18n.t('part', 1)
151
151
  end
@@ -157,23 +157,23 @@ class I18nTest < Test::Unit::TestCase
157
157
  Dir.chdir(dir) do
158
158
  file = File.join(dir, 'locale.yml')
159
159
 
160
- File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%s-%pA:") }
160
+ File.write(file, %Q(locale: ja\nformat_number_header: "%s-%pA:"))
161
161
  I18n.setup('ja')
162
162
  assert_equal '1-B:', I18n.t('format_number_header', [1, 2])
163
163
 
164
- File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%s.%pa:") }
164
+ File.write(file, %Q(locale: ja\nformat_number_header: "%s.%pa:"))
165
165
  I18n.setup('ja')
166
166
  assert_equal '2.c:', I18n.t('format_number_header', [2, 3])
167
167
 
168
- File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%pA,%pAW:") }
168
+ File.write(file, %Q(locale: ja\nformat_number_header: "%pA,%pAW:"))
169
169
  I18n.setup('ja')
170
170
  assert_equal 'C,D:', I18n.t('format_number_header', [3, 4])
171
171
 
172
- File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%pJ・%pJ:") }
172
+ File.write(file, %Q(locale: ja\nformat_number_header: "%pJ・%pJ:"))
173
173
  I18n.setup('ja')
174
174
  assert_equal '十二・二十六:', I18n.t('format_number_header', [12, 26])
175
175
 
176
- File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%pdW―%pdW:") }
176
+ File.write(file, %Q(locale: ja\nformat_number_header: "%pdW―%pdW:"))
177
177
  I18n.setup('ja')
178
178
  assert_equal '3―12:', I18n.t('format_number_header', [3, 12])
179
179
  end
@@ -185,11 +185,11 @@ class I18nTest < Test::Unit::TestCase
185
185
  Dir.chdir(dir) do
186
186
  file = File.join(dir, 'locale.yml')
187
187
 
188
- File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%2$d") }
188
+ File.write(file, %Q(locale: ja\nformat_number_header: "%2$d"))
189
189
  I18n.setup('ja')
190
190
  assert_equal '10', I18n.t('format_number_header', [1, 10])
191
191
 
192
- File.open(file, 'w') { |f| f.write %Q(locale: ja\nformat_number_header: "%2$d-%1$d") }
192
+ File.write(file, %Q(locale: ja\nformat_number_header: "%2$d-%1$d"))
193
193
  I18n.setup('ja')
194
194
  # ERROR: returns raw format
195
195
  assert_equal '%2$d-%1$d', I18n.t('format_number_header', [1])
@@ -215,7 +215,7 @@ class I18nTest < Test::Unit::TestCase
215
215
  end
216
216
 
217
217
  def test_en
218
- I18n.setup 'en'
218
+ I18n.setup('en')
219
219
  assert_equal 'Figure ', I18n.t('image')
220
220
  assert_equal 'Table ', I18n.t('table')
221
221
  assert_equal 'Chapter 1', I18n.t('chapter', 1)
@@ -223,7 +223,7 @@ class I18nTest < Test::Unit::TestCase
223
223
  end
224
224
 
225
225
  def test_nil
226
- I18n.setup 'nil'
226
+ I18n.setup('nil')
227
227
  assert_equal 'image', I18n.t('image')
228
228
  assert_equal 'table', I18n.t('table')
229
229
  assert_equal 'etc', I18n.t('etc')
@@ -236,13 +236,13 @@ class I18nTest < Test::Unit::TestCase
236
236
  end
237
237
 
238
238
  def _setup_htmlbuilder
239
- I18n.setup 'en'
239
+ I18n.setup('en')
240
240
  @builder = HTMLBuilder.new
241
- @config = ReVIEW::Configure[
242
- 'secnolevel' => 2, # for IDGXMLBuilder, HTMLBuilder
243
- 'stylesheet' => nil, # for HTMLBuilder
244
- 'ext' => '.re'
245
- ]
241
+ @config = ReVIEW::Configure.values.merge(
242
+ { 'secnolevel' => 2, # for IDGXMLBuilder, HTMLBuilder
243
+ 'stylesheet' => nil, # for HTMLBuilder
244
+ 'ext' => '.re' }
245
+ )
246
246
  @book = Book::Base.new('.')
247
247
  @book.config = @config
248
248
  @compiler = ReVIEW::Compiler.new(@builder)
@@ -295,6 +295,6 @@ class I18nTest < Test::Unit::TestCase
295
295
  end
296
296
 
297
297
  def teardown
298
- I18n.setup 'ja'
298
+ I18n.setup('ja')
299
299
  end
300
300
  end
@@ -48,6 +48,19 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
48
48
  assert_equal %Q(<title id="test" aid:pstyle="h3">1.0.1 this is test.</title><?dtp level="3" section="1.0.1 this is test."?>), actual
49
49
  end
50
50
 
51
+ def test_headline_secttags
52
+ @config['structuredxml'] = true
53
+ 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")
54
+ expected = '<chapter id="chap:1"><title aid:pstyle="h1">第1章 HEAD1</title><?dtp level="1" section="第1章 HEAD1"?>' +
55
+ '<sect id="sect:1.1"><title aid:pstyle="h2">1.1 HEAD1-1</title><?dtp level="2" section="1.1 HEAD1-1"?>' +
56
+ '<sect2 id="sect:1.1.1"><title aid:pstyle="h3">HEAD1-1-1</title><?dtp level="3" section="HEAD1-1-1"?></sect2></sect>' +
57
+ '<sect id="sect:1.2"><title aid:pstyle="h2">1.2 HEAD1-2</title><?dtp level="2" section="1.2 HEAD1-2"?>' +
58
+ '<sect3 id="sect:1.2.0.1"><title aid:pstyle="h4">HEAD1-2-0-1</title><?dtp level="4" section="HEAD1-2-0-1"?>' +
59
+ '<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>' +
60
+ '<sect id="sect:1.3"><title aid:pstyle="h2">1.3 HEAD1-3</title><?dtp level="2" section="1.3 HEAD1-3"?></sect></chapter>'
61
+ assert_equal expected, actual
62
+ end
63
+
51
64
  def test_label
52
65
  actual = compile_block("//label[label_test]\n")
53
66
  assert_equal %Q(<label id='label_test' />), actual
@@ -100,6 +113,27 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
100
113
  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
101
114
  end
102
115
 
116
+ def test_table
117
+ actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
118
+ expected = <<-EOS.chomp
119
+ <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>
120
+ EOS
121
+ assert_equal expected, actual
122
+
123
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
124
+ expected = <<-EOS.chomp
125
+ <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>
126
+ EOS
127
+ assert_equal expected, actual
128
+
129
+ @config['caption_position']['table'] = 'bottom'
130
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
131
+ expected = <<-EOS.chomp
132
+ <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>
133
+ EOS
134
+ assert_equal expected, actual
135
+ end
136
+
103
137
  def test_customize_cellwidth
104
138
  actual = compile_block("//tsize[2,3,5]\n//table{\nA\tB\tC\n//}\n")
105
139
  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
@@ -134,16 +168,50 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
134
168
  end
135
169
 
136
170
  def test_empty_table
137
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
171
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
138
172
  assert_equal ':2: error: no rows in the table', e.message
139
173
 
140
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
174
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
141
175
  assert_equal ':3: error: no rows in the table', e.message
142
176
  end
143
177
 
144
178
  def test_emtable
145
179
  actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
146
180
  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
181
+
182
+ @config['caption_position']['table'] = 'bottom'
183
+ actual = compile_block("//emtable[foo]{\nA\n//}\n//emtable{\nA\n//}")
184
+ 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
185
+ end
186
+
187
+ def test_table_row_separator
188
+ src = "//table{\n1\t2\t\t3 4| 5\n------------\na b\tc d |e\n//}\n"
189
+ expected = <<-EOS.chomp
190
+ <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>
191
+ EOS
192
+ actual = compile_block(src)
193
+ assert_equal expected, actual
194
+
195
+ @config['table_row_separator'] = 'singletab'
196
+ actual = compile_block(src)
197
+ expected = <<-EOS.chomp
198
+ <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>
199
+ EOS
200
+ assert_equal expected, actual
201
+
202
+ @config['table_row_separator'] = 'spaces'
203
+ actual = compile_block(src)
204
+ expected = <<-EOS.chomp
205
+ <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>
206
+ EOS
207
+ assert_equal expected, actual
208
+
209
+ @config['table_row_separator'] = 'verticalbar'
210
+ actual = compile_block(src)
211
+ expected = <<-EOS.chomp
212
+ <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>
213
+ EOS
214
+ assert_equal expected, actual
147
215
  end
148
216
 
149
217
  def test_inline_br
@@ -196,19 +264,40 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
196
264
  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
197
265
  end
198
266
 
267
+ def test_dt_inline
268
+ actual = compile_block("//footnote[bar][bar]\n\n : foo@<fn>{bar}[]<>&@<m>$\\alpha[]$\n")
269
+
270
+ expected = <<-EOS.chomp
271
+ <dl><dt>foo<footnote>bar</footnote>[]&lt;&gt;&amp;<replace idref="texinline-1"><pre>\\alpha[]</pre></replace></dt><dd></dd></dl>
272
+ EOS
273
+ assert_equal expected, actual
274
+ end
275
+
199
276
  def test_paragraph
200
277
  actual = compile_block("foo\nbar\n")
201
278
  assert_equal '<p>foobar</p>', actual
279
+
280
+ @book.config['join_lines_by_lang'] = true
281
+ actual = compile_block("foo\nbar\n")
282
+ assert_equal '<p>foo bar</p>', actual
202
283
  end
203
284
 
204
285
  def test_tabbed_paragraph
205
286
  actual = compile_block("\tfoo\nbar\n")
206
287
  assert_equal %Q(<p inlist="1">foobar</p>), actual
288
+
289
+ @book.config['join_lines_by_lang'] = true
290
+ actual = compile_block("\tfoo\nbar\n")
291
+ assert_equal %Q(<p inlist="1">foo bar</p>), actual
207
292
  end
208
293
 
209
294
  def test_quote
210
295
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
211
296
  assert_equal '<quote><p>foobar</p><p>buz</p></quote>', actual
297
+
298
+ @book.config['join_lines_by_lang'] = true
299
+ actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
300
+ assert_equal '<quote><p>foo bar</p><p>buz</p></quote>', actual
212
301
  end
213
302
 
214
303
  def test_major_blocks
@@ -246,29 +335,188 @@ class IDGXMLBuidlerTest < Test::Unit::TestCase
246
335
  assert_equal expected, actual
247
336
  end
248
337
 
338
+ def test_minicolumn_blocks
339
+ %w[note memo tip info warning important caution notice].each do |type|
340
+ src = <<-EOS
341
+ //#{type}[#{type}1]{
342
+
343
+ //}
344
+
345
+ //#{type}[#{type}2]{
346
+ //}
347
+ EOS
348
+
349
+ if type == 'notice' # exception pattern
350
+ expected = <<-EOS.chomp
351
+ <#{type}-t><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}-t>
352
+ EOS
353
+ else
354
+ expected = <<-EOS.chomp
355
+ <#{type}><title aid:pstyle='#{type}-title'>#{type}1</title></#{type}><#{type}><title aid:pstyle='#{type}-title'>#{type}2</title></#{type}>
356
+ EOS
357
+ end
358
+ assert_equal expected, compile_block(src)
359
+
360
+ src = <<-EOS
361
+ //#{type}[#{type}2]{
362
+
363
+ //}
364
+
365
+ //#{type}[#{type}3]{
366
+
367
+ //}
368
+
369
+ //#{type}[#{type}4]{
370
+
371
+ //}
372
+
373
+ //#{type}[#{type}5]{
374
+
375
+ //}
376
+
377
+ //#{type}[#{type}6]{
378
+
379
+ //}
380
+ EOS
381
+
382
+ if type == 'notice' # exception pattern
383
+ expected = <<-EOS.chomp
384
+ <#{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>
385
+ EOS
386
+ else
387
+ expected = <<-EOS.chomp
388
+ <#{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}>
389
+ EOS
390
+ end
391
+ assert_equal expected, compile_block(src)
392
+
393
+ src = <<-EOS
394
+ //#{type}{
395
+
396
+ * A
397
+
398
+ 1. B
399
+
400
+ //}
401
+
402
+ //#{type}[OMITEND1]{
403
+
404
+ //emlist{
405
+ LIST
406
+ //}
407
+
408
+ //}
409
+ //#{type}[OMITEND2]{
410
+ //}
411
+ EOS
412
+
413
+ if type == 'notice' # exception pattern
414
+ expected = <<-EOS.chomp
415
+ <#{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
416
+ </pre></list></#{type}-t><#{type}-t><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}-t>
417
+ EOS
418
+ else
419
+ expected = <<-EOS.chomp
420
+ <#{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
421
+ </pre></list></#{type}><#{type}><title aid:pstyle='#{type}-title'>OMITEND2</title></#{type}>
422
+ EOS
423
+ end
424
+ assert_equal expected, compile_block(src)
425
+ end
426
+ end
427
+
428
+ def test_minicolumn_blocks_nest_error1
429
+ %w[note memo tip info warning important caution notice].each do |type|
430
+ @builder.doc_status.clear
431
+ src = <<-EOS
432
+ //#{type}{
433
+
434
+ //#{type}{
435
+ //}
436
+
437
+ //}
438
+ EOS
439
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
440
+ assert_match(/minicolumn cannot be nested:/, e.message)
441
+ end
442
+ end
443
+
444
+ def test_minicolumn_blocks_nest_error2
445
+ %w[note memo tip info warning important caution notice].each do |type|
446
+ @builder.doc_status.clear
447
+ src = <<-EOS
448
+ //#{type}{
449
+
450
+ //#{type}{
451
+
452
+ //}
453
+
454
+ //}
455
+ EOS
456
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
457
+ assert_match(/minicolumn cannot be nested:/, e.message)
458
+ end
459
+ end
460
+
461
+ def test_minicolumn_blocks_nest_error3
462
+ %w[memo tip info warning important caution notice].each do |type|
463
+ @builder.doc_status.clear
464
+ src = <<-EOS
465
+ //#{type}{
466
+
467
+ //note{
468
+ //}
469
+
470
+ //}
471
+ EOS
472
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
473
+ assert_match(/minicolumn cannot be nested:/, e.message)
474
+ end
475
+ end
476
+
249
477
  def test_term
250
478
  actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
251
479
  assert_equal '<term><p>test1test1.5</p><p>test<i>2</i></p></term>', actual
480
+
481
+ @book.config['join_lines_by_lang'] = true
482
+ actual = compile_block("//term{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
483
+ assert_equal '<term><p>test1 test1.5</p><p>test<i>2</i></p></term>', actual
252
484
  end
253
485
 
254
486
  def test_point
255
487
  actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
256
488
  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
489
+
490
+ @book.config['join_lines_by_lang'] = true
491
+ actual = compile_block("//point[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
492
+ 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
257
493
  end
258
494
 
259
495
  def test_point_without_caption
260
496
  actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
261
497
  assert_equal '<point><p>test1test1.5</p><p>test<i>2</i></p></point>', actual
498
+
499
+ @book.config['join_lines_by_lang'] = true
500
+ actual = compile_block("//point{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
501
+ assert_equal '<point><p>test1 test1.5</p><p>test<i>2</i></p></point>', actual
262
502
  end
263
503
 
264
504
  def test_emlist
265
505
  actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
266
506
  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
507
+
508
+ @config['caption_position']['list'] = 'bottom'
509
+ actual = compile_block("//emlist[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
510
+ 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
267
511
  end
268
512
 
269
513
  def test_emlistnum
270
514
  actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
271
515
  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
516
+
517
+ @config['caption_position']['list'] = 'bottom'
518
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
519
+ 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
272
520
  end
273
521
 
274
522
  def test_emlist_listinfo
@@ -311,7 +559,7 @@ EOS
311
559
 
312
560
  def test_list
313
561
  def @chapter.list(_id)
314
- Book::ListIndex::Item.new('samplelist', 1)
562
+ Book::Index::Item.new('samplelist', 1)
315
563
  end
316
564
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
317
565
  expected = <<-EOS.chomp
@@ -320,13 +568,24 @@ test1.5
320
568
 
321
569
  test<i>2</i>
322
570
  </pre></codelist>
571
+ EOS
572
+ assert_equal expected, actual
573
+
574
+ @config['caption_position']['list'] = 'bottom'
575
+ actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
576
+ expected = <<-EOS.chomp
577
+ <codelist><pre>test1
578
+ test1.5
579
+
580
+ test<i>2</i>
581
+ </pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
323
582
  EOS
324
583
  assert_equal expected, actual
325
584
  end
326
585
 
327
586
  def test_listnum
328
587
  def @chapter.list(_id)
329
- Book::ListIndex::Item.new('samplelist', 1)
588
+ Book::Index::Item.new('samplelist', 1)
330
589
  end
331
590
  actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
332
591
  expected = <<-EOS.chomp
@@ -335,13 +594,24 @@ EOS
335
594
  <span type='lineno'> 3: </span>
336
595
  <span type='lineno'> 4: </span>test<i>2</i>
337
596
  </pre></codelist>
597
+ EOS
598
+ assert_equal expected, actual
599
+
600
+ @config['caption_position']['list'] = 'bottom'
601
+ actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
602
+ expected = <<-EOS.chomp
603
+ <codelist><pre><span type='lineno'> 1: </span>test1
604
+ <span type='lineno'> 2: </span>test1.5
605
+ <span type='lineno'> 3: </span>
606
+ <span type='lineno'> 4: </span>test<i>2</i>
607
+ </pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
338
608
  EOS
339
609
  assert_equal expected, actual
340
610
  end
341
611
 
342
612
  def test_listnum_linenum
343
613
  def @chapter.list(_id)
344
- Book::ListIndex::Item.new('samplelist', 1)
614
+ Book::Index::Item.new('samplelist', 1)
345
615
  end
346
616
  actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
347
617
  expected = <<-EOS.chomp
@@ -350,13 +620,24 @@ EOS
350
620
  <span type='lineno'>102: </span>
351
621
  <span type='lineno'>103: </span>test<i>2</i>
352
622
  </pre></codelist>
623
+ EOS
624
+ assert_equal expected, actual
625
+
626
+ @config['caption_position']['list'] = 'bottom'
627
+ actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
628
+ expected = <<-EOS.chomp
629
+ <codelist><pre><span type='lineno'>100: </span>test1
630
+ <span type='lineno'>101: </span>test1.5
631
+ <span type='lineno'>102: </span>
632
+ <span type='lineno'>103: </span>test<i>2</i>
633
+ </pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
353
634
  EOS
354
635
  assert_equal expected, actual
355
636
  end
356
637
 
357
638
  def test_list_listinfo
358
639
  def @chapter.list(_id)
359
- Book::ListIndex::Item.new('samplelist', 1)
640
+ Book::Index::Item.new('samplelist', 1)
360
641
  end
361
642
  @config['listinfo'] = true
362
643
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
@@ -366,6 +647,17 @@ EOS
366
647
  </listinfo><listinfo line="3">
367
648
  </listinfo><listinfo line="4" end="4">test<i>2</i>
368
649
  </listinfo></pre></codelist>
650
+ EOS
651
+ assert_equal expected, actual
652
+
653
+ @config['caption_position']['list'] = 'bottom'
654
+ actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
655
+ expected = <<-EOS.chomp
656
+ <codelist><pre><listinfo line="1" begin="1">test1
657
+ </listinfo><listinfo line="2">test1.5
658
+ </listinfo><listinfo line="3">
659
+ </listinfo><listinfo line="4" end="4">test<i>2</i>
660
+ </listinfo></pre><caption>リスト1.1 this is <b>test</b>&lt;&amp;&gt;_</caption></codelist>
369
661
  EOS
370
662
  assert_equal expected, actual
371
663
  end
@@ -384,6 +676,15 @@ EOS
384
676
  <list type='cmd'><caption aid:pstyle='cmd-title'>cap1</caption><pre>lineA
385
677
  lineB
386
678
  </pre></list>
679
+ EOS
680
+ assert_equal expected, actual
681
+
682
+ @config['caption_position']['list'] = 'bottom'
683
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
684
+ expected = <<-EOS.chomp
685
+ <list type='cmd'><pre>lineA
686
+ lineB
687
+ </pre><caption aid:pstyle='cmd-title'>cap1</caption></list>
387
688
  EOS
388
689
  assert_equal expected, actual
389
690
  end
@@ -396,6 +697,17 @@ bar
396
697
 
397
698
  buz
398
699
  </pre></source>
700
+ EOS
701
+ assert_equal expected, actual
702
+
703
+ @config['caption_position']['list'] = 'bottom'
704
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
705
+ expected = <<-EOS.chomp
706
+ <source><pre>foo
707
+ bar
708
+
709
+ buz
710
+ </pre><caption>foo/bar/test.rb</caption></source>
399
711
  EOS
400
712
  assert_equal expected, actual
401
713
  end
@@ -406,6 +718,18 @@ EOS
406
718
  <source><pre>foo
407
719
  bar
408
720
 
721
+ buz
722
+ </pre></source>
723
+ EOS
724
+ assert_equal expected, actual
725
+ end
726
+
727
+ def test_source_nil_caption
728
+ actual = compile_block("//source{\nfoo\nbar\n\nbuz\n//}\n")
729
+ expected = <<-EOS.chomp
730
+ <source><pre>foo
731
+ bar
732
+
409
733
  buz
410
734
  </pre></source>
411
735
  EOS
@@ -421,6 +745,17 @@ EOS
421
745
  </listinfo><listinfo line="3">
422
746
  </listinfo><listinfo line="4" end="4">test<i>2</i>
423
747
  </listinfo></insn>
748
+ EOS
749
+ assert_equal expected, actual
750
+
751
+ @config['caption_position']['list'] = 'bottom'
752
+ actual = compile_block("//insn[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
753
+ expected = <<-EOS.chomp
754
+ <insn><listinfo line="1" begin="1">test1
755
+ </listinfo><listinfo line="2">test1.5
756
+ </listinfo><listinfo line="3">
757
+ </listinfo><listinfo line="4" end="4">test<i>2</i>
758
+ </listinfo><floattitle type="insn">this is <b>test</b>&lt;&amp;&gt;_</floattitle></insn>
424
759
  EOS
425
760
  assert_equal expected, actual
426
761
  end
@@ -434,6 +769,17 @@ EOS
434
769
  </listinfo><listinfo line="3">
435
770
  </listinfo><listinfo line="4" end="4">test<i>2</i>
436
771
  </listinfo></box>
772
+ EOS
773
+ assert_equal expected, actual
774
+
775
+ @config['caption_position']['list'] = 'bottom'
776
+ actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
777
+ expected = <<-EOS.chomp
778
+ <box><listinfo line="1" begin="1">test1
779
+ </listinfo><listinfo line="2">test1.5
780
+ </listinfo><listinfo line="3">
781
+ </listinfo><listinfo line="4" end="4">test<i>2</i>
782
+ </listinfo><caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption></box>
437
783
  EOS
438
784
  assert_equal expected, actual
439
785
  end
@@ -447,6 +793,17 @@ test1.5
447
793
 
448
794
  test<i>2</i>
449
795
  </box>
796
+ EOS
797
+ assert_equal expected, actual
798
+
799
+ @config['caption_position']['list'] = 'bottom'
800
+ actual = compile_block("//box[this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
801
+ expected = <<-EOS.chomp
802
+ <box>test1
803
+ test1.5
804
+
805
+ test<i>2</i>
806
+ <caption aid:pstyle="box-title">this is <b>test</b>&lt;&amp;&gt;_</caption></box>
450
807
  EOS
451
808
  assert_equal expected, actual
452
809
  end
@@ -454,11 +811,19 @@ EOS
454
811
  def test_flushright
455
812
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
456
813
  assert_equal %Q(<p align='right'>foobar</p><p align='right'>buz</p>), actual
814
+
815
+ @book.config['join_lines_by_lang'] = true
816
+ actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
817
+ assert_equal %Q(<p align='right'>foo bar</p><p align='right'>buz</p>), actual
457
818
  end
458
819
 
459
820
  def test_centering
460
821
  actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
461
822
  assert_equal %Q(<p align='center'>foobar</p><p align='center'>buz</p>), actual
823
+
824
+ @book.config['join_lines_by_lang'] = true
825
+ actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
826
+ assert_equal %Q(<p align='center'>foo bar</p><p align='center'>buz</p>), actual
462
827
  end
463
828
 
464
829
  def test_blankline
@@ -469,22 +834,30 @@ EOS
469
834
  def test_noindent
470
835
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
471
836
  assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foobar</p><p>foo2bar2</p>), actual
837
+
838
+ @book.config['join_lines_by_lang'] = true
839
+ actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
840
+ assert_equal %Q(<p aid:pstyle="noindent" noindent='1'>foo bar</p><p>foo2 bar2</p>), actual
472
841
  end
473
842
 
474
843
  def test_image
475
844
  def @chapter.image(_id)
476
- item = Book::ImageIndex::Item.new('sampleimg', 1)
845
+ item = Book::Index::Item.new('sampleimg', 1)
477
846
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
478
847
  item
479
848
  end
480
849
 
481
850
  actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
482
851
  assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>図1.1 sample photo</caption></img>), actual
852
+
853
+ @config['caption_position']['image'] = 'top'
854
+ actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
855
+ assert_equal %Q(<img><caption>図1.1 sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
483
856
  end
484
857
 
485
858
  def test_image_with_metric
486
859
  def @chapter.image(_id)
487
- item = Book::ImageIndex::Item.new('sampleimg', 1)
860
+ item = Book::Index::Item.new('sampleimg', 1)
488
861
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
489
862
  item
490
863
  end
@@ -495,7 +868,7 @@ EOS
495
868
 
496
869
  def test_image_with_metric2
497
870
  def @chapter.image(_id)
498
- item = Book::ImageIndex::Item.new('sampleimg', 1)
871
+ item = Book::Index::Item.new('sampleimg', 1)
499
872
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
500
873
  item
501
874
  end
@@ -506,18 +879,22 @@ EOS
506
879
 
507
880
  def test_indepimage
508
881
  def @chapter.image(_id)
509
- item = Book::ImageIndex::Item.new('sampleimg', 1)
882
+ item = Book::Index::Item.new('sampleimg', 1)
510
883
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
511
884
  item
512
885
  end
513
886
 
514
887
  actual = compile_block("//indepimage[sampleimg][sample photo]\n")
515
888
  assert_equal %Q(<img><Image href="file://images/chap1-sampleimg.png" /><caption>sample photo</caption></img>), actual
889
+
890
+ @config['caption_position']['image'] = 'top'
891
+ actual = compile_block("//indepimage[sampleimg][sample photo]\n")
892
+ assert_equal %Q(<img><caption>sample photo</caption><Image href="file://images/chap1-sampleimg.png" /></img>), actual
516
893
  end
517
894
 
518
895
  def test_indepimage_without_caption
519
896
  def @chapter.image(_id)
520
- item = Book::ImageIndex::Item.new('sampleimg', 1)
897
+ item = Book::Index::Item.new('sampleimg', 1)
521
898
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
522
899
  item
523
900
  end
@@ -528,7 +905,7 @@ EOS
528
905
 
529
906
  def test_indepimage_with_metric
530
907
  def @chapter.image(_id)
531
- item = Book::ImageIndex::Item.new('sampleimg', 1)
908
+ item = Book::Index::Item.new('sampleimg', 1)
532
909
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
533
910
  item
534
911
  end
@@ -539,7 +916,7 @@ EOS
539
916
 
540
917
  def test_indepimage_with_metric2
541
918
  def @chapter.image(_id)
542
- item = Book::ImageIndex::Item.new('sampleimg', 1)
919
+ item = Book::Index::Item.new('sampleimg', 1)
543
920
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
544
921
  item
545
922
  end
@@ -550,7 +927,7 @@ EOS
550
927
 
551
928
  def test_indepimage_without_caption_but_with_metric
552
929
  def @chapter.image(_id)
553
- item = Book::ImageIndex::Item.new('sampleimg', 1)
930
+ item = Book::Index::Item.new('sampleimg', 1)
554
931
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
555
932
  item
556
933
  end
@@ -620,18 +997,31 @@ inside column
620
997
  this is @<column>{foo}.
621
998
  EOS
622
999
  expected = <<-EOS.chomp
623
- <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>
1000
+ <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>
624
1001
  EOS
625
1002
 
626
1003
  assert_equal expected, column_helper(review)
1004
+
1005
+ @config['chapterlink'] = nil
1006
+ expected = <<-EOS.chomp
1007
+ <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>
1008
+ EOS
1009
+ assert_equal expected, column_helper(review)
627
1010
  end
628
1011
 
629
1012
  def test_column_in_aother_chapter_ref
630
1013
  def @chapter.column_index
631
- items = [Book::ColumnIndex::Item.new('chap1|column', 1, 'column_cap')]
632
- Book::ColumnIndex.new(items)
1014
+ item = Book::Index::Item.new('chap1|column', 1, 'column_cap')
1015
+ idx = Book::ColumnIndex.new
1016
+ idx.add_item(item)
1017
+ idx
633
1018
  end
634
1019
 
1020
+ actual = compile_inline('test @<column>{chap1|column} test2')
1021
+ expected = 'test <link href="column-1">コラム「column_cap」</link> test2'
1022
+ assert_equal expected, actual
1023
+
1024
+ @config['chapterlink'] = nil
635
1025
  actual = compile_inline('test @<column>{chap1|column} test2')
636
1026
  expected = 'test コラム「column_cap」 test2'
637
1027
  assert_equal expected, actual
@@ -657,9 +1047,15 @@ EOS
657
1047
  * BBB
658
1048
  -BB
659
1049
  EOS
660
-
661
1050
  expected = <<-EOS.chomp
662
1051
  <ul><li aid:pstyle="ul-item">AAA-AA</li><li aid:pstyle="ul-item">BBB-BB</li></ul>
1052
+ EOS
1053
+ actual = compile_block(src)
1054
+ assert_equal expected, actual
1055
+
1056
+ @book.config['join_lines_by_lang'] = true
1057
+ expected = <<-EOS.chomp
1058
+ <ul><li aid:pstyle="ul-item">AAA -AA</li><li aid:pstyle="ul-item">BBB -BB</li></ul>
663
1059
  EOS
664
1060
  actual = compile_block(src)
665
1061
  assert_equal expected, actual
@@ -735,18 +1131,18 @@ EOS
735
1131
  end
736
1132
 
737
1133
  def test_inline_unknown
738
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<img>{n}\n" }
1134
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
739
1135
  assert_equal ':1: error: unknown image: n', e.message
740
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<fn>{n}\n" }
1136
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
741
1137
  assert_equal ':1: error: unknown footnote: n', e.message
742
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<hd>{n}\n" }
1138
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
743
1139
  assert_equal ':1: error: unknown headline: n', e.message
744
1140
  %w[list table column].each do |name|
745
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
1141
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
746
1142
  assert_equal ":1: error: unknown #{name}: n", e.message
747
1143
  end
748
1144
  %w[chap chapref title].each do |name|
749
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
1145
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
750
1146
  assert_equal ':1: error: key not found: "n"', e.message
751
1147
  end
752
1148
  end
@@ -777,24 +1173,24 @@ EOS
777
1173
 
778
1174
  def test_inline_imgref
779
1175
  def @chapter.image(_id)
780
- item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
1176
+ item = Book::Index::Item.new('sampleimg', 1, 'sample photo')
781
1177
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
782
1178
  item
783
1179
  end
784
1180
 
785
- actual = compile_block "@<imgref>{sampleimg}\n"
1181
+ actual = compile_block("@<imgref>{sampleimg}\n")
786
1182
  expected = %Q(<p><span type='image'>図1.1「sample photo」</span></p>)
787
1183
  assert_equal expected, actual
788
1184
  end
789
1185
 
790
1186
  def test_inline_imgref2
791
1187
  def @chapter.image(_id)
792
- item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
1188
+ item = Book::Index::Item.new('sampleimg', 1)
793
1189
  item.instance_eval { @path = './images/chap1-sampleimg.png' }
794
1190
  item
795
1191
  end
796
1192
 
797
- actual = compile_block "@<imgref>{sampleimg}\n"
1193
+ actual = compile_block("@<imgref>{sampleimg}\n")
798
1194
  expected = %Q(<p><span type='image'>図1.1</span></p>)
799
1195
  assert_equal expected, actual
800
1196
  end
@@ -875,5 +1271,209 @@ EOS
875
1271
  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>)
876
1272
  actual = compile_block(src)
877
1273
  assert_equal expected, actual
1274
+
1275
+ @config['caption_position']['equation'] = 'bottom'
1276
+ 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>)
1277
+ actual = compile_block(src)
1278
+ assert_equal expected, actual
1279
+ end
1280
+
1281
+ def test_nest_error_close1
1282
+ src = <<-EOS
1283
+ //beginchild
1284
+ EOS
1285
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1286
+ assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
1287
+ end
1288
+
1289
+ def test_nest_error_close2
1290
+ src = <<-EOS
1291
+ * foo
1292
+
1293
+ //beginchild
1294
+
1295
+ 1. foo
1296
+
1297
+ //beginchild
1298
+
1299
+ : foo
1300
+
1301
+ //beginchild
1302
+ EOS
1303
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1304
+ assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
1305
+ end
1306
+
1307
+ def test_nest_error_close3
1308
+ src = <<-EOS
1309
+ * foo
1310
+
1311
+ //beginchild
1312
+
1313
+ 1. foo
1314
+
1315
+ //beginchild
1316
+
1317
+ : foo
1318
+
1319
+ //beginchild
1320
+
1321
+ //endchild
1322
+ EOS
1323
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1324
+ assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
1325
+ end
1326
+
1327
+ def test_nest_ul
1328
+ src = <<-EOS
1329
+ * UL1
1330
+
1331
+ //beginchild
1332
+
1333
+ 1. UL1-OL1
1334
+ 2. UL1-OL2
1335
+
1336
+ * UL1-UL1
1337
+ * UL1-UL2
1338
+
1339
+ : UL1-DL1
1340
+ UL1-DD1
1341
+ : UL1-DL2
1342
+ UL1-DD2
1343
+
1344
+ //endchild
1345
+
1346
+ * UL2
1347
+
1348
+ //beginchild
1349
+
1350
+ UL2-PARA
1351
+
1352
+ //endchild
1353
+ EOS
1354
+
1355
+ expected = <<-EOS.chomp
1356
+ <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>
1357
+ EOS
1358
+
1359
+ actual = compile_block(src)
1360
+ assert_equal expected, actual
1361
+ end
1362
+
1363
+ def test_nest_ol
1364
+ src = <<-EOS
1365
+ 1. OL1
1366
+
1367
+ //beginchild
1368
+
1369
+ 1. OL1-OL1
1370
+ 2. OL1-OL2
1371
+
1372
+ * OL1-UL1
1373
+ * OL1-UL2
1374
+
1375
+ : OL1-DL1
1376
+ OL1-DD1
1377
+ : OL1-DL2
1378
+ OL1-DD2
1379
+
1380
+ //endchild
1381
+
1382
+ 2. OL2
1383
+
1384
+ //beginchild
1385
+
1386
+ OL2-PARA
1387
+
1388
+ //endchild
1389
+ EOS
1390
+
1391
+ expected = <<-EOS.chomp
1392
+ <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>
1393
+ EOS
1394
+
1395
+ actual = compile_block(src)
1396
+ assert_equal expected, actual
1397
+ end
1398
+
1399
+ def test_nest_dl
1400
+ src = <<-EOS
1401
+ : DL1
1402
+
1403
+ //beginchild
1404
+
1405
+ 1. DL1-OL1
1406
+ 2. DL1-OL2
1407
+
1408
+ * DL1-UL1
1409
+ * DL1-UL2
1410
+
1411
+ : DL1-DL1
1412
+ DL1-DD1
1413
+ : DL1-DL2
1414
+ DL1-DD2
1415
+
1416
+ //endchild
1417
+
1418
+ : DL2
1419
+ DD2
1420
+
1421
+ //beginchild
1422
+
1423
+ * DD2-UL1
1424
+ * DD2-UL2
1425
+
1426
+ DD2-PARA
1427
+
1428
+ //endchild
1429
+ EOS
1430
+
1431
+ expected = <<-EOS.chomp
1432
+ <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>
1433
+ EOS
1434
+
1435
+ actual = compile_block(src)
1436
+ assert_equal expected, actual
1437
+ end
1438
+
1439
+ def test_nest_multi
1440
+ src = <<-EOS
1441
+ 1. OL1
1442
+
1443
+ //beginchild
1444
+
1445
+ 1. OL1-OL1
1446
+
1447
+ //beginchild
1448
+
1449
+ * OL1-OL1-UL1
1450
+
1451
+ OL1-OL1-PARA
1452
+
1453
+ //endchild
1454
+
1455
+ 2. OL1-OL2
1456
+
1457
+ * OL1-UL1
1458
+
1459
+ //beginchild
1460
+
1461
+ : OL1-UL1-DL1
1462
+ OL1-UL1-DD1
1463
+
1464
+ OL1-UL1-PARA
1465
+
1466
+ //endchild
1467
+
1468
+ * OL1-UL2
1469
+
1470
+ //endchild
1471
+ EOS
1472
+ expected = <<-EOS.chomp
1473
+ <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>
1474
+ EOS
1475
+
1476
+ actual = compile_block(src)
1477
+ assert_equal expected, actual
878
1478
  end
879
1479
  end