diff --git a/src/io.jl b/src/io.jl index be5ca8b135..77d0831897 100644 --- a/src/io.jl +++ b/src/io.jl @@ -729,6 +729,42 @@ function writetable(filename::String, return end +############################################################################## +# +# HTML output +# +############################################################################## +function html_escape(cell::String) + cell = replace(cell, "&", "&") + cell = replace(cell, "<", "<") + cell = replace(cell, ">", ">") + return cell +end + +function Base.writemime(io::IO, + ::MIME"text/html", + df::DataFrame) + n = size(df, 1) + column_names = colnames(df) + write(io, "
") + for column_name in column_names + write(io, " | $column_name | ") + end + write(io, "
---|---|
$row | ") + for column_name in column_names + cell = string(df[row, column_name]) + write(io, "$(html_escape(cell)) | ") + end + write(io, "