| 56 | } |
| 57 | |
| 58 | beforeAfter(node, detect) { |
| 59 | let value |
| 60 | if (node.type === 'decl') { |
| 61 | value = this.raw(node, null, 'beforeDecl') |
| 62 | } else if (node.type === 'comment') { |
| 63 | value = this.raw(node, null, 'beforeComment') |
| 64 | } else if (detect === 'before') { |
| 65 | value = this.raw(node, null, 'beforeRule') |
| 66 | } else { |
| 67 | value = this.raw(node, null, 'beforeClose') |
| 68 | } |
| 69 | |
| 70 | let buf = node.parent |
| 71 | let depth = 0 |
| 72 | while (buf && buf.type !== 'root') { |
| 73 | depth += 1 |
| 74 | buf = buf.parent |
| 75 | } |
| 76 | |
| 77 | if (value.includes('\n')) { |
| 78 | let indent = this.raw(node, null, 'indent') |
| 79 | if (indent.length) { |
| 80 | for (let step = 0; step < depth; step++) value += indent |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | return value |
| 85 | } |
| 86 | |
| 87 | block(node, start) { |
| 88 | let between = this.raw(node, 'between', 'beforeOpen') |