UNPKG

stylelint-css-in-js-syntax

Version:

This plugin provides [ESLint](https://eslint.org/) rules that limit the line length of your comments. Furthermore, an **automatic fix** is included such that you can save time manually formatting your comments. As such it is recommended to apply this rule

22 lines (20 loc) 913 B
function restoreExpressions(rawCss) { const refs = rawCss.match(/\/\*refs (.*)\*\/$/)?.[1]?.split(";"); if (!refs) { throw new Error( "restoreExpressions(): Expected refs comment to be included in source" ); } return rawCss.replace(/ref-\d+:ignore((.|\s)*?)_;?/gm, (replaceable) => { const refIndex = Number(replaceable.match(/ref-(\d+)/)?.[1]); const base64js = refs[refIndex] ?? ""; const includeSemiColon = replaceable.trimEnd().endsWith(";"); return `\${${Buffer.from(base64js, "base64").toString("utf-8")}}${includeSemiColon ? ";" : ""}`; }).replace(/ref-\d+_((.|\s)*?)_/gm, (replaceable) => { const refIndex = Number(replaceable.match(/ref-(\d+)/)?.[1]); const base64js = refs[refIndex] ?? ""; return `\${${Buffer.from(base64js, "base64").toString("utf-8")}}`; }); } export { restoreExpressions }; //# sourceMappingURL=util.restore-expressions.mjs.map