.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / remark-stringify / lib / visitors / image.js
1 'use strict';
2
3 var uri = require('../util/enclose-uri');
4 var title = require('../util/enclose-title');
5
6 module.exports = image;
7
8 /* Stringify an image.
9  *
10  * Is smart about enclosing `url` (see `encloseURI()`) and
11  * `title` (see `encloseTitle()`).
12  *
13  *    ![foo](</fav icon.png> 'My "favourite" icon')
14  *
15  * Supports named entities in `url`, `alt`, and `title`
16  * when in `settings.encode` mode.
17  */
18 function image(node) {
19   var self = this;
20   var content = uri(self.encode(node.url || '', node));
21   var exit = self.enterLink();
22   var alt = self.encode(self.escape(node.alt || '', node));
23
24   exit();
25
26   if (node.title) {
27     content += ' ' + title(self.encode(node.title, node));
28   }
29
30   return '![' + alt + '](' + content + ')';
31 }