Skip to content

Commit

Permalink
set id to <div> of indepimage as same as image.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Sep 4, 2016
1 parent eb68457 commit 57df4c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/review/htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def image_image(id, caption, metric)
end

def image_dummy(id, caption, lines)
puts %Q[<div class="image">]
puts %Q[<div id="#{normalize_id(id)}" class="image">]
puts %Q[<pre class="dummyimage">]
lines.each do |line|
puts detab(line)
Expand Down Expand Up @@ -769,7 +769,7 @@ def footnote(id, str)
def indepimage(id, caption="", metric=nil)
metrics = parse_metric("html", metric)
caption = "" if caption.nil?
puts %Q[<div class="image">]
puts %Q[<div id="#{normalize_id(id)}" class="image">]
begin
puts %Q[<img src="#{@chapter.image(id).path.sub(/\A\.\//, "")}" alt="#{escape_html(compile_inline(caption))}"#{metrics} />]
rescue
Expand Down
10 changes: 5 additions & 5 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def @chapter.image(id)
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
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
end

def test_indepimage_without_caption
Expand All @@ -444,7 +444,7 @@ def @chapter.image(id)
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
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" />\n</div>\n|, actual
end

def test_indepimage_with_metric
Expand All @@ -455,7 +455,7 @@ def @chapter.image(id)
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" class="width-120per" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
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
end

def test_indepimage_with_metric2
Expand All @@ -466,7 +466,7 @@ def @chapter.image(id)
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" class="width-120per sample" />\n<p class="caption">\n図: sample photo\n</p>\n</div>\n|, actual
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
end

def test_indepimage_without_caption_but_with_metric
Expand All @@ -477,7 +477,7 @@ def @chapter.image(id)
end

actual = compile_block("//indepimage[sampleimg][][scale=1.2]\n")
assert_equal %Q|<div class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n|, actual
assert_equal %Q|<div id="sampleimg" class="image">\n<img src="images/chap1-sampleimg.png" alt="" class="width-120per" />\n</div>\n|, actual
end

def test_dlist
Expand Down

0 comments on commit 57df4c4

Please sign in to comment.