/*-
 * #%L
 * SciJava polyglot kernel for Jupyter.
 * %%
 * Copyright (C) 2017 Hadrien Mary
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package net.imagej.notebook.converter;

import net.imagej.table.Table;

import org.scijava.convert.Converter;
import org.scijava.notebook.converter.NotebookOutputConverter;
import org.scijava.notebook.converter.output.HTMLNotebookOutput;
import org.scijava.plugin.Plugin;

@Plugin(type = Converter.class)
public class TableToHTMLNotebookConverter<O extends Table>
        extends NotebookOutputConverter<O, HTMLNotebookOutput> {

    @Override
    public Class getInputType() {
        return Table.class;
    }

    @Override
    public Class getOutputType() {
        return HTMLNotebookOutput.class;
    }

    @Override
    public HTMLNotebookOutput convert(Object object) {

        Table table = (Table) object;

        String htmlString = "<table>";

        // Set column headers
        htmlString += "<tr>";
        for (int i = 0; i < table.getColumnCount(); i++) {
            htmlString += "<th>";
            htmlString += table.getColumnHeader(i);
            htmlString += "</th>";
        }
        htmlString += "</tr>";

        // Append the rows
        for (int i = 0; i < table.getRowCount(); i++) {
            htmlString += "<tr>";
            for (int j = 0; j < table.getColumnCount(); j++) {
                htmlString += "<td>";
                htmlString += table.get(j, i);
                htmlString += "</td>";
            }
            htmlString += "</tr>";
        }

        htmlString += "</table>";

        return new HTMLNotebookOutput(htmlString);
    }

}

@@ -271,17 +271,16 @@
 se at%0A *
- 
 %0A *     
@@ -325,17 +325,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -699,16 +699,48 @@
 erter;%0A%0A
+import net.imagej.table.Column;%0A
 import n
@@ -839,16 +839,20 @@
 nverter.
+HTML
 Notebook
@@ -913,24 +913,29 @@
 .output.HTML
+Table
 NotebookOutp
@@ -1047,17 +1047,17 @@
 nverter%3C
-O
+C
  extends
@@ -1061,19 +1061,32 @@
 nds 
-Table%3E%0A    
+Column%3C? extends T%3E, T%3E%0A
     
@@ -1093,16 +1093,20 @@
 extends 
+HTML
 Notebook
@@ -1125,15 +1125,30 @@
 ter%3C
-O
+Table%3CC, T%3E
 , HTML
+Table
 Note
@@ -1158,17 +1158,17 @@
 kOutput%3E
- 
+%0A
 %7B%0A%0A    @
@@ -1176,36 +1176,100 @@
 verride%0A    
-public Class
+@SuppressWarnings(%7B %22rawtypes%22, %22unchecked%22 %7D)%0A    public Class%3CTable%3CC, T%3E%3E
  getInputTyp
@@ -1288,16 +1288,24 @@
   return
+ (Class)
  Table.c
@@ -1347,16 +1347,41 @@
 ic Class
+%3CHTMLTableNotebookOutput%3E
  getOutp
@@ -1406,24 +1406,29 @@
  return HTML
+Table
 NotebookOutp
@@ -1469,24 +1469,29 @@
  public HTML
+Table
 NotebookOutp
@@ -1501,16 +1501,22 @@
 convert(
+final 
 Object o
@@ -1533,21 +1533,72 @@
         
-Table
+@SuppressWarnings(%22unchecked%22)%0A        final Table%3CC, T%3E
  table =
@@ -1604,16 +1604,22 @@
 = (Table
+%3CC, T%3E
 ) object
@@ -2183,32 +2183,39 @@
   htmlString += 
+asHTML(
 table.get(j, i);
@@ -2213,16 +2213,17 @@
 et(j, i)
+)
 ;%0A      
@@ -2369,24 +2369,29 @@
 urn new HTML
+Table
 NotebookOutp

Update to use table style and extend HTMLNotebookOutputConverter