review 4.0.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) 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 +141 -38
  6. data/Dockerfile +21 -5
  7. data/NEWS.ja.md +338 -1
  8. data/NEWS.md +339 -2
  9. data/README.md +11 -7
  10. data/Rakefile +7 -2
  11. data/appveyor.yml +0 -20
  12. data/bin/review +2 -4
  13. data/bin/review-catalog-converter +4 -4
  14. data/bin/review-check +8 -12
  15. data/bin/review-checkdep +2 -5
  16. data/bin/review-compile +11 -20
  17. data/bin/review-epub2html +1 -4
  18. data/bin/review-epubmaker +3 -4
  19. data/bin/review-idgxmlmaker +1 -3
  20. data/bin/review-index +5 -86
  21. data/bin/review-init +1 -4
  22. data/bin/review-pdfmaker +1 -3
  23. data/bin/review-preproc +3 -5
  24. data/bin/review-textmaker +1 -3
  25. data/bin/review-update +1 -4
  26. data/bin/review-validate +5 -5
  27. data/bin/review-vol +5 -82
  28. data/bin/review-webmaker +1 -3
  29. data/doc/config.yml.sample +55 -12
  30. data/doc/config.yml.sample-simple +4 -3
  31. data/doc/format.ja.md +119 -17
  32. data/doc/format.md +106 -17
  33. data/doc/makeindex.ja.md +2 -2
  34. data/doc/pdfmaker.ja.md +42 -0
  35. data/doc/pdfmaker.md +41 -0
  36. data/doc/quickstart.ja.md +55 -25
  37. data/doc/quickstart.md +47 -17
  38. data/lib/review.rb +1 -1
  39. data/lib/review/book.rb +2 -2
  40. data/lib/review/book/base.rb +69 -30
  41. data/lib/review/book/bib.rb +21 -0
  42. data/lib/review/book/book_unit.rb +158 -0
  43. data/lib/review/book/chapter.rb +33 -26
  44. data/lib/review/book/index.rb +39 -206
  45. data/lib/review/book/index/item.rb +8 -2
  46. data/lib/review/book/page_metric.rb +7 -7
  47. data/lib/review/book/part.rb +26 -11
  48. data/lib/review/book/volume.rb +5 -5
  49. data/lib/review/builder.rb +124 -27
  50. data/lib/review/call_hook.rb +20 -0
  51. data/lib/review/catalog.rb +3 -2
  52. data/lib/review/compiler.rb +197 -91
  53. data/lib/review/configure.rb +95 -9
  54. data/lib/review/converter.rb +1 -1
  55. data/lib/review/epub2html.rb +6 -1
  56. data/lib/review/epubmaker.rb +116 -117
  57. data/lib/review/epubmaker/content.rb +113 -0
  58. data/lib/review/epubmaker/epubcommon.rb +372 -0
  59. data/lib/review/epubmaker/epubv2.rb +178 -0
  60. data/lib/review/epubmaker/epubv3.rb +231 -0
  61. data/lib/review/epubmaker/producer.rb +168 -0
  62. data/lib/review/epubmaker/reviewheaderlistener.rb +12 -2
  63. data/lib/review/epubmaker/zip_exporter.rb +84 -0
  64. data/lib/review/exception.rb +6 -0
  65. data/lib/review/extentions/string.rb +0 -4
  66. data/lib/review/htmlbuilder.rb +132 -87
  67. data/lib/review/htmlutils.rb +8 -11
  68. data/lib/review/i18n.rb +2 -1
  69. data/lib/review/idgxmlbuilder.rb +156 -76
  70. data/lib/review/idgxmlmaker.rb +22 -18
  71. data/lib/review/img_math.rb +245 -0
  72. data/lib/review/index_builder.rb +654 -0
  73. data/lib/review/init.rb +17 -18
  74. data/lib/review/latexbox.rb +58 -0
  75. data/lib/review/latexbuilder.rb +173 -43
  76. data/lib/review/latexutils.rb +9 -1
  77. data/lib/review/lineinput.rb +112 -2
  78. data/lib/review/logger.rb +42 -3
  79. data/lib/review/makerhelper.rb +12 -187
  80. data/lib/review/markdownbuilder.rb +51 -2
  81. data/lib/review/pdfmaker.rb +78 -73
  82. data/lib/review/plaintextbuilder.rb +98 -14
  83. data/lib/review/preprocessor.rb +18 -12
  84. data/lib/review/rstbuilder.rb +28 -9
  85. data/lib/review/sec_counter.rb +14 -0
  86. data/lib/review/template.rb +6 -0
  87. data/lib/review/textmaker.rb +21 -19
  88. data/lib/review/textutils.rb +3 -12
  89. data/lib/review/tocprinter.rb +242 -97
  90. data/lib/review/topbuilder.rb +91 -24
  91. data/lib/review/update.rb +12 -13
  92. data/lib/review/version.rb +1 -1
  93. data/lib/review/volumeprinter.rb +97 -0
  94. data/lib/review/webmaker.rb +34 -33
  95. data/lib/review/webtocprinter.rb +39 -35
  96. data/lib/review/yamlloader.rb +2 -1
  97. data/review.gemspec +5 -3
  98. data/samples/sample-book/src/.gitignore +1 -0
  99. data/samples/sample-book/src/config-ebook.yml +4 -0
  100. data/samples/sample-book/src/config-epub2.yml +1 -1
  101. data/samples/sample-book/src/config-jlreq-ebook.yml +4 -0
  102. data/samples/sample-book/src/config.yml +3 -3
  103. data/samples/sample-book/src/lib/tasks/review.rake +26 -6
  104. data/samples/syntax-book/Gemfile +1 -1
  105. data/samples/syntax-book/ch01.re +3 -1
  106. data/samples/syntax-book/ch02.re +28 -21
  107. data/samples/syntax-book/ch03.re +1 -1
  108. data/samples/syntax-book/config-jlreq-lualatex.yml +4 -0
  109. data/samples/syntax-book/config-print.yml +3 -0
  110. data/samples/syntax-book/config.yml +1 -1
  111. data/samples/syntax-book/images/img3-2.png +0 -0
  112. data/samples/syntax-book/lib/tasks/review.rake +23 -8
  113. data/templates/html/_colophon.html.erb +23 -0
  114. data/templates/html/_colophon_history.html.erb +9 -0
  115. data/templates/html/_cover.html.erb +10 -0
  116. data/templates/html/_part_body.html.erb +6 -0
  117. data/templates/html/_titlepage.html.erb +20 -0
  118. data/templates/html/layout-html5.html.erb +6 -0
  119. data/templates/html/layout-xhtml1.html.erb +6 -0
  120. data/templates/latex/config.erb +41 -29
  121. data/templates/latex/review-jlreq/README.md +3 -1
  122. data/templates/latex/review-jlreq/review-base.sty +47 -22
  123. data/templates/latex/review-jlreq/review-jlreq.cls +25 -24
  124. data/templates/latex/review-jlreq/review-style.sty +6 -1
  125. data/templates/latex/review-jlreq/review-tcbox.sty +348 -0
  126. data/templates/latex/review-jlreq/reviewmacro.sty +5 -0
  127. data/templates/latex/review-jsbook/README.md +7 -5
  128. data/templates/latex/review-jsbook/review-base.sty +47 -21
  129. data/templates/latex/review-jsbook/review-jsbook.cls +12 -2
  130. data/templates/latex/review-jsbook/review-style.sty +6 -1
  131. data/templates/latex/review-jsbook/review-tcbox.sty +348 -0
  132. data/templates/latex/review-jsbook/reviewmacro.sty +5 -0
  133. data/templates/opf/epubv2.opf.erb +7 -7
  134. data/templates/opf/epubv3.opf.erb +7 -7
  135. data/templates/opf/opf_manifest_epubv2.opf.erb +10 -0
  136. data/templates/opf/opf_manifest_epubv3.opf.erb +10 -0
  137. data/templates/opf/opf_metainfo_epubv2.opf.erb +17 -0
  138. data/templates/opf/opf_metainfo_epubv3.opf.erb +49 -0
  139. data/templates/opf/opf_tocx_epubv2.opf.erb +9 -0
  140. data/templates/opf/opf_tocx_epubv3.opf.erb +17 -0
  141. data/templates/web/html/layout-html5.html.erb +9 -8
  142. data/templates/web/html/layout-xhtml1.html.erb +6 -0
  143. data/test/assets/header_listener.html +35 -0
  144. data/test/assets/img_math/img1.png +0 -0
  145. data/test/assets/img_math/img2.png +0 -0
  146. data/test/assets/img_math/img3.png +0 -0
  147. data/test/assets/syntax_book_index_detail.txt +58 -0
  148. data/test/assets/test_template.tex +12 -9
  149. data/test/assets/test_template_backmatter.tex +12 -9
  150. data/test/book_test_helper.rb +11 -5
  151. data/test/run_test.rb +1 -1
  152. data/test/test_book.rb +62 -63
  153. data/test/test_book_chapter.rb +99 -56
  154. data/test/test_book_part.rb +3 -3
  155. data/test/test_builder.rb +24 -15
  156. data/test/test_catalog.rb +1 -0
  157. data/test/test_catalog_converter_cmd.rb +1 -1
  158. data/test/test_converter.rb +1 -0
  159. data/test/test_epub3maker.rb +170 -126
  160. data/test/test_epubmaker.rb +249 -129
  161. data/test/test_epubmaker_cmd.rb +14 -7
  162. data/test/test_helper.rb +23 -11
  163. data/test/test_htmlbuilder.rb +956 -76
  164. data/test/test_htmlutils.rb +0 -12
  165. data/test/test_i18n.rb +33 -33
  166. data/test/test_idgxmlbuilder.rb +568 -10
  167. data/test/test_idgxmlmaker_cmd.rb +50 -0
  168. data/test/test_image_finder.rb +52 -70
  169. data/test/test_img_math.rb +111 -0
  170. data/test/test_index.rb +62 -52
  171. data/test/test_indexbuilder.rb +52 -0
  172. data/test/test_latexbuilder.rb +1056 -30
  173. data/test/test_latexbuilder_v2.rb +52 -12
  174. data/test/test_lineinput.rb +20 -93
  175. data/test/test_logger.rb +7 -7
  176. data/test/test_makerhelper.rb +0 -12
  177. data/test/test_markdownbuilder.rb +32 -0
  178. data/test/test_pdfmaker.rb +100 -11
  179. data/test/test_pdfmaker_cmd.rb +101 -7
  180. data/test/test_plaintextbuilder.rb +531 -25
  181. data/test/test_review_ext.rb +2 -1
  182. data/test/test_reviewheaderlistener.rb +49 -0
  183. data/test/test_rstbuilder.rb +25 -1
  184. data/test/test_sec_counter.rb +156 -0
  185. data/test/test_template.rb +12 -2
  186. data/test/test_textmaker_cmd.rb +58 -0
  187. data/test/test_tocprinter.rb +46 -0
  188. data/test/test_topbuilder.rb +365 -10
  189. data/test/test_update.rb +44 -44
  190. data/test/test_webtocprinter.rb +75 -43
  191. data/test/test_zip_exporter.rb +5 -6
  192. data/vendor/gentombow/LICENSE +1 -1
  193. data/vendor/gentombow/Makefile +0 -1
  194. data/vendor/gentombow/bounddvi-en.pdf +0 -0
  195. data/vendor/gentombow/bounddvi-en.tex +1 -0
  196. data/vendor/gentombow/bounddvi.pdf +0 -0
  197. data/vendor/gentombow/bounddvi.sty +30 -7
  198. data/vendor/gentombow/bounddvi.tex +1 -0
  199. data/vendor/gentombow/create_archive.sh +1 -0
  200. data/vendor/gentombow/gentombow-ja.pdf +0 -0
  201. data/vendor/gentombow/gentombow-ja.tex +9 -0
  202. data/vendor/gentombow/gentombow.pdf +0 -0
  203. data/vendor/gentombow/gentombow.sty +32 -10
  204. data/vendor/gentombow/gentombow.tex +8 -0
  205. data/vendor/gentombow/tests/gentombow-01-pdfx.tex +8 -0
  206. data/vendor/gentombow/tests/gentombow-02-pdfx.tex +8 -0
  207. data/vendor/jsclasses/LICENSE +1 -1
  208. data/vendor/jsclasses/Makefile +3 -2
  209. data/vendor/jsclasses/create_archive.sh +5 -5
  210. data/vendor/jsclasses/jis/Makefile +3 -2
  211. data/vendor/jsclasses/jis/jsarticle.cls +74 -31
  212. data/vendor/jsclasses/jis/jsbook.cls +74 -31
  213. data/vendor/jsclasses/jis/jsclasses.dtx +176 -36
  214. data/vendor/jsclasses/jis/jsclasses.ins +15 -5
  215. data/vendor/jsclasses/jis/jslogo.dtx +4 -4
  216. data/vendor/jsclasses/jis/jslogo.ins +9 -0
  217. data/vendor/jsclasses/jis/jslogo.sty +4 -16
  218. data/vendor/jsclasses/jis/jspf.cls +73 -30
  219. data/vendor/jsclasses/jis/jsreport.cls +74 -31
  220. data/vendor/jsclasses/jis/jsverb.ins +9 -0
  221. data/vendor/jsclasses/jis/jsverb.sty +1 -13
  222. data/vendor/jsclasses/jis/kiyou.cls +74 -31
  223. data/vendor/jsclasses/jis/minijs.sty +65 -22
  224. data/vendor/jsclasses/jis/okumacro.dtx +4 -5
  225. data/vendor/jsclasses/jis/okumacro.ins +9 -0
  226. data/vendor/jsclasses/jis/okumacro.sty +4 -17
  227. data/vendor/jsclasses/jis/okuverb.ins +9 -0
  228. data/vendor/jsclasses/jis/okuverb.sty +1 -13
  229. data/vendor/jsclasses/jis/winjis.sty +23 -19
  230. data/vendor/jsclasses/jsarticle.cls +74 -31
  231. data/vendor/jsclasses/jsbook.cls +74 -31
  232. data/vendor/jsclasses/jsclasses.dtx +176 -36
  233. data/vendor/jsclasses/jsclasses.ins +15 -5
  234. data/vendor/jsclasses/jsclasses.pdf +0 -0
  235. data/vendor/jsclasses/jslogo.dtx +4 -4
  236. data/vendor/jsclasses/jslogo.ins +9 -0
  237. data/vendor/jsclasses/jslogo.pdf +0 -0
  238. data/vendor/jsclasses/jslogo.sty +4 -16
  239. data/vendor/jsclasses/jspf.cls +73 -30
  240. data/vendor/jsclasses/jsreport.cls +74 -31
  241. data/vendor/jsclasses/jsverb.ins +9 -0
  242. data/vendor/jsclasses/jsverb.pdf +0 -0
  243. data/vendor/jsclasses/jsverb.sty +1 -13
  244. data/vendor/jsclasses/kiyou.cls +74 -31
  245. data/vendor/jsclasses/minijs.sty +68 -22
  246. data/vendor/jsclasses/okumacro.dtx +4 -5
  247. data/vendor/jsclasses/okumacro.ins +9 -0
  248. data/vendor/jsclasses/okumacro.pdf +0 -0
  249. data/vendor/jsclasses/okumacro.sty +4 -17
  250. data/vendor/jsclasses/okuverb.ins +9 -0
  251. data/vendor/jsclasses/okuverb.pdf +0 -0
  252. data/vendor/jsclasses/okuverb.sty +1 -13
  253. data/vendor/jsclasses/tests/relfont.tex +10 -0
  254. data/vendor/jsclasses/winjis.sty +23 -19
  255. metadata +109 -20
  256. data/.rubocop_todo.yml +0 -7
  257. data/lib/epubmaker.rb +0 -23
  258. data/lib/epubmaker/content.rb +0 -110
  259. data/lib/epubmaker/epubcommon.rb +0 -441
  260. data/lib/epubmaker/epubv2.rb +0 -143
  261. data/lib/epubmaker/epubv3.rb +0 -233
  262. data/lib/epubmaker/producer.rb +0 -375
  263. data/lib/epubmaker/zip_exporter.rb +0 -81
  264. data/lib/lineinput.rb +0 -155
  265. data/lib/review/book/compilable.rb +0 -178
  266. data/lib/review/tocparser.rb +0 -271
  267. data/samples/syntax-book/review-ext.rb +0 -14
  268. data/test/test_tocparser.rb +0 -25
