diff --git a/lib/revert.js b/lib/revert.js index 82b68ce..bbc606f 100644 --- a/lib/revert.js +++ b/lib/revert.js @@ -16,7 +16,7 @@ function revert(h, node) { if (subtype === 'collapsed') { suffix += '[]' } else if (subtype === 'full') { - suffix += '[' + node.identifier + ']' + suffix += '[' + (node.label || node.identifier) + ']' } if (node.type === 'imageReference') { diff --git a/test/image-reference.js b/test/image-reference.js index 89eb321..9eb5593 100644 --- a/test/image-reference.js +++ b/test/image-reference.js @@ -66,5 +66,18 @@ test('ImageReference', function(t) { 'should transform `imageReference`s to `img`s' ) + t.deepEqual( + to( + u('imageReference', { + identifier: 'tango', + label: 'Tango', + referenceType: 'full', + alt: 'uniform' + }) + ), + u('text', '![uniform][Tango]'), + 'should fall back on the label on a full `imageReference` (GH-22)' + ) + t.end() }) diff --git a/test/link-reference.js b/test/link-reference.js index 2118b8b..cb94e42 100644 --- a/test/link-reference.js +++ b/test/link-reference.js @@ -69,5 +69,18 @@ test('LinkReference', function(t) { 'should transform `linkReference`s to `a`s' ) + t.deepEqual( + to( + u('linkReference', { + identifier: 'oscar', + label: 'Oscar', + referenceType: 'full', + alt: 'papa' + }) + ), + u('text', '![papa][Oscar]'), + 'should fall back on the label on a full `linkReference` (GH-22)' + ) + t.end() })