browser: support new caniuse data
[sheet.git] / tools / convert-caniuse.pl
index 7006b18f99b371dbaef57005a524e6c6da214b11..467b9ba7b5405cdfc37304638332ea1960c89260 100755 (executable)
@@ -12,14 +12,14 @@ my $source = readline;
 
 for ($source) { # cleanup
        # convert seperate variables to hash keys
-       s/\A/{/;
-       s/^caniuse\.(\w+) /"$1":/gm;
+       s/\A/{\n/;
+       s/^caniuse\.(\w+) *= */"$1":/gm;
        s/;$/,/gm;
        s/,\s*\Z/\n}/;
        # fractions not supported by barekey
-       s/(?<=[,{]) (\d*\.\d) (?=:')/"$1"/gx;
+       s/(?<=[,{\n]) (\d*\.\d) (?=:['"])/"$1"/gx;
        # escapes not supported in singlequote
-       s{'((?:[^\\']+|\\.)*)'}{
+       s{: *\K'((?:[^\\']+|\\.)*)'}{
                my $_ = $1;
                s/"/\\"/g;
                s/\\'/'/g;