cminify
cminify copied to clipboard
Doesn't care about whitespace inside string literals
"a: %d %d %d\n"
becomes
"a:%d%d%d\n"
oops.
It is intended that string literals stay untouched.
I followed this bug into the function minify_operator(op)
.
There is the regex / *{} */
used (where {} in the regex was replaced with one of the elements of OPS) to strip down spaces around operators.
The problem is that every occurrence of that is replaced regardless of its context (inside or outside of a string literal).
It may be possible to extend this regex. In my opinion it would be easier no to use a regex and additionally process the whole file at once instead the lines one after the other (iterating over an array). Think of this code snippet:
"hello \
world\
&"
If a regex is used it would required to count the number of occurrences " or test, if the last character of a line is backslash in order to know if the context is a string literal.
I'm contributing hereby some knowledge, but my Python skills not good enough to rewrite the broken function.
I apologize for my English and some phrases that could be expressed better. I hope you get the point. :-)
I think it wouldn't be too hard extending the regex to exclude everything between a potential couple of quotes (") that aren't in a comment but I won't have time to look into that before some weeks at least.
Still it's an important bug to fix.
so no fix there?
Hello, sorry, I'm being overworked with other research projects right now but I am aware of all the issues with this project. I'll try to focus on the minifier for a week or two this summer to address all these problems. But these days I can't just yet. :-(
Cheers
Waiting for you...