Menu

Disable decimals for sizes when not needed.

daniels
2014-07-31
2014-07-31
  • daniels

    daniels - 2014-07-31

    I'm using jstyleparser to parse the CSS and the issue is that when i try to save to a file by using rule.toString() the sizes found in the rules (width, padding, etc.. anything with a number) are saved with a decimal.

    So for example if in the original CSS file width was 80px now when saving I get 80.0px

    Is there a way to have it leave the size as it is? As in display a decimal only if it exists in the original CSS file.

    Also is this the correct way to save a parsed CSS file, use toString() ?

    All I need is to load the CSS and split it in other files based on the IE 4095 selectors limit.

     
  • Radek Burget

    Radek Burget - 2014-07-31

    Generally, the toString() method is not inteded for saving the CSS back. It is not guaranteed that you obtain a syntactically correct ouptut in all cases. If you need a perfect output that corresponds to your needs, I recommed to go through the SytleSheet and the Rules and format the ouput yourself. The StyleSheet is basically a collection as described here:
    http://cssbox.sourceforge.net/jstyleparser/manual.php#sheet

    so it should be quite easy to go through it and do the same thing with the RuleSets.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.