Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML: listのidをdivの属性に入れていなかった #724

Merged
merged 2 commits into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/review/htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def read(lines)
alias_method :lead, :read

def list(lines, id, caption, lang = nil)
puts %Q[<div class="caption-code">]
puts %Q[<div id="#{normalize_id(id)}" class="caption-code">]
begin
list_header id, caption, lang
rescue KeyError
Expand Down Expand Up @@ -477,7 +477,7 @@ def source_body(id, lines, lang)
end

def listnum(lines, id, caption, lang = nil)
puts %Q[<div class="code">]
puts %Q[<div id="#{normalize_id(id)}" class="code">]
begin
list_header id, caption, lang
rescue KeyError
Expand Down
30 changes: 15 additions & 15 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ 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
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
end

def test_inline_list
Expand Down Expand Up @@ -555,7 +555,7 @@ def @chapter.list(id)
actual = compile_block("//list[samplelist][this is @<b>{test}<&>_]{\ntest1\ntest1.5\n\ntest@<i>{2}\n//}\n")

expected = <<-EOS
<div class="caption-code">
<div id="samplelist" class="caption-code">
<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<pre class="list highlight">test1
test1.5
Expand All @@ -581,7 +581,7 @@ def @chapter.list(id)
@book.config["highlight"]["html"] = "pygments"
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| +
assert_equal %Q|<div id="samplelist" class=\"caption-code\">\n| +
%Q|<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>\n| +
%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| +
%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| +
Expand All @@ -606,7 +606,7 @@ def @chapter.list(id)
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")

expected = <<-EOS
<div class=\"caption-code\">
<div id="samplelist" class=\"caption-code\">
<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<pre class=\"list highlight\">def foo(a1, a2=:test)
(1..3).times{|i| a.include?(:foo)}
Expand All @@ -632,7 +632,7 @@ def @chapter.list(id)
@book.config["highlight"]["html"] = "rouge"
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 highlight">test1\ntest1.5\n\ntest&lt;i&gt;2&lt;/i&gt;\n</pre>\n</div>\n|, actual
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
end

def test_list_rouge_lang
Expand All @@ -649,7 +649,7 @@ def @chapter.list(id)
@book.config["highlight"]["html"] = "rouge"
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")

expected = "<div class=\"caption-code\">\n" +
expected = "<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 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" +
" <span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">.</span><span class=\"nf\">.</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" +
Expand All @@ -676,15 +676,15 @@ def @chapter.list(id)
@book.config["highlight"]["html"] = "rouge"
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 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
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
end

def test_list_ext
def @chapter.list(id)
Book::ListIndex::Item.new("samplelist.rb",1)
end
actual = compile_block("//list[samplelist.rb][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 language-rb">test1\ntest1.5\n\ntest<i>2</i>\n</pre>\n</div>\n|, actual
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
end

def test_listnum
Expand All @@ -703,7 +703,7 @@ def foo(a1, a2=:test)
EOS

expected =<<-EOS
<div class="code">
<div id="samplelist" class="code">
<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<pre class="list language-ruby"> 1: def foo(a1, a2=:test)
2: (1..3).times{|i| a.include?(:foo)}
Expand Down Expand Up @@ -733,7 +733,7 @@ def foo(a1, a2=:test)
EOS

expected =<<-EOS
<div class="code">
<div id="samplelist" class="code">
<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<pre class="list language-ruby">100: def foo(a1, a2=:test)
101: (1..3).times{|i| a.include?(:foo)}
Expand Down Expand Up @@ -761,7 +761,7 @@ def @chapter.list(id)
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")

expected = <<-EOS
<div class="code">
<div id="samplelist" class="code">
<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><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>)
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </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>)}
Expand All @@ -788,7 +788,7 @@ def @chapter.list(id)
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")

expected = <<-EOB
<div class=\"code\">
<div id=\"samplelist\" class=\"code\">
<p class=\"caption\">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<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>)
<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>)}
Expand Down Expand Up @@ -817,7 +817,7 @@ def @chapter.list(id)
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")

expected = <<-EOS
<div class="code">
<div id="samplelist" class="code">
<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><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>)
<span style="background-color: #f0f0f0; padding: 0 5px 0 5px">2 </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>)}
Expand All @@ -843,7 +843,7 @@ def @chapter.list(id)
@book.config["highlight"]["html"] = "rouge"
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<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=\"p\">.</span><span class=\"nf\">.</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
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=\"p\">.</span><span class=\"nf\">.</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
end

def test_listnum_rouge_lang_linenum
Expand All @@ -861,7 +861,7 @@ def @chapter.list(id)
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")

expected = <<-EOB
<div class="code">
<div id="samplelist" class="code">
<p class="caption">リスト1.1: this is <b>test</b>&lt;&amp;&gt;_</p>
<table class="highlight rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">100
101
Expand Down