aboutsummaryrefslogtreecommitdiff
path: root/lib/document-to-html.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-06-10 15:40:05 +0100
committerMichael Williamson <mike@zwobble.org>2014-06-10 15:40:05 +0100
commit296ac78496e4d94dafd1a4f6f872a1283b796318 (patch)
tree1d30666e971e63a5bf0e4008bf1a0abacde3d0be /lib/document-to-html.js
parent88b21ba0d0989a5c4f142f5971d33b069a7dfb26 (diff)
Pass all footnotes into document object
Diffstat (limited to 'lib/document-to-html.js')
-rw-r--r--lib/document-to-html.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index b984089..5b8db9a 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -28,6 +28,8 @@ function DocumentConverter(options) {
function DocumentConversion(options) {
var footnoteNumber = 1;
+ var footnoteIds = [];
+
options = options || {};
var defaultParagraphStyle = htmlPaths.topLevelElement("p");
@@ -73,7 +75,7 @@ function DocumentConversion(options) {
return style.to;
} else {
if (element.styleId) {
- messages.push(unrecognisedStyleWarning("paragraph", element));;
+ messages.push(unrecognisedStyleWarning("paragraph", element));
}
return defaultParagraphStyle;
}
@@ -134,7 +136,10 @@ function DocumentConversion(options) {
} else {
html.closeAll();
html.open(htmlPaths.element("ol"));
- convertElements(document.footnotes, html, messages, function(error) {
+ var footnotes = footnoteIds.map(function(id) {
+ return document.footnotes.findFootnoteById(id);
+ });
+ convertElements(footnotes, html, messages, function(error) {
if (error) {
callback(error);
} else {
@@ -169,6 +174,7 @@ function DocumentConversion(options) {
"footnoteReference": function(element, html, messages, callback) {
html.open(htmlPaths.element("sup"));
html.open(htmlPaths.element("a", {href: "#footnote-" + element.footnoteId}));
+ footnoteIds.push(element.footnoteId);
html.text((footnoteNumber++).toString());
html.close();
html.close();