Skip to content

Commit 7cd0e1a

Browse files
committed
make showtable more lenient
and support e.g. Arrays
1 parent 195903b commit 7cd0e1a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/TableView.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ to_css_size(s::AbstractString) = s
2020
to_css_size(s::Real) = "$(s)px"
2121

2222
function showtable(table; dark = false, height = :auto, width = "100%")
23-
if !Tables.istable(typeof(table))
24-
throw(ArgumentError("Argument is not a table."))
23+
if !Tables.istable(table)
24+
try
25+
table = Tables.table(table)
26+
catch err
27+
throw(ArgumentError("Argument is not a table."))
28+
end
2529
end
2630

2731
tablelength = Base.IteratorSize(table) == Base.HasLength() ? length(Tables.rows(table)) : nothing

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ end
1919
]
2020
@test showtable(nttable) isa WebIO.Scope
2121
end
22+
@testset "normal array" begin
23+
array = rand(10, 10)
24+
@test showtable(array) isa WebIO.Scope
25+
end

0 commit comments

Comments
 (0)