How to use the css.stringify function in css

To help you get started, we’ve selected a few css examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / generate-github-markdown-css / index.js View on Github external
[].push.apply(mdBodyProps, el.declarations);
				return false;
			}
		}

		return el.declarations && el.declarations.length !== 0;
	});

	// Merge `.markdown-body` rules
	style.stylesheet.rules.unshift({
		type: 'rule',
		selectors: ['.markdown-body'],
		declarations: mdBodyProps
	});

	return css.stringify(style);
};
github yanglin5689446 / linbox / src / components / Mail / Message.js View on Github external
stylesheets.forEach((stylesheet) => {
    try {
      const css = cssParser.parse(stylesheet.innerText)
      Object.values(css.stylesheet.rules)
        .forEach((rule) => {
          if (rule.type === 'rule') {
            rule.selectors = stripAndAddScope(rule.selectors) // eslint-disable-line
          } else if (rule.type === 'media') {
            rule.rules.forEach((r) => {
              r.selectors = stripAndAddScope(r.selectors)  // eslint-disable-line
            })
          }
        })
      stylesheet.innerText = cssParser.stringify(css, { compress: true })  // eslint-disable-line
    } catch (e) {
      stylesheet.innerText = ''  // eslint-disable-line
    }
  })
github SAP / less-openui5 / lib / index.js View on Github external
const sScopeSelector = "." + sScopeName;
				const oScope = scope(oDiff.diff, sScopeSelector);

				let oCssScopeRoot;

				if (oDiff.stack) {
					oCssScopeRoot = scope.scopeCssRoot(oDiff.stack.stylesheet.rules, sScopeName);

					if (oCssScopeRoot) {
						oScope.stylesheet.rules.unshift(oCssScopeRoot);
					}
				}

				// Append scope + stack to embeddedCompareFile (actually target file, which is currently always the same i.e. "library.css")
				// The stack gets appended to the embeddedFile only
				let sAppend = css.stringify(oScope, {
					compress: options.compiler && options.compiler.compress === true
				});

				if (scopeOptions.baseFilePath !== options.lessInputPath && oDiff.stack && oDiff.stack.stylesheet.rules.length > 0) {
					sAppend += "\n" + css.stringify(oDiff.stack, {
						compress: options.compiler && options.compiler.compress === true
					});
				}

				return sAppend + "\n";
			}
github CaMnter / applets-conversion-cli / test / css / replace-import.ts View on Github external
it('replace import「double quotes」', () => {
    const code = '@import \"./sign/save.wxss\";\n';
    const stylesheet = parse(code, {});
    replaceImport(CssType.wxss, CssType.acss, stylesheet);
    const result = stringify(stylesheet, { indent: '  ' });
    expect(result).to.equal('@import "./sign/save.acss";');
  })
github commercetools / merchant-center-application-kit / tokens / generate-base-colors.js View on Github external
type: 'rule',
        selectors: [':root'],
        declarations: [commentTitle, ...declarationsBody],
      },
    ],
    parsingErrors: [],
  },
};

fs.writeFileSync(
  path.join(
    __dirname,
    '../../../',
    'packages-shared/ui-kit/materials/colors/colors.mod.css'
  ),
  css.stringify(AST),
  'utf-8'
);
github mixi-inc / css-semdiff / src / bin / css-astdiff.ts View on Github external
    .map((styleSheet) => css.stringify(styleSheet))
    .map((cssString) => `${msg}:\n${indent(cssString)}`)
github bevacqua / cave / src / cave.js View on Github external
function result () {
    return css.stringify(sheet) + '\n';
  }
}
github twitter-archive / css-flip / lib / css-flip.js View on Github external
function flip(str, options) {
  var ast = css.parse(str, options);

  flipNode(ast.stylesheet);

  return css.stringify(ast, options);
}
github ForbesLindesay / code-mirror / build.js View on Github external
function readCSS(path) {
  return css.stringify(css.parse(read(path)), { compress: true });
}
function write(path, src) {
github jhamlet / svg-react-loader / lib / sanitize / filters / prefix-style-class-id.js View on Github external
rule.selectors =
                selectors.
                map(function (sel) {
                    return sel.
                        replace(
                            CLASSNAME_OR_ID_SELECTOR_REGEX,
                            function (match, pre, post) {
                                var newname = pre + opts.prefix + post;
                                opts.cache[post] = newname;
                                return newname;
                            }
                        );
                });
        });

    return css.stringify(ast, { compress: true });
}