summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-02-09 20:55:09 +0000
committerMichael Williamson <mike@zwobble.org>2015-02-09 20:55:09 +0000
commitf4d64b66a06b6faf8e5f604c069e1bff3185d4e7 (patch)
tree080aa88f4a6a3624003cc894b8f8ee39b0c5ce3e
parentfbd5458c9c0e1435406bdfc1fe0927db3076e5f2 (diff)
Move bookmark handling next to hyperlink handling
-rw-r--r--lib/document-to-html.js14
-rw-r--r--tests/document-to-html.tests.js22
2 files changed, 18 insertions, 18 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index 8a6e080..e9d35b9 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -250,6 +250,13 @@ function DocumentConversion(options) {
}
});
},
+ "bookmarkStart": function(element, html, messages, callback) {
+ html.open(htmlPaths.element("a", {
+ id: htmlId(element.name)
+ }), {alwaysWrite: true});
+ html.close();
+ callback();
+ },
"noteReference": function(element, html, messages, callback) {
html.open(htmlPaths.element("sup"));
html.open(htmlPaths.element("a", {
@@ -286,13 +293,6 @@ function DocumentConversion(options) {
"lineBreak": function(element, html, messages, callback) {
html.selfClosing(htmlPaths.element("br"));
callback();
- },
- "bookmarkStart": function(element, html, messages, callback) {
- html.open(htmlPaths.element("a", {
- id: htmlId(element.name)
- }), {alwaysWrite: true});
- html.close();
- callback();
}
};
return {
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js
index 18c9f75..41b8129 100644
--- a/tests/document-to-html.tests.js
+++ b/tests/document-to-html.tests.js
@@ -253,6 +253,17 @@ describe('DocumentConverter', function() {
});
});
+ test('bookmarks are converted to anchors', function() {
+ var bookmarkStart = new documents.BookmarkStart({name: "_Peter"});
+ var converter = new DocumentConverter({
+ idPrefix: "doc-42"
+ });
+ var document = new documents.Document([bookmarkStart]);
+ return converter.convertToHtml(document).then(function(result) {
+ assert.equal(result.value, '<a id="doc-42-_Peter"></a>');
+ });
+ });
+
test('docx tab is converted to tab in HTML', function() {
var tab = new documents.Tab();
var converter = new DocumentConverter();
@@ -418,17 +429,6 @@ describe('DocumentConverter', function() {
assert.equal(result.value.indexOf("<p>Hello.</p>"), 0);
});
});
-
- test('bookmarks are converted to anchors', function() {
- var bookmarkStart = new documents.BookmarkStart({name: "_Peter"});
- var converter = new DocumentConverter({
- idPrefix: "doc-42"
- });
- var document = new documents.Document([bookmarkStart]);
- return converter.convertToHtml(document).then(function(result) {
- assert.equal(result.value, '<a id="doc-42-_Peter"></a>');
- });
- });
});
function paragraphOfText(text, styleId, styleName) {