review 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -1
  3. data/.travis.yml +16 -15
  4. data/NEWS.ja.md +75 -0
  5. data/NEWS.md +75 -0
  6. data/appveyor.yml +20 -2
  7. data/bin/review-catalog-converter +3 -3
  8. data/bin/review-check +3 -3
  9. data/bin/review-compile +6 -6
  10. data/bin/review-epubmaker +3 -35
  11. data/bin/review-index +5 -5
  12. data/bin/review-preproc +4 -4
  13. data/bin/review-vol +5 -5
  14. data/doc/format.ja.md +6 -4
  15. data/doc/format.md +3 -1
  16. data/lib/epubmaker/epubcommon.rb +1 -2
  17. data/lib/epubmaker/epubv2.rb +1 -1
  18. data/lib/epubmaker/epubv3.rb +1 -0
  19. data/lib/epubmaker/producer.rb +2 -1
  20. data/lib/review/book/base.rb +5 -5
  21. data/lib/review/book/index.rb +18 -5
  22. data/lib/review/builder.rb +8 -2
  23. data/lib/review/compiler.rb +11 -34
  24. data/lib/review/epub2html.rb +37 -4
  25. data/lib/review/epubmaker.rb +40 -3
  26. data/lib/review/htmlbuilder.rb +2 -2
  27. data/lib/review/idgxmlbuilder.rb +9 -8
  28. data/lib/review/init.rb +7 -7
  29. data/lib/review/latexbuilder.rb +36 -14
  30. data/lib/review/location.rb +32 -0
  31. data/lib/review/markdownbuilder.rb +8 -1
  32. data/lib/review/plaintextbuilder.rb +9 -9
  33. data/lib/review/preprocessor.rb +2 -24
  34. data/lib/review/topbuilder.rb +4 -4
  35. data/lib/review/update.rb +3 -3
  36. data/lib/review/version.rb +1 -1
  37. data/lib/review/yamlloader.rb +23 -16
  38. data/review.gemspec +3 -2
  39. data/templates/latex/config.erb +4 -0
  40. data/templates/latex/review-jlreq/review-base.sty +45 -22
  41. data/templates/latex/review-jsbook/review-base.sty +20 -15
  42. data/templates/latex/review-jsbook/review-jsbook.cls +3 -3
  43. data/templates/opf/epubv3.opf.erb +1 -0
  44. data/test/assets/test_template.tex +4 -0
  45. data/test/assets/test_template_backmatter.tex +4 -0
  46. data/test/test_book.rb +1 -1
  47. data/test/test_builder.rb +16 -0
  48. data/test/test_catalog.rb +5 -0
  49. data/test/test_htmlbuilder.rb +471 -96
  50. data/test/test_idgxmlbuilder.rb +132 -17
  51. data/test/test_index.rb +40 -0
  52. data/test/test_latexbuilder.rb +668 -72
  53. data/test/test_latexbuilder_v2.rb +597 -68
  54. data/test/test_markdownbuilder.rb +90 -13
  55. data/test/test_md2inaobuilder.rb +20 -7
  56. data/test/test_plaintextbuilder.rb +241 -19
  57. data/test/test_preprocessor.rb +2 -16
  58. data/test/test_rstbuilder.rb +216 -22
  59. data/test/test_topbuilder.rb +334 -22
  60. metadata +20 -6
@@ -1,3 +1,3 @@
1
1
  module ReVIEW
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.2.0'.freeze
3
3
  end
@@ -15,31 +15,38 @@ module ReVIEW
15
15
  loaded_files = {}
16
16
  yaml = {}
17
17
 
18
- loop do
19
- # Check exit condition
20
- return yaml if file_queue.empty?
21
-
18
+ while file_queue.present?
22
19
  current_file = file_queue.shift
23
20
  current_yaml = YAML.load_file(current_file)
24
21
  yaml = current_yaml.deep_merge(yaml)
25
22
 
26
- next unless yaml.key?('inherit')
23
+ if yaml.key?('inherit')
24
+ inherit_files = parse_inherit(yaml, yamlfile, loaded_files)
25
+ file_queue = inherit_files + file_queue
26
+ end
27
+ end
28
+
29
+ yaml
30
+ end
27
31
 
28
- buf = []
29
- yaml['inherit'].reverse_each do |item|
30
- inherit_file = File.expand_path(item, File.dirname(yamlfile))
32
+ def parse_inherit(yaml, yamlfile, loaded_files)
33
+ files = []
31
34
 
32
- # Check loop
33
- if loaded_files[inherit_file]
34
- raise "Found circular YAML inheritance '#{inherit_file}' in #{yamlfile}."
35
- end
35
+ yaml['inherit'].reverse_each do |item|
36
+ inherit_file = File.expand_path(item, File.dirname(yamlfile))
36
37
 
37
- loaded_files[inherit_file] = true
38
- buf << inherit_file
38
+ # Check loop
39
+ if loaded_files[inherit_file]
40
+ raise "Found circular YAML inheritance '#{inherit_file}' in #{yamlfile}."
39
41
  end
40
- yaml.delete('inherit')
41
- file_queue = buf + file_queue
42
+
43
+ loaded_files[inherit_file] = true
44
+ files << inherit_file
42
45
  end
46
+
47
+ yaml.delete('inherit')
48
+
49
+ files
43
50
  end
44
51
  end
45
52
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = 'Re:VIEW: a easy-to-use digital publishing system'
13
13
  gem.description = 'Re:VIEW is a digital publishing system for books and ebooks. It supports InDesign, EPUB and LaTeX.'
14
14
  gem.required_rubygems_version = Gem::Requirement.new('>= 0') if gem.respond_to? :required_rubygems_version=
15
- gem.date = '2019-02-28'
15
+ gem.date = '2019-06-29'
16
16
 
17
17
  gem.files = `git ls-files`.split("\n")
18
18
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -25,7 +25,8 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency('rubyzip')
26
26
  gem.add_development_dependency('pygments.rb')
27
27
  gem.add_development_dependency('rake')
28
- gem.add_development_dependency('rubocop', '~> 0.57.2')
28
+ gem.add_development_dependency('rubocop', '~> 0.72.0')
29
+ gem.add_development_dependency('rubocop-performance')
29
30
  gem.add_development_dependency('simplecov')
30
31
  gem.add_development_dependency('test-unit')
31
32
  end
