Open myearwood opened 10 years ago
to avoid this bug, add a line break after every closing bracket before passing the CSS into the parser. This can be done using the strings library.
import "strings"
myCSS = strings.Replace(myCSS,";",";\n",-1)
myCSS = strings.Replace(myCSS,"}","}\n",-1)
//pass myCSS into the parser
The tokenizer seems to work for pretty printed CSS, but it has trouble picking up closing brackets for CSS without line breaks. Because it does not identify the line breaks, it produces a string token with lots of CSS insider of it. All that CSS is inaccessible.
Implications of this bug
Much of the CSS found in the wild has removed line breaks to save space. This bug prevents much of the CSS found on the web from being parsed properly.
Steps to reproduce
the following valid CSS parses correctly when pretty printed, and incorrectly when it is not pretty printed. Inspect the tokens produced for the pretty printed version and the non- pretty printed version.