How to use the css-tree.toPlainObject function in css-tree

To help you get started, we’ve selected a few css-tree 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 pocketjoso / penthouse / test / basic-tests.js View on Github external
.then(result => {
        const resultRules = csstree.toPlainObject(csstree.parse(result)).children
        const originalRules = csstree.toPlainObject(csstree.parse(originalCss)).children
        resultRules.should.have.length.lessThan(originalRules.length)
        // not be empty
      })
  })
github geosolutions-it / MapStore2 / web / client / utils / MarkerUtils.js View on Github external
const loadGlyphs = (font) => {
    const parsedCss = csstree.toPlainObject(csstree.parse(css[font]));
    return parsedCss.children.reduce((previous, rule) => {
        if (rule.prelude) {
            const classSelector = getNodeOfType(rule.prelude, (node) => node.type === 'ClassSelector');
            const pseudoClassSelector = getNodeOfType(rule.prelude, (node) => node.type === 'PseudoClassSelector');
            if (classSelector && classSelector.name && classSelector.name.indexOf('fa-') === 0 && pseudoClassSelector && pseudoClassSelector.name === 'before') {
                const text = getNodeOfType(getNodeOfType(rule.block, (node) => node.type === 'Declaration' && node.property === 'content').value, (node) => node.type === 'String').value;
                /* eslint-disable */
                return assign(previous, {
                    [classSelector.name.substring(3)]: eval("'\\u" + text.substring(2, text.length - 1) + "'")
                });
                /* eslint-enable */
            }
        }
        return previous;
    }, {});
};
github ElemeFE / page-skeleton-webpack-plugin / src / skeleton.js View on Github external
const stylesheetAstArray = styles.map((style) => {
      const ast = parse(style, {
        parseValue: false,
        parseRulePrelude: false
      })
      return toPlainObject(ast)
    })
github peterbe / minimalcss / hack.js View on Github external
response.text().then(text => {
        const ast = csstree.parse(text, { parseValue: false })
        const obj = csstree.toPlainObject(ast)
        stylesheetsContents[url] = obj
      })
    }
github ElemeFE / page-skeleton-webpack-plugin / src / skeleton.js View on Github external
response.text().then((text) => {
          const ast = parse(text, {
            parseValue: false,
            parseRulePrelude: false
          })
          stylesheetAstObjects[requestUrl] = toPlainObject(ast)
          stylesheetContents[requestUrl] = text
        })
      }
github wookaoer / page-skeleton-core / src / skeletonCore.js View on Github external
response.text().then((text) => {
                    const ast = parse(text, {
                        parseValue: false,
                        parseRulePrelude: false
                    });
                    stylesheetAstObjects[requestUrl] = toPlainObject(ast);
                    stylesheetContents[requestUrl] = text
                })
            }
github anthonydugois / fp-units / src / core / _ast.js View on Github external
const nodes: (s: string) => Object[] = str =>
  R.propOr([], 'children', toPlainObject(parse(str, { context: 'value' })))
github marktext / marktext / src / muya / lib / utils / exportStyledHTML.js View on Github external
styleSheets = styleSheets.map(style => {
      const ast = parse(style, {
        parseValue: false,
        parseRulePrelude: false
      })

      return toPlainObject(ast)
    })
    const cleanedStyles = styleSheets.map(ast => {
github wookaoer / page-skeleton-core / src / skeletonCore.js View on Github external
const stylesheetAstArray = styles.map((style) => {
            const ast = parse(style, {
                parseValue: false,
                parseRulePrelude: false
            });
            return toPlainObject(ast)
        });