How to use postcss-safe-parser - 7 common examples

To help you get started, we’ve selected a few postcss-safe-parser 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 ktsn / vue-designer / tests / parser / style / modify.spec.ts View on Github external
function parse(code: string): STStyle[] {
    return [transformStyle(_parse(code), code, 0)]
  }
github ktsn / vue-designer / tests / parser / style / scoped.spec.ts View on Github external
function getAst(code: string) {
  const root = parse(code)
  return transformStyle(root, code, 0)
}
github ktsn / vue-designer / tests / parser / style / transform.spec.ts View on Github external
function getAst(code: string): STStyle {
  const root = parse(code)
  return transformStyle(root, code, 0)
}
github sbekrin / styled-email-components / src / inline-mail-style.js View on Github external
generateStyleObject(executionContext) {
      const flatStyles = flatten(this.rules, executionContext).join('');
      const hash = createHash(flatStyles);
      if (!generated[hash]) {
        const rules = [];
        parse(flatStyles).each(node => {
          switch (node.type) {
            case 'decl':
              rules.push([node.prop, node.value]);
              return;
            case 'comment':
              return;
            default:
              if (process.env.NODE_ENV !== 'production') {
                console.warn(
                  `Node of type ${node.type} not supported as an inline style`,
                );
              }
          }
        });
        const styles = cssToStyle(rules);
        const instance = stylesheet.create({ generated: styles });
github springload / metatemplate / src / style.ts View on Github external
cssProperty(node.prop, node.value, cssVariables, node.important) +
          ";";
        break;
      }

      default: {
        throw Error(
          `MetaTemplate: Unrecognised CSS node type "${
            node.type
          }". Please contribute your CSS as a test case to the project.`
        );
      }
    }
    return response;
  };
  const cssNodes = [...cssParser(cssString).nodes];
  return cssNodes.map(node => renderCSS(node)).join("\n");
};
github springload / metatemplate / src / template-formats / react-ts-styled-components / template.react-ts-styled-components.ts View on Github external
.map(node => node.trim())
            .join(";\n") + ";\n";
      }

      if (isDynamic) {
        css += "`}\n";
      }

      if (isWrapped) {
        css += "}\n";
      }

      return css.trim();
    };

    const cssNodes = [...cssParser(cssString).nodes];
    let css = cssNodes.map(node => renderCSS(node)).join("\n");

    return {
      scBody: css,
      usedProps: uniq(usedProps)
    };
  };
github ktsn / vue-designer / src / parser / vue-file.ts View on Github external
const styleAsts = styles.map((s, i) => {
    return transformStyle(postcssParse(s.content), s.content, i)
  })

postcss-safe-parser

Fault-tolerant CSS parser for PostCSS

MIT
Latest version published 3 months ago

Package Health Score

80 / 100
Full package analysis

Popular postcss-safe-parser functions