class HTMLBuidlerTest

Public Instance Methods

column_helper(review) click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 705
def column_helper(review)
  compile_block(review)
end
on_APPENDIX?() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 45
def on_APPENDIX?
  true
end
setup() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 11
def setup
  ReVIEW::I18n.setup
  @builder = HTMLBuilder.new()
  @config = ReVIEW::Configure.values
  @config.merge!({
    "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
    "stylesheet" => nil, # for HTMLBuilder
    "htmlext" => "html",
  })
  @book = Book::Base.new(".")
  @book.config = @config
  @compiler = ReVIEW::Compiler.new(@builder)
  @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
  location = Location.new(nil, nil)
  @builder.bind(@compiler, @chapter, location)
  I18n.setup("ja")
end
test_bib() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 653
def test_bib
  def @chapter.bibpaper(id)
    Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
  end

  assert_equal %Q<a href="bib.html#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}")
end
test_bib_htmlext() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 669
def test_bib_htmlext
  def @chapter.bibpaper(id)
    Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
  end

  @config["htmlext"] = "xhtml"
  assert_equal %Q<a href="bib.xhtml#bib-samplebib">[1]</a>|, compile_inline("@<bib>{samplebib}")
end
test_bib_noramlized() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 661
def test_bib_noramlized
  def @chapter.bibpaper(id)
    Book::BibpaperIndex::Item.new("sampleb=ib",1,"sample bib")
  end

  assert_equal %Q<a href="bib.html#bib-id_sample_3Dbib">[1]</a>|, compile_inline("@<bib>{sample=bib}")
end
test_bibpaper() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 678
def test_bibpaper
  def @chapter.bibpaper(id)
    Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
  end

  actual = compile_block("//bibpaper[samplebib][sample bib @<b>{bold}]{\na\nb\n//}\n")
  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
end
test_bibpaper_normalized() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 687
def test_bibpaper_normalized
  def @chapter.bibpaper(id)
    Book::BibpaperIndex::Item.new("sample=bib",1,"sample bib")
  end

  actual = compile_block("//bibpaper[sample=bib][sample bib @<b>{bold}]{\na\nb\n//}\n")
  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
end
test_bibpaper_with_anchor() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 696
def test_bibpaper_with_anchor
  def @chapter.bibpaper(id)
    Book::BibpaperIndex::Item.new("samplebib",1,"sample bib")
  end

  actual = compile_block("//bibpaper[samplebib][sample bib @<href>{http://example.jp}]{\na\nb\n//}\n")
  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
