Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.
Close

#50 CssParser not work with css comments

0.9.15
closed
RBRi
None
1
2015-01-02
2014-07-08
No

.a {*color:red;text-align:center;}

1 Attachments

Discussion

  • RBRi

    RBRi - 2014-07-08

    Hi Ivan,

    did some tests but i can't see your problem.
    Please provide more details.

    • which parser do you use
    • your complete input
    • the expected result
     
  • Ivan Di Francesco

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,10 @@
    -Example: p {color:red;/*text-align:center;}
    +<html>
    +<style>
    +.a {*color:red;text-align:center;}
    +.b {color:red;text-align:center;}
    +</style>
    +
    +<p class="a">TEST</p>
    +<p class="b">TEST1</p>
    +
    +</html>
    
     
  • Ivan Di Francesco

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,7 +4,7 @@
     .b {color:red;text-align:center;}
     </style>
    
    -<p class="a">TEST</p>
    -<p class="b">TEST1</p>
    +< p class="a">TEST</p>
    +< p class="b">TEST1</p>
    
     </html>
    
     
  • Ivan Di Francesco

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,10 +1 @@
    -<html>
    -<style>
     .a {*color:red;text-align:center;}
    -.b {color:red;text-align:center;}
    -</style>
    -
    -< p class="a">TEST</p>
    -< p class="b">TEST1</p>
    -
    -</html>
    
     
  • Ivan Di Francesco

    I update description and attach file with complete test.
    I'm using cssparser 0.914, this is the method I use to parse the css:

    CSSOMParser parser = new CSSOMParser();
    InputSource is = getCssInputSourceForStyleSheet(cssText,scriptURI);
    is.setURI(scriptURI);
    CSSStyleSheetImpl sheet = (CSSStyleSheetImpl) parser.parseStyleSheet(is, null, null);
    sheet.setHref(scriptURI);
    sheet.setOwnerNode(ownerNode);

    Expected Result:
    TEST black, center-aligned
    TEST1 color red, center-aligned

    When processing css .a {color:red;text-align:center;} with parser.parseStyleSheet i have this error:
    Error in style rule. (Invalid token "
    ". Was expecting one of: <EOF>, <S>, <IDENT>, "}", ";".)

    Sorry for my bad english...

     
  • RBRi

    RBRi - 2014-07-09

    Hi Ivan,

    first of all, the error you got is correct. '*color' is not a valid identifier. You can proof that with your sample. The browser also ignores the color rule.
    Outside of that, CSSParser seems to be a bit too aggressive. The parser skips to the end of the rule instead of skipping to the next semicolon like the browser does.
    Will address this issue. But please do not expect some update in the next two weeks. There is too mutch serious work to do at the moment.

    RBRi
    
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous

    Anonymous - 2015-01-01

    Hi Ivan,

    sorry for the long silence. Because of the current structure of the parser, is was not that easy to handle this a bit smarter. Finally i made a fix (it's more a hack but it does the job).
    A new snapshot build will be available shortly. If you do not use maven, you can download the snapshot here: https://wetator.ci.cloudbees.com/

    Thanks for the report and enjoy using CSSParser.

     
  • RBRi

    RBRi - 2015-01-01
    • status: open --> closed
    • assigned_to: RBRi
     
  • Ivan Di Francesco

    Thanks, the fix work!!!

     

Anonymous
Anonymous

Cancel  Add attachments