Skip to content

Commit 7e86884

Browse files
committed
Use table only if ndim is 1 or 2
1 parent 4277050 commit 7e86884

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

lib/rubydown.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@
99

1010
class Numo::NArray
1111
def to_html
12-
rows = self.to_a.map do |row|
13-
elems = row.map do |elem|
12+
case ndim
13+
when 2
14+
rows = self.to_a.map do |row|
15+
elems = row.map do |elem|
16+
"<td>#{elem}</td>"
17+
end
18+
"<tr>#{elems.join}</tr>"
19+
end
20+
"<table>#{rows.join}</table>"
21+
when 1
22+
cols = self.to_a.map do |elem|
1423
"<td>#{elem}</td>"
1524
end
16-
"<tr>#{elems.join}</tr>"
25+
"<table><tr>#{cols.join}</tr></table>"
26+
else
27+
inspect
1728
end
18-
"<table>#{rows.join}</table>"
19-
end
20-
end
21-
22-
class Numo::Int32
23-
def to_html
24-
<<-HTML
25-
#{self.to_a}
26-
HTML
2729
end
2830
end
2931

0 commit comments

Comments
 (0)