@@ -16,6 +16,7 @@ class MARKDOWNBuilderTest < Test::Unit::TestCase
16
16
  @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
17
17
  location = Location.new(nil, nil)
18
18
  @builder.bind(@compiler, @chapter, location)
19
+ I18n.setup(@config['language'])
19
20
  end
20
21
 
21
22
  def test_quote
@@ -47,7 +48,9 @@ EOS
47
48
  <div class="memo">
48
49
  <p class="caption">this is **test**<&>_</p>
49
50
  test1
51
+
50
52
  test*2*
53
+
51
54
  </div>
52
55
  EOS
53
56
  assert_equal expected, actual
@@ -103,6 +106,35 @@ EOS
103
106
  assert_equal %Q(test <span class="red">コメント</span> test2), actual
104
107
  end
105
108
 
109
+ def test_inline_hd_chap
110
+ def @chapter.headline_index
111
+ item = Book::Index::Item.new('chap1|test', [1, 1], 'te_st')
112
+ idx = Book::HeadlineIndex.new(self)
113
+ idx.add_item(item)
114
+ idx
115
+ end
116
+
117
+ @config['secnolevel'] = 2
118
+ actual = compile_inline('test @<hd>{chap1|test} test2')
119
+ assert_equal 'test <a href="#h1-1-1">「te_st」</a> test2', actual
120
+
121
+ actual = compile_inline('test @<hd>{test} test2')
122
+ assert_equal 'test <a href="#h1-1-1">「te_st」</a> test2', actual
123
+
124
+ @config['secnolevel'] = 3
125
+ actual = compile_inline('test @<hd>{chap1|test} test2')
126
+ assert_equal 'test <a href="#h1-1-1">「1.1.1 te_st」</a> test2', actual
127
+
128
+ @config['chapterlink'] = nil
129
+ @config['secnolevel'] = 2
130
+ actual = compile_inline('test @<hd>{chap1|test} test2')
131
+ assert_equal 'test 「te_st」 test2', actual
132
+
133
+ @config['secnolevel'] = 3
134
+ actual = compile_inline('test @<hd>{chap1|test} test2')
135
+ assert_equal 'test 「1.1.1 te_st」 test2', actual
136
+ end
137
+
106
138
  def test_ul_nest1
