diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-07-07 21:27:53 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-07-07 21:27:53 +0100 |
| commit | c0a14c171f5bdfda6cb76b1589a43ada3b5768ce (patch) | |
| tree | 7055a83898f6af08a0a7239812ef1d5c52732716 /test | |
| parent | 1c439031d328a09bfb178b1182c09bb62d03782c (diff) | |
Add conversion of comments
Diffstat (limited to 'test')
| -rw-r--r-- | test/document-to-html.tests.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/document-to-html.tests.js b/test/document-to-html.tests.js index 436014f..af08050 100644 --- a/test/document-to-html.tests.js +++ b/test/document-to-html.tests.js @@ -486,7 +486,7 @@ test('footnotes are included after the main body', function() { }); test('comments are ignored by default', function() { - var reference = documents.commentReference("4"); + var reference = documents.commentReference({commentId: "4"}); var comment = documents.comment({ commentId: "4", body: [paragraphOfText("Who's there?")] @@ -503,7 +503,37 @@ test('comments are ignored by default', function() { assert.equal(result.value, '<p>Knock knock</p>'); assert.deepEqual(result.messages, []); }); +}); +test('comment references are linked to comment after main body', function() { + var reference = documents.commentReference({commentId: "4"}); + var comment = documents.comment({ + commentId: "4", + body: [paragraphOfText("Who's there?")], + authorName: "The Piemaker", + authorInitials: "TP" + }); + var document = documents.document([ + documents.paragraph([ + runOfText("Knock knock"), + documents.run([reference]) + ]) + ], {comments: [comment]}); + + var converter = new DocumentConverter({ + idPrefix: "doc-42-", + styleMap: [ + {from: documentMatchers.commentReference, to: htmlPaths.element("sup")} + ] + }); + return converter.convertToHtml(document).then(function(result) { + var expectedHtml = ( + '<p>Knock knock<sup><a href="#doc-42-comment-4" id="doc-42-comment-ref-4">[TP1]</a></sup></p>' + + '<dl><dt id="doc-42-comment-4">Comment [TP1]</dt><dd><p>Who\'s there? <a href="#doc-42-comment-ref-4">↑</a></p></dd></dl>' + ); + assert.equal(result.value, expectedHtml); + assert.deepEqual(result.messages, []); + }); }); test('images are written with data URIs', function() { |
