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

fix counting of //imgtable #782

Merged
merged 2 commits into from
May 26, 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
8 changes: 6 additions & 2 deletions lib/review/book/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ def self.parse(src, *args)
# ex. ["//image", "id", "", "caption"]
elements = line.split(/\[(.*?)\]/)
if elements[1].present?
items.push item_class().new(elements[1], seq, elements[3])
seq += 1
if line =~ %r{^//imgtable}
items.push item_class().new(elements[1], 0, elements[3])
else ## %r<^//(image|graph)>
items.push item_class().new(elements[1], seq, elements[3])
seq += 1
end
if elements[1] == ""
warn "warning: no ID of #{item_type()} in #{line}"
end
Expand Down
59 changes: 59 additions & 0 deletions test/test_htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,65 @@ def @chapter.image(id)
assert_equal expected, actual
end

def test_inline_imgref3
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file1 = File.join(dir, "images", "img1.png")
filet1 = File.join(dir, "images", "tbl1.png")
file2 = File.join(dir, "images", "img2.png")
re1 = File.join(dir, "sample1.re")
cat = File.join(dir, "catalog.yml")
FileUtils.mkdir_p(File.join(dir,"images"))
File.open(file1, "w"){|f| f.write("")}
File.open(filet1, "w"){|f| f.write("")}
File.open(file2, "w"){|f| f.write("")}
File.open(cat, "w"){|f| f.write("CHAPS:\n - sample1.re\n")}
File.open(re1,"w"){|f| f.write(<<EOF)}
= test

tbl1 is @<table>{tbl1}.

img2 is @<img>{img2}.

//image[img1][image 1]{
//}

//imgtable[tbl1][table 1]{
//}

//image[img2][image 2]{
//}
EOF
content = File.read(re1)
actual = compile_block(content)

expected =<<-EOS
<h1><a id="h1"></a><span class="secno">第1章 </span>test</h1>
<p>tbl1 is <span class="tableref">表1.1</span>.</p>
<p>img2 is <span class="imgref">図1.2</span>.</p>
<div id="img1" class="image">
<img src="images/img1.png" alt="image 1" />
<p class="caption">
図1.1: image 1
</p>
</div>
<div id="tbl1" class="imgtable image">
<p class="caption">表1.1: table 1</p>
<img src="images/tbl1.png" alt="table 1" />
</div>
<div id="img2" class="image">
<img src="images/img2.png" alt="image 2" />
<p class="caption">
図1.2: image 2
</p>
</div>
EOS

assert_equal expected, actual
end
end
end

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
Expand Down