107
139
  src = <<-EOS
108
140
  * AAA
@@ -10,9 +10,10 @@ class PDFMakerTest < Test::Unit::TestCase
10
10
  @config.merge!(
11
11
  'bookname' => 'sample',
12
12
  'title' => 'Sample Book',
13
- 'review_version' => 3,
13
+ 'aut' => 'anonymous',
14
+ 'review_version' => 4,
14
15
  'urnid' => 'http://example.jp/',
15
- 'date' => '2011-01-01',
16
+ 'date' => '2020-07-11',
16
17
  'language' => 'ja',
17
18
  'texcommand' => 'uplatex'
18
19
  )
@@ -75,7 +76,7 @@ class PDFMakerTest < Test::Unit::TestCase
75
76
  Dir.mktmpdir do |dir|
76
77
  coverfile = 'cover.html'
77
78
  content = '<html><body>test</body></html>'
78
- File.open(File.join(dir, 'cover.tex'), 'w') { |f| f.write(content) }
79
+ File.write(File.join(dir, 'cover.tex'), content)
79
80
  page = @maker.make_custom_page(File.join(dir, coverfile))
80
81
  assert_equal(content, page)
81
82
  end
@@ -144,11 +145,28 @@ class PDFMakerTest < Test::Unit::TestCase
144
145
  @maker.erb_config
