CSS parser for JavaScript?

后端 未结 7 1094
既然无缘
既然无缘 2020-12-13 19:45

Update 2018: This question was asked long before PostCSS existed, and I would have probably used that.

I\'d like to par

7条回答
  •  旧时难觅i
    2020-12-13 20:13

    Here is our open source CSS parser css.js

    Here is a simple parsing example :

    
    

    To stringify parsed data structure into CSS string after editing

    var newCSSString = parser.getCSSForEditor(parsed);
    

    Main features of our CSS parser is :

    • It is lightweight.
    • It outputs easy to understand javascript object. No complex AST.
    • It is battle tested(and unit tested also) and constantly used in our products(JotForm Form Designer).
    • It supports media queries, keyframes and font-face rules.
    • It preserves comments while parsing.

提交回复
热议问题