review 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +90 -66
  3. data/.travis.yml +1 -1
  4. data/Gemfile +0 -1
  5. data/NEWS.ja.md +82 -0
  6. data/NEWS.md +83 -0
  7. data/README.md +5 -3
  8. data/Rakefile +8 -8
  9. data/bin/review +1 -5
  10. data/bin/review-catalog-converter +22 -27
  11. data/bin/review-check +36 -43
  12. data/bin/review-checkdep +10 -15
  13. data/bin/review-compile +37 -55
  14. data/bin/review-epubmaker +4 -5
  15. data/bin/review-index +21 -29
  16. data/bin/review-init +26 -37
  17. data/bin/review-pdfmaker +0 -2
  18. data/bin/review-preproc +25 -45
  19. data/bin/review-validate +19 -18
  20. data/bin/review-vol +15 -27
  21. data/doc/config.yml.sample +5 -2
  22. data/doc/format.ja.md +20 -1
  23. data/doc/format.md +21 -5
  24. data/doc/images/review-generate.png +0 -0
  25. data/lib/epubmaker.rb +1 -3
  26. data/lib/epubmaker/content.rb +24 -27
  27. data/lib/epubmaker/epubcommon.rb +135 -148
  28. data/lib/epubmaker/epubv2.rb +39 -46
  29. data/lib/epubmaker/epubv3.rb +93 -103
  30. data/lib/epubmaker/producer.rb +138 -151
  31. data/lib/epubmaker/zip_exporter.rb +21 -26
  32. data/lib/review/book.rb +3 -6
  33. data/lib/review/book/base.rb +78 -103
  34. data/lib/review/book/chapter.rb +36 -40
  35. data/lib/review/book/compilable.rb +28 -31
  36. data/lib/review/book/image_finder.rb +6 -13
  37. data/lib/review/book/index.rb +100 -121
  38. data/lib/review/book/page_metric.rb +2 -7
  39. data/lib/review/book/part.rb +18 -20
  40. data/lib/review/book/volume.rb +9 -13
  41. data/lib/review/builder.rb +81 -116
  42. data/lib/review/catalog.rb +15 -19
  43. data/lib/review/compiler.rb +64 -83
  44. data/lib/review/configure.rb +87 -97
  45. data/lib/review/converter.rb +2 -7
  46. data/lib/review/epubbuilder.rb +1 -3
  47. data/lib/review/epubmaker.rb +213 -205
  48. data/lib/review/exception.rb +2 -4
  49. data/lib/review/extentions.rb +0 -1
  50. data/lib/review/extentions/hash.rb +2 -2
  51. data/lib/review/extentions/string.rb +5 -30
  52. data/lib/review/htmlbuilder.rb +320 -375
  53. data/lib/review/htmltoc.rb +4 -7
  54. data/lib/review/htmlutils.rb +29 -32
  55. data/lib/review/i18n.rb +33 -44
  56. data/lib/review/i18n.yml +3 -3
  57. data/lib/review/idgxmlbuilder.rb +309 -345
  58. data/lib/review/latexbuilder.rb +175 -212
  59. data/lib/review/latexindex.rb +2 -8
  60. data/lib/review/latexutils.rb +33 -43
  61. data/lib/review/lineinput.rb +1 -1
  62. data/lib/review/logger.rb +21 -0
  63. data/lib/review/makerhelper.rb +1 -4
  64. data/lib/review/markdownbuilder.rb +44 -53
  65. data/lib/review/md2inaobuilder.rb +6 -12
  66. data/lib/review/pdfmaker.rb +143 -173
  67. data/lib/review/preprocessor.rb +64 -101
  68. data/lib/review/rstbuilder.rb +126 -158
  69. data/lib/review/sec_counter.rb +18 -34
  70. data/lib/review/template.rb +4 -5
  71. data/lib/review/textbuilder.rb +2 -3
  72. data/lib/review/textutils.rb +7 -13
  73. data/lib/review/tocparser.rb +31 -56
  74. data/lib/review/tocprinter.rb +26 -52
  75. data/lib/review/topbuilder.rb +219 -247
  76. data/lib/review/unfold.rb +15 -24
  77. data/lib/review/version.rb +1 -1
  78. data/lib/review/webmaker.rb +75 -99
  79. data/lib/review/webtocprinter.rb +15 -20
  80. data/lib/review/yamlloader.rb +13 -15
  81. data/review.gemspec +20 -22
  82. data/templates/latex/layout.tex.erb +2 -2
  83. data/templates/opf/epubv2.opf.erb +7 -7
  84. data/templates/opf/epubv3.opf.erb +7 -7
  85. data/templates/web/html/layout-html5.html.erb +2 -2
  86. data/test/assets/black.eps +280 -0
  87. data/test/assets/fit.png +0 -0
  88. data/test/assets/large.gif +0 -0
  89. data/test/assets/large.jpg +0 -0
  90. data/test/assets/large.png +0 -0
  91. data/test/assets/large.svg +65 -0
  92. data/test/assets/test_template.tex +1 -1
  93. data/test/book_test_helper.rb +2 -2
  94. data/test/run_test.rb +4 -4
  95. data/test/sample-book/src/Rakefile +21 -22
  96. data/test/syntax-book/Gemfile +4 -0
  97. data/test/syntax-book/Rakefile +72 -0
  98. data/test/syntax-book/appA.re +22 -0
  99. data/test/syntax-book/bib.re +6 -0
  100. data/test/syntax-book/catalog.yml +15 -0
  101. data/test/syntax-book/ch01.re +136 -0
  102. data/test/syntax-book/ch02.re +351 -0
  103. data/test/syntax-book/ch03.re +82 -0
  104. data/test/syntax-book/config.yml +35 -0
  105. data/test/syntax-book/images/ball.png +0 -0
  106. data/test/syntax-book/images/cover.jpg +0 -0
  107. data/test/syntax-book/images/fractal.png +0 -0
  108. data/test/syntax-book/images/img3-1.png +0 -0
  109. data/test/syntax-book/images/inlineicon.jpg +0 -0
  110. data/test/syntax-book/images/logic.png +0 -0
  111. data/test/syntax-book/images/logic2.png +0 -0
  112. data/test/syntax-book/images/puzzle.jpg +0 -0
  113. data/test/syntax-book/images/table.jpg +0 -0
  114. data/test/syntax-book/part2.re +6 -0
  115. data/test/syntax-book/pre01.re +26 -0
  116. data/test/syntax-book/review-ext.rb +14 -0
  117. data/test/syntax-book/sty/jumoline.sty +310 -0
  118. data/test/syntax-book/sty/reviewmacro.sty +39 -0
  119. data/test/syntax-book/style.css +494 -0
  120. data/test/syntax-book/syntax.dic +2 -0
  121. data/test/test_book.rb +106 -111
  122. data/test/test_book_chapter.rb +21 -22
  123. data/test/test_book_part.rb +3 -5
  124. data/test/test_builder.rb +11 -22
  125. data/test/test_catalog.rb +17 -18
  126. data/test/test_catalog_converter_cmd.rb +5 -5
  127. data/test/test_compiler.rb +18 -16
  128. data/test/test_configure.rb +35 -38
  129. data/test/test_converter.rb +3 -4
  130. data/test/test_epub3maker.rb +136 -117
  131. data/test/test_epubmaker.rb +107 -114
  132. data/test/test_epubmaker_cmd.rb +2 -4
  133. data/test/test_extentions_hash.rb +32 -33
  134. data/test/test_helper.rb +9 -11
  135. data/test/test_htmlbuilder.rb +454 -420
  136. data/test/test_htmltoc.rb +8 -12
  137. data/test/test_htmlutils.rb +0 -2
  138. data/test/test_i18n.rb +159 -150
  139. data/test/test_idgxmlbuilder.rb +190 -197
  140. data/test/test_image_finder.rb +21 -22
  141. data/test/test_index.rb +24 -29
  142. data/test/test_latexbuilder.rb +274 -264
  143. data/test/test_lineinput.rb +7 -10
  144. data/test/test_location.rb +7 -7
  145. data/test/test_makerhelper.rb +13 -25
  146. data/test/test_markdownbuilder.rb +23 -26
  147. data/test/test_md2inaobuilder.rb +8 -11
  148. data/test/test_pdfmaker.rb +114 -123
  149. data/test/test_pdfmaker_cmd.rb +1 -3
  150. data/test/test_review_ext.rb +3 -5
  151. data/test/test_rstbuilder.rb +92 -97
  152. data/test/test_template.rb +3 -7
  153. data/test/test_textutils.rb +27 -27
  154. data/test/test_tocparser.rb +2 -2
  155. data/test/test_topbuilder.rb +98 -103
  156. data/test/test_webtocprinter.rb +5 -6
  157. data/test/test_yamlloader.rb +42 -42
  158. data/test/test_zip_exporter.rb +12 -18
  159. metadata +86 -9
  160. data/lib/review/ewbbuilder.rb +0 -382
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'test_helper'
4
2
  require 'tmpdir'
5
3
  require 'fileutils'
@@ -26,10 +24,10 @@ class EPUBMakerCmdTest < Test::Unit::TestCase
26
24
  def test_epubmaker_cmd
27
25
  if /mswin|mingw|cygwin/ !~ RUBY_PLATFORM
28
26
  config = prepare_samplebook(@tmpdir1)
29
- builddir = @tmpdir1 + "/" + config['bookname'] + '-epub'
27
+ builddir = @tmpdir1 + '/' + config['bookname'] + '-epub'
30
28
  assert !File.exist?(builddir)
31
29
 
32
- ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG["EXEEXT"]
30
+ ruby_cmd = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) + RbConfig::CONFIG['EXEEXT']
33
31
  Dir.chdir(@tmpdir1) do
34
32
  system("#{ruby_cmd} -S #{REVIEW_EPUBMAKER} config.yml 1>/dev/null 2>/dev/null")
35
33
  end
@@ -3,65 +3,64 @@ require 'review/extentions/hash'
3
3
 
4
4
  class TestExtentionsHash < Test::Unit::TestCase
5
5
  def test_deep_merge_simple
6
- assert_equal({:a => 1, :b => 3, :c => 4},
7
- {:a => 1, :b => 2}.deep_merge({:b => 3, :c => 4}))
6
+ assert_equal({ a: 1, b: 3, c: 4 },
7
+ { a: 1, b: 2 }.deep_merge(b: 3, c: 4))
8
8
  end
9
9
 
10
10
  def test_deep_empty_r
11
- assert_equal({:b => 3, :c => 4},
12
- {}.deep_merge({:b => 3, :c => 4}))
11
+ assert_equal({ b: 3, c: 4 },
12
+ {}.deep_merge(b: 3, c: 4))
13
13
  end
14
14
 
15
15
  def test_deep_empty_l
16
- assert_equal({:a => 1, :b => 2},
17
- {:a => 1, :b => 2}.deep_merge({}))
16
+ assert_equal({ a: 1, b: 2 },
17
+ { a: 1, b: 2 }.deep_merge({}))
18
18
  end
19
19
 
20
20
  def test_deep_merge_nested
21
- assert_equal({:a => {:aa => 1, :ab => 2},
22
- :b => {:ba => 5, :bb => 4, :bc => 6},
23
- :c => {:ca => 1}},
24
- {:a => {:aa => 1, :ab => 2},
25
- :b => {:ba => 3, :bb => 4}}.deep_merge({:b => {:ba => 5, :bc => 6},
26
- :c => {:ca => 1}}))
21
+ assert_equal({ a: { aa: 1, ab: 2 },
22
+ b: { ba: 5, bb: 4, bc: 6 },
23
+ c: { ca: 1 } },
24
+ { a: { aa: 1, ab: 2 },
25
+ b: { ba: 3, bb: 4 } }.deep_merge(b: { ba: 5, bc: 6 },
26
+ c: { ca: 1 }))
27
27
  end
28
28
 
29
29
  def test_deep_merge_with_array
30
- assert_equal({:a => "string", :b => ["BA"],
31
- :c => {:ca => [:cab => "CAB"], :cb => 3}},
32
-
33
- {:a => 1, :b => ["shouldoverriden"],
34
- :c => {:ca => [:caa => "shouldoverriden"], :cb => 3}}.
35
- deep_merge({:a => "string", :b => ["BA"],
36
- :c => {:ca => [:cab => "CAB"]}}))
30
+ assert_equal({ a: 'string', b: ['BA'],
31
+ c: { ca: [cab: 'CAB'], cb: 3 } },
32
+ { a: 1, b: ['shouldoverriden'],
33
+ c: { ca: [caa: 'shouldoverriden'], cb: 3 } }.
34
+ deep_merge(a: 'string', b: ['BA'],
35
+ c: { ca: [cab: 'CAB'] }))
37
36
  end
