diff options
Diffstat (limited to 'lib/document-to-html.js')
| -rw-r--r-- | lib/document-to-html.js | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index fe601bd..6c954e6 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -213,7 +213,55 @@ function DocumentConversion(options) { } }); }, - "image": options.convertImage || defaultConvertImage + "image": options.convertImage || defaultConvertImage, + "table": function(element, html, messages, callback) { + html.closeAll(); + html.open(htmlPaths.element("table")); + convertElements(element.children, html, messages, function(err) { + if (err) { + callback(err); + } else { + html.close(); + callback(); + } + }); + }, + "tableRow": function(element, html, messages, callback) { + html.open(htmlPaths.element("tr")); + convertElements(element.children, html, messages, function(err) { + if (err) { + callback(err); + } else { + html.close(); + callback(); + } + }); + }, + "tableCell": function(element, html, messages, callback) { + html.open(htmlPaths.element("td")); + + async.map(element.children, function(child, callback) { + var cellHtml = new HtmlGenerator(); + elementToHtml(child, cellHtml, messages, function(error) { + if (error) { + callback(error); + } else { + cellHtml.closeAll(); + callback(null, cellHtml); + } + }); + }, function(error, childrenHtml) { + if (error) { + callback(error); + } else { + childrenHtml.forEach(function(childHtml) { + html.append(childHtml); + }); + html.close(); + callback(); + } + }); + } }; return { convertToHtml: convertToHtml |
