definition.js 503 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var uri = require('../util/enclose-uri');
  3. var title = require('../util/enclose-title');
  4. module.exports = definition;
  5. /* Stringify an URL definition.
  6. *
  7. * Is smart about enclosing `url` (see `encloseURI()`) and
  8. * `title` (see `encloseTitle()`).
  9. *
  10. * [foo]: <foo at bar dot com> 'An "example" e-mail'
  11. */
  12. function definition(node) {
  13. var content = uri(node.url);
  14. if (node.title) {
  15. content += ' ' + title(node.title);
  16. }
  17. return '[' + node.identifier + ']: ' + content;
  18. }