From 1caa452c06f31f35ee5ad15f0e9dae97b928daa3 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 28 Mar 2016 12:50:16 +0100 Subject: Generated IDs no longer insert a hyphen after the ID prefix --- NEWS | 4 ++++ lib/document-to-html.js | 4 ++-- tests/document-to-html.tests.js | 8 ++++---- tests/mammoth.tests.js | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 7375048..a17c31c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +# 1.0.0 + +* Generated IDs no longer insert a hyphen after the ID prefix. + # 0.3.33 * Improve collapsing of elements when there are empty elements. diff --git a/lib/document-to-html.js b/lib/document-to-html.js index cb5ec16..96dc740 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -36,7 +36,7 @@ function DocumentConversion(options) { options = _.extend({ignoreEmptyParagraphs: true}, options); var idPrefix = options.idPrefix === undefined ? - Math.floor(Math.random() * 1000000000000000) : + Math.floor(Math.random() * 1000000000000000) + "-" : options.idPrefix; var defaultParagraphStyle = htmlPaths.topLevelElement("p"); @@ -195,7 +195,7 @@ function DocumentConversion(options) { } function htmlId(suffix) { - return idPrefix + "-" + suffix; + return idPrefix + suffix; } function convertTable(element, messages, callback) { diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 2b23613..fae4da5 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -346,7 +346,7 @@ describe('DocumentConverter', function() { {anchor: "_Peter"} ); var converter = new DocumentConverter({ - idPrefix: "doc-42" + idPrefix: "doc-42-" }); return converter.convertToHtml(hyperlink).then(function(result) { assert.equal(result.value, 'Hello.'); @@ -356,7 +356,7 @@ describe('DocumentConverter', function() { test('bookmarks are converted to anchors', function() { var bookmarkStart = new documents.BookmarkStart({name: "_Peter"}); var converter = new DocumentConverter({ - idPrefix: "doc-42" + idPrefix: "doc-42-" }); var document = new documents.Document([bookmarkStart]); return converter.convertToHtml(document).then(function(result) { @@ -426,7 +426,7 @@ describe('DocumentConverter', function() { noteId: "4" }); var converter = new DocumentConverter({ - idPrefix: "doc-42" + idPrefix: "doc-42-" }); return converter.convertToHtml(footnoteReference).then(function(result) { assert.equal(result.value, '[1]'); @@ -455,7 +455,7 @@ describe('DocumentConverter', function() { ); var converter = new DocumentConverter({ - idPrefix: "doc-42" + idPrefix: "doc-42-" }); return converter.convertToHtml(document).then(function(result) { var expectedOutput = '

Knock knock[1]

' + diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 34adb09..0f0ad53 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -226,7 +226,7 @@ describe('mammoth', function() { // TODO: don't duplicate footnotes with multiple references var docxPath = path.join(__dirname, "test-data/footnotes.docx"); var options = { - idPrefix: "doc-42" + idPrefix: "doc-42-" }; return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { var expectedOutput = '

Ouch' + @@ -242,7 +242,7 @@ describe('mammoth', function() { test('endnotes are appended to text', function() { var docxPath = path.join(__dirname, "test-data/endnotes.docx"); var options = { - idPrefix: "doc-42" + idPrefix: "doc-42-" }; return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { var expectedOutput = '

Ouch' + @@ -258,7 +258,7 @@ describe('mammoth', function() { test('relationships are handled properly in footnotes', function() { var docxPath = path.join(__dirname, "test-data/footnote-hyperlink.docx"); var options = { - idPrefix: "doc-42" + idPrefix: "doc-42-" }; return mammoth.convertToHtml({path: docxPath}, options).then(function(result) { var expectedOutput = -- cgit v1.2.3