postcss / postcss-safe-parser

Fault tolerant CSS parser for PostCSS
MIT License
120 stars 12 forks source link

Handle more css errors #1

Closed pocketjoso closed 8 years ago

pocketjoso commented 9 years ago

Hi there, Penthouse needs a fault tolerant css parser, and I thought postcss-safe-parser might do the job. Basically I want the returned css to be the same as what a browser would give you (because I hand it over to an AST parser that isn't fault tolerant). Is this out of scope for this project, or something you would consider?

I'm still setting up my own tests for error handling required, but as an example:

// missing selector
__input: '.one {color:red} {color:yellow} .two {color:green}'
__ safe: '.one {color:red} {color:yellow} .two {color:green}'
browser: '.one {color:red} .two {color:green}'

There are more cases like this obviously, that I can add in if it becomes relevant.

If this is out of scope for this project, if you have any ideas for where I should go to look for a fault tolerant css parser please let me know.

Cheers

ai commented 9 years ago

Safe Parser goal is try to save origin file as close as possible.

But, you task is interesting too. I think, the best way is to write a PostCSS plugin, which will normalize AST from Safe Parser to way how it will be processed in browser.

What do you think?