.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / postcss-sass / stringifier.js
1 var Stringifier = require('postcss/lib/stringifier');
2
3 var SassStringifier = function (builder) {
4     Stringifier.call(this, builder);
5 };
6
7 const DEFAULT_RAW = {
8     colon:        ': ',
9     commentLeft:  ' ',
10     commentRight: ' '
11 };
12
13 SassStringifier.prototype = Object.create(Stringifier.prototype);
14 SassStringifier.prototype.constructor = Stringifier;
15
16 SassStringifier.prototype.has = function has(value) {
17     return typeof value !== 'undefined';
18 };
19
20 SassStringifier.prototype.block = function (node, start) {
21     var between = node.raws.sssBetween || '';
22     this.builder(start + between, node, 'start');
23     if (this.has(node.nodes)) {
24         this.body(node);
25     }
26 };
27
28 SassStringifier.prototype.decl = function (node) {
29     var between = node.raws.between || DEFAULT_RAW.colon;
30     var string  = node.prop + between + this.rawValue(node, 'value');
31     if (node.important) {
32         string += '!important';
33     }
34     this.builder(string, node);
35 };
36
37 SassStringifier.prototype.comment = function (node) {
38     var left  = this.has(node.raws.left) ?
39         node.raws.left : DEFAULT_RAW.commentLeft;
40     var right = this.has(node.raws.right) ?
41         node.raws.right : DEFAULT_RAW.commentRight;
42
43     if (node.raws.commentType === 'single') {
44         this.builder('//' + left + node.text + right, node);
45     } else if (node.raws.commentType === 'multi') {
46         this.builder('/*' + left + node.text + right + '*/', node);
47     }
48 };
49
50
51 module.exports = SassStringifier;