145
146
  tmpl = @maker.template_content
146
147
  expect = File.read(File.join(assets_dir, 'test_template.tex'))
147
- expect.gsub!(/\\def\\review@reviewversion{[^\}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
148
+ expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
148
149
  assert_equal(expect, tmpl)
149
150
  end
150
151
  end
151
152
 
153
+ def test_template_content_with_localconfig
154
+ @config['mycustom'] = { 'value' => '#_TEST_' }
155
+ Dir.mktmpdir do |dir|
156
+ Dir.chdir(dir) do
157
+ Dir.mkdir('layouts')
158
+ File.write(File.join('layouts', 'config-local.tex.erb'), %q(\def\customvalue{<%= escape(@config['mycustom']['value']) %>}) + "\n")
159
+ @maker.basedir = Dir.pwd
160
+ @maker.erb_config
161
+ tmpl = @maker.template_content
162
+ expect = File.read(File.join(assets_dir, 'test_template.tex'))
163
+ expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
164
+ expect.sub!("\\makeatother\n", '\&' + "%% BEGIN: config-local.tex.erb\n\\def\\customvalue{\\#\\textunderscore{}TEST\\textunderscore{}}\n%% END: config-local.tex.erb\n")
165
+ assert_equal(expect, tmpl)
166
+ end
167
+ end
168
+ end
169
+
152
170
  def test_gettemplate_with_backmatter
153
171
  @config.merge!(
154
172
  'backcover' => 'backcover.tex',
@@ -158,13 +176,13 @@ class PDFMakerTest < Test::Unit::TestCase
158
176
  Dir.mktmpdir do |dir|
159
177
  Dir.chdir(dir) do
160
178
  profile = "\\thispagestyle{empty}\\chapter*{Profile}\nsome profile\n"
161
- File.open(File.join(dir, 'profile.tex'), 'w') { |f| f.write(profile) }
179
+ File.write(File.join(dir, 'profile.tex'), profile)
162
180
  advfile = "\\thispagestyle{empty}\\chapter*{Ad}\nsome ad content\n"
163
- File.open(File.join(dir, 'advfile.tex'), 'w') { |f| f.write(advfile) }
181
+ File.write(File.join(dir, 'advfile.tex'), advfile)
164
182
  backcover = "\\clearpage\n\\thispagestyle{empty}\\AddToShipoutPictureBG{%\n\\AtPageLowerLeft{\\includegraphics[width=\\paperwidth,height=\\paperheight]{images/backcover.png}}\n}\n\\null"
165
- File.open(File.join(dir, 'backcover.tex'), 'w') { |f| f.write(backcover) }
183
+ File.write(File.join(dir, 'backcover.tex'), backcover)
166
184
  expect = File.read(File.join(assets_dir, 'test_template_backmatter.tex'))
167
- expect.gsub!(/\\def\\review@reviewversion{[^\}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
185
+ expect.gsub!(/\\def\\review@reviewversion{[^}]+}/, "\\def\\review@reviewversion{#{ReVIEW::VERSION}}")
168
186
  @maker.basedir = Dir.pwd
169
187
  @maker.erb_config
170
188
  tmpl = @maker.template_content
@@ -179,7 +197,7 @@ class PDFMakerTest < Test::Unit::TestCase
179
197
  @config['pht'] = ['Mrs.Smith']
180
198
  @config['language'] = 'ja'
181
199
  history = @maker.make_history_list
182
- expect = ['201111日 発行']
200
+ expect = ['2020711日 発行']
183
201
  assert_equal expect, history
184
202
  end
185
203
 
@@ -190,9 +208,9 @@ class PDFMakerTest < Test::Unit::TestCase
190
208
  @config['language'] = 'ja'
191
209
  @config['history'] =
192
210
  [['2011-08-03 v1.0.0版発行',
193
- '2012-02-15 v1.1.0版発行']]
211
+ '2020-07-11 v1.2.0版発行']]
194
212
  history = @maker.make_history_list
195
- expect = ['2011年8月3日 v1.0.0版発行', '2012215日 v1.1.0版発行']
213
+ expect = ['2011年8月3日 v1.0.0版発行', '2020711日 v1.2.0版発行']
196
214
  assert_equal expect, history
197
215
  end
198
216
 
@@ -243,4 +261,75 @@ class PDFMakerTest < Test::Unit::TestCase
243
261
  '2012年1月31日 ver 1.2.1発行']
244
262
  assert_equal expect, history
245
263
  end
264
+
265
+ def test_box_setting_is_defined
266
+ %w[column note memo tip info warning important caution notice].each do |name|
267
+ @config['pdfmaker']['boxsetting'] = {
268
+ name => { 'style' => 'simplebox' }
269
+ }
270
+ assert !ReVIEW::LaTeXBox.new.tcbox(@config).empty?
271
+ end
272
+ @config['pdfmaker']['boxsetting'] = {
273
+ 'invalid' => { 'style' => 'simplebox' }
274
+ }
275
+ assert ReVIEW::LaTeXBox.new.tcbox(@config).empty?
276
+ end
277
+
278
+ def test_box_setting_options
279
+ @config['pdfmaker']['boxsetting'] = {
280
+ 'note' => { 'style' => 'simplebox' },
281
+ 'important' => { 'style' => 'simplebox', 'options' => 'colback=blue,arc=3mm' },
282
+ 'caution' => { 'style' => 'squarecaptionbox', 'options_with_caption' => 'attach boxed title to top bottom' }
283
+ }
284
+
285
+ expected = <<-EOS
286
+ \\renewenvironment{reviewnote}[1][]{%
287
+ \\csdef{rv@tmp@withcaption}{true}
288
+ \\notblank{##1}{
289
+ \\begin{rv@simplebox@caption}{##1}[]
290
+ }{
291
+ \\csundef{rv@tmp@withcaption}
292
+ \\begin{rv@simplebox@nocaption}[]
293
+ }
294
+ }{
295
+ \\ifcsdef{rv@tmp@withcaption}{
296
+ \\end{rv@simplebox@caption}
297
+ }{
298
+ \\end{rv@simplebox@nocaption}
299
+ }
300
+ }
301
+ \\renewenvironment{reviewimportant}[1][]{%
302
+ \\csdef{rv@tmp@withcaption}{true}
303
+ \\notblank{##1}{
304
+ \\begin{rv@simplebox@caption}{##1}[colback=blue,arc=3mm]
305
+ }{
306
+ \\csundef{rv@tmp@withcaption}
307
+ \\begin{rv@simplebox@nocaption}[colback=blue,arc=3mm]
308
+ }
309
+ }{
310
+ \\ifcsdef{rv@tmp@withcaption}{
311
+ \\end{rv@simplebox@caption}
312
+ }{
313
+ \\end{rv@simplebox@nocaption}
314
+ }
315
+ }
316
+ \\renewenvironment{reviewcaution}[1][]{%
317
+ \\csdef{rv@tmp@withcaption}{true}
318
+ \\notblank{##1}{
319
+ \\begin{rv@squarecaptionbox@caption}{##1}[attach boxed title to top bottom]
320
+ }{
321
+ \\csundef{rv@tmp@withcaption}
322
+ \\begin{rv@squarecaptionbox@nocaption}[]
323
+ }
324
+ }{
325
+ \\ifcsdef{rv@tmp@withcaption}{
326
+ \\end{rv@squarecaptionbox@caption}
327
+ }{
328
+ \\end{rv@squarecaptionbox@nocaption}
329
+ }
330
+ }
331
+ EOS
332
+ actual = ReVIEW::LaTeXBox.new.tcbox(@config)
333
+ assert_equal expected, actual
334
+ end
246
335
  end
@@ -3,15 +3,16 @@ require 'tmpdir'
3
3
  require 'fileutils'
4
4
  require 'yaml'
5
5
  require 'rbconfig'
6
+ require 'open3'
6
7
 
7
- REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker', File.dirname(__FILE__))
8
+ REVIEW_PDFMAKER = File.expand_path('../bin/review-pdfmaker', __dir__)
8
9
 
9
10
  class PDFMakerCmdTest < Test::Unit::TestCase
10
11
  def setup
11
12
  @tmpdir1 = Dir.mktmpdir
12
13
 
13
14
  @old_rubylib = ENV['RUBYLIB']
14
- ENV['RUBYLIB'] = File.expand_path('../lib', File.dirname(__FILE__))
15
+ ENV['RUBYLIB'] = File.expand_path('../lib', __dir__)
15
16
  end
16
17
 
17
18
  def teardown
@@ -19,18 +20,111 @@ class PDFMakerCmdTest < Test::Unit::TestCase
19
20
  ENV['RUBYLIB'] = @old_rubylib
20
21
  end
21
22
 
22
- def test_pdfmaker_cmd
23
+ def common_buildpdf(bookdir, templatedir, configfile, targetpdffile, option = nil)
23
24
  if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
24
- config = prepare_samplebook(@tmpdir1)
25
+ config = prepare_samplebook(@tmpdir1, bookdir, templatedir, configfile)
25
26
  builddir = File.join(@tmpdir1, config['bookname'] + '-pdf')
26
- # assert !File.exist?(builddir)
27
+ assert !File.exist?(builddir)
27
28
 
28
29
  ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
29
30
  Dir.chdir(@tmpdir1) do
30
- system("#{ruby_cmd} -S #{REVIEW_PDFMAKER} config.yml 1>/dev/null 2>/dev/null")
31
+ _o, e, s = Open3.capture3("#{ruby_cmd} -S #{REVIEW_PDFMAKER} #{option} #{configfile}")
32
+ if !e.empty? && !s.success?
33
+ $stderr.puts e
34
+ end
35
+ assert s.success?
31
36
  end
37
+ assert File.exist?(File.join(@tmpdir1, targetpdffile))
38
+ end
39
+ end
40
+
41
+ def test_pdfmaker_cmd_sample_jsbook_print
42
+ begin
43
+ `uplatex -v`
44
+ rescue
45
+ $stderr.puts 'skip test_pdfmaker_cmd_sample_jsbook_print'
46
+ return true
47
+ end
48
+ common_buildpdf('sample-book/src', 'review-jsbook', 'config.yml', 'book.pdf')
49
+ end
50
+
51
+ def test_pdfmaker_cmd_sample_jsbook_ebook
52
+ begin
53
+ `uplatex -v`
54
+ rescue
55
+ $stderr.puts 'skip test_pdfmaker_cmd_sample_jsbook_ebook'
56
+ return true
57
+ end
58
+ common_buildpdf('sample-book/src', 'review-jsbook', 'config-ebook.yml', 'book.pdf')
59
+ end
60
+
61
+ def test_pdfmaker_cmd_sample_jlreq_print
62
+ begin
63
+ `uplatex -v`
64
+ rescue
65
+ $stderr.puts 'skip test_pdfmaker_cmd_sample_jlreq_print'
66
+ return true
67
+ end
68
+ common_buildpdf('sample-book/src', 'review-jlreq', 'config-jlreq.yml', 'book.pdf')
69
+ end
70
+
71
+ def test_pdfmaker_cmd_sample_jlreq_ebook
72
+ begin
73
+ `uplatex -v`
74
+ rescue
75
+ $stderr.puts 'skip test_pdfmaker_cmd_sample_jlreq_ebook'
76
+ return true
77
+ end
78
+ common_buildpdf('sample-book/src', 'review-jlreq', 'config-jlreq-ebook.yml', 'book.pdf')
79
+ end
80
+
81
+ def test_pdfmaker_cmd_syntax_jsbook_print
82
+ begin
83
+ `uplatex -v`
84
+ rescue
85
+ $stderr.puts 'skip test_pdfmaker_cmd_syntax_jsbook_print'
86
+ return true
87
+ end
88
+ common_buildpdf('syntax-book', 'review-jsbook', 'config-print.yml', 'syntax-book.pdf')
89
+ end
90
+
91
+ def test_pdfmaker_cmd_syntax_jsbook_print_buildonly
92
+ begin
93
+ `uplatex -v`
94
+ rescue
95
+ $stderr.puts 'skip test_pdfmaker_cmd_syntax_jsbook_print_buildonly'
96
+ return true
97
+ end
98
+ common_buildpdf('syntax-book', 'review-jsbook', 'config-print.yml', 'syntax-book.pdf', '-y ch01')
99
+ end
100
+
101
+ def test_pdfmaker_cmd_syntax_jsbook_ebook
102
+ begin
103
+ `uplatex -v`
104
+ rescue
105
+ $stderr.puts 'skip test_pdfmaker_cmd_syntax_jsbook_ebook'
106
+ return true
107
+ end
108
+ common_buildpdf('syntax-book', 'review-jsbook', 'config.yml', 'syntax-book.pdf')
109
+ end
110
+
111
+ def test_pdfmaker_cmd_syntax_jlreq_ebook
112
+ begin
113
+ `uplatex -v`
114
+ rescue
115
+ $stderr.puts 'skip test_pdfmaker_cmd_syntax_jlreq_ebook'
116
+ return true
117
+ end
118
+ common_buildpdf('syntax-book', 'review-jlreq', 'config-jlreq.yml', 'syntax-book.pdf')
119
+ end
32
120
 
33
- assert File.exist?(builddir)
121
+ def test_pdfmaker_cmd_syntax_jlreq_ebook_lualatex
122
+ begin
123
+ `lualatex -v`
124
+ rescue
125
+ $stderr.puts 'skip test_pdfmaker_cmd_syntax_jlreq_ebook_lualatex'
126
+ return true
34
127
  end
128
+ common_buildpdf('syntax-book', 'review-jlreq', 'config-jlreq-lualatex.yml', 'syntax-book.pdf')
35
129
  end
36
130
  end
@@ -90,9 +90,16 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
90
90
  assert_equal "\n", actual
91
91
  end
92
92
 
93
- def test_inline_i
94
- actual = compile_inline('test @<i>{inline test} test2')
95
- assert_equal 'test inline test test2', actual
93
+ def test_inline_asis
94
+ %w[i b tti ttb bou ami u strong em code ins tcy].each do |tag|
95
+ actual = compile_inline("test @<#{tag}>{inline test} test2")
96
+ assert_equal 'test inline test test2', actual
97
+ end
98
+ end
99
+
100
+ def test_inline_del
101
+ actual = compile_inline('test @<del>{inline test} test2')
102
+ assert_equal 'test test2', actual
96
103
  end
97
104
 
98
105
  def test_inline_i_and_escape
@@ -100,11 +107,6 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
100
107
  assert_equal 'test inline<&;\\ test test2', actual
101
108
  end
102
109
 
103
- def test_inline_b
104
- actual = compile_inline('test @<b>{inline test} test2')
105
- assert_equal 'test inline test test2', actual
106
- end
107
-
108
110
  def test_inline_b_and_escape
109
111
  actual = compile_inline('test @<b>{inline<&;\\ test} test2')
110
112
  assert_equal 'test inline<&;\\ test test2', actual
@@ -115,16 +117,6 @@ class PLAINTEXTBuidlerTest < Test::Unit::TestCase
115
117
  assert_equal 'test inline test test2}', actual
116
118
  end
117
119
 
118
- def test_inline_tti
119
- actual = compile_inline('test @<tti>{inline test} test2')
120
- assert_equal 'test inline test test2', actual
121
- end
122
-
123
- def test_inline_ttb
124
- actual = compile_inline('test @<ttb>{inline test} test2')
125
- assert_equal 'test inline test test2', actual
126
- end
127
-
128
120
  def test_inline_uchar
129
121
  actual = compile_inline('test @<uchar>{2460} test2')
130
122
  assert_equal 'test ① test2', actual
@@ -249,6 +241,17 @@ EOS
249
241
  foo
250
242
  bar
251
243
 
244
+ EOS
245
+ assert_equal expected, actual
246
+
247
+ @config['caption_position']['list'] = 'bottom'
248
+ actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
249
+ expected = <<-EOS
250
+ foo
251
+ bar
252
+
253
+ リスト1.1 this is test<&>_
254
+
252
255
  EOS
253
256
  assert_equal expected, actual
254
257
  end
@@ -264,6 +267,17 @@ EOS
264
267
  1: foo
265
268
  2: bar
266
269
 
270
+ EOS
271
+ assert_equal expected, actual
272
+
273
+ @config['caption_position']['list'] = 'bottom'
274
+ actual = compile_block("//listnum[test][this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
275
+ expected = <<-EOS
276
+ 1: foo
277
+ 2: bar
278
+
279
+ リスト1.1 this is test<&>_
280
+
267
281
  EOS
268
282
  assert_equal expected, actual
269
283
  end
@@ -277,6 +291,18 @@ bar
277
291
 
278
292
  buz
279
293
 
294
+ EOS
295
+ assert_equal expected, actual
296
+
297
+ @config['caption_position']['list'] = 'bottom'
298
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
299
+ expected = <<-EOS
300
+ foo
301
+ bar
302
+
303
+ buz
304
+ foo/bar/test.rb
305
+
280
306
  EOS
281
307
  assert_equal expected, actual
282
308
  end
@@ -308,6 +334,16 @@ FOO
308
334
  foo
309
335
  bar
310
336
 
337
+ EOS
338
+ assert_equal expected, actual
339
+
340
+ @config['caption_position']['list'] = 'bottom'
341
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
342
+ expected = <<-EOS
343
+ foo
344
+ bar
345
+ FOO
346
+
311
347
  EOS
312
348
  assert_equal expected, actual
313
349
  end
@@ -327,6 +363,16 @@ cap1
327
363
  lineA
328
364
  lineB
329
365
 
366
+ EOS
367
+ assert_equal expected, actual
368
+
369
+ @config['caption_position']['list'] = 'bottom'
370
+ actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
371
+ expected = <<-EOS
372
+ lineA
373
+ lineB
374
+ cap1
375
+
330
376
  EOS
331
377
  assert_equal expected, actual
332
378
  end
@@ -348,6 +394,16 @@ cap1
348
394
  lineA
349
395
  lineB
350
396
 
397
+ EOS
398
+ assert_equal expected, actual
399
+
400
+ @config['caption_position']['list'] = 'bottom'
401
+ actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
402
+ expected = <<-EOS
403
+ lineA
404
+ lineB
405
+ cap1
406
+
351
407
  EOS
352
408
  assert_equal expected, actual
353
409
  end
@@ -359,6 +415,16 @@ this is test<&>_
359
415
  1: foo
360
416
  2: bar
361
417
 
418
+ EOS
419
+ assert_equal expected, actual
420
+
421
+ @config['caption_position']['list'] = 'bottom'
422
+ actual = compile_block("//emlistnum[this is @<b>{test}<&>_]{\nfoo\nbar\n//}\n")
423
+ expected = <<-EOS
424
+ 1: foo
425
+ 2: bar
426
+ this is test<&>_
427
+
362
428
  EOS
363
429
  assert_equal expected, actual
364
430
  end
@@ -387,15 +453,25 @@ EOS
387
453
  aaa\tbbb
388
454
  ccc\tddd<>&
389
455
 
456
+ EOS
457
+ assert_equal expected, actual
458
+
459
+ @config['caption_position']['table'] = 'bottom'
460
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
461
+ expected = <<-EOS
462
+ aaa\tbbb
463
+ ccc\tddd<>&
464
+
465
+ 表1.1 FOO
390
466
  EOS
391
467
  assert_equal expected, actual
392
468
  end
393
469
 
394
470
  def test_empty_table
395
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
471
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n//}\n") }
396
472
  assert_equal ':2: error: no rows in the table', e.message
397
473
 
398
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
474
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("//table{\n------------\n//}\n") }
399
475
  assert_equal ':3: error: no rows in the table', e.message
400
476
  end
401
477
 
@@ -512,6 +588,147 @@ EOS
512
588
  assert_equal expected, actual
513
589
  end
514
590
 
591
+ def test_minicolumn_blocks
592
+ %w[note memo tip info warning important caution notice].each do |type|
593
+ @builder.doc_status.clear
594
+ src = <<-EOS
595
+ //#{type}[#{type}1]{
596
+
597
+ //}
598
+
599
+ //#{type}[#{type}2]{
600
+ //}
601
+ EOS
602
+
603
+ expected = <<-EOS
604
+ #{type}1
605
+
606
+ #{type}2
607
+
608
+ EOS
609
+ assert_equal expected, compile_block(src)
610
+
611
+ src = <<-EOS
612
+ //#{type}[#{type}2]{
613
+
614
+ //}
615
+
616
+ //#{type}[#{type}3]{
617
+
618
+ //}
619
+
620
+ //#{type}[#{type}4]{
621
+
622
+ //}
623
+
624
+ //#{type}[#{type}5]{
625
+
626
+ //}
627
+
628
+ //#{type}[#{type}6]{
629
+
630
+ //}
631
+ EOS
632
+
633
+ expected = <<-EOS
634
+ #{type}2
635
+
636
+ #{type}3
637
+
638
+ #{type}4
639
+
640
+ #{type}5
641
+
642
+ #{type}6
643
+
644
+ EOS
645
+ assert_equal expected, compile_block(src)
646
+
647
+ src = <<-EOS
648
+ //#{type}{
649
+
650
+ * A
651
+
652
+ 1. B
653
+
654
+ //}
655
+
656
+ //#{type}[OMITEND1]{
657
+
658
+ //emlist{
659
+ LIST
660
+ //}
661
+
662
+ //}
663
+ //#{type}[OMITEND2]{
664
+ //}
665
+ EOS
666
+
667
+ expected = <<-EOS
668
+ A
669
+
670
+ 1 B
671
+
672
+ OMITEND1
673
+
674
+ LIST
675
+
676
+ OMITEND2
677
+
678
+ EOS
679
+ assert_equal expected, compile_block(src)
680
+ end
681
+ end
682
+
683
+ def test_minicolumn_blocks_nest_error1
684
+ %w[note memo tip info warning important caution notice].each do |type|
685
+ @builder.doc_status.clear
686
+ src = <<-EOS
687
+ //#{type}{
688
+
689
+ //#{type}{
690
+ //}
691
+
692
+ //}
693
+ EOS
694
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
695
+ assert_match(/minicolumn cannot be nested:/, e.message)
696
+ end
697
+ end
698
+
699
+ def test_minicolumn_blocks_nest_error2
700
+ %w[note memo tip info warning important caution notice].each do |type|
701
+ @builder.doc_status.clear
702
+ src = <<-EOS
703
+ //#{type}{
704
+
705
+ //#{type}{
706
+
707
+ //}
708
+
709
+ //}
710
+ EOS
711
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
712
+ assert_match(/minicolumn cannot be nested:/, e.message)
713
+ end
714
+ end
715
+
716
+ def test_minicolumn_blocks_nest_error3
717
+ %w[memo tip info warning important caution notice].each do |type|
718
+ @builder.doc_status.clear
719
+ src = <<-EOS
720
+ //#{type}{
721
+
722
+ //note{
723
+ //}
724
+
725
+ //}
726
+ EOS
727
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
728
+ assert_match(/minicolumn cannot be nested:/, e.message)
729
+ end
730
+ end
731
+
515
732
  def test_image
516
733
  def @chapter.image(_id)
517
734
  item = Book::Index::Item.new('sampleimg', 1)
@@ -521,6 +738,10 @@ EOS
521
738
 
522
739
  actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
523
740
  assert_equal %Q(図1.1 sample photo\n\n), actual
741
+
742
+ @config['caption_position']['image'] = 'top'
743
+ actual = compile_block("//image[sampleimg][sample photo]{\nfoo\n//}\n")
744
+ assert_equal %Q(図1.1 sample photo\n\n), actual
524
745
  end
525
746
 
526
747
  def test_image_with_metric
@@ -540,18 +761,18 @@ EOS
540
761
  end
541
762
 
542
763
  def test_inline_unknown
543
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<img>{n}\n" }
764
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<img>{n}\n") }
544
765
  assert_equal ':1: error: unknown image: n', e.message
545
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<fn>{n}\n" }
766
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<fn>{n}\n") }
546
767
  assert_equal ':1: error: unknown footnote: n', e.message
547
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<hd>{n}\n" }
768
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<hd>{n}\n") }
548
769
  assert_equal ':1: error: unknown headline: n', e.message
549
770
  %w[list table column].each do |name|
550
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
771
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
551
772
  assert_equal ":1: error: unknown #{name}: n", e.message
552
773
  end
553
774
  %w[chap chapref title].each do |name|
554
- e = assert_raises(ReVIEW::ApplicationError) { compile_block "@<#{name}>{n}\n" }
775
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block("@<#{name}>{n}\n") }
555
776
  assert_equal ':1: error: key not found: "n"', e.message
556
777
  end
557
778
  end
@@ -652,5 +873,290 @@ e=mc^2
652
873
  EOS
653
874
  actual = compile_block(src)
654
875
  assert_equal expected, actual
876
+
877
+ @config['caption_position']['equation'] = 'bottom'
878
+ expected = <<-EOS
879
+ 式1.1
880
+
881
+ e=mc^2
882
+ 式1.1 The Equivalence of Mass and Energy
883
+
884
+ EOS
885
+ actual = compile_block(src)
886
+ assert_equal expected, actual
887
+ end
888
+
889
+ def test_nest_error_open
890
+ src = <<-EOS
891
+ //endchild
892
+ EOS
893
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
894
+ assert_equal ":1: error: //endchild is shown, but any opened //beginchild doesn't exist", e.message
895
+ end
896
+
897
+ def test_nest_error_close1
898
+ src = <<-EOS
899
+ //beginchild
900
+ EOS
901
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
902
+ assert_equal ":1: error: //beginchild is shown, but previous element isn't ul, ol, or dl", e.message
903
+ end
904
+
905
+ def test_nest_error_close2
906
+ src = <<-EOS
907
+ * foo
908
+
909
+ //beginchild
910
+
911
+ 1. foo
912
+
913
+ //beginchild
914
+
915
+ : foo
916
+
917
+ //beginchild
918
+ EOS
919
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
920
+ assert_equal ':12: error: //beginchild of dl,ol,ul misses //endchild', e.message
921
+ end
922
+
923
+ def test_nest_error_close3
924
+ src = <<-EOS
925
+ * foo
926
+
927
+ //beginchild
928
+
929
+ 1. foo
930
+
931
+ //beginchild
932
+
933
+ : foo
934
+
935
+ //beginchild
936
+
937
+ //endchild
938
+ EOS
939
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
940
+ assert_equal ':14: error: //beginchild of ol,ul misses //endchild', e.message
941
+ end
942
+
943
+ def test_nest_ul
944
+ src = <<-EOS
945
+ * UL1
946
+
947
+ //beginchild
948
+
949
+ 1. UL1-OL1
950
+ 2. UL1-OL2
951
+
952
+ * UL1-UL1
953
+ * UL1-UL2
954
+
955
+ : UL1-DL1
956
+ UL1-DD1
957
+ : UL1-DL2
958
+ UL1-DD2
959
+
960
+ //endchild
961
+
962
+ * UL2
963
+
964
+ //beginchild
965
+
966
+ UL2-PARA
967
+
968
+ //endchild
969
+ EOS
970
+
971
+ expected = <<-EOS
972
+ UL1
973
+
974
+ 1 UL1-OL1
975
+ 2 UL1-OL2
976
+
977
+ UL1-UL1
978
+ UL1-UL2
979
+
980
+ UL1-DL1
981
+ UL1-DD1
982
+ UL1-DL2
983
+ UL1-DD2
984
+
985
+ UL2
986
+ UL2-PARA
987
+ EOS
988
+
989
+ actual = compile_block(src)
990
+ assert_equal expected, actual
991
+ end
992
+
993
+ def test_nest_ol
994
+ src = <<-EOS
995
+ 1. OL1
996
+
997
+ //beginchild
998
+
999
+ 1. OL1-OL1
1000
+ 2. OL1-OL2
1001
+
1002
+ * OL1-UL1
1003
+ * OL1-UL2
1004
+
1005
+ : OL1-DL1
1006
+ OL1-DD1
1007
+ : OL1-DL2
1008
+ OL1-DD2
1009
+
1010
+ //endchild
1011
+
1012
+ 2. OL2
1013
+
1014
+ //beginchild
1015
+
1016
+ OL2-PARA
1017
+
1018
+ //endchild
1019
+ EOS
1020
+
1021
+ expected = <<-EOS
1022
+ 1 OL1
1023
+
1024
+ 1 OL1-OL1
1025
+ 2 OL1-OL2
1026
+
1027
+ OL1-UL1
1028
+ OL1-UL2
1029
+
1030
+ OL1-DL1
1031
+ OL1-DD1
1032
+ OL1-DL2
1033
+ OL1-DD2
1034
+
1035
+ 2 OL2
1036
+ OL2-PARA
1037
+ EOS
1038
+
1039
+ actual = compile_block(src)
1040
+ assert_equal expected, actual
1041
+ end
1042
+
1043
+ def test_nest_dl
1044
+ src = <<-EOS
1045
+ : DL1
1046
+
1047
+ //beginchild
1048
+
1049
+ 1. DL1-OL1
1050
+ 2. DL1-OL2
1051
+
1052
+ * DL1-UL1
1053
+ * DL1-UL2
1054
+
1055
+ : DL1-DL1
1056
+ DL1-DD1
1057
+ : DL1-DL2
1058
+ DL1-DD2
1059
+
1060
+ //endchild
1061
+
1062
+ : DL2
1063
+ DD2
1064
+
1065
+ //beginchild
1066
+
1067
+ * DD2-UL1
1068
+ * DD2-UL2
1069
+
1070
+ DD2-PARA
1071
+
1072
+ //endchild
1073
+ EOS
1074
+
1075
+ expected = <<-EOS
1076
+ DL1
1077
+
1078
+ 1 DL1-OL1
1079
+ 2 DL1-OL2
1080
+
1081
+ DL1-UL1
1082
+ DL1-UL2
1083
+
1084
+ DL1-DL1
1085
+ DL1-DD1
1086
+ DL1-DL2
1087
+ DL1-DD2
1088
+
1089
+ DL2
1090
+ DD2
1091
+
1092
+ DD2-UL1
1093
+ DD2-UL2
1094
+
1095
+ DD2-PARA
1096
+ EOS
1097
+
1098
+ actual = compile_block(src)
1099
+ assert_equal expected, actual
1100
+ end
1101
+
1102
+ def test_nest_multi
1103
+ src = <<-EOS
1104
+ 1. OL1
1105
+
1106
+ //beginchild
1107
+
1108
+ 1. OL1-OL1
1109
+
1110
+ //beginchild
1111
+
1112
+ * OL1-OL1-UL1
1113
+
1114
+ OL1-OL1-PARA
1115
+
1116
+ //endchild
1117
+
1118
+ 2. OL1-OL2
1119
+
1120
+ * OL1-UL1
1121
+
1122
+ //beginchild
1123
+
1124
+ : OL1-UL1-DL1
1125
+ OL1-UL1-DD1
1126
+
1127
+ OL1-UL1-PARA
1128
+
1129
+ //endchild
1130
+
1131
+ * OL1-UL2
1132
+
1133
+ //endchild
1134
+ EOS
1135
+ expected = <<-EOS
1136
+ 1 OL1
1137
+
1138
+ 1 OL1-OL1
1139
+
1140
+
1141
+ OL1-OL1-UL1
1142
+
1143
+ OL1-OL1-PARA
1144
+
1145
+ 2 OL1-OL2
1146
+
1147
+ OL1-UL1
1148
+
1149
+
1150
+ OL1-UL1-DL1
1151
+ OL1-UL1-DD1
1152
+
1153
+ OL1-UL1-PARA
1154
+
1155
+ OL1-UL2
1156
+
1157
+ EOS
1158
+
1159
+ actual = compile_block(src)
1160
+ assert_equal expected, actual
655
1161
  end
656
1162
  end