source: imaps-frontend/node_modules/clean-css/lib/writer/simple.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[79a0317]1var all = require('./helpers').all;
2
3function store(serializeContext, token) {
4 var value = typeof token == 'string'
5 ? token
6 : token[1];
7 var wrap = serializeContext.wrap;
8
9 wrap(serializeContext, value);
10 track(serializeContext, value);
11 serializeContext.output.push(value);
12}
13
14function wrap(serializeContext, value) {
15 if (serializeContext.column + value.length > serializeContext.format.wrapAt) {
16 track(serializeContext, serializeContext.format.breakWith);
17 serializeContext.output.push(serializeContext.format.breakWith);
18 }
19}
20
21function track(serializeContext, value) {
22 var parts = value.split('\n');
23
24 serializeContext.line += parts.length - 1;
25 serializeContext.column = parts.length > 1 ? 0 : (serializeContext.column + parts.pop().length);
26}
27
28function serializeStyles(tokens, context) {
29 var serializeContext = {
30 column: 0,
31 format: context.options.format,
32 indentBy: 0,
33 indentWith: '',
34 line: 1,
35 output: [],
36 spaceAfterClosingBrace: context.options.compatibility.properties.spaceAfterClosingBrace,
37 store: store,
38 wrap: context.options.format.wrapAt
39 ? wrap
40 : function() { /* noop */ }
41 };
42
43 all(serializeContext, tokens);
44
45 return { styles: serializeContext.output.join('') };
46}
47
48module.exports = serializeStyles;
Note: See TracBrowser for help on using the repository browser.