diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-06-10 15:22:36 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-06-10 15:22:36 +0100 |
| commit | 03293a8e2265dd84eb05a31b8100cf1a310c51bb (patch) | |
| tree | 4d87de615c8fcd81ebeb88b4e1f29d79568ebce5 /lib/document-to-html.js | |
| parent | 8be57d82ffae15aa753ca57ce19c581bf0d6b897 (diff) | |
Add basic footnote output
Diffstat (limited to 'lib/document-to-html.js')
| -rw-r--r-- | lib/document-to-html.js | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index 9741781..5e50e89 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -117,7 +117,22 @@ function DocumentConverter(options) { var elementConverters = { "document": function(document, html, messages, callback) { - convertElements(document.children, html, messages, callback); + convertElements(document.children, html, messages, function(error) { + if (error) { + callback(error); + } else { + html.closeAll(); + html.open(htmlPaths.element("ol")); + convertElements(document.footnotes, html, messages, function(error) { + if (error) { + callback(error); + } else { + html.close(); + callback(); + } + }); + } + }); }, "paragraph": convertParagraph, "run": convertRun, @@ -141,13 +156,28 @@ function DocumentConverter(options) { }); }, "footnoteReference": function(element, html, messages, callback) { + var number = element.footnoteNumber.toString(); html.open(htmlPaths.element("sup")); - html.open(htmlPaths.element("a", {href: "#footnote-" + element.id})); - html.text("1"); + html.open(htmlPaths.element("a", {href: "#footnote-" + number})); + html.text(element.footnoteNumber.toString()); html.close(); html.close(); callback(); }, + "footnote": function(element, html, messages, callback) { + html.open(htmlPaths.element("li", {id: "footnote-" + element.footnoteNumber})); + var footnoteHtml = new HtmlGenerator(); + convertElements(element.body, footnoteHtml, messages, function(err) { + if (err) { + callback(err); + } else { + footnoteHtml.closeAll(); + html.append(footnoteHtml); + html.close(); + callback(); + } + }); + }, "image": options.convertImage || defaultConvertImage }; return { |
