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/definition.js
2020-11-01 22:46:04 +00:00

37 lines
692 B
JavaScript

'use strict'
var uri = require('../util/enclose-uri')
var title = require('../util/enclose-title')
module.exports = definition
var space = ' '
var colon = ':'
var leftSquareBracket = '['
var rightSquareBracket = ']'
// Stringify an URL definition.
//
// Is smart about enclosing `url` (see `encloseURI()`) and `title` (see
// `encloseTitle()`).
//
// ```markdown
// [foo]: <foo at bar dot com> 'An "example" e-mail'
// ```
function definition(node) {
var content = uri(node.url)
if (node.title) {
content += space + title(node.title)
}
return (
leftSquareBracket +
(node.label || node.identifier) +
rightSquareBracket +
colon +
space +
content
)
}