                 input_lines.push(x)
             else
                 input_lines_process()
-                mark = marks[0]
-                switch x[0]
+                mark = marks[0] # assumption it's always 1
+                switch x[0]     # first char is the marker
                     when MARKERS.cell
                         x
-
                     when MARKERS.output
+                        # assume, all cells are evaluated and hence mark.rendered contains the html
                         console.log 'output', mark
-                        out = "<div class='output'>#{mark.widgetNode.innerHTML}</div>"
-                        html.push(out)
+                        for mesg_ser in mark.rendered.split(MARKERS.output)
+                            if mesg_ser.length == 0
+                                continue
+                            try
+                                mesg = misc.from_json(mesg_ser)
+                            catch e
+                                console.warn("invalid output message '#{m}' in line '#{line}'")
+                                continue
+
+                            output_html = @html_process_output_mesg(mesg, mark)
+                            if output_html?
+                                html.push(output_html)
 
         input_lines_process()
-        html_data = (h for h in html).join('\n')
+        html_data =
+            title     : @filename
+            filename  : @filename
+            content   : (h for h in html).join('\n')
+            timestamp : "#{new Date()}"
 
         salvus_client.write_text_file_to_project
             project_id : @editor.project_id
             path       : @output_file
-            content    : html_data
+            content    : @generate_html(html_data)
             cb         : (err, resp) =>
                 console.log err, resp
                 @cb?(err, resp)

            when 'html'
                @html(opts.cb)

    html: (cb) ->
        # the following fits mentally into sagews.SynchronizedWorksheet
        {MARKERS} = require('smc-util/sagews')
        html = [] # list of elements
        cm = @editor.codemirror
        input_lines = []
        input_lines_process = ->
            if input_lines.length > 0
                html.push("<pre>#{input_lines.join('\n')}</pre>")
                input_lines = []
        for line in [0...cm.lineCount()]
            x = cm.getLine(line)
            console.log "line", x

{salvus_client} = require('./salvus_client')
{redux}         = require('./smc-react')
{project_tasks} = require('./project_tasks')
markdown        = require('./markdown')

# abstract class
class Printer
