This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/remark-stringify/lib/visitors/link-reference.js

28 lines
612 B
JavaScript
Raw Normal View History

'use strict'
var copy = require('../util/copy-identifier-encoding')
var label = require('../util/label')
module.exports = linkReference
var leftSquareBracket = '['
var rightSquareBracket = ']'
var shortcut = 'shortcut'
var collapsed = 'collapsed'
function linkReference(node) {
var self = this
var type = node.referenceType
var exit = self.enterLinkReference(self, node)
var value = self.all(node).join('')
exit()
if (type === shortcut || type === collapsed) {
value = copy(value, node.label || node.identifier)
}
return leftSquareBracket + value + rightSquareBracket + label(node)
}