@@ -102,6 +102,10 @@
102
102
  \@ifundefined{reviewimagecaption}{% for 3.0.0 compatibility
103
103
  \newcommand{\reviewimagecaption}[1]{\caption{##1}}
104
104
  }
105
+ \@ifundefined{reviewincludegraphics}{% for 3.2.0 compatibility
106
+ \DeclareRobustCommand{\reviewincludegraphics}[2][]{%
107
+ \includegraphics[##1]{##2}}
108
+ }
105
109
  }
106
110
 
107
111
  \makeatother
@@ -47,6 +47,9 @@
47
47
 
48
48
  \newcommand{\reviewindepimagecaption[2]}{\@makecaption{}{#2}}
49
49
 
50
+ \DeclareRobustCommand{\reviewincludegraphics}[2][]{%
51
+ \includegraphics[#1]{#2}}
52
+
50
53
  % 表
51
54
  \newenvironment{reviewtablesetup}{%
52
55
  }{}
@@ -69,16 +72,26 @@
69
72
 
70
73
  \newcommand{\reviewbackslash}[0]{\textbackslash{}}
71
74
 
75
+ % 古いjlreq.clsへの互換(当面のad-hoc対応)
76
+ \ifdefined\jlreq@@makecaption@font@setting
77
+ \else
78
+ \let\jlreq@@makecaption@font@setting\jlreq@@makecaption@font
79
+ \fi
80
+ \ifdefined\jlreq@@makecaption@label@@font@setting
81
+ \else
82
+ \let\jlreq@@makecaption@label@font@setting\jlreq@@makecaption@label@font
83
+ \fi
84
+
72
85
  \renewcommand{\@makecaption}[2]{{% %本当はl,c,rを[]で指定したい
73
86
  \reset@font\small
74
87
  \vskip\abovecaptionskip
75
88
  \jlreq@ifempty{#1}{%
76
- \sbox\@tempboxa{{\jlreq@@makecaption@font #2}}}{%
77
- \sbox\@tempboxa{{\jlreq@@makecaption@label@font #1}\review@intn@captionprefix{\jlreq@@makecaption@font #2}}}
89
+ \sbox\@tempboxa{{\jlreq@@makecaption@font@setting #2}}}{%
90
+ \sbox\@tempboxa{{\jlreq@@makecaption@label@font@setting #1}\review@intn@captionprefix{\jlreq@@makecaption@font@setting #2}}}
78
91
  \ifdim \wd\@tempboxa >\hsize
79
92
  \jlreq@ifempty{#1}{%
80
- {\jlreq@@makecaption@font #2}}{%
81
- {\jlreq@@makecaption@label@font #1}\review@intn@captionprefix{\jlreq@@makecaption@font #2}}\relax\par
93
+ {\jlreq@@makecaption@font@setting #2}}{%
94
+ {\jlreq@@makecaption@label@font@setting #1}\review@intn@captionprefix{\jlreq@@makecaption@font@setting #2}}\relax\par
82
95
  \else
83
96
  \global\@minipagefalse
84
97
  \hbox to\hsize{\box\@tempboxa\hfil}% キャプションLeft
@@ -92,10 +105,10 @@
92
105
  \newcommand{\reviewemlistcaption}[1]{\review@commoncaption{}{#1}}
93
106
  \newcommand{\reviewsourcecaption}[1]{\review@commoncaption{}{#1}}
94
107
  \newcommand{\reviewcmdcaption}[1]{\review@commoncaption{}{#1}}
95
- \newenvironment{reviewlistblock}{\list{}{\topsep.5\baselineskip \leftmargin\z@ \itemindent\z@}\item\relax}{\endlist}% 上下アキ0.5
108
+ \newenvironment{reviewlistblock}{\list{}{\topsep.5\baselineskip \leftmargin\z@ \itemindent\z@}\item\needspace{4\Cvs}\relax}{\endlist}% 上下アキ0.5
96
109
 
97
110
  \newcommand{\reviewequationcaption}[1]{\review@commoncaption{}{#1}}
98
- \newenvironment{reviewequationblock}{}{}
111
+ \newenvironment{reviewequationblock}{\needspace{2\Cvs}}{}
99
112
 
100
113
  \newcommand{\reviewimageref}[2]{\review@intn@image #1}
101
114
  \newcommand{\reviewtableref}[2]{\review@intn@table #1}
@@ -146,27 +159,27 @@
146
159
  {\end{tcolorbox}}
147
160
 
148
161
  % 書体
149
- \newcommand{\reviewkw}[1]{\textbf{\textgt{#1}}}
150
- \newcommand{\reviewami}[1]{#1}% FIXME
151
- \newcommand{\reviewballoon}[1]{←{#1}}
152
- \newcommand{\reviewem}[1]{\textbf{#1}}
153
- \newcommand{\reviewstrong}[1]{\textbf{#1}}
154
- \newcommand{\reviewunderline}[1]{\underline{#1}}% ulemかjumolineで上書き。デフォルトはulemにしている
155
- \newcommand{\reviewit}[1]{\textit{#1}}
156
- \newcommand{\reviewbold}[1]{\textbf{#1}}
157
- \newcommand{\reviewcode}[1]{\texttt{#1}}
158
- \newcommand{\reviewtt}[1]{\texttt{#1}}
159
- \newcommand{\reviewtti}[1]{\texttt{\textit{#1}}}
160
- \newcommand{\reviewttb}[1]{\texttt{\textbf{#1}}}
162
+ \DeclareRobustCommand{\reviewkw}[1]{\textbf{\textgt{#1}}}
163
+ \DeclareRobustCommand{\reviewami}[1]{#1}% FIXME
164
+ \DeclareRobustCommand{\reviewballoon}[1]{←{#1}}
165
+ \DeclareRobustCommand{\reviewem}[1]{\textbf{#1}}
166
+ \DeclareRobustCommand{\reviewstrong}[1]{\textbf{#1}}
167
+ \DeclareRobustCommand{\reviewunderline}[1]{\underline{#1}}% ulemかjumolineで上書き。デフォルトはulemにしている
168
+ \DeclareRobustCommand{\reviewit}[1]{\textit{#1}}
169
+ \DeclareRobustCommand{\reviewbold}[1]{\textbf{#1}}
170
+ \DeclareRobustCommand{\reviewcode}[1]{\texttt{#1}}
171
+ \DeclareRobustCommand{\reviewtt}[1]{\texttt{#1}}
172
+ \DeclareRobustCommand{\reviewtti}[1]{\texttt{\textit{#1}}}
173
+ \DeclareRobustCommand{\reviewttb}[1]{\texttt{\textbf{#1}}}
174
+ \DeclareRobustCommand{\reviewbou}[1]{\kenten{#1}}
161
175
 
162
176
  %% @<del> is ignored in LaTeX with default style
163
- \newcommand{\reviewstrike}[1]{#1}
164
-
177
+ %% \DeclareRobustCommand{\reviewstrike}[1]{#1}
165
178
  %%%% for ulem.sty:
166
- \renewcommand{\reviewstrike}[1]{\sout{#1}}
179
+ \DeclareRobustCommand{\reviewstrike}[1]{\sout{#1}}
167
180
  %%
168
181
  %%%% for jumoline.sty:
169
- %%\renewcommand{\reviewstrike}[1]{\Middleline{#1}}
182
+ %%\DeclareRobustCommand{\reviewstrike}[1]{\Middleline{#1}}
170
183
 
171
184
  \newcommand{\reviewtitlefont}[0]{\usefont{T1}{phv}{b}{n}\gtfamily}
172
185
  \newcommand{\reviewmainfont}[0]{}
@@ -203,6 +216,16 @@
203
216
  \renewcommand{\appendixname}{\reviewappendixname}
204
217
  \fi
205
218
 
219
+ % maxwidth is the original width if it is less than linewidth
220
+ %% otherwise use linewidth (to make sure the graphics do not exceed the margin)
221
+ \def\maxwidth{%
222
+ \ifdim\Gin@nat@width>\linewidth
223
+ \linewidth
224
+ \else
225
+ \Gin@nat@width
226
+ \fi
227
+ }
228
+
206
229
  % hooks
207
230
  \def\reviewbegindocumenthook{}
208
231
 
@@ -16,6 +16,7 @@
16
16
  \RequirePackage[deluxe]{otf}%
17
17
  }
18
18
  \RequirePackage{caption}
19
+ \RequirePackage{needspace}
19
20
  \RequirePackage{suffix}
20
21
  \RequirePackage[T1]{fontenc}\RequirePackage{textcomp}%T1/TS1
21
22
  \RequirePackage{lmodern}
@@ -121,11 +122,14 @@
121
122
  \end{alltt}\end{center}
122
123
  \end{figure}}
123
124
 
125
+ \DeclareRobustCommand{\reviewincludegraphics}[2][]{%
126
+ \includegraphics[#1]{#2}}
127
+
124
128
  \newcommand{\reviewequationcaption}[1]{%
125
129
  \medskip{\small\noindent #1}}
126
- \newenvironment{reviewequationblock}{}{}
130
+ \newenvironment{reviewequationblock}{\needspace{2\Cvs}}{}
127
131
 
128
- \newenvironment{reviewlistblock}{}{}
132
+ \newenvironment{reviewlistblock}{\needspace{2\Cvs}}{}
129
133
 
130
134
  \newenvironment{reviewemlist}{%
131
135
  \medskip\small\begin{shaded}\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
@@ -252,21 +256,22 @@
252
256
  \reviewminicolumntitle{#1}
253
257
  }{\end{reviewminicolumn}}
254
258
 
255
- \newcommand{\reviewkw}[1]{\textbf{\textgt{#1}}}
256
- \newcommand{\reviewami}[1]{\mask{#1}{A}}
257
- \newcommand{\reviewem}[1]{\textbf{#1}}
258
- \newcommand{\reviewstrong}[1]{\textbf{#1}}
259
- \newcommand{\reviewballoon}[1]{←{#1}}
260
- \newcommand{\reviewunderline}[1]{\Underline{#1}}
261
- \newcommand{\reviewit}[1]{\textit{#1}}
262
- \newcommand{\reviewbold}[1]{\textbf{#1}}
263
- \newcommand{\reviewcode}[1]{\texttt{#1}}
264
- \newcommand{\reviewtt}[1]{\texttt{#1}}
265
- \newcommand{\reviewtti}[1]{\texttt{\textit{#1}}}
266
- \newcommand{\reviewttb}[1]{\texttt{\textbf{#1}}}
259
+ \DeclareRobustCommand{\reviewkw}[1]{\textbf{\textgt{#1}}}
260
+ \DeclareRobustCommand{\reviewami}[1]{\mask{#1}{A}}
261
+ \DeclareRobustCommand{\reviewem}[1]{\textbf{#1}}
262
+ \DeclareRobustCommand{\reviewstrong}[1]{\textbf{#1}}
263
+ \DeclareRobustCommand{\reviewballoon}[1]{←{#1}}
264
+ \DeclareRobustCommand{\reviewunderline}[1]{\Underline{#1}}
265
+ \DeclareRobustCommand{\reviewit}[1]{\textit{#1}}
266
+ \DeclareRobustCommand{\reviewbold}[1]{\textbf{#1}}
267
+ \DeclareRobustCommand{\reviewcode}[1]{\texttt{#1}}
268
+ \DeclareRobustCommand{\reviewtt}[1]{\texttt{#1}}
269
+ \DeclareRobustCommand{\reviewtti}[1]{\texttt{\textit{#1}}}
270
+ \DeclareRobustCommand{\reviewttb}[1]{\texttt{\textbf{#1}}}
271
+ \DeclareRobustCommand{\reviewbou}[1]{\kenten{#1}}
267
272
 
268
273
  %% @<del> is ignored in LaTeX with default style
269
- \newcommand{\reviewstrike}[1]{#1}
274
+ \DeclareRobustCommand{\reviewstrike}[1]{#1}
270
275
 
271
276
  %%%% for ulem.sty:
272
277
  %%\renewcommand{\reviewstrike}[1]{\sout{#1}}
@@ -1,5 +1,5 @@
1
1
  %#!ptex2pdf -l -u -ot '-synctex=1' test-rejsbk
2
- % Copyright (c) 2018 Munehiro Yamamoto, Kenshi Muto.
2
+ % Copyright (c) 2018-2019 Munehiro Yamamoto, Kenshi Muto.
3
3
  %
4
4
  % Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  % of this software and associated documentation files (the "Software"), to deal
@@ -458,8 +458,8 @@
458
458
 
459
459
  %% シンプルな通しノンブル
460
460
  \ifrecls@serialpage
461
- \renewcommand*{\pagenumbering}[1]{%
462
- \gdef\thepage{\@arabic\c@page}}
461
+ \def\pagenumbering#1{%
462
+ \gdef\thepage{\csname @arabic\endcsname\c@page}}
463
463
  \fi
464
464
 
465
465
  %% 開始ページを変更
@@ -2,6 +2,7 @@
2
2
  <package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId" xml:lang="<%= @producer.config['language'] %>"<%= @package_attrs %>>
3
3
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
4
4
  <%= @opf_metainfo %>
5
+ <%= @opf_coverimage %>
5
6
  </metadata>
6
7
  <%= @opf_manifest %>
7
8
  <%= @opf_toc %>
@@ -48,6 +48,10 @@
48
48
  \@ifundefined{reviewimagecaption}{% for 3.0.0 compatibility
49
49
  \newcommand{\reviewimagecaption}[1]{\caption{##1}}
50
50
  }
51
+ \@ifundefined{reviewincludegraphics}{% for 3.2.0 compatibility
52
+ \DeclareRobustCommand{\reviewincludegraphics}[2][]{%
53
+ \includegraphics[##1]{##2}}
54
+ }
51
55
  }
52
56
 
53
57
  \makeatother
@@ -59,6 +59,10 @@ some ad content
59
59
  \@ifundefined{reviewimagecaption}{% for 3.0.0 compatibility
60
60
  \newcommand{\reviewimagecaption}[1]{\caption{##1}}
61
61
  }
62
+ \@ifundefined{reviewincludegraphics}{% for 3.2.0 compatibility
63
+ \DeclareRobustCommand{\reviewincludegraphics}[2][]{%
64
+ \includegraphics[##1]{##2}}
65
+ }
62
66
  }
63
67
 
64
68
  \makeatother
@@ -237,7 +237,7 @@ EOC
237
237
  "part1_chapter1.re\n",
238
238
  '',
239
239
  [
240
- '', # XXX: OK?
240
+ '' # XXX: OK?
241
241
  ]
242
242
  ],
243
243
  [
@@ -80,6 +80,22 @@ class BuidlerTest < Test::Unit::TestCase
80
80
  assert_equal [:text, text], @b.compile_inline(text)
81
81
  end
82
82
 
83
+ def test_inline_missing_ref
84
+ b = Builder.new
85
+ chapter = ReVIEW::Book::Chapter.new(ReVIEW::Book::Base.load, 1, 'chap1', nil, StringIO.new)
86
+ b.bind(nil, chapter, nil)
87
+ e = assert_raises(ReVIEW::ApplicationError) { b.inline_list('unknown|list1') }
88
+ assert_equal ': error: unknown list: unknown|list1', e.message
89
+ e = assert_raises(ReVIEW::ApplicationError) { b.inline_table('unknown|table1') }
90
+ assert_equal ': error: unknown table: unknown|table1', e.message
91
+ e = assert_raises(ReVIEW::ApplicationError) { b.inline_img('unknown|img1') }
92
+ assert_equal ': error: unknown image: unknown|img1', e.message
93
+ e = assert_raises(ReVIEW::ApplicationError) { b.inline_column('unknown|column1') }
94
+ assert_equal ': error: unknown column: unknown|column1', e.message
95
+ e = assert_raises(ReVIEW::ApplicationError) { b.inline_fn('unknown|footnote1') }
96
+ assert_equal ': error: unknown footnote: unknown|footnote1', e.message
97
+ end
98
+
83
99
  class XBuilder < Builder
84
100
  def list_header(id, caption)
85
101
  end
@@ -64,6 +64,11 @@ part2.re
64
64
  assert_equal('', sut.parts)
65
65
  end
66
66
 
67
+ def test_empty_parts
68
+ sut = Catalog.new(StringIO.new)
69
+ assert_equal([], sut.parts_with_chaps)
70
+ end
71
+
67
72
  def test_parts2
68
73
  sut = Catalog.new(yaml_with_parts)
69
74
  assert_equal(['ch01.re',
@@ -191,7 +191,15 @@ class HTMLBuidlerTest < Test::Unit::TestCase
191
191
 
192
192
  def test_inline_in_table
193
193
  actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
194
- assert_equal %Q(<div class="table">\n<table>\n<tr><th><b>1</b></th><th><i>2</i></th></tr>\n<tr><td><b>3</b></td><td><i>4</i>&lt;&gt;&amp;</td></tr>\n</table>\n</div>\n), actual
194
+ expected = <<-EOS
195
+ <div class="table">
196
+ <table>
197
+ <tr><th><b>1</b></th><th><i>2</i></th></tr>
198
+ <tr><td><b>3</b></td><td><i>4</i>&lt;&gt;&amp;</td></tr>
199
+ </table>
200
+ </div>
201
+ EOS
202
+ assert_equal expected, actual
195
203
  end
196
204
 
197
205
  def test_inline_br
@@ -430,32 +438,59 @@ EOS
430
438
 
431
439
  def test_quote
432
440
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
433
- assert_equal %Q(<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n), actual
441
+ expected = <<-EOS
442
+ <blockquote><p>foobar</p>
443
+ <p>buz</p></blockquote>
444
+ EOS
445
+ assert_equal expected, actual
434
446
  end
435
447
 
436
448
  def test_memo
437
449
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
438
- assert_equal %Q(<div class="memo">\n<p class="caption">this is <b>test</b>&lt;&amp;&gt;_</p>\n<p>test1</p>\n<p>test<i>2</i></p>\n</div>\n), actual
450
+ expected = <<-EOS
451
+ <div class="memo">
452
+ <p class="caption">this is <b>test</b>&lt;&amp;&gt;_</p>
453
+ <p>test1</p>
454
+ <p>test<i>2</i></p>
455
+ </div>
456
+ EOS
457
+ assert_equal expected, actual
439
458
  end
440
459
 
441
460
  def test_blankline
442
461
  actual = compile_block("//blankline\nfoo\n")
443
- assert_equal %Q(<p><br /></p>\n<p>foo</p>\n), actual
462
+ expected = <<-EOS
463
+ <p><br /></p>
464
+ <p>foo</p>
465
+ EOS
466
+ assert_equal expected, actual
444
467
  end
445
468
 
446
469
  def test_noindent
447
470
  actual = compile_block("//noindent\nfoo\nbar\n\nfoo2\nbar2\n")
448
- assert_equal %Q(<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n), actual
471
+ expected = <<-EOS
472
+ <p class="noindent">foobar</p>
473
+ <p>foo2bar2</p>
474
+ EOS
475
+ assert_equal expected, actual
449
476
  end
450
477
 
451
478
  def test_flushright
452
479
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
453
- assert_equal %Q(<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n), actual
480
+ expected = <<-EOS
481
+ <p class="flushright">foobar</p>
482
+ <p class="flushright">buz</p>
483
+ EOS
484
+ assert_equal expected, actual
454
485
  end
455
486
 
456
487
  def test_centering
457
488
  actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
458
- assert_equal %Q(<p class="center">foobar</p>\n<p class="center">buz</p>\n), actual
489
+ expected = <<-EOS
490
+ <p class="center">foobar</p>
491
+ <p class="center">buz</p>
492
+ EOS
493
+ assert_equal expected, actual
459
494
  end
460
495
 
461
496
  def test_image
@@ -466,7 +501,15 @@ EOS
466
501
  end
467
502
 
468
503
  actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
469
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n), actual
504
+ expected = <<-EOS
505
+ <div id="sampleimg" class="image">
506
+ <img src="images/chap1-sampleimg.png" alt="sample photo" />
507
+ <p class="caption">
508
+ 図1.1: sample photo
509
+ </p>
510
+ </div>
511
+ EOS
512
+ assert_equal expected, actual
470
513
  end
471
514
 
472
515
  def test_image_with_metric
@@ -477,7 +520,15 @@ EOS
477
520
  end
478
521
 
479
522
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
480
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n), actual
523
+ expected = <<-EOS
524
+ <div id="sampleimg" class="image">
525
+ <img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
526
+ <p class="caption">
527
+ 図1.1: sample photo
528
+ </p>
529
+ </div>
530
+ EOS
531
+ assert_equal expected, actual
481
532
  end
482
533
 
483
534
  def test_image_with_metric2
@@ -488,7 +539,15 @@ EOS
488
539
  end
489
540
 
490
541
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
491
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n), actual
542
+ expected = <<-EOS
543
+ <div id="sampleimg" class="image">
544
+ <img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
545
+ <p class="caption">
546
+ 図1.1: sample photo
547
+ </p>
548
+ </div>
549
+ EOS
550
+ assert_equal expected, actual
492
551
  end
493
552
 
494
553
  def test_image_with_tricky_id
@@ -499,7 +558,15 @@ EOS
499
558
  end
500
559
 
501
560
  actual = compile_block("//image[123 あ_;][sample photo]{\n//}\n")
502
- assert_equal %Q(<div id="id_123-_E3_81_82___3B" class="image">\n<img src="images/chap1-123 あ_;.png" alt="sample photo" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n), actual
561
+ expected = <<-EOS
562
+ <div id="id_123-_E3_81_82___3B" class="image">
563
+ <img src="images/chap1-123 あ_;.png" alt="sample photo" />
564
+ <p class="caption">
565
+ 図1.1: sample photo
566
+ </p>
567
+ </div>
568
+ EOS
569
+ assert_equal expected, actual
503
570
  end
504
571
 
505
572
  def test_indepimage
@@ -510,7 +577,15 @@ EOS
510
577
  end
511
578
 
512
579
  actual = compile_block("//indepimage[sampleimg][sample photo]\n")
513
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n), actual
580
+ expected = <<-EOS
581
+ <div id="sampleimg" class="image">
582
+ <img src="images/chap1-sampleimg.png" alt="sample photo" />
583
+ <p class="caption">
584
+ 図: sample photo
585
+ </p>
586
+ </div>
587
+ EOS
588
+ assert_equal expected, actual
514
589
  end
515
590
 
516
591
  def test_indepimage_without_caption
@@ -521,7 +596,12 @@ EOS
521
596
  end
522
597
 
523
598
  actual = compile_block("//indepimage[sampleimg]\n")
524
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n), actual
599
+ expected = <<-EOS
600
+ <div id="sampleimg" class="image">
601
+ <img src="images/chap1-sampleimg.png" alt="" />
602
+ </div>
603
+ EOS
604
+ assert_equal expected, actual
525
605
  end
526
606
 
527
607
  def test_indepimage_with_metric
@@ -532,7 +612,15 @@ EOS
532
612
  end
533
613
 
534
614
  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
535
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n), actual
615
+ expected = <<-EOS
616
+ <div id="sampleimg" class="image">
617
+ <img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per" />
618
+ <p class="caption">
619
+ 図: sample photo
620
+ </p>
621
+ </div>
622
+ EOS
623
+ assert_equal expected, actual
536
624
  end
537
625
 
538
626
  def test_indepimage_with_metric2
@@ -543,7 +631,15 @@ EOS
543
631
  end
544
632
 
545
633
  actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
546
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n), actual
634
+ expected = <<-EOS
635
+ <div id="sampleimg" class="image">
636
+ <img src="images/chap1-sampleimg.png" alt="sample photo" class="width-120per sample" />
637
+ <p class="caption">
638
+ 図: sample photo
639
+ </p>
640
+ </div>
641
+ EOS
642
+ assert_equal expected, actual
547
643
  end
548
644
 
549
645
  def test_indepimage_without_caption_but_with_metric
@@ -554,28 +650,74 @@ EOS
554
650
  end
555
651
 
556
652
  actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
557
- assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n), actual
653
+ expected = <<-EOS
654
+ <div id="sampleimg" class="image">
655
+ <img src="images/chap1-sampleimg.png" alt="" class="width-120per" />
656
+ </div>
657
+ EOS
658
+ assert_equal expected, actual
558
659
  end
559
660
 
560
661
  def test_dlist
561
662
  actual = compile_block(": foo\n foo.\n bar.\n")
562
- assert_equal %Q(<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n), actual
663
+ expected = <<-EOS
664
+ <dl>
665
+ <dt>foo</dt>
666
+ <dd>foo.bar.</dd>
667
+ </dl>
668
+ EOS
669
+ assert_equal expected, actual
563
670
  end
564
671
 
565
672
  def test_dlist_with_bracket
566
673
  actual = compile_block(": foo[bar]\n foo.\n bar.\n")
567
- assert_equal %Q(<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n), actual
674
+ expected = <<-EOS
675
+ <dl>
676
+ <dt>foo[bar]</dt>
677
+ <dd>foo.bar.</dd>
678
+ </dl>
679
+ EOS
680
+ assert_equal expected, actual
568
681
  end
569
682
 
570
683
  def test_dlist_with_comment
571
684
  source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
572
685
  actual = compile_block(source)
573
- assert_equal %Q(<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n), actual
686
+ expected = <<-EOS
687
+ <dl>
688
+ <dt>title</dt>
689
+ <dd>body</dd>
690
+ <dt>title2</dt>
691
+ <dd>body2</dd>
692
+ </dl>
693
+ EOS
694
+ assert_equal expected, actual
574
695
  end
575
696
 
576
697
  def test_dlist_beforeulol
577
698
  actual = compile_block(" : foo\n foo.\n\npara\n\n : foo\n foo.\n\n 1. bar\n\n : foo\n foo.\n\n * bar\n")
578
- assert_equal %Q(<dl>\n<dt>foo</dt>\n<dd>foo.</dd>\n</dl>\n<p>para</p>\n<dl>\n<dt>foo</dt>\n<dd>foo.</dd>\n</dl>\n<ol>\n<li>bar</li>\n</ol>\n<dl>\n<dt>foo</dt>\n<dd>foo.</dd>\n</dl>\n<ul>\n<li>bar</li>\n</ul>\n), actual
699
+ expected = <<-EOS
700
+ <dl>
701
+ <dt>foo</dt>
702
+ <dd>foo.</dd>
703
+ </dl>
704
+ <p>para</p>
705
+ <dl>
706
+ <dt>foo</dt>
707
+ <dd>foo.</dd>
708
+ </dl>
709
+ <ol>
710
+ <li>bar</li>
711
+ </ol>
712
+ <dl>
713
+ <dt>foo</dt>
714
+ <dd>foo.</dd>
715
+ </dl>
716
+ <ul>
717
+ <li>bar</li>
718
+ </ul>
719
+ EOS
720
+ assert_equal expected, actual
579
721
  end
580
722
 
581
723
  def test_list
@@ -583,7 +725,17 @@ EOS
583
725
  Book::ListIndex::Item.new('samplelist', 1)
584
726
  end
585
727
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
586
- assert_equal %Q(<div id="samplelist" class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<pre class="list">test1\ntest1.5\n\ntest<i>2</i>\n</pre>\n</div>\n), actual
728
+ expected = <<-EOS
729
+ <div id="samplelist" class="caption-code">
730
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
731
+ <pre class="list">test1
732
+ test1.5
733
+
734
+ test<i>2</i>
735
+ </pre>
736
+ </div>
737
+ EOS
738
+ assert_equal expected, actual
587
739
  end
588
740
 
589
741
  def test_inline_list
@@ -706,7 +858,17 @@ end
706
858
  @book.config['highlight']['html'] = 'rouge'
707
859
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
708
860
 
709
- assert_equal %Q(<div id="samplelist" class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<pre class="list highlight">test1\ntest1.5\n\ntest&lt;i&gt;2&lt;/i&gt;\n</pre>\n</div>\n), actual
861
+ expected = <<-EOS
862
+ <div id="samplelist" class="caption-code">
863
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
864
+ <pre class="list highlight">test1
865
+ test1.5
866
+
867
+ test&lt;i&gt;2&lt;/i&gt;
868
+ </pre>
869
+ </div>
870
+ EOS
871
+ assert_equal expected, actual
710
872
  end
711
873
 
712
874
  def test_list_rouge_lang
@@ -751,7 +913,18 @@ EOS
751
913
  @book.config['highlight']['html'] = 'rouge'
752
914
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
753
915
 
754
- assert_equal %Q(<div id="samplelist" class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<pre class="list highlight">def foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n</pre>\n</div>\n), actual
916
+ expected = <<-EOS
917
+ <div id="samplelist" class="caption-code">
918
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
919
+ <pre class="list highlight">def foo(a1, a2=:test)
920
+ (1..3).times{|i| a.include?(:foo)}
921
+ return true
922
+ end
923
+
924
+ </pre>
925
+ </div>
926
+ EOS
927
+ assert_equal expected, actual
755
928
  end
756
929
 
757
930
  def test_listnum
@@ -964,9 +1137,68 @@ EOB
964
1137
  assert_equal expected, actual
965
1138
  end
966
1139
 
1140
+ def test_source
1141
+ actual = compile_block("//source[foo/bar/test.rb]{\nfoo\nbar\n\nbuz\n//}\n")
1142
+ expected = <<-EOS
1143
+ <div class="source-code">
1144
+ <p class="caption">foo/bar/test.rb</p>
1145
+ <pre class="source">foo
1146
+ bar
1147
+
1148
+ buz
1149
+ </pre>
1150
+ </div>
1151
+ EOS
1152
+ assert_equal expected, actual
1153
+ end
1154
+
1155
+ def test_source_empty_caption
1156
+ actual = compile_block("//source[]{\nfoo\nbar\n\nbuz\n//}\n")
1157
+ expected = <<-EOS
1158
+ <div class="source-code">
1159
+ <pre class="source">foo
1160
+ bar
1161
+
1162
+ buz
1163
+ </pre>
1164
+ </div>
1165
+ EOS
1166
+ assert_equal expected, actual
1167
+ end
1168
+
1169
+ def test_box
1170
+ actual = compile_block("//box{\nfoo\nbar\n//}\n")
1171
+ expected = <<-EOS
1172
+ <div class="syntax">
1173
+ <pre class="syntax">foo
1174
+ bar
1175
+ </pre>
1176
+ </div>
1177
+ EOS
1178
+ assert_equal expected, actual
1179
+
1180
+ actual = compile_block("//box[FOO]{\nfoo\nbar\n//}\n")
1181
+ expected = <<-EOS
1182
+ <div class="syntax">
1183
+ <p class="caption">FOO</p>
1184
+ <pre class="syntax">foo
1185
+ bar
1186
+ </pre>
1187
+ </div>
1188
+ EOS
1189
+ assert_equal expected, actual
1190
+ end
1191
+
967
1192
  def test_emlist
968
1193
  actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
969
- assert_equal %Q(<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n), actual
1194
+ expected = <<-EOS
1195
+ <div class="emlist-code">
1196
+ <pre class="emlist">lineA
1197
+ lineB
1198
+ </pre>
1199
+ </div>
1200
+ EOS
1201
+ assert_equal expected, actual
970
1202
  end
971
1203
 
972
1204
  def test_emlist_pygments_lang
@@ -990,12 +1222,28 @@ EOB
990
1222
 
991
1223
  def test_emlist_caption
992
1224
  actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
993
- assert_equal %Q(<div class="emlist-code">\n<p class="caption">cap1</p>\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n), actual
1225
+ expected = <<-EOS
1226
+ <div class="emlist-code">
1227
+ <p class="caption">cap1</p>
1228
+ <pre class="emlist">lineA
1229
+ lineB
1230
+ </pre>
1231
+ </div>
1232
+ EOS
1233
+ assert_equal expected, actual
994
1234
  end
995
1235
 
996
1236
  def test_emlist_with_tab
997
1237
  actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
998
- assert_equal %Q(<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n), actual
1238
+ expected = <<-EOS
1239
+ <div class="emlist-code">
1240
+ <pre class="emlist"> lineA
1241
+ lineB
1242
+ lineC
1243
+ </pre>
1244
+ </div>
1245
+ EOS
1246
+ assert_equal expected, actual
999
1247
  end
1000
1248
 
1001
1249
  def test_emlistnum
@@ -1042,12 +1290,27 @@ EOS
1042
1290
  def test_emlist_with_4tab
1043
1291
  @config['tabwidth'] = 4
1044
1292
  actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
1045
- assert_equal %Q(<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n), actual
1293
+ expected = <<-EOS
1294
+ <div class="emlist-code">
1295
+ <pre class="emlist"> lineA
1296
+ lineB
1297
+ lineC
1298
+ </pre>
1299
+ </div>
1300
+ EOS
1301
+ assert_equal expected, actual
1046
1302
  end
1047
1303
 
1048
1304
  def test_cmd
1049
1305
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
1050
- assert_equal %Q(<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n), actual
1306
+ expected = <<-EOS
1307
+ <div class="cmd-code">
1308
+ <pre class="cmd">lineA
1309
+ lineB
1310
+ </pre>
1311
+ </div>
1312
+ EOS
1313
+ assert_equal expected, actual
1051
1314
  end
1052
1315
 
1053
1316
  def test_cmd_pygments
@@ -1059,12 +1322,27 @@ EOS
1059
1322
  @book.config['highlight'] = {}
1060
1323
  @book.config['highlight']['html'] = 'pygments'
1061
1324
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
1062
- assert_equal %Q(<div class="cmd-code">\n<pre class="cmd"><span style="color: #888888">lineA</span>\n<span style="color: #888888">lineB</span>\n</pre>\n</div>\n), actual
1325
+ expected = <<-EOS
1326
+ <div class="cmd-code">
1327
+ <pre class="cmd"><span style="color: #888888">lineA</span>
1328
+ <span style="color: #888888">lineB</span>
1329
+ </pre>
1330
+ </div>
1331
+ EOS
1332
+ assert_equal expected, actual
1063
1333
  end
1064
1334
 
1065
1335
  def test_cmd_caption
1066
1336
  actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
1067
- assert_equal %Q(<div class="cmd-code">\n<p class="caption">cap1</p>\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n), actual
1337
+ expected = <<-EOS
1338
+ <div class="cmd-code">
1339
+ <p class="caption">cap1</p>
1340
+ <pre class="cmd">lineA
1341
+ lineB
1342
+ </pre>
1343
+ </div>
1344
+ EOS
1345
+ assert_equal expected, actual
1068
1346
  end
1069
1347
 
1070
1348
  def test_texequation
@@ -1153,7 +1431,12 @@ EOS
1153
1431
  end
1154
1432
 
1155
1433
  actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
1156
- assert_equal %Q(<div class="bibpaper">\n<a id="bib-samplebib">[1]</a> sample bib <b>bold</b>\n<p>ab</p></div>\n), actual
1434
+ expected = <<-EOS
1435
+ <div class="bibpaper">
1436
+ <a id="bib-samplebib">[1]</a> sample bib <b>bold</b>
1437
+ <p>ab</p></div>
1438
+ EOS
1439
+ assert_equal expected, actual
1157
1440
  end
1158
1441
 
1159
1442
  def test_bibpaper_normalized
@@ -1162,7 +1445,12 @@ EOS
1162
1445
  end
1163
1446
 
1164
1447
  actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
1165
- assert_equal %Q(<div class="bibpaper">\n<a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>\n<p>ab</p></div>\n), actual
1448
+ expected = <<-EOS
1449
+ <div class="bibpaper">
1450
+ <a id="bib-id_sample_3Dbib">[1]</a> sample bib <b>bold</b>
1451
+ <p>ab</p></div>
1452
+ EOS
1453
+ assert_equal expected, actual
1166
1454
  end
1167
1455
 
1168
1456
  def test_bibpaper_with_anchor
@@ -1171,7 +1459,12 @@ EOS
1171
1459
  end
1172
1460
 
1173
1461
  actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
1174
- assert_equal %Q(<div class="bibpaper">\n<a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>\n<p>ab</p></div>\n), actual
1462
+ expected = <<-EOS
1463
+ <div class="bibpaper">
1464
+ <a id="bib-samplebib">[1]</a> sample bib <a href="http://example.jp" class="link">http://example.jp</a>
1465
+ <p>ab</p></div>
1466
+ EOS
1467
+ assert_equal expected, actual
1175
1468
  end
1176
1469
 
1177
1470
  def column_helper(review)
@@ -1279,7 +1572,12 @@ EOS
1279
1572
  * AAA
1280
1573
  * BBB
1281
1574
  EOS
1282
- expected = "<ul>\n<li>AAA</li>\n<li>BBB</li>\n</ul>\n"
1575
+ expected = <<-EOS
1576
+ <ul>
1577
+ <li>AAA</li>
1578
+ <li>BBB</li>
1579
+ </ul>
1580
+ EOS
1283
1581
  actual = compile_block(src)
1284
1582
  assert_equal expected, actual
1285
1583
  end
@@ -1291,7 +1589,12 @@ EOS
1291
1589
  * BBB
1292
1590
  -BB
1293
1591
  EOS
1294
- expected = "<ul>\n<li>AAA-AA</li>\n<li>BBB-BB</li>\n</ul>\n"
1592
+ expected = <<-EOS
1593
+ <ul>
1594
+ <li>AAA-AA</li>
1595
+ <li>BBB-BB</li>
1596
+ </ul>
1597
+ EOS
1295
1598
  actual = compile_block(src)
1296
1599
  assert_equal expected, actual
1297
1600
  end
@@ -1342,25 +1645,10 @@ EOS
1342
1645
  src = <<-EOS
1343
1646
  ** AAA
1344
1647
  * AA
1345
- * BBB
1346
- ** BB
1347
1648
  EOS
1348
1649
 
1349
- expected = <<-EOS
1350
- <ul>
1351
- <li><ul>
1352
- <li>AAA</li>
1353
- </ul>
1354
- </li>
1355
- <li>AA</li>
1356
- <li>BBB<ul>
1357
- <li>BB</li>
1358
- </ul>
1359
- </li>
1360
- </ul>
1361
- EOS
1362
- actual = compile_block(src)
1363
- assert_equal expected, actual
1650
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block(src) }
1651
+ assert_equal ':1: error: too many *.', e.message
1364
1652
  end
1365
1653
 
1366
1654
  def test_ul_nest4
@@ -1391,37 +1679,6 @@ EOS
1391
1679
  assert_equal expected, actual
1392
1680
  end
1393
1681
 
1394
- def test_ul_nest5
1395
- src = <<-EOS
1396
- * A
1397
- ** AA
1398
- **** AAAA
1399
- * B
1400
- ** BB
1401
- EOS
1402
-
1403
- expected = <<-EOS
1404
- <ul>
1405
- <li>A<ul>
1406
- <li>AA<ul>
1407
- <li><ul>
1408
- <li>AAAA</li>
1409
- </ul>
1410
- </li>
1411
- </ul>
1412
- </li>
1413
- </ul>
1414
- </li>
1415
- <li>B<ul>
1416
- <li>BB</li>
1417
- </ul>
1418
- </li>
1419
- </ul>
1420
- EOS
1421
- actual = compile_block(src)
1422
- assert_equal expected, actual
1423
- end
1424
-
1425
1682
  def test_ol
1426
1683
  src = <<-EOS
1427
1684
  3. AAA
@@ -1687,8 +1944,35 @@ EOS
1687
1944
 
1688
1945
  def test_table
1689
1946
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1690
- assert_equal %Q(<div class="table">\n<table>\n<tr><th>aaa</th><th>bbb</th></tr>\n<tr><td>ccc</td><td>ddd&lt;&gt;&amp;</td></tr>\n</table>\n</div>\n),
1691
- actual
1947
+ expected = <<-EOS
1948
+ <div class="table">
1949
+ <table>
1950
+ <tr><th>aaa</th><th>bbb</th></tr>
1951
+ <tr><td>ccc</td><td>ddd&lt;&gt;&amp;</td></tr>
1952
+ </table>
1953
+ </div>
1954
+ EOS
1955
+ assert_equal expected, actual
1956
+
1957
+ actual = compile_block("//table[foo][FOO]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1958
+ expected = <<-EOS
1959
+ <div id="foo" class="table">
1960
+ <p class="caption">表1.1: FOO</p>
1961
+ <table>
1962
+ <tr><th>aaa</th><th>bbb</th></tr>
1963
+ <tr><td>ccc</td><td>ddd&lt;&gt;&amp;</td></tr>
1964
+ </table>
1965
+ </div>
1966
+ EOS
1967
+ assert_equal expected, actual
1968
+ end
1969
+
1970
+ def test_empty_table
1971
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n//}\n" }
1972
+ assert_equal ':2: error: no rows in the table', e.message
1973
+
1974
+ e = assert_raises(ReVIEW::ApplicationError) { compile_block "//table{\n------------\n//}\n" }
1975
+ assert_equal ':3: error: no rows in the table', e.message
1692
1976
  end
1693
1977
 
1694
1978
  def test_inline_table
@@ -1701,8 +1985,22 @@ EOS
1701
1985
 
1702
1986
  def test_emtable
1703
1987
  actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1704
- assert_equal %Q(<div class="table">\n<p class="caption">foo</p>\n<table>\n<tr><th>aaa</th><th>bbb</th></tr>\n<tr><td>ccc</td><td>ddd&lt;&gt;&amp;</td></tr>\n</table>\n</div>\n<div class="table">\n<table>\n<tr><th>aaa</th><th>bbb</th></tr>\n<tr><td>ccc</td><td>ddd&lt;&gt;&amp;</td></tr>\n</table>\n</div>\n),
1705
- actual
1988
+ expected = <<-EOS
1989
+ <div class="table">
1990
+ <p class="caption">foo</p>
1991
+ <table>
1992
+ <tr><th>aaa</th><th>bbb</th></tr>
1993
+ <tr><td>ccc</td><td>ddd&lt;&gt;&amp;</td></tr>
1994
+ </table>
1995
+ </div>
1996
+ <div class="table">
1997
+ <table>
1998
+ <tr><th>aaa</th><th>bbb</th></tr>
1999
+ <tr><td>ccc</td><td>ddd&lt;&gt;&amp;</td></tr>
2000
+ </table>
2001
+ </div>
2002
+ EOS
2003
+ assert_equal expected, actual
1706
2004
  end
1707
2005
 
1708
2006
  def test_imgtable
@@ -1713,41 +2011,118 @@ EOS
1713
2011
  end
1714
2012
 
1715
2013
  actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1716
- expected = %Q(<div id="sampleimg" class="imgtable image">\n<p class="caption">表1.1: test for imgtable</p>\n<img src="images/chap1-sampleimg.png" alt="test for imgtable" />\n</div>\n)
2014
+ expected = <<-EOS
2015
+ <div id="sampleimg" class="imgtable image">
2016
+ <p class="caption">表1.1: test for imgtable</p>
2017
+ <img src="images/chap1-sampleimg.png" alt="test for imgtable" />
2018
+ </div>
2019
+ EOS
1717
2020
  assert_equal expected, actual
1718
2021
  end
1719
2022
 
1720
2023
  def test_major_blocks
1721
2024
  actual = compile_block("//note{\nA\n\nB\n//}\n//note[caption]{\nA\n//}")
1722
- expected = %Q(<div class="note">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="note">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2025
+ expected = <<-EOS
2026
+ <div class="note">
2027
+ <p>A</p>
2028
+ <p>B</p>
2029
+ </div>
2030
+ <div class="note">
2031
+ <p class="caption">caption</p>
2032
+ <p>A</p>
2033
+ </div>
2034
+ EOS
1723
2035
  assert_equal expected, actual
1724
2036
 
1725
2037
  actual = compile_block("//memo{\nA\n\nB\n//}\n//memo[caption]{\nA\n//}")
1726
- expected = %Q(<div class="memo">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="memo">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2038
+ expected = <<-EOS
2039
+ <div class="memo">
2040
+ <p>A</p>
2041
+ <p>B</p>
2042
+ </div>
2043
+ <div class="memo">
2044
+ <p class="caption">caption</p>
2045
+ <p>A</p>
2046
+ </div>
2047
+ EOS
1727
2048
  assert_equal expected, actual
1728
2049
 
1729
2050
  actual = compile_block("//info{\nA\n\nB\n//}\n//info[caption]{\nA\n//}")
1730
- expected = %Q(<div class="info">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="info">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2051
+ expected = <<-EOS
2052
+ <div class="info">
2053
+ <p>A</p>
2054
+ <p>B</p>
2055
+ </div>
2056
+ <div class="info">
2057
+ <p class="caption">caption</p>
2058
+ <p>A</p>
2059
+ </div>
2060
+ EOS
1731
2061
  assert_equal expected, actual
1732
2062
 
1733
2063
  actual = compile_block("//important{\nA\n\nB\n//}\n//important[caption]{\nA\n//}")
1734
- expected = %Q(<div class="important">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="important">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2064
+ expected = <<-EOS
2065
+ <div class="important">
2066
+ <p>A</p>
2067
+ <p>B</p>
2068
+ </div>
2069
+ <div class="important">
2070
+ <p class="caption">caption</p>
2071
+ <p>A</p>
2072
+ </div>
2073
+ EOS
1735
2074
  assert_equal expected, actual
1736
2075
 
1737
2076
  actual = compile_block("//caution{\nA\n\nB\n//}\n//caution[caption]{\nA\n//}")
1738
- expected = %Q(<div class="caution">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="caution">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2077
+ expected = <<-EOS
2078
+ <div class="caution">
2079
+ <p>A</p>
2080
+ <p>B</p>
2081
+ </div>
2082
+ <div class="caution">
2083
+ <p class="caption">caption</p>
2084
+ <p>A</p>
2085
+ </div>
2086
+ EOS
1739
2087
  assert_equal expected, actual
1740
2088
 
1741
2089
  actual = compile_block("//notice{\nA\n\nB\n//}\n//notice[caption]{\nA\n//}")
1742
- expected = %Q(<div class="notice">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="notice">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2090
+ expected = <<-EOS
2091
+ <div class="notice">
2092
+ <p>A</p>
2093
+ <p>B</p>
2094
+ </div>
2095
+ <div class="notice">
2096
+ <p class="caption">caption</p>
2097
+ <p>A</p>
2098
+ </div>
2099
+ EOS
1743
2100
  assert_equal expected, actual
1744
2101
 
1745
2102
  actual = compile_block("//warning{\nA\n\nB\n//}\n//warning[caption]{\nA\n//}")
1746
- expected = %Q(<div class="warning">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="warning">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2103
+ expected = <<-EOS
2104
+ <div class="warning">
2105
+ <p>A</p>
2106
+ <p>B</p>
2107
+ </div>
2108
+ <div class="warning">
2109
+ <p class="caption">caption</p>
2110
+ <p>A</p>
2111
+ </div>
2112
+ EOS
1747
2113
  assert_equal expected, actual
1748
2114
 
1749
2115
  actual = compile_block("//tip{\nA\n\nB\n//}\n//tip[caption]{\nA\n//}")
1750
- expected = %Q(<div class="tip">\n<p>A</p>\n<p>B</p>\n</div>\n<div class="tip">\n<p class="caption">caption</p>\n<p>A</p>\n</div>\n)
2116
+ expected = <<-EOS
2117
+ <div class="tip">
2118
+ <p>A</p>
2119
+ <p>B</p>
2120
+ </div>
2121
+ <div class="tip">
2122
+ <p class="caption">caption</p>
2123
+ <p>A</p>
2124
+ </div>
2125
+ EOS
1751
2126
  assert_equal expected, actual
1752
2127
  end
1753
2128