end
test_block_raw0() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 983
def test_block_raw0
  actual = compile_block("//raw[<>!\"\\n& ]\n")
  expected = %Q(<>!\"\n& )
  assert_equal expected, actual
end
test_block_raw1() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 989
def test_block_raw1
  actual = compile_block("//raw[|html|<>!\"\\n& ]\n")
  expected = %Q(<>!\"\n& )
  assert_equal expected, actual
end
test_block_raw2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 995
def test_block_raw2
  actual = compile_block("//raw[|html, latex|<>!\"\\n& ]\n")
  expected = %Q(<>!\"\n& )
  assert_equal expected, actual
end
test_block_raw3() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 1001
def test_block_raw3
  actual = compile_block("//raw[|latex, idgxml|<>!\"\\n& ]\n")
  expected = ''
  assert_equal expected, actual
end
test_block_raw4() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 1007
def test_block_raw4
  actual = compile_block("//raw[|html <>!\"\\n& ]\n")
  expected = %Q(|html <>!\"\n& )
  assert_equal expected, actual
end
test_centering() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 340
def test_centering
  actual = compile_block("//centering{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q<p class="center">foobar</p>\n<p class="center">buz</p>\n|, actual
end
test_cmd() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 632
def test_cmd
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
  assert_equal %Q<div class="cmd-code">\n<pre class="cmd">lineA\nlineB\n</pre>\n</div>\n|, actual
end
test_cmd_caption() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 648
def test_cmd_caption
  actual = compile_block("//cmd[cap1]{\nlineA\nlineB\n//}\n")
  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
end
test_cmd_pygments() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 637
def test_cmd_pygments
  begin
    require 'pygments'
  rescue LoadError
    return true
  end
  @book.config["pygments"] = true
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
  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
end
test_column_1() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 709
  def test_column_1
    review =<<-EOS
===[column] prev column

inside prev column

===[column] test

inside column

===[/column]
EOS
    expected =<<-EOS
<div class="column">

<h3><a id="column-1"></a>prev column</h3>
<p>inside prev column</p>
</div>
<div class="column">

<h3><a id="column-2"></a>test</h3>
<p>inside column</p>
</div>
EOS
    assert_equal expected, column_helper(review)
  end
test_column_2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 736
  def test_column_2
    review =<<-EOS
===[column] test

inside column

=== next level
EOS
    expected =<<-EOS
<div class="column">

<h3><a id="column-1"></a>test</h3>
<p>inside column</p>
</div>

<h3><a id="h1-0-1"></a>next level</h3>
EOS

    assert_equal expected, column_helper(review)
  end
test_column_3() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 757
  def test_column_3
    review =<<-EOS
===[column] test

inside column

===[/column_dummy]
EOS
    assert_raise(ReVIEW::CompileError) do
      column_helper(review)
    end
  end
test_column_ref() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 770
  def test_column_ref
    review =<<-EOS
===[column]{foo} test

inside column

=== next level

this is @<column>{foo}.
EOS
    expected =<<-EOS
<div class="column">

<h3 id="foo"><a id="column-1"></a>test</h3>
<p>inside column</p>
</div>

<h3><a id="h1-0-1"></a>next level</h3>
<p>this is コラム「test」.</p>
EOS

    assert_equal expected, column_helper(review)
  end
test_dlist() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 444
def test_dlist
  actual = compile_block(": foo\n  foo.\n  bar.\n")
  assert_equal %Q<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
end
test_dlist_with_bracket() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 449
def test_dlist_with_bracket
  actual = compile_block(": foo[bar]\n    foo.\n    bar.\n")
  assert_equal %Q<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
end
test_dlist_with_comment() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 454
def test_dlist_with_comment
  source = ": title\n  body\n\#@ comment\n\#@ comment\n: title2\n  body2\n"
  actual = compile_block(source)
  assert_equal %Q<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n|, actual
end
test_emlist() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 586
def test_emlist
  actual = compile_block("//emlist{\nlineA\nlineB\n//}\n")
  assert_equal %Q<div class="emlist-code">\n<pre class="emlist">lineA\nlineB\n</pre>\n</div>\n|, actual
end
test_emlist_caption() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 603
def test_emlist_caption
  actual = compile_block("//emlist[cap1]{\nlineA\nlineB\n//}\n")
  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
end
test_emlist_pygments_lang() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 591
def test_emlist_pygments_lang
  begin
    require 'pygments'
  rescue LoadError
    $stderr.puts "skip test_emlist_pygments_lang (cannot find pygments.rb)"
    return true
  end
  @book.config["pygments"] = true
  actual = compile_block("//emlist[][sql]{\nSELECT COUNT(*) FROM tests WHERE tests.no > 10 AND test.name LIKE 'ABC%'\n//}\n")
  assert_equal "<div class=\"emlist-code\">\n<pre class=\"emlist\"><span style=\"color: #008000; font-weight: bold\">SELECT</span> <span style=\"color: #008000; font-weight: bold\">COUNT</span>(<span style=\"color: #666666\">*</span>) <span style=\"color: #008000; font-weight: bold\">FROM</span> tests <span style=\"color: #008000; font-weight: bold\">WHERE</span> tests.<span style=\"color: #008000; font-weight: bold\">no</span> <span style=\"color: #666666\">&gt;</span> <span style=\"color: #666666\">10</span> <span style=\"color: #008000; font-weight: bold\">AND</span> test.name <span style=\"color: #008000; font-weight: bold\">LIKE</span> <span style=\"color: #BA2121\">&#39;ABC%&#39;</span>\n</pre>\n</div>\n", actual
end
test_emlist_with_4tab() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 626
def test_emlist_with_4tab
  @config["tabwidth"] = 4
  actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
  assert_equal %Q<div class="emlist-code">\n<pre class="emlist">    lineA\n        lineB\n    lineC\n</pre>\n</div>\n|, actual
end
test_emlist_with_tab() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 608
def test_emlist_with_tab
  actual = compile_block("//emlist{\n\tlineA\n\t\tlineB\n\tlineC\n//}\n")
  assert_equal %Q<div class="emlist-code">\n<pre class="emlist">        lineA\n                lineB\n        lineC\n</pre>\n</div>\n|, actual
end
test_emlistnum() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 613
  def test_emlistnum
    @book.config["highlight"] = false
    actual = compile_block("//emlistnum{\nlineA\nlineB\n//}\n")
    expected =<<-EOS
<div class="emlistnum-code">
<pre class="emlist"> 1: lineA
 2: lineB
</pre>
</div>
EOS
    assert_equal expected, actual
  end
test_flushright() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 335
def test_flushright
  actual = compile_block("//flushright{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q<p class="flushright">foobar</p>\n<p class="flushright">buz</p>\n|, actual
end
test_headline_level1() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 38
def test_headline_level1
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q<h1 id="test"><a id="h1"></a><span class="secno">第1章 </span>this is test.</h1>\n|, actual
end
test_headline_level1_postdef() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 43
def test_headline_level1_postdef
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q<h1 id="test"><a id="h1"></a><span class="secno">付録1 </span>this is test.</h1>\n|, actual
end
test_headline_level1_postdef_alpha() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 85
def test_headline_level1_postdef_alpha
  @chapter.book.config["appendix_format"] = "alpha"
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q<h1 id="test"><a id="hA"></a><span class="secno">付録A </span>this is test.</h1>\n|, actual
end
test_headline_level1_postdef_roman() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 63
def test_headline_level1_postdef_roman
  @chapter.book.config["appendix_format"] = "roman"
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q<h1 id="test"><a id="hI"></a><span class="secno">付録I </span>this is test.</h1>\n|, actual
end
test_headline_level1_with_inlinetag() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 118
def test_headline_level1_with_inlinetag
  actual = compile_block("={test} this @<b>{is} test.<&\">\n")
  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
end
test_headline_level1_with_tricky_id() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 113
def test_headline_level1_with_tricky_id
  actual = compile_block("={123 あ_;} this is test.\n")
  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
end
test_headline_level1_without_secno() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 107
def test_headline_level1_without_secno
  @book.config["secnolevel"] = 0
  actual = compile_block("={test} this is test.\n")
  assert_equal %Q<h1 id="test"><a id="h1"></a>this is test.</h1>\n|, actual
end
test_headline_level2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 123
def test_headline_level2
  actual = compile_block("=={test} this is test.\n")
  assert_equal %Q\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
end
test_headline_level2_postdef() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 53
def test_headline_level2_postdef
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  actual = compile_block("=={test} this is test.\n")
  assert_equal %Q\n<h2 id="test"><a id="h1-1"></a><span class="secno">1.1 </span>this is test.</h2>\n|, actual
end
test_headline_level2_postdef_alpha() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 96
def test_headline_level2_postdef_alpha
  @chapter.book.config["appendix_format"] = "alpha"
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  actual = compile_block("=={test} this is test.\n")
  assert_equal %Q\n<h2 id="test"><a id="hA-1"></a><span class="secno">A.1 </span>this is test.</h2>\n|, actual
end
test_headline_level2_postdef_roman() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 74
def test_headline_level2_postdef_roman
  @chapter.book.config["appendix_format"] = "roman"
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  actual = compile_block("=={test} this is test.\n")
  assert_equal %Q\n<h2 id="test"><a id="hI-1"></a><span class="secno">I.1 </span>this is test.</h2>\n|, actual
end
test_headline_level3() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 128
def test_headline_level3
  actual = compile_block("==={test} this is test.\n")
  assert_equal %Q\n<h3 id="test"><a id="h1-0-1"></a>this is test.</h3>\n|, actual
end
test_headline_level3_with_secno() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 133
def test_headline_level3_with_secno
  @book.config["secnolevel"] = 3
  actual = compile_block("==={test} this is test.\n")
  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
end
test_href() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 149
def test_href
  actual = compile_inline("@<href>{http://github.com,GitHub}")
  assert_equal %Q<a href="http://github.com" class="link">GitHub</a>|, actual
end
test_href_without_label() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 154
def test_href_without_label
  actual = compile_inline("@<href>{http://github.com}")
  assert_equal %Q<a href="http://github.com" class="link">http://github.com</a>|, actual
end
test_image() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 345
def test_image
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//image[sampleimg][sample photo]{\n//}\n")
  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
end
test_image_with_metric() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 356
def test_image_with_metric
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//image[sampleimg][sample photo][scale=1.2]{\n//}\n")
  assert_equal %Q<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, actual
end
test_image_with_metric2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 367
def test_image_with_metric2
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//image[sampleimg][sample photo][scale=1.2,html::class=sample,latex::ignore=params]{\n//}\n")
  assert_equal %Q<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" class="sample" />\n<p class="caption">\n図1.1: sample photo\n</p>\n</div>\n|, actual
end
test_image_with_tricky_id() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 378
def test_image_with_tricky_id
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("123 あ_;",1)
    item.instance_eval{@path="./images/chap1-123 あ_;.png"}
    item
  end

  actual = compile_block("//image[123 あ_;][sample photo]{\n//}\n")
  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
end
test_indepimage() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 389
def test_indepimage
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo]\n")
  assert_equal %Q<div 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
end
test_indepimage_with_metric() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 411
def test_indepimage_with_metric
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2]\n")
  assert_equal %Q<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
end
test_indepimage_with_metric2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 422
def test_indepimage_with_metric2
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][sample photo][scale=1.2, html::class=\"sample\",latex::ignore=params]\n")
  assert_equal %Q<div class="image">\n<img src="images/chap1-sampleimg.png" alt="sample photo" width="120%" class="sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
end
test_indepimage_without_caption() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 400
def test_indepimage_without_caption
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg]\n")
  assert_equal %Q<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|, actual
end
test_indepimage_without_caption_but_with_metric() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 433
def test_indepimage_without_caption_but_with_metric
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg",1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
  assert_equal %Q<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" width="120%" />\n</div>\n|, actual
end
test_inline_b() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 189
def test_inline_b
  actual = compile_inline("test @<b>{inline test} test2")
  assert_equal %Qtest <b>inline test</b> test2|, actual
end
test_inline_b_and_escape() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 194
def test_inline_b_and_escape
  actual = compile_inline("test @<b>{inline<&;\\ test} test2")
  assert_equal %Qtest <b>inline&lt;&amp;;\\ test</b> test2|, actual
end
test_inline_br() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 174
def test_inline_br
  actual = compile_inline("@<br>{}")
  assert_equal %Q<br />|, actual
end
test_inline_fn() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 1013
  def test_inline_fn
    fn = Book::FootnoteIndex.parse(['//footnote[foo][bar\a\$buz]'])
    @chapter.instance_eval{@footnote_index=fn}
    actual = compile_block("//footnote[foo][bar\\a\\$buz]\n")
    expected =<<-'EOS'
<div class="footnote" id="fn-foo"><p class="footnote">[<a href="#fnb-foo">*1</a>] bar\a\$buz</p></div>
EOS
    assert_equal expected, actual
  end
test_inline_fn_with_tricky_id() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 1023
  def test_inline_fn_with_tricky_id
    fn = Book::FootnoteIndex.parse(['//footnote[123 あ_;][bar\a\$buz]'])
    @chapter.instance_eval{@footnote_index=fn}
    actual = compile_block("//footnote[123 あ_;][bar\\a\\$buz]\n")
    expected =<<-'EOS'
<div class="footnote" id="fn-id_123-_E3_81_82___3B"><p class="footnote">[<a href="#fnb-id_123-_E3_81_82___3B">*1</a>] bar\a\$buz</p></div>
EOS
    assert_equal expected, actual
  end
test_inline_hd_chap() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 214
def test_inline_hd_chap
  def @chapter.headline_index
    items = [Book::HeadlineIndex::Item.new("chap1|test", [1, 1], "te_st")]
    Book::HeadlineIndex.new(items, self)
  end

  @config["secnolevel"] = 2
  actual = compile_inline("test @<hd>{chap1|test} test2")
  assert_equal %Qtest 「te_st」 test2|, actual

  @config["secnolevel"] = 3
  actual = compile_inline("test @<hd>{chap1|test} test2")
  assert_equal %Qtest 「1.1.1 te_st」 test2|, actual
end
test_inline_hd_chap_postdef_alpha() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 245
def test_inline_hd_chap_postdef_alpha
  @chapter.book.config["appendix_format"] = "alpha"
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  def @chapter.headline_index
    items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
    Book::HeadlineIndex.new(items, self)
  end

  actual = compile_inline("test @<hd>{test} test2")
  assert_equal %Qtest 「A.1 te_st」 test2|, actual
end
test_inline_hd_chap_postdef_roman() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 229
def test_inline_hd_chap_postdef_roman
  @chapter.book.config["appendix_format"] = "roman"
  @chapter.instance_eval do
    def on_APPENDIX?
      true
    end
  end
  def @chapter.headline_index
    items = [Book::HeadlineIndex::Item.new("test", [1], "te_st")]
    Book::HeadlineIndex.new(items, self)
  end

  actual = compile_inline("test @<hd>{test} test2")
  assert_equal %Qtest 「I.1 te_st」 test2|, actual
end
test_inline_href() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 159
def test_inline_href
  actual = compile_inline("@<href>{http://github.com,Git\\,Hub}")
  assert_equal %Q<a href="http://github.com" class="link">Git,Hub</a>|, actual
end
test_inline_i() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 179
def test_inline_i
  actual = compile_inline("test @<i>{inline test} test2")
  assert_equal %Qtest <i>inline test</i> test2|, actual
end
test_inline_i_and_escape() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 184
def test_inline_i_and_escape
  actual = compile_inline("test @<i>{inline<&;\\ test} test2")
  assert_equal %Qtest <i>inline&lt;&amp;;\\ test</i> test2|, actual
end
test_inline_imgref() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 294
def test_inline_imgref
  def @chapter.image(id)
    item = Book::ImageIndex::Item.new("sampleimg", 1, 'sample photo')
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block "@<imgref>{sampleimg}\n"
  expected = "<p>図1.1「sample photo」</p>\n"
  assert_equal expected, actual
end
test_inline_imgref2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 306
def test_inline_imgref2
  def @chapter.image(id)
    item = Book::NumberlessImageIndex::Item.new("sampleimg", 1)
    item.instance_eval{@path="./images/chap1-sampleimg.png"}
    item
  end

  actual = compile_block "@<imgref>{sampleimg}\n"
  expected = "<p>図1.1</p>\n"
  assert_equal expected, actual
end
test_inline_in_table() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 169
def test_inline_in_table
  actual = compile_block("//table{\n@<b>{1}\t@<i>{2}\n------------\n@<b>{3}\t@<i>{4}<>&\n//}\n")
  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
end
test_inline_mathml() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 281
def test_inline_mathml
  begin
    require 'math_ml'
    require "math_ml/symbol/character_reference"
  rescue LoadError
    return true
  end
  @config["mathml"] = true
  actual = compile_inline("@<m>{\\frac{-b \\pm \\sqrt{b^2 - 4ac\\}\\}{2a\\}}")
  @config["mathml"] = nil
  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
end
test_inline_raw() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 164
def test_inline_raw
  actual = compile_inline("@<raw>{@<tt>{inline\\}}")
  assert_equal %Q@<tt>{inline}|, actual
end
test_inline_raw0() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 959
def test_inline_raw0
  assert_equal "normal", compile_inline("@<raw>{normal}")
end
test_inline_raw1() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 963
def test_inline_raw1
  assert_equal "body", compile_inline("@<raw>{|html|body}")
end
test_inline_raw2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 967
def test_inline_raw2
  assert_equal "body", compile_inline("@<raw>{|html, latex|body}")
end
test_inline_raw3() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 971
def test_inline_raw3
  assert_equal "", compile_inline("@<raw>{|idgxml, latex|body}")
end
test_inline_raw4() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 975
def test_inline_raw4
  assert_equal "|html body", compile_inline("@<raw>{|html body}")
end
test_inline_raw5() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 979
def test_inline_raw5
  assert_equal "nor\nmal", compile_inline("@<raw>{|html|nor\\nmal}")
end
test_inline_ref() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 276
def test_inline_ref
  actual = compile_inline("@<ref>{外部参照<>&}")
  assert_equal %Q<a target='外部参照&lt;&gt;&amp;'>「●● 外部参照&lt;&gt;&amp;」</a>|, actual
end
test_inline_ruby() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 266
def test_inline_ruby
  actual = compile_inline("@<ruby>{粗雑,クルード}と思われているなら@<ruby>{繊細,テクニカル}にやり、繊細と思われているなら粗雑にやる。")
  assert_equal "<ruby><rb>粗雑</rb><rp>(</rp><rt>クルード</rt><rp>)</rp></ruby>と思われているなら<ruby><rb>繊細</rb><rp>(</rp><rt>テクニカル</rt><rp>)</rp></ruby>にやり、繊細と思われているなら粗雑にやる。", actual
end
test_inline_ruby_comma() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 271
def test_inline_ruby_comma
  actual = compile_inline("@<ruby>{foo\\, bar\\, buz,フー・バー・バズ}")
  assert_equal "<ruby><rb>foo, bar, buz</rb><rp>(</rp><rt>フー・バー・バズ</rt><rp>)</rp></ruby>", actual
end
test_inline_tt() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 199
def test_inline_tt
  actual = compile_inline("test @<tt>{inline test} test2")
  assert_equal %Qtest <tt>inline test</tt> test2|, actual
end
test_inline_ttb() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 209
def test_inline_ttb
  actual = compile_inline("test @<ttb>{inline test} test2")
  assert_equal %Qtest <tt><b>inline test</b></tt> test2|, actual
end
test_inline_tti() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 204
def test_inline_tti
  actual = compile_inline("test @<tti>{inline test} test2")
  assert_equal %Qtest <tt><i>inline test</i></tt> test2|, actual
end
test_inline_uchar() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 261
def test_inline_uchar
  actual = compile_inline("test @<uchar>{2460} test2")
  assert_equal %Qtest &#x2460; test2|, actual
end
test_label() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 139
def test_label
  actual = compile_block("//label[label_test]\n")
  assert_equal %Q<a id="label_test"></a>\n|, actual
end
test_label_with_tricky_id() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 144
def test_label_with_tricky_id
  actual = compile_block("//label[123 あ_;]\n")
  assert_equal %Q<a id="id_123-_E3_81_82___3B"></a>\n|, actual
end
test_list() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 460
def test_list
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  end
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")
  assert_equal %Q<div 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
end
test_list_pygments() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 468
def test_list_pygments
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  end
  begin
    require 'pygments'
  rescue LoadError
    $stderr.puts "skip test_list_pygments_lang (cannot find pygments.rb)"
    return true
  end
  @book.config["pygments"] = true
  actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")

  assert_equal %Q<div 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&lt;i&gt;2&lt;/i&gt;\n</pre>\n</div>\n|, actual
end
test_list_pygments_lang() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 484
def test_list_pygments_lang
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  end
  begin
    require 'pygments'
  rescue LoadError
    $stderr.puts "skip test_list_pygments_lang (cannot find pygments.rb)"
    return true
  end
  @book.config["pygments"] = true
  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")

  assert_equal %Q<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n| +
               %Q<pre class=\"list\"><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| +
               %Q  (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">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| +
               %Q  <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n| +
               %Q<span style=\"color: #008000; font-weight: bold\">end</span>\n| +
               %Q</pre>\n| +
               %Q</div>\n|, actual
end
test_list_pygments_nulllang() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 506
def test_list_pygments_nulllang
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  end
  begin
    require 'pygments'
  rescue LoadError
    $stderr.puts "skip test_list_pygments_nulllang (cannot find pygments.rb)"
    return true
  end
  @book.config["pygments"] = true
  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")

  assert_equal "<div class=\"caption-code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<pre class=\"list\">def foo(a1, a2=:test)\n  (1..3).times{|i| a.include?(:foo)}\n  return true\nend\n</pre>\n</div>\n", actual
end
test_listnum() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 522
  def test_listnum
    def @chapter.list(id)
      Book::ListIndex::Item.new("samplelist",1)
    end

    @book.config["highlight"] = false
    actual = compile_block("//listnum[samplelist][this is @<b>{test}<&>_][ruby]{
def foo(a1, a2=:test)
  (1..3).times{|i| a.include?(:foo)}
  return true
end
//}
")

    expected =<<-EOS
<div class="code">
<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<pre class="list"> 1: def foo(a1, a2=:test)
 2:   (1..3).times{|i| a.include?(:foo)}
 3:   return true
 4: end
</pre>
</div>
EOS

    assert_equal expected, actual
  end
test_listnum_pygments_lang() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 551
def test_listnum_pygments_lang
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  end
  begin
    require 'pygments'
  rescue LoadError
    $stderr.puts "skip test_listnum_pygments_lang (cannot find pygments.rb)"
    return true
  end
  @book.config["pygments"] = true
  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")

  assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</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>)\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span>   (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span>   <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div>\n</div>\n", actual
end
test_listnum_pygments_lang_without_lang() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 567
def test_listnum_pygments_lang_without_lang
  def @chapter.list(id)
    Book::ListIndex::Item.new("samplelist",1)
  end
  begin
    require 'pygments'
  rescue LoadError
    $stderr.puts "skip test_listnum_pygments_lang (cannot find pygments.rb)"
    return true
  end
  @book.config["highlight"] = {}
  @book.config["highlight"]["html"] = "pygments"
  @book.config["highlight"]["lang"] = "ruby"
  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")

  assert_equal "<div class=\"code\">\n<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n<div class=\"highlight\" style=\"background: #f8f8f8\"><pre style=\"line-height: 125%\"><span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">1</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>)\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">2</span>   (<span style=\"color: #666666\">1.</span>.<span style=\"color: #666666\">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<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">3</span>   <span style=\"color: #008000; font-weight: bold\">return</span> <span style=\"color: #008000\">true</span>\n<span style=\"background-color: #f0f0f0; padding: 0 5px 0 5px\">4</span> <span style=\"color: #008000; font-weight: bold\">end</span>\n</pre></div>\n</div>\n", actual
end
test_memo() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 324
def test_memo
  actual = compile_block("//memo[this is @<b>{test}<&>_]{\ntest1\n\ntest@<i>{2}\n//}\n")
  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
end
test_noindent() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 329
def test_noindent
  @builder.noindent
  actual = compile_block("foo\nbar\n\nfoo2\nbar2\n")
  assert_equal %Q<p class="noindent">foobar</p>\n<p>foo2bar2</p>\n|, actual
end
test_ol() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 943
  def test_ol
    src =<<-EOS
  3. AAA
  3. BBB
EOS

    expected =<<-EOS
<ol>
<li>AAA</li>
<li>BBB</li>
</ol>
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_quote() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 319
def test_quote
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q<blockquote><p>foobar</p>\n<p>buz</p></blockquote>\n|, actual
end
test_ul() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 795
  def test_ul
    src =<<-EOS
  * AAA
  * BBB
EOS
    expected = "<ul>\n<li>AAA</li>\n<li>BBB</li>\n</ul>\n"
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_cont() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 805
  def test_ul_cont
    src =<<-EOS
  * AAA
    -AA
  * BBB
    -BB
EOS
    expected = "<ul>\n<li>AAA-AA</li>\n<li>BBB-BB</li>\n</ul>\n"
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest1() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 817
  def test_ul_nest1
    src =<<-EOS
  * AAA
  ** AA
EOS

    expected =<<-EOS
<ul>
<li>AAA<ul>
<li>AA</li>
</ul>
</li>
</ul>
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 835
  def test_ul_nest2
    src =<<-EOS
  * AAA
  ** AA
  * BBB
  ** BB
EOS

    expected =<<-EOS
<ul>
<li>AAA<ul>
<li>AA</li>
</ul>
</li>
<li>BBB<ul>
<li>BB</li>
</ul>
</li>
</ul>
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest3() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 859
  def test_ul_nest3
    src =<<-EOS
  ** AAA
  * AA
  * BBB
  ** BB
EOS

    expected =<<-EOS
<ul>
<li><ul>
<li>AAA</li>
</ul>
</li>
<li>AA</li>
<li>BBB<ul>
<li>BB</li>
</ul>
</li>
</ul>
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest4() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 884
  def test_ul_nest4
    src =<<-EOS
  * A
  ** AA
  *** AAA
  * B
  ** BB
EOS

    expected =<<-EOS
<ul>
<li>A<ul>
<li>AA<ul>
<li>AAA</li>
</ul>
</li>
</ul>
</li>
<li>B<ul>
<li>BB</li>
</ul>
</li>
</ul>
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest5() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 912
  def test_ul_nest5
    src =<<-EOS
  * A
  ** AA
  **** AAAA
  * B
  ** BB
EOS

    expected =<<-EOS
<ul>
<li>A<ul>
<li>AA<ul>
<li><ul>
<li>AAAA</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>B<ul>
<li>BB</li>
</ul>
</li>
</ul>
EOS
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_xmlns_ops_prefix_epub2() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 34
def test_xmlns_ops_prefix_epub2
  assert_equal "ops", @builder.xmlns_ops_prefix
end
test_xmlns_ops_prefix_epub3() click to toggle source
# File ../../../../../test/test_htmlbuilder.rb, line 29
def test_xmlns_ops_prefix_epub3
  @book.config["epubversion"] = 3
  assert_equal "epub", @builder.xmlns_ops_prefix
end