38
37
 
39
38
  def test_deep_merge_b_simple
40
- a = {:a => 1, :b => 2}
41
- a.deep_merge!({:b => 3, :c => 4})
42
- assert_equal({:a => 1, :b => 3, :c => 4}, a)
39
+ a = { a: 1, b: 2 }
40
+ a.deep_merge!(b: 3, c: 4)
41
+ assert_equal({ a: 1, b: 3, c: 4 }, a)
43
42
  end
44
43
 
45
44
  def test_deep_b_empty_r
46
45
  a = {}
47
- a.deep_merge!({:b => 3, :c => 4})
48
- assert_equal({:b => 3, :c => 4}, a)
46
+ a.deep_merge!(b: 3, c: 4)
47
+ assert_equal({ b: 3, c: 4 }, a)
49
48
  end
50
49
 
51
50
  def test_deep_b_empty_l
52
- a = {:a => 1, :b => 2}
51
+ a = { a: 1, b: 2 }
53
52
  a.deep_merge!({})
54
- assert_equal({:a => 1, :b => 2}, a)
53
+ assert_equal({ a: 1, b: 2 }, a)
55
54
  end
56
55
 
57
56
  def test_deep_merge_b_nested
58
- a = {:a => {:aa => 1, :ab => 2},
59
- :b => {:ba => 3, :bb => 4}}
60
- a.deep_merge!({:b => {:ba => 5, :bc => 6},
61
- :c => {:ca => 1}})
62
- assert_equal({:a => {:aa => 1, :ab => 2},
63
- :b => {:ba => 5, :bb => 4, :bc => 6},
64
- :c => {:ca => 1}},
57
+ a = { a: { aa: 1, ab: 2 },
58
+ b: { ba: 3, bb: 4 } }
59
+ a.deep_merge!(b: { ba: 5, bc: 6 },
60
+ c: { ca: 1 })
61
+ assert_equal({ a: { aa: 1, ab: 2 },
62
+ b: { ba: 5, bb: 4, bc: 6 },
63
+ c: { ca: 1 } },
65
64
  a)
66
65
  end
67
66
  end
@@ -2,18 +2,18 @@ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib/')
2
2
  require 'test/unit'
3
3
 
4
4
  def touch_file(path)
5
- File.open(path, "w").close
5
+ File.open(path, 'w').close
6
6
  path
7
7
  end
8
8
 
9
9
  def assets_dir
10
- File.join(File.dirname(__FILE__), "assets")
10
+ File.join(File.dirname(__FILE__), 'assets')
11
11
  end
12
12
 
13
13
  def prepare_samplebook(srcdir)
14
- samplebook_dir = File.expand_path("sample-book/src/", File.dirname(__FILE__))
15
- FileUtils.cp_r(Dir.glob(samplebook_dir + "/*"), srcdir)
16
- YAML.load(File.open(srcdir + "/config.yml"))
14
+ samplebook_dir = File.expand_path('sample-book/src/', File.dirname(__FILE__))
15
+ FileUtils.cp_r(Dir.glob(samplebook_dir + '/*'), srcdir)
16
+ YAML.load(File.open(srcdir + '/config.yml'))
17
17
  end
18
18
 
19
19
  def compile_inline(text)
@@ -22,9 +22,7 @@ end
22
22
 
23
23
  def compile_block(text)
24
24
  method_name = "compile_block_#{@builder.target_name}"
25
- if !self.respond_to?(method_name, true)
26
- method_name = "compile_block_default"
27
- end
25
+ method_name = 'compile_block_default' unless self.respond_to?(method_name, true)
28
26
  self.__send__(method_name, text)
29
27
  end
30
28
 
@@ -35,15 +33,15 @@ end
35
33
 
36
34
  def compile_block_html(text)
37
35
  @chapter.content = text
38
- matched = @compiler.compile(@chapter).match(/<body>\n(.+)<\/body>/m)
36
+ matched = @compiler.compile(@chapter).match(Regexp.new(%Q(<body>\n(.+)</body>), Regexp::MULTILINE))
39
37
  if matched && matched.size > 1
40
38
  matched[1]
41
39
  else
42
- ""
40
+ ''
43
41
  end
44
42
  end
45
43
 
46
44
  def compile_block_idgxml(text)
47
45
  @chapter.content = text
48
- @compiler.compile(@chapter).gsub(/.*<doc xmlns:aid="http:\/\/ns.adobe.com\/AdobeInDesign\/4.0\/">/m,"").gsub(/<\/doc>\n/, "")
46
+ @compiler.compile(@chapter).gsub(Regexp.new(%Q(.*<doc xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/">), Regexp::MULTILINE), '').gsub("</doc>\n", '')
49
47
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'test_helper'
4
2
  require 'review'
5
3
 
@@ -8,73 +6,71 @@ class HTMLBuidlerTest < Test::Unit::TestCase
8
6
 
9
7
  def setup
10
8
  ReVIEW::I18n.setup
11
- @builder = HTMLBuilder.new()
9
+ @builder = HTMLBuilder.new
12
10
  @config = ReVIEW::Configure.values
13
- @config.merge!({
14
- "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
15
- "stylesheet" => nil, # for HTMLBuilder
16
- "htmlext" => "html",
17
- })
18
- @book = Book::Base.new(".")
11
+ @config['secnolevel'] = 2
12
+ @config['stylesheet'] = nil
13
+ @config['htmlext'] = 'html'
14
+ @book = Book::Base.new('.')
19
15
  @book.config = @config
20
16
  @compiler = ReVIEW::Compiler.new(@builder)
21
17
  @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
22
18
  location = Location.new(nil, nil)
23
19
  @builder.bind(@compiler, @chapter, location)
24
- I18n.setup("ja")
20
+ I18n.setup('ja')
25
21
  end
26
22
 
27
23
  def test_xmlns_ops_prefix_epub3
28
- assert_equal "epub", @builder.xmlns_ops_prefix
24
+ assert_equal 'epub', @builder.xmlns_ops_prefix
29
25
  end
30
26
 
31
27
  def test_xmlns_ops_prefix_epub2
32
- @book.config["epubversion"] = 2
33
- assert_equal "ops", @builder.xmlns_ops_prefix
28
+ @book.config['epubversion'] = 2
29
+ assert_equal 'ops', @builder.xmlns_ops_prefix
34
30
  end
35
31
 
36
32
  def test_headline_level1
37
33
  actual = compile_block("={test} this is test.\n")
38
- assert_equal %Q|<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n|, actual
34
+ assert_equal %Q(<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n), actual
39
35
  end
40
36
 
41
37
  def test_headline_level1_postdef
42
38
  @chapter.instance_eval do
43
- def on_APPENDIX?
39
+ def on_appendix?
44
40
  true
45
41
  end
46
42
  end
47
43
  actual = compile_block("={test} this is test.\n")
48
- assert_equal %Q|<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n|, actual
44
+ assert_equal %Q(<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n), actual
49
45
  end
50
46
 
51
47
  def test_headline_level2_postdef
52
48
  @chapter.instance_eval do
53
- def on_APPENDIX?
49
+ def on_appendix?
54
50
  true
55
51
  end
56
52
  end
57
53
  actual = compile_block("=={test} this is test.\n")
58
- assert_equal %Q|\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
54
+ assert_equal %Q(\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n), actual
59
55
  end
60
56
 
61
57
  def test_headline_postdef_roman
62
58
  Dir.mktmpdir do |dir|
63
59
  Dir.chdir(dir) do
64
- file = File.join(dir, "locale.yml")
65
- File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pR")}
66
- I18n.setup("ja")
60
+ file = File.join(dir, 'locale.yml')
61
+ File.open(file, 'w') { |f| f.write("locale: ja\nappendix: 付録%pR") }
62
+ I18n.setup('ja')
67
63
  @chapter.instance_eval do
68
- def on_APPENDIX?
64
+ def on_appendix?
69
65
  true
70
66
  end
71
67
  end
72
68
 
73
69
  actual = compile_block("={test} this is test.\n")
74
- assert_equal %Q|<h1 id="test"><a id="hI"></a><span class="secno">付録I </span>this is test.</h1>\n|, actual
70
+ assert_equal %Q(<h1 id="test"><a id="hI"></a><span class="secno">付録I </span>this is test.</h1>\n), actual
75
71
 
76
72
  actual = compile_block("=={test} this is test.\n")
77
- assert_equal %Q|\n<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n|, actual
73
+ assert_equal %Q(\n<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n), actual
78
74
  end
79
75
  end
80
76
  end
@@ -82,193 +78,193 @@ class HTMLBuidlerTest < Test::Unit::TestCase
82
78
  def test_headline_postdef_alpha
83
79
  Dir.mktmpdir do |dir|
84
80
  Dir.chdir(dir) do
85
- file = File.join(dir, "locale.yml")
86
- File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pA")}
87
- I18n.setup("ja")
81
+ file = File.join(dir, 'locale.yml')
82
+ File.open(file, 'w') { |f| f.write("locale: ja\nappendix: 付録%pA") }
83
+ I18n.setup('ja')
88
84
  @chapter.instance_eval do
89
- def on_APPENDIX?
85
+ def on_appendix?
90
86
  true
91
87
  end
92
88
  end
93
89
 
94
90
  actual = compile_block("={test} this is test.\n")
95
- assert_equal %Q|<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n|, actual
91
+ assert_equal %Q(<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n), actual
96
92
 
97
93
  actual = compile_block("=={test} this is test.\n")
98
- assert_equal %Q|\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
94
+ assert_equal %Q(\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n), actual
99
95
  end
100
96
  end
101
97
  end
102
98
 
103
99
  def test_headline_level1_without_secno
104
- @book.config["secnolevel"] = 0
100
+ @book.config['secnolevel'] = 0
105
101
  actual = compile_block("={test} this is test.\n")
106
- assert_equal %Q|<h1 id="test"><a id="h1"></a>this is test.</h1>\n|, actual
102
+ assert_equal %Q(<h1 id="test"><a id="h1"></a>this is test.</h1>\n), actual
107
103
  end
108
104
 
109
105
  def test_headline_level1_with_tricky_id
110
106
  actual = compile_block("={123 あ_;} this is test.\n")
111
- assert_equal %Q|<h1 id="id_123-_E3_81_82___3B"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n|, actual
107
+ assert_equal %Q(<h1 id="id_123-_E3_81_82___3B"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n), actual
112
108
  end
113
109
 
114
110
  def test_headline_level1_with_inlinetag
115
- actual = compile_block("={test} this @<b>{is} test.<&\">\n")
116
- assert_equal %Q|<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this <b>is</b> test.&lt;&amp;&quot;&gt;</h1>\n|, actual
111
+ actual = compile_block(%Q(={test} this @<b>{is} test.<&">\n))
112
+ assert_equal %Q(<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this <b>is</b> test.&lt;&amp;&quot;&gt;</h1>\n), actual
117
113
  end
118
114
 
119
115
  def test_headline_level2
120
116
  actual = compile_block("=={test} this is test.\n")
121
- assert_equal %Q|\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
117
+ assert_equal %Q(\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n), actual
122
118
  end
123
119
 
124
120
  def test_headline_level3
125
121
  actual = compile_block("==={test} this is test.\n")
126
- assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n|, actual
122
+ assert_equal %Q(\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n), actual
127
123
  end
128
124
 
129
125
  def test_headline_level3_with_secno
130
- @book.config["secnolevel"] = 3
126
+ @book.config['secnolevel'] = 3
131
127
  actual = compile_block("==={test} this is test.\n")
132
- assert_equal %Q|\n<h3 id="test"><a id="h1-0-1"></a><span class="secno">1.0.1 </span>this is test.</h3>\n|, actual
128
+ assert_equal %Q(\n<h3 id="test"><a id="h1-0-1"></a><span class="secno">1.0.1 </span>this is test.</h3>\n), actual
133
129
  end
134
130
 
135
131
  def test_label
136
132
  actual = compile_block("//label[label_test]\n")
137
- assert_equal %Q|<a id="label_test"></a>\n|, actual
133
+ assert_equal %Q(<a id="label_test"></a>\n), actual
138
134
  end
139
135
 
140
136
  def test_label_with_tricky_id
141
137
  actual = compile_block("//label[123 あ_;]\n")
142
- assert_equal %Q|<a id="id_123-_E3_81_82___3B"></a>\n|, actual
138
+ assert_equal %Q(<a id="id_123-_E3_81_82___3B"></a>\n), actual
143
139
  end
144
140
 
145
141
  def test_href
146
- actual = compile_inline("@<href>{http://github.com,GitHub}")
147
- assert_equal %Q|<a href="http://github.com" class="link">GitHub</a>|, actual
142
+ actual = compile_inline('@<href>{http://github.com,GitHub}')
143
+ assert_equal %Q(<a href="http://github.com" class="link">GitHub</a>), actual
148
144
  end
149
145
 
150
146
  def test_href_without_label
151
- actual = compile_inline("@<href>{http://github.com}")
152
- assert_equal %Q|<a href="http://github.com" class="link">http://github.com</a>|, actual
147
+ actual = compile_inline('@<href>{http://github.com}')
148
+ assert_equal %Q(<a href="http://github.com" class="link">http://github.com</a>), actual
153
149
  end
154
150
 
155
151
  def test_inline_href
156
- actual = compile_inline("@<href>{http://github.com,Git\\,Hub}")
157
- assert_equal %Q|<a href="http://github.com" class="link">Git,Hub</a>|, actual
152
+ actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
153
+ assert_equal %Q(<a href="http://github.com" class="link">Git,Hub</a>), actual
158
154
 
159
- @book.config["epubmaker"] ||= {}
160
- @book.config["epubmaker"]["externallink"] = false
161
- actual = compile_inline("@<href>{http://github.com&q=1,Git\\,Hub}")
162
- assert_equal %Q|<a href="http://github.com&amp;q=1" class="link">Git,Hub</a>|, actual
155
+ @book.config['epubmaker'] ||= {}
156
+ @book.config['epubmaker']['externallink'] = false
157
+ actual = compile_inline('@<href>{http://github.com&q=1,Git\\,Hub}')
158
+ assert_equal %Q(<a href="http://github.com&amp;q=1" class="link">Git,Hub</a>), actual
163
159
 
164
- actual = compile_inline("@<href>{http://github.com&q=1}")
165
- assert_equal %Q|<a href="http://github.com&amp;q=1" class="link">http://github.com&amp;q=1</a>|, actual
160
+ actual = compile_inline('@<href>{http://github.com&q=1}')
161
+ assert_equal %Q(<a href="http://github.com&amp;q=1" class="link">http://github.com&amp;q=1</a>), actual
166
162
  end
167
163
 
168
164
  def test_inline_href_epubmaker
169
- @book.config.maker = "epubmaker"
170
- actual = compile_inline("@<href>{http://github.com,Git\\,Hub}")
171
- assert_equal %Q|<a href="http://github.com" class="link">Git,Hub</a>|, actual
165
+ @book.config.maker = 'epubmaker'
166
+ actual = compile_inline('@<href>{http://github.com,Git\\,Hub}')
167
+ assert_equal %Q(<a href="http://github.com" class="link">Git,Hub</a>), actual
172
168
 
173
- @book.config["epubmaker"] ||= {}
174
- @book.config["epubmaker"]["externallink"] = false
175
- actual = compile_inline("@<href>{http://github.com&q=1,Git\\,Hub}")
176
- assert_equal %Q|Git,Hub(http://github.com&amp;q=1)|, actual
169
+ @book.config['epubmaker'] ||= {}
170
+ @book.config['epubmaker']['externallink'] = false
171
+ actual = compile_inline('@<href>{http://github.com&q=1,Git\\,Hub}')
172
+ assert_equal 'Git,Hub(http://github.com&amp;q=1)', actual
177
173
 
178
- actual = compile_inline("@<href>{http://github.com&q=1}")
179
- assert_equal %Q|http://github.com&amp;q=1|, actual
174
+ actual = compile_inline('@<href>{http://github.com&q=1}')
175
+ assert_equal 'http://github.com&amp;q=1', actual
180
176
 
181
- @book.config["epubmaker"]["externallink"] = true
182
- actual = compile_inline("@<href>{http://github.com&q=1,Git\\,Hub}")
183
- assert_equal %Q|<a href="http://github.com&amp;q=1" class="link">Git,Hub</a>|, actual
184
- actual = compile_inline("@<href>{http://github.com&q=1}")
185
- assert_equal %Q|<a href="http://github.com&amp;q=1" class="link">http://github.com&amp;q=1</a>|, actual
177
+ @book.config['epubmaker']['externallink'] = true
178
+ actual = compile_inline('@<href>{http://github.com&q=1,Git\\,Hub}')
179
+ assert_equal %Q(<a href="http://github.com&amp;q=1" class="link">Git,Hub</a>), actual
180
+ actual = compile_inline('@<href>{http://github.com&q=1}')
181
+ assert_equal %Q(<a href="http://github.com&amp;q=1" class="link">http://github.com&amp;q=1</a>), actual
186
182
  end
187
183
 
188
184
  def test_inline_raw
189
- actual = compile_inline("@<raw>{@<tt>{inline\\}}")
190
- assert_equal %Q|@<tt>{inline}|, actual
185
+ actual = compile_inline('@<raw>{@<tt>{inline\\}}')
186
+ assert_equal '@<tt>{inline}', actual
191
187
  end
192
188
 
193
189
  def test_inline_in_table
194
190
  actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
195
- 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
191
+ 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
196
192
  end
197
193
 
198
194
  def test_inline_br
199
- actual = compile_inline("@<br>{}")
200
- assert_equal %Q|<br />|, actual
195
+ actual = compile_inline('@<br>{}')
196
+ assert_equal '<br />', actual
201
197
  end
202
198
 
203
199
  def test_inline_i
204
- actual = compile_inline("test @<i>{inline test} test2")
205
- assert_equal %Q|test <i>inline test</i> test2|, actual
200
+ actual = compile_inline('test @<i>{inline test} test2')
201
+ assert_equal 'test <i>inline test</i> test2', actual
206
202
  end
207
203
 
208
204
  def test_inline_i_and_escape
209
- actual = compile_inline("test @<i>{inline<&;\\ test} test2")
210
- assert_equal %Q|test <i>inline&lt;&amp;;\\ test</i> test2|, actual
205
+ actual = compile_inline('test @<i>{inline<&;\\ test} test2')
206
+ assert_equal 'test <i>inline&lt;&amp;;\\ test</i> test2', actual
211
207
  end
212
208
 
213
209
  def test_inline_b
214
- actual = compile_inline("test @<b>{inline test} test2")
215
- assert_equal %Q|test <b>inline test</b> test2|, actual
210
+ actual = compile_inline('test @<b>{inline test} test2')
211
+ assert_equal 'test <b>inline test</b> test2', actual
216
212
  end
217
213
 
218
214
  def test_inline_b_and_escape
219
- actual = compile_inline("test @<b>{inline<&;\\ test} test2")
220
- assert_equal %Q|test <b>inline&lt;&amp;;\\ test</b> test2|, actual
215
+ actual = compile_inline('test @<b>{inline<&;\\ test} test2')
216
+ assert_equal 'test <b>inline&lt;&amp;;\\ test</b> test2', actual
221
217
  end
222
218
 
223
219
  def test_inline_tt
224
- actual = compile_inline("test @<tt>{inline test} test2")
225
- assert_equal %Q|test <code class="tt">inline test</code> test2|, actual
220
+ actual = compile_inline('test @<tt>{inline test} test2')
221
+ assert_equal %Q(test <code class="tt">inline test</code> test2), actual
226
222
  end
227
223
 
228
224
  def test_inline_tti
229
- actual = compile_inline("test @<tti>{inline test} test2")
230
- assert_equal %Q|test <code class="tt"><i>inline test</i></code> test2|, actual
225
+ actual = compile_inline('test @<tti>{inline test} test2')
226
+ assert_equal %Q(test <code class="tt"><i>inline test</i></code> test2), actual
231
227
  end
232
228
 
233
229
  def test_inline_ttb
234
- actual = compile_inline("test @<ttb>{inline test} test2")
235
- assert_equal %Q|test <code class="tt"><b>inline test</b></code> test2|, actual
230
+ actual = compile_inline('test @<ttb>{inline test} test2')
231
+ assert_equal %Q(test <code class="tt"><b>inline test</b></code> test2), actual
236
232
  end
237
233
 
238
234
  def test_inline_hd_chap
239
235
  def @chapter.headline_index
240
- items = [Book::HeadlineIndex::Item.new("chap1|test", [1, 1], "te_st")]
236
+ items = [Book::HeadlineIndex::Item.new('chap1|test', [1, 1], 'te_st')]
241
237
  Book::HeadlineIndex.new(items, self)
242
238
  end
243
239
 
244
- @config["secnolevel"] = 2
245
- actual = compile_inline("test @<hd>{chap1|test} test2")
246
- assert_equal %Q|test 「te_st」 test2|, actual
240
+ @config['secnolevel'] = 2
241
+ actual = compile_inline('test @<hd>{chap1|test} test2')
242
+ assert_equal 'test 「te_st」 test2', actual
247
243
 
248
- @config["secnolevel"] = 3
249
- actual = compile_inline("test @<hd>{chap1|test} test2")
250
- assert_equal %Q|test 「1.1.1 te_st」 test2|, actual
244
+ @config['secnolevel'] = 3
245
+ actual = compile_inline('test @<hd>{chap1|test} test2')
246
+ assert_equal 'test 「1.1.1 te_st」 test2', actual
251
247
  end
252
248
 
253
249
  def test_inline_hd_chap_postdef_roman
254
250
  Dir.mktmpdir do |dir|
255
251
  Dir.chdir(dir) do
256
- file = File.join(dir, "locale.yml")
257
- File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pR")}
258
- I18n.setup("ja")
252
+ file = File.join(dir, 'locale.yml')
253
+ File.open(file, 'w') { |f| f.write("locale: ja\nappendix: 付録%pR") }
254
+ I18n.setup('ja')
259
255
  @chapter.instance_eval do
260
- def on_APPENDIX?
256
+ def on_appendix?
261
257
  true
262
258
  end
263
259
  end
264
260
 
265
261
  def @chapter.headline_index
266
- items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
262
+ items = [Book::HeadlineIndex::Item.new('test', [1], 'te_st')]
267
263
  Book::HeadlineIndex.new(items, self)
268
264
  end
269
265
 
270
- actual = compile_inline("test @<hd>{test} test2")
271
- assert_equal %Q|test 「I.1 te_st」 test2|, actual
266
+ actual = compile_inline('test @<hd>{test} test2')
267
+ assert_equal 'test 「I.1 te_st」 test2', actual
272
268
  end
273
269
  end
274
270
  end
@@ -276,109 +272,109 @@ class HTMLBuidlerTest < Test::Unit::TestCase
276
272
  def test_inline_hd_chap_postdef_alpha
277
273
  Dir.mktmpdir do |dir|
278
274
  Dir.chdir(dir) do
279
- file = File.join(dir, "locale.yml")
280
- File.open(file, "w"){|f| f.write("locale: ja\nappendix: 付録%pA")}
281
- I18n.setup("ja")
275
+ file = File.join(dir, 'locale.yml')
276
+ File.open(file, 'w') { |f| f.write("locale: ja\nappendix: 付録%pA") }
277
+ I18n.setup('ja')
282
278
  @chapter.instance_eval do
283
- def on_APPENDIX?
279
+ def on_appendix?
284
280
  true
285
281
  end
286
282
  end
287
283
 
288
284
  def @chapter.headline_index
289
- items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
285
+ items = [Book::HeadlineIndex::Item.new('test', [1], 'te_st')]
290
286
  Book::HeadlineIndex.new(items, self)
291
287
  end
292
288
 
293
- actual = compile_inline("test @<hd>{test} test2")
294
- assert_equal %Q|test 「A.1 te_st」 test2|, actual
289
+ actual = compile_inline('test @<hd>{test} test2')
290
+ assert_equal 'test 「A.1 te_st」 test2', actual
295
291
  end
296
292
  end
297
293
  end
298
294
 
299
295
  def test_inline_uchar
300
- actual = compile_inline("test @<uchar>{2460} test2")
301
- assert_equal %Q|test &#x2460; test2|, actual
296
+ actual = compile_inline('test @<uchar>{2460} test2')
297
+ assert_equal 'test &#x2460; test2', actual
302
298
  end
303
299
 
304
300
  def test_inline_ruby
305
- actual = compile_inline("@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。")
306
- assert_equal "<ruby>粗雑<rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby>繊細<rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。", actual
301
+ actual = compile_inline('@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。')
302
+ assert_equal '<ruby>粗雑<rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby>繊細<rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。', actual
307
303
  end
308
304
 
309
305
  def test_inline_ruby_comma
310
- actual = compile_inline("@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}")
311
- assert_equal "<ruby>foo, bar, buz<rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>", actual
306
+ actual = compile_inline('@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}')
307
+ assert_equal '<ruby>foo, bar, buz<rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>', actual
312
308
  end
313
309
 
314
310
  def test_inline_ref
315
- actual = compile_inline("@<ref>{外部参照<>&}")
316
- assert_equal %Q|<a target='外部参照&lt;&gt;&amp;'>「●● 外部参照&lt;&gt;&amp;」</a>|, actual
311
+ actual = compile_inline('@<ref>{外部参照<>&}')
312
+ assert_equal %Q(<a target='外部参照&lt;&gt;&amp;'>「●● 外部参照&lt;&gt;&amp;」</a>), actual
317
313
  end
318
314
 
319
315
  def test_inline_mathml
320
316
  begin
321
317
  require 'math_ml'
322
- require "math_ml/symbol/character_reference"
318
+ require 'math_ml/symbol/character_reference'
323
319
  rescue LoadError
324
320
  return true
325
321
  end
326
- @config["mathml"] = true
327
- actual = compile_inline("@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}")
328
- @config["mathml"] = nil
329
- assert_equal "<span class=\"equation\"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>&#xb1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span>", actual
322
+ @config['mathml'] = true
323
+ actual = compile_inline('@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}')
324
+ @config['mathml'] = nil
325
+ assert_equal %Q(<span class="equation"><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mfrac><mrow><mo stretchy='false'>-</mo><mi>b</mi><mo stretchy='false'>&#xb1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo stretchy='false'>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math></span>), actual
330
326
  end
331
327
 
332
328
  def test_inline_img
333
- def @chapter.image(id)
334
- item = Book::ImageIndex::Item.new("sampleimg", 1, 'sample photo')
335
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
329
+ def @chapter.image(_id)
330
+ item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
331
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
336
332
  item
337
333
  end
338
334
 
339
335
  actual = compile_block "@<img>{sampleimg}\n"
340
- expected = %Q|<p><span class="imgref">図1.1</span></p>\n|
336
+ expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
341
337
  assert_equal expected, actual
342
338
  end
343
339
 
344
340
  def test_inline_imgref
345
- def @chapter.image(id)
346
- item = Book::ImageIndex::Item.new("sampleimg", 1, 'sample photo')
347
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
341
+ def @chapter.image(_id)
342
+ item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample photo')
343
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
348
344
  item
349
345
  end
350
346
 
351
347
  actual = compile_block "@<imgref>{sampleimg}\n"
352
- expected = %Q|<p><span class="imgref">図1.1</span>「sample photo」</p>\n|
348
+ expected = %Q(<p><span class="imgref">図1.1</span>「sample photo」</p>\n)
353
349
  assert_equal expected, actual
354
350
  end
355
351
 
356
352
  def test_inline_imgref2
357
- def @chapter.image(id)
358
- item = Book::NumberlessImageIndex::Item.new("sampleimg", 1)
359
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
353
+ def @chapter.image(_id)
354
+ item = Book::NumberlessImageIndex::Item.new('sampleimg', 1)
355
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
360
356
  item
361
357
  end
362
358
 
363
359
  actual = compile_block "@<imgref>{sampleimg}\n"
364
- expected = %Q|<p><span class="imgref">図1.1</span></p>\n|
360
+ expected = %Q(<p><span class="imgref">図1.1</span></p>\n)
365
361
  assert_equal expected, actual
366
362
  end
367
363
 
368
364
  def test_inline_imgref3
369
365
  Dir.mktmpdir do |dir|
370
366
  Dir.chdir(dir) do
371
- file1 = File.join(dir, "images", "img1.png")
372
- filet1 = File.join(dir, "images", "tbl1.png")
373
- file2 = File.join(dir, "images", "img2.png")
374
- re1 = File.join(dir, "sample1.re")
375
- cat = File.join(dir, "catalog.yml")
376
- FileUtils.mkdir_p(File.join(dir,"images"))
377
- File.open(file1, "w"){|f| f.write("")}
378
- File.open(filet1, "w"){|f| f.write("")}
379
- File.open(file2, "w"){|f| f.write("")}
380
- File.open(cat, "w"){|f| f.write("CHAPS:\n - sample1.re\n")}
381
- File.open(re1,"w"){|f| f.write(<<EOF)}
367
+ file1 = File.join(dir, 'images', 'img1.png')
368
+ filet1 = File.join(dir, 'images', 'tbl1.png')
369
+ file2 = File.join(dir, 'images', 'img2.png')
370
+ re1 = File.join(dir, 'sample1.re')
371
+ cat = File.join(dir, 'catalog.yml')
372
+ FileUtils.mkdir_p(File.join(dir, 'images'))
373
+ File.open(file1, 'w') { |f| f.write('') }
374
+ File.open(filet1, 'w') { |f| f.write('') }
375
+ File.open(file2, 'w') { |f| f.write('') }
376
+ File.open(cat, 'w') { |f| f.write("CHAPS:\n - sample1.re\n") }
377
+ File.open(re1, 'w') { |f| f.write(<<EOF) }
382
378
  = test
383
379
 
384
380
  tbl1 is @<table>{tbl1}.
@@ -397,7 +393,7 @@ EOF
397
393
  content = File.read(re1)
398
394
  actual = compile_block(content)
399
395
 
400
- expected =<<-EOS
396
+ expected = <<-EOS
401
397
  <h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
402
398
  <p>tbl1 is <span class="tableref">表1.1</span>.</p>
403
399
  <p>img2 is <span class="imgref">図1.2</span>.</p>
@@ -426,170 +422,170 @@ EOS
426
422
 
427
423
  def test_quote
428
424
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
429
- assert_equal %Q|<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n|, actual
425
+ assert_equal %Q(<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n), actual
430
426
  end
431
427
 
432
428
  def test_memo
433
429
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
434
- 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
430
+ 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
435
431
  end
436
432
 
437
433
  def test_noindent
438
434
  @builder.noindent
439
435
  actual = compile_block("foo\nbar\n\nfoo2\nbar2\n")
440
- assert_equal %Q|<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n|, actual
436
+ assert_equal %Q(<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n), actual
441
437
  end
442
438
 
443
439
  def test_flushright
444
440
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
445
- assert_equal %Q|<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n|, actual
441
+ assert_equal %Q(<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n), actual
446
442
  end
447
443
 
448
444
  def test_centering
449
445
  actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
450
- assert_equal %Q|<p class="center">foobar</p>\n<p class="center">buz</p>\n|, actual
446
+ assert_equal %Q(<p class="center">foobar</p>\n<p class="center">buz</p>\n), actual
451
447
  end
452
448
 
453
449
  def test_image
454
- def @chapter.image(id)
455
- item = Book::ImageIndex::Item.new("sampleimg",1)
456
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
450
+ def @chapter.image(_id)
451
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
452
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
457
453
  item
458
454
  end
459
455
 
460
456
  actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
461
- 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
457
+ 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
462
458
  end
463
459
 
464
460
  def test_image_with_metric
465
- def @chapter.image(id)
466
- item = Book::ImageIndex::Item.new("sampleimg",1)
467
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
461
+ def @chapter.image(_id)
462
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
463
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
468
464
  item
469
465
  end
470
466
 
471
467
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
472
- 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
468
+ 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
473
469
  end
474
470
 
475
471
  def test_image_with_metric2
476
- def @chapter.image(id)
477
- item = Book::ImageIndex::Item.new("sampleimg",1)
478
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
472
+ def @chapter.image(_id)
473
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
474
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
479
475
  item
480
476
  end
481
477
 
482
478
  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
483
- 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
479
+ 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
484
480
  end
485
481
 
486
482
  def test_image_with_tricky_id
487
- def @chapter.image(id)
488
- item = Book::ImageIndex::Item.new("123 あ_;",1)
489
- item.instance_eval{@path="./images/chap1-123 あ_;.png"}
483
+ def @chapter.image(_id)
484
+ item = Book::ImageIndex::Item.new('123 あ_;', 1)
485
+ item.instance_eval { @path = './images/chap1-123 あ_;.png' }
490
486
  item
491
487
  end
492
488
 
493
489
  actual = compile_block("//image[123 あ_;][sample photo]{\n//}\n")
494
- 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
490
+ 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
495
491
  end
496
492
 
497
493
  def test_indepimage
498
- def @chapter.image(id)
499
- item = Book::ImageIndex::Item.new("sampleimg",1)
500
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
494
+ def @chapter.image(_id)
495
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
496
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
501
497
  item
502
498
  end
503
499
 
504
500
  actual = compile_block("//indepimage[sampleimg][sample photo]\n")
505
- 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
501
+ 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
506
502
  end
507
503
 
508
504
  def test_indepimage_without_caption
509
- def @chapter.image(id)
510
- item = Book::ImageIndex::Item.new("sampleimg",1)
511
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
505
+ def @chapter.image(_id)
506
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
507
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
512
508
  item
513
509
  end
514
510
 
515
511
  actual = compile_block("//indepimage[sampleimg]\n")
516
- assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|, actual
512
+ assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n), actual
517
513
  end
518
514
 
519
515
  def test_indepimage_with_metric
520
- def @chapter.image(id)
521
- item = Book::ImageIndex::Item.new("sampleimg",1)
522
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
516
+ def @chapter.image(_id)
517
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
518
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
523
519
  item
524
520
  end
525
521
 
526
522
  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
527
- 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
523
+ 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
528
524
  end
529
525
 
530
526
  def test_indepimage_with_metric2
531
- def @chapter.image(id)
532
- item = Book::ImageIndex::Item.new("sampleimg",1)
533
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
527
+ def @chapter.image(_id)
528
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
529
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
534
530
  item
535
531
  end
536
532
 
537
- actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\",latex::ignore=params]\n")
538
- 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
533
+ actual = compile_block(%Q(//indepimage[sampleimg][sample photo][scale=1.2, html::class="sample",latex::ignore=params]\n))
534
+ 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
539
535
  end
540
536
 
541
537
  def test_indepimage_without_caption_but_with_metric
542
- def @chapter.image(id)
543
- item = Book::ImageIndex::Item.new("sampleimg",1)
544
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
538
+ def @chapter.image(_id)
539
+ item = Book::ImageIndex::Item.new('sampleimg', 1)
540
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
545
541
  item
546
542
  end
547
543
 
548
544
  actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
549
- assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n|, actual
545
+ assert_equal %Q(<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n), actual
550
546
  end
551
547
 
552
548
  def test_dlist
553
549
  actual = compile_block(": foo\n foo.\n bar.\n")
554
- assert_equal %Q|<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
550
+ assert_equal %Q(<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n), actual
555
551
  end
556
552
 
557
553
  def test_dlist_with_bracket
558
554
  actual = compile_block(": foo[bar]\n foo.\n bar.\n")
559
- assert_equal %Q|<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
555
+ assert_equal %Q(<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n), actual
560
556
  end
561
557
 
562
558
  def test_dlist_with_comment
563
559
  source = ": title\n body\n\#@ comment\n\#@ comment\n: title2\n body2\n"
564
560
  actual = compile_block(source)
565
- assert_equal %Q|<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n|, actual
561
+ assert_equal %Q(<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n), actual
566
562
  end
567
563
 
568
564
  def test_dlist_beforeulol
569
565
  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")
570
- 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
566
+ 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
571
567
  end
572
568
 
573
569
  def test_list
574
- def @chapter.list(id)
575
- Book::ListIndex::Item.new("samplelist",1)
570
+ def @chapter.list(_id)
571
+ Book::ListIndex::Item.new('samplelist', 1)
576
572
  end
577
573
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
578
- 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
574
+ 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
579
575
  end
580
576
 
581
577
  def test_inline_list
582
- def @chapter.list(id)
583
- Book::ListIndex::Item.new("samplelist",1)
578
+ def @chapter.list(_id)
579
+ Book::ListIndex::Item.new('samplelist', 1)
584
580
  end
585
581
  actual = compile_block("@<list>{sampletest}\n")
586
- assert_equal %Q|<p><span class="listref">リスト1.1</span></p>\n|, actual
582
+ assert_equal %Q(<p><span class="listref">リスト1.1</span></p>\n), actual
587
583
  end
588
584
 
589
585
  def test_inline_list_href
590
586
  book = ReVIEW::Book::Base.load
591
- book.config["chapterlink"] = true
592
- book.catalog = ReVIEW::Catalog.new({"CHAPS"=>%w(ch1.re ch2.re)})
587
+ book.config['chapterlink'] = true
588
+ book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
593
589
  io1 = StringIO.new("//list[sampletest]{\nfoo\n//}\n")
594
590
  io2 = StringIO.new("= BAR\n")
595
591
  chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
@@ -598,22 +594,22 @@ EOS
598
594
  builder = ReVIEW::HTMLBuilder.new
599
595
  comp = ReVIEW::Compiler.new(builder)
600
596
  builder.bind(comp, chap2, nil)
601
- actual = builder.inline_list("ch1|sampletest")
602
- assert_equal %Q|<span class="listref"><a href="./ch1.html#sampletest">リスト1.1</a></span>|, actual
597
+ actual = builder.inline_list('ch1|sampletest')
598
+ assert_equal %Q(<span class="listref"><a href="./ch1.html#sampletest">リスト1.1</a></span>), actual
603
599
  end
604
600
 
605
601
  def test_list_pygments
606
- def @chapter.list(id)
607
- Book::ListIndex::Item.new("samplelist",1)
602
+ def @chapter.list(_id)
603
+ Book::ListIndex::Item.new('samplelist', 1)
608
604
  end
609
605
  begin
610
606
  require 'pygments'
611
607
  rescue LoadError
612
- $stderr.puts "skip test_list_pygments_lang (cannot find pygments.rb)"
608
+ $stderr.puts 'skip test_list_pygments_lang (cannot find pygments.rb)'
613
609
  return true
614
610
  end
615
- @book.config["highlight"] = {}
616
- @book.config["highlight"]["html"] = "pygments"
611
+ @book.config['highlight'] = {}
612
+ @book.config['highlight']['html'] = 'pygments'
617
613
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
618
614
 
619
615
  expected = <<-EOS
@@ -630,47 +626,51 @@ test&lt;i&gt;2&lt;/i&gt;
630
626
  end
631
627
 
632
628
  def test_list_pygments_lang
633
- def @chapter.list(id)
634
- Book::ListIndex::Item.new("samplelist",1)
629
+ def @chapter.list(_id)
630
+ Book::ListIndex::Item.new('samplelist', 1)
635
631
  end
636
632
  begin
637
633
  require 'pygments'
638
634
  rescue LoadError
639
- $stderr.puts "skip test_list_pygments_lang (cannot find pygments.rb)"
635
+ $stderr.puts 'skip test_list_pygments_lang (cannot find pygments.rb)'
640
636
  return true
641
637
  end
642
- @book.config["highlight"] = {}
643
- @book.config["highlight"]["html"] = "pygments"
638
+ @book.config['highlight'] = {}
639
+ @book.config['highlight']['html'] = 'pygments'
644
640
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
645
641
 
646
- assert_equal %Q|<div id="samplelist" class=\"caption-code\">\n| +
647
- %Q|<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n| +
648
- %Q|<pre class=\"list language-ruby highlight\"><span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)\n| +
649
- %Q| (<span style=\"color: #666666\">1..3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">\|</span>i<span style=\"color: #666666\">\|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}\n| +
650
- %Q| <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n| +
651
- %Q|<span style=\"color: #008000; font-weight: bold\">end</span>\n| +
652
- %Q|</pre>\n| +
653
- %Q|</div>\n|, actual
642
+ expected = <<-EOS
643
+ <div id="samplelist" class="caption-code">
644
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
645
+ <pre class="list language-ruby highlight"><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">foo</span>(a1, a2<span style="color: #666666">=</span><span style="color: #19177C">:test</span>)
646
+ (<span style="color: #666666">1..3</span>)<span style="color: #666666">.</span>times{<span style="color: #666666">\|</span>i<span style="color: #666666">|</span> a<span style="color: #666666">.</span>include?(<span style="color: #19177C">:foo</span>)}
647
+ <span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">true</span>
648
+ <span style="color: #008000; font-weight: bold">end</span>
649
+ </pre>
650
+ </div>
651
+ EOS
652
+
653
+ assert_equal expected, actual
654
654
  end
655
655
 
656
656
  def test_list_pygments_nulllang
657
- def @chapter.list(id)
658
- Book::ListIndex::Item.new("samplelist",1)
657
+ def @chapter.list(_id)
658
+ Book::ListIndex::Item.new('samplelist', 1)
659
659
  end
660
660
  begin
661
661
  require 'pygments'
662
662
  rescue LoadError
663
- $stderr.puts "skip test_list_pygments_nulllang (cannot find pygments.rb)"
663
+ $stderr.puts 'skip test_list_pygments_nulllang (cannot find pygments.rb)'
664
664
  return true
665
665
  end
666
- @book.config["highlight"] = {}
667
- @book.config["highlight"]["html"] = "pygments"
666
+ @book.config['highlight'] = {}
667
+ @book.config['highlight']['html'] = 'pygments'
668
668
  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")
669
669
 
670
670
  expected = <<-EOS
671
- <div id="samplelist" class=\"caption-code\">
672
- <p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
673
- <pre class=\"list highlight\">def foo(a1, a2=:test)
671
+ <div id="samplelist" class="caption-code">
672
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
673
+ <pre class="list highlight">def foo(a1, a2=:test)
674
674
  (1..3).times{|i| a.include?(:foo)}
675
675
  return true
676
676
  end
@@ -684,43 +684,44 @@ end
684
684
  begin
685
685
  require 'rouge'
686
686
  rescue LoadError
687
- $stderr.puts "skip test_list_rouge (cannot find Rouge)"
687
+ $stderr.puts 'skip test_list_rouge (cannot find Rouge)'
688
688
  return true
689
689
  end
690
- def @chapter.list(id)
691
- Book::ListIndex::Item.new("samplelist",1)
690
+ def @chapter.list(_id)
691
+ Book::ListIndex::Item.new('samplelist', 1)
692
692
  end
693
- @book.config["highlight"] = {}
694
- @book.config["highlight"]["html"] = "rouge"
693
+ @book.config['highlight'] = {}
694
+ @book.config['highlight']['html'] = 'rouge'
695
695
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
696
696
 
697
- 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
697
+ 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
698
698
  end
699
699
 
700
700
  def test_list_rouge_lang
701
701
  begin
702
702
  require 'rouge'
703
703
  rescue LoadError
704
- $stderr.puts "skip test_list_rouge_lang (cannot find Rouge)"
704
+ $stderr.puts 'skip test_list_rouge_lang (cannot find Rouge)'
705
705
  return true
706
706
  end
707
- def @chapter.list(id)
708
- Book::ListIndex::Item.new("samplelist",1)
707
+ def @chapter.list(_id)
708
+ Book::ListIndex::Item.new('samplelist', 1)
709
709
  end
710
- @book.config["highlight"] = {}
711
- @book.config["highlight"]["html"] = "rouge"
710
+ @book.config['highlight'] = {}
711
+ @book.config['highlight']['html'] = 'rouge'
712
712
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
713
713
 
714
- expected = "<div id=\"samplelist\" class=\"caption-code\">\n" +
715
- "<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n" +
716
- "<pre class=\"list language-ruby highlight\"><span class=\"k\">def</span> <span class=\"nf\">foo</span><span class=\"p\">(</span><span class=\"n\">a1</span><span class=\"p\">,</span> <span class=\"n\">a2</span><span class=\"o\">=</span><span class=\"ss\">:test</span><span class=\"p\">)</span>\n" +
717
- " <span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"o\">..</span><span class=\"mi\">3</span><span class=\"p\">).</span><span class=\"nf\">times</span><span class=\"p\">{</span><span class=\"o\">|</span><span class=\"n\">i</span><span class=\"o\">|</span> <span class=\"n\">a</span><span class=\"p\">.</span><span class=\"nf\">include?</span><span class=\"p\">(</span><span class=\"ss\">:foo</span><span class=\"p\">)}</span>\n" +
718
- " <span class=\"k\">return</span> <span class=\"kp\">true</span>\n" +
719
- "<span class=\"k\">end</span>\n" +
720
- "\n" +
721
- "</pre>\n" +
722
- "</div>\n"
714
+ expected = <<-EOS
715
+ <div id="samplelist" class="caption-code">
716
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
717
+ <pre class="list language-ruby highlight"><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a2</span><span class="o">=</span><span class="ss">:test</span><span class="p">)</span>
718
+ <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">3</span><span class="p">).</span><span class="nf">times</span><span class="p">{</span><span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="n">a</span><span class="p">.</span><span class="nf">include?</span><span class="p">(</span><span class="ss">:foo</span><span class="p">)}</span>
719
+ <span class="k">return</span> <span class="kp">true</span>
720
+ <span class="k">end</span>
723
721
 
722
+ </pre>
723
+ </div>
724
+ EOS
724
725
  assert_equal expected, actual
725
726
  end
726
727
 
@@ -728,33 +729,33 @@ end
728
729
  begin
729
730
  require 'rouge'
730
731
  rescue LoadError
731
- $stderr.puts "skip test_list_rouge_nulllang (cannot find Rouge)"
732
+ $stderr.puts 'skip test_list_rouge_nulllang (cannot find Rouge)'
732
733
  return true
733
734
  end
734
- def @chapter.list(id)
735
- Book::ListIndex::Item.new("samplelist",1)
735
+ def @chapter.list(_id)
736
+ Book::ListIndex::Item.new('samplelist', 1)
736
737
  end
737
- @book.config["highlight"] = {}
738
- @book.config["highlight"]["html"] = "rouge"
738
+ @book.config['highlight'] = {}
739
+ @book.config['highlight']['html'] = 'rouge'
739
740
  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")
740
741
 
741
- assert_equal "<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
742
+ 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
742
743
  end
743
744
 
744
745
  def test_list_ext
745
- def @chapter.list(id)
746
- Book::ListIndex::Item.new("samplelist.rb",1)
746
+ def @chapter.list(_id)
747
+ Book::ListIndex::Item.new('samplelist.rb', 1)
747
748
  end
748
749
  actual = compile_block("//list[samplelist.rb][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
749
- assert_equal %Q|<div id="samplelist.rb" class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<pre class="list language-rb">test1\ntest1.5\n\ntest<i>2</i>\n</pre>\n</div>\n|, actual
750
+ assert_equal %Q(<div id="samplelist.rb" class="caption-code">\n<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<pre class="list language-rb">test1\ntest1.5\n\ntest<i>2</i>\n</pre>\n</div>\n), actual
750
751
  end
751
752
 
752
753
  def test_listnum
753
- def @chapter.list(id)
754
- Book::ListIndex::Item.new("samplelist",1)
754
+ def @chapter.list(_id)
755
+ Book::ListIndex::Item.new('samplelist', 1)
755
756
  end
756
757
 
757
- @book.config["highlight"] = false
758
+ @book.config['highlight'] = false
758
759
  actual = compile_block(<<-EOS)
759
760
  //listnum[samplelist][this is @<b>{test}<&>_][ruby]{
760
761
  def foo(a1, a2=:test)
@@ -764,7 +765,7 @@ end
764
765
  //}
765
766
  EOS
766
767
 
767
- expected =<<-EOS
768
+ expected = <<-EOS
768
769
  <div id="samplelist" class="code">
769
770
  <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
770
771
  <pre class="list language-ruby"> 1: def foo(a1, a2=:test)
@@ -779,11 +780,11 @@ EOS
779
780
  end
780
781
 
781
782
  def test_listnum_linenum
782
- def @chapter.list(id)
783
- Book::ListIndex::Item.new("samplelist",1)
783
+ def @chapter.list(_id)
784
+ Book::ListIndex::Item.new('samplelist', 1)
784
785
  end
785
786
 
786
- @book.config["highlight"] = false
787
+ @book.config['highlight'] = false
787
788
  actual = compile_block(<<-EOS)
788
789
  //firstlinenum[100]
789
790
  //listnum[samplelist][this is @<b>{test}<&>_][ruby]{
@@ -794,7 +795,7 @@ end
794
795
  //}
795
796
  EOS
796
797
 
797
- expected =<<-EOS
798
+ expected = <<-EOS
798
799
  <div id="samplelist" class="code">
799
800
  <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
800
801
  <pre class="list language-ruby">100: def foo(a1, a2=:test)
@@ -809,17 +810,17 @@ EOS
809
810
  end
810
811
 
811
812
  def test_listnum_pygments_lang
812
- def @chapter.list(id)
813
- Book::ListIndex::Item.new("samplelist",1)
813
+ def @chapter.list(_id)
814
+ Book::ListIndex::Item.new('samplelist', 1)
814
815
  end
815
816
  begin
816
817
  require 'pygments'
817
818
  rescue LoadError
818
- $stderr.puts "skip test_listnum_pygments_lang (cannot find pygments.rb)"
819
+ $stderr.puts 'skip test_listnum_pygments_lang (cannot find pygments.rb)'
819
820
  return true
820
821
  end
821
- @book.config["highlight"] = {}
822
- @book.config["highlight"]["html"] = "pygments"
822
+ @book.config['highlight'] = {}
823
+ @book.config['highlight']['html'] = 'pygments'
823
824
  actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
824
825
 
825
826
  expected = <<-EOS
@@ -836,46 +837,46 @@ EOS
836
837
  end
837
838
 
838
839
  def test_listnum_pygments_lang_linenum
839
- def @chapter.list(id)
840
- Book::ListIndex::Item.new("samplelist",1)
840
+ def @chapter.list(_id)
841
+ Book::ListIndex::Item.new('samplelist', 1)
841
842
  end
842
843
  begin
843
844
  require 'pygments'
844
845
  rescue LoadError
845
- $stderr.puts "skip test_listnum_pygments_lang (cannot find pygments.rb)"
846
+ $stderr.puts 'skip test_listnum_pygments_lang (cannot find pygments.rb)'
846
847
  return true
847
848
  end
848
- @book.config["highlight"] = {}
849
- @book.config["highlight"]["html"] = "pygments"
849
+ @book.config['highlight'] = {}
850
+ @book.config['highlight']['html'] = 'pygments'
850
851
  actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
851
852
 
852
- expected = <<-EOB
853
- <div id=\"samplelist\" class=\"code\">
854
- <p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
855
- <div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span></span><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">100 </span><span style=\"color: #008000; font-weight: bold\">def</span> <span style=\"color: #0000FF\">foo</span>(a1, a2<span style=\"color: #666666\">=</span><span style=\"color: #19177C\">:test</span>)
856
- <span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">101 </span> (<span style=\"color: #666666\">1..3</span>)<span style=\"color: #666666\">.</span>times{<span style=\"color: #666666\">|</span>i<span style=\"color: #666666\">|</span> a<span style=\"color: #666666\">.</span>include?(<span style=\"color: #19177C\">:foo</span>)}
857
- <span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">102 </span> <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>
858
- <span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">103 </span><span style=\"color: #008000; font-weight: bold\">end</span>
853
+ expected = <<-EOS
854
+ <div id="samplelist" class="code">
855
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
856
+ <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">100 </span><span style="color: #008000; font-weight: bold">def</span> <span style="color: #0000FF">foo</span>(a1, a2<span style="color: #666666">=</span><span style="color: #19177C">:test</span>)
857
+ <span style="background-color: #f0f0f0; padding: 0 5px 0 5px">101 </span> (<span style="color: #666666">1..3</span>)<span style="color: #666666">.</span>times{<span style="color: #666666">|</span>i<span style="color: #666666">|</span> a<span style="color: #666666">.</span>include?(<span style="color: #19177C">:foo</span>)}
858
+ <span style="background-color: #f0f0f0; padding: 0 5px 0 5px">102 </span> <span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000">true</span>
859
+ <span style="background-color: #f0f0f0; padding: 0 5px 0 5px">103 </span><span style="color: #008000; font-weight: bold">end</span>
859
860
  </pre></div>
860
861
  </div>
861
- EOB
862
+ EOS
862
863
 
863
864
  assert_equal expected, actual
864
865
  end
865
866
 
866
867
  def test_listnum_pygments_lang_without_lang
867
- def @chapter.list(id)
868
- Book::ListIndex::Item.new("samplelist",1)
868
+ def @chapter.list(_id)
869
+ Book::ListIndex::Item.new('samplelist', 1)
869
870
  end
870
871
  begin
871
872
  require 'pygments'
872
873
  rescue LoadError
873
- $stderr.puts "skip test_listnum_pygments_lang (cannot find pygments.rb)"
874
+ $stderr.puts 'skip test_listnum_pygments_lang (cannot find pygments.rb)'
874
875
  return true
875
876
  end
876
- @book.config["highlight"] = {}
877
- @book.config["highlight"]["html"] = "pygments"
878
- @book.config["highlight"]["lang"] = "ruby"
877
+ @book.config['highlight'] = {}
878
+ @book.config['highlight']['html'] = 'pygments'
879
+ @book.config['highlight']['lang'] = 'ruby'
879
880
  actual = compile_block("//listnum[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")
880
881
 
881
882
  expected = <<-EOS
@@ -895,31 +896,48 @@ EOB
895
896
  begin
896
897
  require 'rouge'
897
898
  rescue LoadError
898
- $stderr.puts "skip test_listnum_rouge_lang (cannot find Rouge)"
899
+ $stderr.puts 'skip test_listnum_rouge_lang (cannot find Rouge)'
899
900
  return true
900
901
  end
901
- def @chapter.list(id)
902
- Book::ListIndex::Item.new("samplelist",1)
902
+ def @chapter.list(_id)
903
+ Book::ListIndex::Item.new('samplelist', 1)
903
904
  end
904
- @book.config["highlight"] = {}
905
- @book.config["highlight"]["html"] = "rouge"
905
+ @book.config['highlight'] = {}
906
+ @book.config['highlight']['html'] = 'rouge'
906
907
  actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
907
908
 
908
- assert_equal "<div id=\"samplelist\" class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<table class=\"highlight rouge-table\"><tbody><tr><td class=\"rouge-gutter gl\"><pre class=\"lineno\">1\n2\n3\n4\n5\n</pre></td><td class=\"rouge-code\"><pre><span class=\"k\">def</span> <span class=\"nf\">foo</span><span class=\"p\">(</span><span class=\"n\">a1</span><span class=\"p\">,</span> <span class=\"n\">a2</span><span class=\"o\">=</span><span class=\"ss\">:test</span><span class=\"p\">)</span>\n <span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"o\">..</span><span class=\"mi\">3</span><span class=\"p\">).</span><span class=\"nf\">times</span><span class=\"p\">{</span><span class=\"o\">|</span><span class=\"n\">i</span><span class=\"o\">|</span> <span class=\"n\">a</span><span class=\"p\">.</span><span class=\"nf\">include?</span><span class=\"p\">(</span><span class=\"ss\">:foo</span><span class=\"p\">)}</span>\n <span class=\"k\">return</span> <span class=\"kp\">true</span>\n<span class=\"k\">end</span>\n\n</pre></td></tr></tbody></table>\n</div>\n", actual
909
+ expected = <<-EOS
910
+ <div id="samplelist" class="code">
911
+ <p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
912
+ <table class="highlight rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
913
+ 2
914
+ 3
915
+ 4
916
+ 5
917
+ </pre></td><td class="rouge-code"><pre><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a1</span><span class="p">,</span> <span class="n">a2</span><span class="o">=</span><span class="ss">:test</span><span class="p">)</span>
918
+ <span class="p">(</span><span class="mi">1</span><span class="o">..</span><span class="mi">3</span><span class="p">).</span><span class="nf">times</span><span class="p">{</span><span class="o">|</span><span class="n">i</span><span class="o">|</span> <span class="n">a</span><span class="p">.</span><span class="nf">include?</span><span class="p">(</span><span class="ss">:foo</span><span class="p">)}</span>
919
+ <span class="k">return</span> <span class="kp">true</span>
920
+ <span class="k">end</span>
921
+
922
+ </pre></td></tr></tbody></table>
923
+ </div>
924
+ EOS
925
+
926
+ assert_equal expected, actual
909
927
  end
910
928
 
911
929
  def test_listnum_rouge_lang_linenum
912
930
  begin
913
931
  require 'rouge'
914
932
  rescue LoadError
915
- $stderr.puts "skip test_listnum_rouge_lang_linenum (cannot find Rouge)"
933
+ $stderr.puts 'skip test_listnum_rouge_lang_linenum (cannot find Rouge)'
916
934
  return true
917
935
  end
918
- def @chapter.list(id)
919
- Book::ListIndex::Item.new("samplelist",1)
936
+ def @chapter.list(_id)
937
+ Book::ListIndex::Item.new('samplelist', 1)
920
938
  end
921
- @book.config["highlight"] = {}
922
- @book.config["highlight"]["html"] = "rouge"
939
+ @book.config['highlight'] = {}
940
+ @book.config['highlight']['html'] = 'rouge'
923
941
  actual = compile_block("//firstlinenum[100]\n//listnum[samplelist][this is @<b>{test}<&>_][ruby]{\ndef foo(a1, a2=:test)\n (1..3).times{|i| a.include?(:foo)}\n return true\nend\n\n//}\n")
924
942
 
925
943
  expected = <<-EOB
@@ -944,18 +962,18 @@ EOB
944
962
 
945
963
  def test_emlist
946
964
  actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
947
- assert_equal %Q|<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, actual
965
+ assert_equal %Q(<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n), actual
948
966
  end
949
967
 
950
968
  def test_emlist_pygments_lang
951
969
  begin
952
970
  require 'pygments'
953
971
  rescue LoadError
954
- $stderr.puts "skip test_emlist_pygments_lang (cannot find pygments.rb)"
972
+ $stderr.puts 'skip test_emlist_pygments_lang (cannot find pygments.rb)'
955
973
  return true
956
974
  end
957
- @book.config["highlight"] = {}
958
- @book.config["highlight"]["html"] = "pygments"
975
+ @book.config['highlight'] = {}
976
+ @book.config['highlight']['html'] = 'pygments'
959
977
  actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
960
978
  expected = <<-EOS
961
979
  <div class="emlist-code">
@@ -968,18 +986,18 @@ EOB
968
986
 
969
987
  def test_emlist_caption
970
988
  actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
971
- 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
989
+ 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
972
990
  end
973
991
 
974
992
  def test_emlist_with_tab
975
993
  actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
976
- assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, actual
994
+ assert_equal %Q(<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n), actual
977
995
  end
978
996
 
979
997
  def test_emlistnum
980
- @book.config["highlight"] = false
998
+ @book.config['highlight'] = false
981
999
  actual = compile_block("//emlistnum{\nlineA\nlineB\n//}\n")
982
- expected =<<-EOS
1000
+ expected = <<-EOS
983
1001
  <div class="emlistnum-code">
984
1002
  <pre class="emlist"> 1: lineA
985
1003
  2: lineB
@@ -990,9 +1008,9 @@ EOS
990
1008
  end
991
1009
 
992
1010
  def test_emlistnum_lang
993
- @book.config["highlight"] = false
1011
+ @book.config['highlight'] = false
994
1012
  actual = compile_block("//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
995
- expected =<<-EOS
1013
+ expected = <<-EOS
996
1014
  <div class="emlistnum-code">
997
1015
  <p class="caption">cap</p>
998
1016
  <pre class="emlist language-text"> 1: lineA
@@ -1004,9 +1022,9 @@ EOS
1004
1022
  end
1005
1023
 
1006
1024
  def test_emlistnum_lang_linenum
1007
- @book.config["highlight"] = false
1025
+ @book.config['highlight'] = false
1008
1026
  actual = compile_block("//firstlinenum[1000]\n//emlistnum[cap][text]{\nlineA\nlineB\n//}\n")
1009
- expected =<<-EOS
1027
+ expected = <<-EOS
1010
1028
  <div class="emlistnum-code">
1011
1029
  <p class="caption">cap</p>
1012
1030
  <pre class="emlist language-text">1000: lineA
@@ -1018,14 +1036,14 @@ EOS
1018
1036
  end
1019
1037
 
1020
1038
  def test_emlist_with_4tab
1021
- @config["tabwidth"] = 4
1039
+ @config['tabwidth'] = 4
1022
1040
  actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
1023
- assert_equal %Q|<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n|, actual
1041
+ assert_equal %Q(<div class="emlist-code">\n<pre class="emlist"> lineA\n lineB\n lineC\n</pre>\n</div>\n), actual
1024
1042
  end
1025
1043
 
1026
1044
  def test_cmd
1027
1045
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
1028
- assert_equal %Q|<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|, actual
1046
+ assert_equal %Q(<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n), actual
1029
1047
  end
1030
1048
 
1031
1049
  def test_cmd_pygments
@@ -1034,67 +1052,67 @@ EOS
1034
1052
  rescue LoadError
1035
1053
  return true
1036
1054
  end
1037
- @book.config["highlight"] = {}
1038
- @book.config["highlight"]["html"] = "pygments"
1055
+ @book.config['highlight'] = {}
1056
+ @book.config['highlight']['html'] = 'pygments'
1039
1057
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
1040
- assert_equal "<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
1058
+ 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
1041
1059
  end
1042
1060
 
1043
1061
  def test_cmd_caption
1044
1062
  actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
1045
- 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
1063
+ 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
1046
1064
  end
1047
1065
 
1048
1066
  def test_bib
1049
- def @chapter.bibpaper(id)
1050
- Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
1067
+ def @chapter.bibpaper(_id)
1068
+ Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1051
1069
  end
1052
1070
 
1053
- assert_equal %Q|<a href="bib.html#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}")
1071
+ assert_equal %Q(<a href="bib.html#bib-samplebib">[1]</a>), compile_inline('@<bib>{samplebib}')
1054
1072
  end
1055
1073
 
1056
1074
  def test_bib_noramlized
1057
- def @chapter.bibpaper(id)
1058
- Book::BibpaperIndex::Item.new("sampleb=ib",1,"sample bib")
1075
+ def @chapter.bibpaper(_id)
1076
+ Book::BibpaperIndex::Item.new('sampleb=ib', 1, 'sample bib')
1059
1077
  end
1060
1078
 
1061
- assert_equal %Q|<a href="bib.html#bib-id_sample_3Dbib">[1]</a>|, compile_inline("@<bib>{sample=bib}")
1079
+ assert_equal %Q(<a href="bib.html#bib-id_sample_3Dbib">[1]</a>), compile_inline('@<bib>{sample=bib}')
1062
1080
  end
1063
1081
 
1064
1082
  def test_bib_htmlext
1065
- def @chapter.bibpaper(id)
1066
- Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
1083
+ def @chapter.bibpaper(_id)
1084
+ Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1067
1085
  end
1068
1086
 
1069
- @config["htmlext"] = "xhtml"
1070
- assert_equal %Q|<a href="bib.xhtml#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}")
1087
+ @config['htmlext'] = 'xhtml'
1088
+ assert_equal %Q(<a href="bib.xhtml#bib-samplebib">[1]</a>), compile_inline('@<bib>{samplebib}')
1071
1089
  end
1072
1090
 
1073
1091
  def test_bibpaper
1074
- def @chapter.bibpaper(id)
1075
- Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
1092
+ def @chapter.bibpaper(_id)
1093
+ Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1076
1094
  end
1077
1095
 
1078
1096
  actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
1079
- 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
1097
+ 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
1080
1098
  end
1081
1099
 
1082
1100
  def test_bibpaper_normalized
1083
- def @chapter.bibpaper(id)
1084
- Book::BibpaperIndex::Item.new("sample=bib",1,"sample bib")
1101
+ def @chapter.bibpaper(_id)
1102
+ Book::BibpaperIndex::Item.new('sample=bib', 1, 'sample bib')
1085
1103
  end
1086
1104
 
1087
1105
  actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
1088
- 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
1106
+ 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
1089
1107
  end
1090
1108
 
1091
1109
  def test_bibpaper_with_anchor
1092
- def @chapter.bibpaper(id)
1093
- Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
1110
+ def @chapter.bibpaper(_id)
1111
+ Book::BibpaperIndex::Item.new('samplebib', 1, 'sample bib')
1094
1112
  end
1095
1113
 
1096
1114
  actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
1097
- 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
1115
+ 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
1098
1116
  end
1099
1117
 
1100
1118
  def column_helper(review)
@@ -1102,7 +1120,7 @@ EOS
1102
1120
  end
1103
1121
 
1104
1122
  def test_column_1
1105
- review =<<-EOS
1123
+ review = <<-EOS
1106
1124
  ===[column] prev column
1107
1125
 
1108
1126
  inside prev column
@@ -1113,7 +1131,7 @@ inside column
1113
1131
 
1114
1132
  ===[/column]
1115
1133
  EOS
1116
- expected =<<-EOS
1134
+ expected = <<-EOS
1117
1135
  <div class="column">
1118
1136
 
1119
1137
  <h3><a id="column-1"></a>prev column</h3>
@@ -1129,14 +1147,14 @@ EOS
1129
1147
  end
1130
1148
 
1131
1149
  def test_column_2
1132
- review =<<-EOS
1150
+ review = <<-EOS
1133
1151
  ===[column] test
1134
1152
 
1135
1153
  inside column
1136
1154
 
1137
1155
  === next level
1138
1156
  EOS
1139
- expected =<<-EOS
1157
+ expected = <<-EOS
1140
1158
  <div class="column">
1141
1159
 
1142
1160
  <h3><a id="column-1"></a>test</h3>
@@ -1150,20 +1168,20 @@ EOS
1150
1168
  end
1151
1169
 
1152
1170
  def test_column_3
1153
- review =<<-EOS
1171
+ review = <<-EOS
1154
1172
  ===[column] test
1155
1173
 
1156
1174
  inside column
1157
1175
 
1158
1176
  ===[/column_dummy]
1159
1177
  EOS
1160
- assert_raise(ReVIEW::CompileError) do
1178
+ assert_raise(ReVIEW::ApplicationError) do
1161
1179
  column_helper(review)
1162
1180
  end
1163
1181
  end
1164
1182
 
1165
1183
  def test_column_ref
1166
- review =<<-EOS
1184
+ review = <<-EOS
1167
1185
  ===[column]{foo} test
1168
1186
 
1169
1187
  inside column
@@ -1172,7 +1190,7 @@ inside column
1172
1190
 
1173
1191
  this is @<column>{foo}.
1174
1192
  EOS
1175
- expected =<<-EOS
1193
+ expected = <<-EOS
1176
1194
  <div class="column">
1177
1195
 
1178
1196
  <h3 id="foo"><a id="column-1"></a>test</h3>
@@ -1188,17 +1206,17 @@ EOS
1188
1206
 
1189
1207
  def test_column_in_aother_chapter_ref
1190
1208
  def @chapter.column_index
1191
- items = [Book::ColumnIndex::Item.new("chap1|column", 1, "column_cap")]
1209
+ items = [Book::ColumnIndex::Item.new('chap1|column', 1, 'column_cap')]
1192
1210
  Book::ColumnIndex.new(items)
1193
1211
  end
1194
1212
 
1195
- actual = compile_inline("test @<column>{chap1|column} test2")
1196
- expected = "test コラム「column_cap」 test2"
1213
+ actual = compile_inline('test @<column>{chap1|column} test2')
1214
+ expected = 'test コラム「column_cap」 test2'
1197
1215
  assert_equal expected, actual
1198
1216
  end
1199
1217
 
1200
1218
  def test_ul
1201
- src =<<-EOS
1219
+ src = <<-EOS
1202
1220
  * AAA
1203
1221
  * BBB
1204
1222
  EOS
@@ -1208,7 +1226,7 @@ EOS
1208
1226
  end
1209
1227
 
1210
1228
  def test_ul_cont
1211
- src =<<-EOS
1229
+ src = <<-EOS
1212
1230
  * AAA
1213
1231
  -AA
1214
1232
  * BBB
@@ -1220,12 +1238,12 @@ EOS
1220
1238
  end
1221
1239
 
1222
1240
  def test_ul_nest1
1223
- src =<<-EOS
1241
+ src = <<-EOS
1224
1242
  * AAA
1225
1243
  ** AA
1226
1244
  EOS
1227
1245
 
1228
- expected =<<-EOS
1246
+ expected = <<-EOS
1229
1247
  <ul>
1230
1248
  <li>AAA<ul>
1231
1249
  <li>AA</li>
@@ -1238,14 +1256,14 @@ EOS
1238
1256
  end
1239
1257
 
1240
1258
  def test_ul_nest2
1241
- src =<<-EOS
1259
+ src = <<-EOS
1242
1260
  * AAA
1243
1261
  ** AA
1244
1262
  * BBB
1245
1263
  ** BB
1246
1264
  EOS
1247
1265
 
1248
- expected =<<-EOS
1266
+ expected = <<-EOS
1249
1267
  <ul>
1250
1268
  <li>AAA<ul>
1251
1269
  <li>AA</li>
@@ -1262,14 +1280,14 @@ EOS
1262
1280
  end
1263
1281
 
1264
1282
  def test_ul_nest3
1265
- src =<<-EOS
1283
+ src = <<-EOS
1266
1284
  ** AAA
1267
1285
  * AA
1268
1286
  * BBB
1269
1287
  ** BB
1270
1288
  EOS
1271
1289
 
1272
- expected =<<-EOS
1290
+ expected = <<-EOS
1273
1291
  <ul>
1274
1292
  <li><ul>
1275
1293
  <li>AAA</li>
@@ -1287,7 +1305,7 @@ EOS
1287
1305
  end
1288
1306
 
1289
1307
  def test_ul_nest4
1290
- src =<<-EOS
1308
+ src = <<-EOS
1291
1309
  * A
1292
1310
  ** AA
1293
1311
  *** AAA
@@ -1295,7 +1313,7 @@ EOS
1295
1313
  ** BB
1296
1314
  EOS
1297
1315
 
1298
- expected =<<-EOS
1316
+ expected = <<-EOS
1299
1317
  <ul>
1300
1318
  <li>A<ul>
1301
1319
  <li>AA<ul>
@@ -1315,7 +1333,7 @@ EOS
1315
1333
  end
1316
1334
 
1317
1335
  def test_ul_nest5
1318
- src =<<-EOS
1336
+ src = <<-EOS
1319
1337
  * A
1320
1338
  ** AA
1321
1339
  **** AAAA
@@ -1323,7 +1341,7 @@ EOS
1323
1341
  ** BB
1324
1342
  EOS
1325
1343
 
1326
- expected =<<-EOS
1344
+ expected = <<-EOS
1327
1345
  <ul>
1328
1346
  <li>A<ul>
1329
1347
  <li>AA<ul>
@@ -1346,12 +1364,12 @@ EOS
1346
1364
  end
1347
1365
 
1348
1366
  def test_ol
1349
- src =<<-EOS
1367
+ src = <<-EOS
1350
1368
  3. AAA
1351
1369
  3. BBB
1352
1370
  EOS
1353
1371
 
1354
- expected =<<-EOS
1372
+ expected = <<-EOS
1355
1373
  <ol>
1356
1374
  <li>AAA</li>
1357
1375
  <li>BBB</li>
@@ -1362,43 +1380,43 @@ EOS
1362
1380
  end
1363
1381
 
1364
1382
  def test_inline_raw0
1365
- assert_equal "normal", compile_inline("@<raw>{normal}")
1383
+ assert_equal 'normal', compile_inline('@<raw>{normal}')
1366
1384
  end
1367
1385
 
1368
1386
  def test_inline_raw1
1369
- assert_equal "body", compile_inline("@<raw>{|html|body}")
1387
+ assert_equal 'body', compile_inline('@<raw>{|html|body}')
1370
1388
  end
1371
1389
 
1372
1390
  def test_inline_raw2
1373
- assert_equal "body", compile_inline("@<raw>{|html, latex|body}")
1391
+ assert_equal 'body', compile_inline('@<raw>{|html, latex|body}')
1374
1392
  end
1375
1393
 
1376
1394
  def test_inline_raw3
1377
- assert_equal "", compile_inline("@<raw>{|idgxml, latex|body}")
1395
+ assert_equal '', compile_inline('@<raw>{|idgxml, latex|body}')
1378
1396
  end
1379
1397
 
1380
1398
  def test_inline_raw4
1381
- assert_equal "|html body", compile_inline("@<raw>{|html body}")
1399
+ assert_equal '|html body', compile_inline('@<raw>{|html body}')
1382
1400
  end
1383
1401
 
1384
1402
  def test_inline_raw5
1385
- assert_equal "nor\nmal", compile_inline("@<raw>{|html|nor\\nmal}")
1403
+ assert_equal "nor\nmal", compile_inline('@<raw>{|html|nor\\nmal}')
1386
1404
  end
1387
1405
 
1388
1406
  def test_inline_embed0
1389
- assert_equal "normal", compile_inline("@<embed>{normal}")
1407
+ assert_equal 'normal', compile_inline('@<embed>{normal}')
1390
1408
  end
1391
1409
 
1392
1410
  def test_inline_embed1
1393
- assert_equal "body", compile_inline("@<embed>{|html|body}")
1411
+ assert_equal 'body', compile_inline('@<embed>{|html|body}')
1394
1412
  end
1395
1413
 
1396
1414
  def test_inline_embed3
1397
- assert_equal "", compile_inline("@<embed>{|idgxml, latex|body}")
1415
+ assert_equal '', compile_inline('@<embed>{|idgxml, latex|body}')
1398
1416
  end
1399
1417
 
1400
1418
  def test_inline_embed5
1401
- assert_equal 'nor\\nmal', compile_inline("@<embed>{|html|nor\\nmal}")
1419
+ assert_equal 'nor\\nmal', compile_inline('@<embed>{|html|nor\\nmal}')
1402
1420
  end
1403
1421
 
1404
1422
  def test_inline_embed_math1
@@ -1443,82 +1461,82 @@ EOS
1443
1461
  end
1444
1462
 
1445
1463
  def test_block_raw0
1446
- actual = compile_block("//raw[<>!\"\\n& ]\n")
1447
- expected = %Q(<>!\"\n& )
1464
+ actual = compile_block(%Q(//raw[<>!"\\n& ]\n))
1465
+ expected = %Q(<>!"\n& )
1448
1466
  assert_equal expected, actual
1449
1467
  end
1450
1468
 
1451
1469
  def test_block_raw1
1452
- actual = compile_block("//raw[|html|<>!\"\\n& ]\n")
1453
- expected = %Q(<>!\"\n& )
1470
+ actual = compile_block(%Q(//raw[|html|<>!"\\n& ]\n))
1471
+ expected = %Q(<>!"\n& )
1454
1472
  assert_equal expected, actual
1455
1473
  end
1456
1474
 
1457
1475
  def test_block_raw2
1458
- actual = compile_block("//raw[|html, latex|<>!\"\\n& ]\n")
1459
- expected = %Q(<>!\"\n& )
1476
+ actual = compile_block(%Q(//raw[|html, latex|<>!"\\n& ]\n))
1477
+ expected = %Q(<>!"\n& )
1460
1478
  assert_equal expected, actual
1461
1479
  end
1462
1480
 
1463
1481
  def test_block_raw3
1464
- actual = compile_block("//raw[|latex, idgxml|<>!\"\\n& ]\n")
1482
+ actual = compile_block(%Q(//raw[|latex, idgxml|<>!"\\n& ]\n))
1465
1483
  expected = ''
1466
1484
  assert_equal expected, actual
1467
1485
  end
1468
1486
 
1469
1487
  def test_block_raw4
1470
- actual = compile_block("//raw[|html <>!\"\\n& ]\n")
1471
- expected = %Q(|html <>!\"\n& )
1488
+ actual = compile_block(%Q(//raw[|html <>!"\\n& ]\n))
1489
+ expected = %Q(|html <>!"\n& )
1472
1490
  assert_equal expected, actual
1473
1491
  end
1474
1492
 
1475
1493
  def test_embed0
1476
1494
  lines = '//embed{' + "\n" +
1477
- ' <>!\\"\\\\n& ' + "\n" +
1495
+ %Q( <>!"\\\\n& ) + "\n" +
1478
1496
  '//}' + "\n"
1479
1497
  actual = compile_block(lines)
1480
- expected = ' <>!\\"\\\\n& ' + "\n"
1498
+ expected = %Q( <>!"\\\\n& ) + "\n"
1481
1499
  assert_equal expected, actual
1482
1500
  end
1483
1501
 
1484
1502
  def test_embed1
1485
1503
  actual = compile_block("//embed[|html|]{\n" +
1486
- "<>!\\\"\\\\n& \n" +
1504
+ %Q(<>!"\\\\n& \n) +
1487
1505
  "//}\n")
1488
- expected = %Q(<>!\\\"\\\\n& \n)
1506
+ expected = %Q(<>!"\\\\n& \n)
1489
1507
  assert_equal expected, actual
1490
1508
  end
1491
1509
 
1492
1510
  def test_embed2
1493
1511
  actual = compile_block("//embed[html, latex]{\n" +
1494
- "<>!\\\"\\\\n& \n" +
1512
+ %Q(<>!"\\\\n& \n) +
1495
1513
  "//}\n")
1496
- expected = %Q(<>!\\\"\\\\n& \n)
1514
+ expected = %Q(<>!"\\\\n& \n)
1497
1515
  assert_equal expected, actual
1498
1516
  end
1499
1517
 
1500
1518
  def test_embed2a
1501
1519
  actual = compile_block("//embed[|html, latex|]{\n" +
1502
- "<>!\\\"\\\\n& \n" +
1520
+ %Q(<>!"\\\\n& \n) +
1503
1521
  "//}\n")
1504
- expected = %Q(<>!\\\"\\\\n& \n)
1522
+ expected = %Q(<>!"\\\\n& \n)
1505
1523
  assert_equal expected, actual
1506
1524
  end
1507
1525
 
1508
1526
  def test_embed2b
1509
1527
  actual = compile_block("//embed[html, latex]{\n" +
1510
1528
  '#@# comments are not ignored in //embed block' + "\n" +
1511
- "<>!\\\"\\\\n& \n" +
1529
+ %Q(<>!"\\\\n& \n) +
1512
1530
  "//}\n")
1513
- expected = '#@# comments are not ignored in //embed block' + "\n" + %Q(<>!\\\"\\\\n& \n)
1531
+ expected = '#@# comments are not ignored in //embed block' + "\n" + %Q(<>!"\\\\n& \n)
1514
1532
  assert_equal expected, actual
1515
1533
  end
1516
1534
 
1517
1535
  def test_inline_fn
1518
1536
  fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\\a\\$buz]'])
1519
- @chapter.instance_eval{@footnote_index=fn}
1537
+ @chapter.instance_eval { @footnote_index = fn }
1520
1538
  actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
1521
- expected =<<-'EOS'
1539
+ expected = <<-'EOS'
1522
1540
  <div class="footnote" epub:type="footnote" id="fn-foo"><p class="footnote">[*1] bar\a\$buz</p></div>
1523
1541
  EOS
1524
1542
  assert_equal expected, actual
@@ -1526,9 +1544,9 @@ EOS
1526
1544
 
1527
1545
  def test_inline_fn_with_tricky_id
1528
1546
  fn = Book::FootnoteIndex.parse(['//footnote[123 あ_;][bar\\a\\$buz]'])
1529
- @chapter.instance_eval{@footnote_index=fn}
1547
+ @chapter.instance_eval { @footnote_index = fn }
1530
1548
  actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
1531
- expected =<<-'EOS'
1549
+ expected = <<-'EOS'
1532
1550
  <div class="footnote" epub:type="footnote" id="fn-id_123-_E3_81_82___3B"><p class="footnote">[*1] bar\a\$buz</p></div>
1533
1551
  EOS
1534
1552
  assert_equal expected, actual
@@ -1536,7 +1554,7 @@ EOS
1536
1554
 
1537
1555
  def test_inline_hd
1538
1556
  book = ReVIEW::Book::Base.load
1539
- book.catalog = ReVIEW::Catalog.new({"CHAPS"=>%w(ch1.re ch2.re)})
1557
+ book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
1540
1558
  io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
1541
1559
  io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
1542
1560
  chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
@@ -1545,55 +1563,66 @@ EOS
1545
1563
  builder = ReVIEW::HTMLBuilder.new
1546
1564
  comp = ReVIEW::Compiler.new(builder)
1547
1565
  builder.bind(comp, chap2, nil)
1548
- hd = builder.inline_hd("ch1|test1-1")
1549
- assert_equal "「1.1 test1-1」", hd
1566
+ hd = builder.inline_hd('ch1|test1-1')
1567
+ assert_equal '「1.1 test1-1」', hd
1550
1568
  end
1551
1569
 
1552
1570
  def test_inline_hd_for_part
1553
1571
  book = ReVIEW::Book::Base.load
1554
- book.catalog = ReVIEW::Catalog.new({"CHAPS"=>%w(ch1.re ch2.re)})
1572
+ book.catalog = ReVIEW::Catalog.new('CHAPS' => %w[ch1.re ch2.re])
1555
1573
  io1 = StringIO.new("= test1\n\nfoo\n\n== test1-1\n\nbar\n\n== test1-2\n\nbar\n\n")
1556
1574
  io2 = StringIO.new("= test2\n\nfoo\n\n== test2-1\n\nbar\n\n== test2-2\n\nbar\n\n")
1557
1575
  io_p1 = StringIO.new("= part1\n\nfoo\n\n== part1-1\n\nbar\n\n== part1-2\n\nbar\n\n")
1558
1576
  chap1 = ReVIEW::Book::Chapter.new(book, 1, 'ch1', 'ch1.re', io1)
1559
1577
  chap2 = ReVIEW::Book::Chapter.new(book, 2, 'ch2', 'ch2.re', io2)
1560
- book.parts = [ReVIEW::Book::Part.new(self, 1, [chap1, chap2], "part1.re", io_p1)]
1578
+ book.parts = [ReVIEW::Book::Part.new(self, 1, [chap1, chap2], 'part1.re', io_p1)]
1561
1579
  builder = ReVIEW::HTMLBuilder.new
1562
1580
  comp = ReVIEW::Compiler.new(builder)
1563
1581
  builder.bind(comp, chap2, nil)
1564
- hd = builder.inline_hd("part1|part1-1")
1565
- assert_equal "「1.1 part1-1」", hd
1582
+ hd = builder.inline_hd('part1|part1-1')
1583
+ assert_equal '「1.1 part1-1」', hd
1584
+ end
1585
+
1586
+ def test_inline_hd_with_block
1587
+ io1 = StringIO.new("= test1\n=={foo} foo\n//emlist{\n======\nbar\n======\n}\n//}\n=={bar} bar")
1588
+ chap1 = Book::Chapter.new(@book, 1, '-', nil, io1)
1589
+ location = Location.new(nil, nil)
1590
+ @builder.bind(@compiler, chap1, location)
1591
+ hd = @builder.inline_hd('foo')
1592
+ assert_equal '「1.1 foo」', hd
1593
+ hd = @builder.inline_hd('bar')
1594
+ assert_equal '「1.2 bar」', hd
1566
1595
  end
1567
1596
 
1568
1597
  def test_table
1569
1598
  actual = compile_block("//table{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1570
- 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|,
1599
+ 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),
1571
1600
  actual
1572
1601
  end
1573
1602
 
1574
1603
  def test_inline_table
1575
- def @chapter.table(id)
1576
- Book::TableIndex::Item.new("sampletable",1)
1604
+ def @chapter.table(_id)
1605
+ Book::TableIndex::Item.new('sampletable', 1)
1577
1606
  end
1578
1607
  actual = compile_block("@<table>{sampletest}\n")
1579
- assert_equal %Q|<p><span class="tableref">表1.1</span></p>\n|, actual
1608
+ assert_equal %Q(<p><span class="tableref">表1.1</span></p>\n), actual
1580
1609
  end
1581
1610
 
1582
1611
  def test_emtable
1583
1612
  actual = compile_block("//emtable[foo]{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n//emtable{\naaa\tbbb\n------------\nccc\tddd<>&\n//}\n")
1584
- 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|,
1613
+ 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),
1585
1614
  actual
1586
1615
  end
1587
1616
 
1588
1617
  def test_imgtable
1589
- def @chapter.image(id)
1590
- item = Book::ImageIndex::Item.new("sampleimg",1, 'sample img')
1591
- item.instance_eval{@path="./images/chap1-sampleimg.png"}
1618
+ def @chapter.image(_id)
1619
+ item = Book::ImageIndex::Item.new('sampleimg', 1, 'sample img')
1620
+ item.instance_eval { @path = './images/chap1-sampleimg.png' }
1592
1621
  item
1593
1622
  end
1594
1623
 
1595
1624
  actual = compile_block("//imgtable[sampleimg][test for imgtable]{\n//}\n")
1596
- 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|
1625
+ 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)
1597
1626
  assert_equal expected, actual
1598
1627
  end
1599
1628
 
@@ -1632,24 +1661,29 @@ EOS
1632
1661
  end
1633
1662
 
1634
1663
  def test_comment
1635
- actual = compile_block("//comment[コメント]")
1636
- assert_equal %Q||, actual
1664
+ actual = compile_block('//comment[コメント]')
1665
+ assert_equal '', actual
1637
1666
  end
1638
1667
 
1639
1668
  def test_comment_for_draft
1640
- @config["draft"] = true
1641
- actual = compile_block("//comment[コメント]")
1642
- assert_equal %Q|<div class="draft-comment">コメント</div>\n|, actual
1669
+ @config['draft'] = true
1670
+ actual = compile_block('//comment[コメント]')
1671
+ assert_equal %Q(<div class="draft-comment">コメント</div>\n), actual
1643
1672
  end
1644
1673
 
1645
1674
  def test_inline_comment
1646
- actual = compile_inline("test @<comment>{コメント} test2")
1647
- assert_equal %Q|test test2|, actual
1675
+ actual = compile_inline('test @<comment>{コメント} test2')
1676
+ assert_equal 'test test2', actual
1648
1677
  end
1649
1678
 
1650
1679
  def test_inline_comment_for_draft
1651
- @config["draft"] = true
1652
- actual = compile_inline("test @<comment>{コメント} test2")
1653
- assert_equal %Q|test <span class="draft-comment">コメント</span> test2|, actual
1680
+ @config['draft'] = true
1681
+ actual = compile_inline('test @<comment>{コメント} test2')
1682
+ assert_equal %Q(test <span class="draft-comment">コメント</span> test2), actual
1683
+ end
1684
+
1685
+ def test_inline_fence
1686
+ actual = compile_inline('test @<code>|@<code>{$サンプル$}|')
1687
+ assert_equal 'test <code class="inline-code tt">@&lt;code&gt;{$サンプル$}</code>', actual
1654
1688
  end
1655
1689
  end