From 055afaf799aae9bd32c08424bfd704993f94eba7 Mon Sep 17 00:00:00 2001 From: Bob Pritchett Date: Sun, 7 Dec 2025 12:20:02 -0700 Subject: [PATCH 1/4] feat: enhance CSS parsing and unit handling - Added support for additional CSS escape sequences (b, f, j, q, v, w, y) in parse-css.pegjs. - Updated Length type in style.ts to include new units (cm, mm, Q, in, pc, pt, px, em). - Refactored resolveEm function to resolveUnit for better unit conversion handling. - Improved unit conversion logic for various length units in resolveUnit function. - Added VSCode launch configuration for debugging Vite applications in Chrome and Edge. - Created VSCode settings to disable format on save and Prettier. --- .vscode/launch.json | 36 + .vscode/settings.json | 4 + package-lock.json | 37 +- package.json | 2 +- src/parse-css.js | 1594 ++++++++++++++++++++++++++++++++--------- src/parse-css.pegjs | 44 +- src/style.ts | 30 +- 7 files changed, 1353 insertions(+), 394 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..872135d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Vite App (Chrome)", + "type": "chrome", + "request": "launch", + "url": "http://localhost:5173", // Change if your Vite/port is different (e.g., for playground script) + "webRoot": "${workspaceFolder}/src", // <-- This line goes here (or "${workspaceFolder}" if your entry files are at root) + "sourceMaps": true, + "skipFiles": [ + "/**" + ], + "sourceMapPathOverrides": { // <-- This entire block goes here + "vite://*": "${webRoot}/*" + } + }, + { + "name": "Debug Vite App (Edge)", + "type": "msedge", + "request": "launch", + "url": "http://localhost:5173", + "webRoot": "${workspaceFolder}/src", + "sourceMaps": true, + "skipFiles": [ + "/**" + ], + "sourceMapPathOverrides": { + "vite://*": "${webRoot}/*" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..884fa76 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.formatOnSave": false, + "prettier.enable": false +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d83157d..6c39b93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dropflow", - "version": "0.5.1", + "version": "0.6.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dropflow", - "version": "0.5.1", + "version": "0.6.1", "license": "MIT", "devDependencies": { "@codemirror/lang-html": "^6.4.8", @@ -23,7 +23,7 @@ "peggy": "^2.0.1", "punycode": "^2.1.1", "typescript": "^5.8.3", - "vite": "^7.0.6" + "vite": "^7.2.6" } }, "node_modules/@codemirror/autocomplete": { @@ -1532,11 +1532,14 @@ } }, "node_modules/fdir": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz", - "integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", "dev": true, "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, "peerDependencies": { "picomatch": "^3 || ^4" }, @@ -2579,14 +2582,14 @@ } }, "node_modules/tinyglobby": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", - "integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==", + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", "dev": true, "license": "MIT", "dependencies": { - "fdir": "^6.4.4", - "picomatch": "^4.0.2" + "fdir": "^6.5.0", + "picomatch": "^4.0.3" }, "engines": { "node": ">=12.0.0" @@ -2650,18 +2653,18 @@ "license": "MIT" }, "node_modules/vite": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.0.6.tgz", - "integrity": "sha512-MHFiOENNBd+Bd9uvc8GEsIzdkn1JxMmEeYX35tI3fv0sJBUTfW5tQsoaOwuY4KhBI09A3dUJ/DXf2yxPVPUceg==", + "version": "7.2.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.6.tgz", + "integrity": "sha512-tI2l/nFHC5rLh7+5+o7QjKjSR04ivXDF4jcgV0f/bTQ+OJiITy5S6gaynVsEM+7RqzufMnVbIon6Sr5x1SDYaQ==", "dev": true, "license": "MIT", "dependencies": { "esbuild": "^0.25.0", - "fdir": "^6.4.6", + "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", - "rollup": "^4.40.0", - "tinyglobby": "^0.2.14" + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" }, "bin": { "vite": "bin/vite.js" diff --git a/package.json b/package.json index 3439aff..c86c589 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "peggy": "^2.0.1", "punycode": "^2.1.1", "typescript": "^5.8.3", - "vite": "^7.0.6" + "vite": "^7.2.6" }, "name": "dropflow", "version": "0.6.1", diff --git a/src/parse-css.js b/src/parse-css.js index d701c5c..a178119 100644 --- a/src/parse-css.js +++ b/src/parse-css.js @@ -431,39 +431,53 @@ function peg$parse(input, options) { var peg$c175 = "\f"; var peg$c176 = "a"; var peg$c177 = "0"; - var peg$c178 = "c"; - var peg$c179 = "d"; - var peg$c180 = "g"; - var peg$c181 = "\\g"; - var peg$c182 = "h"; - var peg$c183 = "\\h"; - var peg$c184 = "i"; - var peg$c185 = "\\i"; - var peg$c186 = "k"; - var peg$c187 = "\\k"; - var peg$c188 = "l"; - var peg$c189 = "\\l"; - var peg$c190 = "m"; - var peg$c191 = "\\m"; - var peg$c192 = "n"; - var peg$c193 = "\\n"; - var peg$c194 = "o"; - var peg$c195 = "\\o"; - var peg$c196 = "p"; - var peg$c197 = "\\p"; - var peg$c198 = "r"; - var peg$c199 = "\\r"; - var peg$c200 = "s"; - var peg$c201 = "\\s"; - var peg$c202 = "t"; - var peg$c203 = "\\t"; - var peg$c204 = "u"; - var peg$c205 = "\\u"; - var peg$c206 = "x"; - var peg$c207 = "\\x"; - var peg$c208 = "z"; - var peg$c209 = "\\z"; - var peg$c210 = "("; + var peg$c178 = "b"; + var peg$c179 = "\\b"; + var peg$c180 = "c"; + var peg$c181 = "d"; + var peg$c182 = "f"; + var peg$c183 = "\\f"; + var peg$c184 = "g"; + var peg$c185 = "\\g"; + var peg$c186 = "h"; + var peg$c187 = "\\h"; + var peg$c188 = "i"; + var peg$c189 = "\\i"; + var peg$c190 = "j"; + var peg$c191 = "\\j"; + var peg$c192 = "k"; + var peg$c193 = "\\k"; + var peg$c194 = "l"; + var peg$c195 = "\\l"; + var peg$c196 = "m"; + var peg$c197 = "\\m"; + var peg$c198 = "n"; + var peg$c199 = "\\n"; + var peg$c200 = "o"; + var peg$c201 = "\\o"; + var peg$c202 = "p"; + var peg$c203 = "\\p"; + var peg$c204 = "q"; + var peg$c205 = "\\q"; + var peg$c206 = "r"; + var peg$c207 = "\\r"; + var peg$c208 = "s"; + var peg$c209 = "\\s"; + var peg$c210 = "t"; + var peg$c211 = "\\t"; + var peg$c212 = "u"; + var peg$c213 = "\\u"; + var peg$c214 = "v"; + var peg$c215 = "\\v"; + var peg$c216 = "w"; + var peg$c217 = "\\w"; + var peg$c218 = "x"; + var peg$c219 = "\\x"; + var peg$c220 = "y"; + var peg$c221 = "\\y"; + var peg$c222 = "z"; + var peg$c223 = "\\z"; + var peg$c224 = "("; var peg$r0 = /^[0-9]/; var peg$r1 = /^[0-4]/; @@ -483,24 +497,31 @@ function peg$parse(input, options) { var peg$r15 = /^[+\-]/; var peg$r16 = /^[!#$%&*-[\]-~]/; var peg$r17 = /^[Aa]/; - var peg$r18 = /^[Cc]/; - var peg$r19 = /^[Dd]/; - var peg$r20 = /^[Ee]/; - var peg$r21 = /^[Gg]/; - var peg$r22 = /^[Hh]/; - var peg$r23 = /^[Ii]/; - var peg$r24 = /^[Kk]/; - var peg$r25 = /^[Ll]/; - var peg$r26 = /^[Mm]/; - var peg$r27 = /^[Nn]/; - var peg$r28 = /^[Oo]/; - var peg$r29 = /^[Pp]/; - var peg$r30 = /^[Rr]/; - var peg$r31 = /^[Ss]/; - var peg$r32 = /^[Tt]/; - var peg$r33 = /^[Uu]/; - var peg$r34 = /^[Xx]/; - var peg$r35 = /^[Zz]/; + var peg$r18 = /^[Bb]/; + var peg$r19 = /^[Cc]/; + var peg$r20 = /^[Dd]/; + var peg$r21 = /^[Ee]/; + var peg$r22 = /^[Ff]/; + var peg$r23 = /^[Gg]/; + var peg$r24 = /^[Hh]/; + var peg$r25 = /^[Ii]/; + var peg$r26 = /^[Jj]/; + var peg$r27 = /^[Kk]/; + var peg$r28 = /^[Ll]/; + var peg$r29 = /^[Mm]/; + var peg$r30 = /^[Nn]/; + var peg$r31 = /^[Oo]/; + var peg$r32 = /^[Pp]/; + var peg$r33 = /^[Qq]/; + var peg$r34 = /^[Rr]/; + var peg$r35 = /^[Ss]/; + var peg$r36 = /^[Tt]/; + var peg$r37 = /^[Uu]/; + var peg$r38 = /^[Vv]/; + var peg$r39 = /^[Ww]/; + var peg$r40 = /^[Xx]/; + var peg$r41 = /^[Yy]/; + var peg$r42 = /^[Zz]/; var peg$e0 = peg$literalExpectation(";", false); var peg$e1 = peg$literalExpectation(":", false); @@ -702,71 +723,92 @@ function peg$parse(input, options) { var peg$e197 = peg$literalExpectation("a", true); var peg$e198 = peg$literalExpectation("0", false); var peg$e199 = peg$classExpectation(["A", "a"], false, false); - var peg$e200 = peg$literalExpectation("c", true); - var peg$e201 = peg$classExpectation(["C", "c"], false, false); - var peg$e202 = peg$literalExpectation("d", true); - var peg$e203 = peg$classExpectation(["D", "d"], false, false); - var peg$e204 = peg$literalExpectation("e", true); - var peg$e205 = peg$classExpectation(["E", "e"], false, false); - var peg$e206 = peg$literalExpectation("g", true); - var peg$e207 = peg$classExpectation(["G", "g"], false, false); - var peg$e208 = peg$literalExpectation("\\g", true); - var peg$e209 = peg$literalExpectation("h", true); - var peg$e210 = peg$classExpectation(["H", "h"], false, false); - var peg$e211 = peg$literalExpectation("\\h", true); - var peg$e212 = peg$literalExpectation("i", true); - var peg$e213 = peg$classExpectation(["I", "i"], false, false); - var peg$e214 = peg$literalExpectation("\\i", true); - var peg$e215 = peg$literalExpectation("k", true); - var peg$e216 = peg$classExpectation(["K", "k"], false, false); - var peg$e217 = peg$literalExpectation("\\k", true); - var peg$e218 = peg$literalExpectation("l", true); - var peg$e219 = peg$classExpectation(["L", "l"], false, false); - var peg$e220 = peg$literalExpectation("\\l", true); - var peg$e221 = peg$literalExpectation("m", true); - var peg$e222 = peg$classExpectation(["M", "m"], false, false); - var peg$e223 = peg$literalExpectation("\\m", true); - var peg$e224 = peg$literalExpectation("n", true); - var peg$e225 = peg$classExpectation(["N", "n"], false, false); - var peg$e226 = peg$literalExpectation("\\n", true); - var peg$e227 = peg$literalExpectation("o", true); - var peg$e228 = peg$classExpectation(["O", "o"], false, false); - var peg$e229 = peg$literalExpectation("\\o", true); - var peg$e230 = peg$literalExpectation("p", true); - var peg$e231 = peg$classExpectation(["P", "p"], false, false); - var peg$e232 = peg$literalExpectation("\\p", true); - var peg$e233 = peg$literalExpectation("r", true); - var peg$e234 = peg$classExpectation(["R", "r"], false, false); - var peg$e235 = peg$literalExpectation("\\r", true); - var peg$e236 = peg$literalExpectation("s", true); - var peg$e237 = peg$classExpectation(["S", "s"], false, false); - var peg$e238 = peg$literalExpectation("\\s", true); - var peg$e239 = peg$literalExpectation("t", true); - var peg$e240 = peg$classExpectation(["T", "t"], false, false); - var peg$e241 = peg$literalExpectation("\\t", true); - var peg$e242 = peg$literalExpectation("u", true); - var peg$e243 = peg$classExpectation(["U", "u"], false, false); - var peg$e244 = peg$literalExpectation("\\u", true); - var peg$e245 = peg$literalExpectation("x", true); - var peg$e246 = peg$classExpectation(["X", "x"], false, false); - var peg$e247 = peg$literalExpectation("\\x", true); - var peg$e248 = peg$literalExpectation("z", true); - var peg$e249 = peg$classExpectation(["Z", "z"], false, false); - var peg$e250 = peg$literalExpectation("\\z", true); - var peg$e251 = peg$otherExpectation("whitespace"); - var peg$e252 = peg$otherExpectation("string"); - var peg$e253 = peg$otherExpectation("identifier"); - var peg$e254 = peg$otherExpectation("hash"); - var peg$e255 = peg$otherExpectation("length"); - var peg$e256 = peg$otherExpectation("angle"); - var peg$e257 = peg$otherExpectation("time"); - var peg$e258 = peg$otherExpectation("frequency"); - var peg$e259 = peg$otherExpectation("percentage"); - var peg$e260 = peg$otherExpectation("number"); - var peg$e261 = peg$otherExpectation("uri"); - var peg$e262 = peg$literalExpectation("(", true); - var peg$e263 = peg$otherExpectation("function"); - var peg$e264 = peg$literalExpectation("(", false); + var peg$e200 = peg$literalExpectation("b", true); + var peg$e201 = peg$classExpectation(["B", "b"], false, false); + var peg$e202 = peg$literalExpectation("\\b", true); + var peg$e203 = peg$literalExpectation("c", true); + var peg$e204 = peg$classExpectation(["C", "c"], false, false); + var peg$e205 = peg$literalExpectation("d", true); + var peg$e206 = peg$classExpectation(["D", "d"], false, false); + var peg$e207 = peg$literalExpectation("e", true); + var peg$e208 = peg$classExpectation(["E", "e"], false, false); + var peg$e209 = peg$literalExpectation("f", true); + var peg$e210 = peg$classExpectation(["F", "f"], false, false); + var peg$e211 = peg$literalExpectation("\\f", true); + var peg$e212 = peg$literalExpectation("g", true); + var peg$e213 = peg$classExpectation(["G", "g"], false, false); + var peg$e214 = peg$literalExpectation("\\g", true); + var peg$e215 = peg$literalExpectation("h", true); + var peg$e216 = peg$classExpectation(["H", "h"], false, false); + var peg$e217 = peg$literalExpectation("\\h", true); + var peg$e218 = peg$literalExpectation("i", true); + var peg$e219 = peg$classExpectation(["I", "i"], false, false); + var peg$e220 = peg$literalExpectation("\\i", true); + var peg$e221 = peg$literalExpectation("j", true); + var peg$e222 = peg$classExpectation(["J", "j"], false, false); + var peg$e223 = peg$literalExpectation("\\j", true); + var peg$e224 = peg$literalExpectation("k", true); + var peg$e225 = peg$classExpectation(["K", "k"], false, false); + var peg$e226 = peg$literalExpectation("\\k", true); + var peg$e227 = peg$literalExpectation("l", true); + var peg$e228 = peg$classExpectation(["L", "l"], false, false); + var peg$e229 = peg$literalExpectation("\\l", true); + var peg$e230 = peg$literalExpectation("m", true); + var peg$e231 = peg$classExpectation(["M", "m"], false, false); + var peg$e232 = peg$literalExpectation("\\m", true); + var peg$e233 = peg$literalExpectation("n", true); + var peg$e234 = peg$classExpectation(["N", "n"], false, false); + var peg$e235 = peg$literalExpectation("\\n", true); + var peg$e236 = peg$literalExpectation("o", true); + var peg$e237 = peg$classExpectation(["O", "o"], false, false); + var peg$e238 = peg$literalExpectation("\\o", true); + var peg$e239 = peg$literalExpectation("p", true); + var peg$e240 = peg$classExpectation(["P", "p"], false, false); + var peg$e241 = peg$literalExpectation("\\p", true); + var peg$e242 = peg$literalExpectation("q", true); + var peg$e243 = peg$classExpectation(["Q", "q"], false, false); + var peg$e244 = peg$literalExpectation("\\q", true); + var peg$e245 = peg$literalExpectation("r", true); + var peg$e246 = peg$classExpectation(["R", "r"], false, false); + var peg$e247 = peg$literalExpectation("\\r", true); + var peg$e248 = peg$literalExpectation("s", true); + var peg$e249 = peg$classExpectation(["S", "s"], false, false); + var peg$e250 = peg$literalExpectation("\\s", true); + var peg$e251 = peg$literalExpectation("t", true); + var peg$e252 = peg$classExpectation(["T", "t"], false, false); + var peg$e253 = peg$literalExpectation("\\t", true); + var peg$e254 = peg$literalExpectation("u", true); + var peg$e255 = peg$classExpectation(["U", "u"], false, false); + var peg$e256 = peg$literalExpectation("\\u", true); + var peg$e257 = peg$literalExpectation("v", true); + var peg$e258 = peg$classExpectation(["V", "v"], false, false); + var peg$e259 = peg$literalExpectation("\\v", true); + var peg$e260 = peg$literalExpectation("w", true); + var peg$e261 = peg$classExpectation(["W", "w"], false, false); + var peg$e262 = peg$literalExpectation("\\w", true); + var peg$e263 = peg$literalExpectation("x", true); + var peg$e264 = peg$classExpectation(["X", "x"], false, false); + var peg$e265 = peg$literalExpectation("\\x", true); + var peg$e266 = peg$literalExpectation("y", true); + var peg$e267 = peg$classExpectation(["Y", "y"], false, false); + var peg$e268 = peg$literalExpectation("\\y", true); + var peg$e269 = peg$literalExpectation("z", true); + var peg$e270 = peg$classExpectation(["Z", "z"], false, false); + var peg$e271 = peg$literalExpectation("\\z", true); + var peg$e272 = peg$otherExpectation("whitespace"); + var peg$e273 = peg$otherExpectation("string"); + var peg$e274 = peg$otherExpectation("identifier"); + var peg$e275 = peg$otherExpectation("hash"); + var peg$e276 = peg$otherExpectation("length"); + var peg$e277 = peg$otherExpectation("angle"); + var peg$e278 = peg$otherExpectation("time"); + var peg$e279 = peg$otherExpectation("frequency"); + var peg$e280 = peg$otherExpectation("percentage"); + var peg$e281 = peg$otherExpectation("number"); + var peg$e282 = peg$otherExpectation("uri"); + var peg$e283 = peg$literalExpectation("(", true); + var peg$e284 = peg$otherExpectation("function"); + var peg$e285 = peg$literalExpectation("(", false); var peg$f0 = function(declarationsHead, declarationsTail) { return combine(buildList(declarationsHead, declarationsTail, 2)); }; var peg$f1 = function(name, value) { @@ -1222,49 +1264,57 @@ function peg$parse(input, options) { }; var peg$f144 = function(chars) { return chars.join(''); }; var peg$f145 = function() { return 'a'; }; - var peg$f146 = function() { return 'c'; }; - var peg$f147 = function() { return 'd'; }; - var peg$f148 = function() { return 'e'; }; - var peg$f149 = function() { return 'g'; }; - var peg$f150 = function() { return 'h'; }; - var peg$f151 = function() { return 'i'; }; - var peg$f152 = function() { return 'k'; }; - var peg$f153 = function() { return 'l'; }; - var peg$f154 = function() { return 'm'; }; - var peg$f155 = function() { return 'n'; }; - var peg$f156 = function() { return 'o'; }; - var peg$f157 = function() { return 'p'; }; - var peg$f158 = function() { return 'r'; }; - var peg$f159 = function() { return 's'; }; - var peg$f160 = function() { return 't'; }; - var peg$f161 = function() { return 'u'; }; - var peg$f162 = function() { return 'x'; }; - var peg$f163 = function() { return 'z'; }; - var peg$f164 = function(string) { return string; }; - var peg$f165 = function(ident) { return ident; }; - var peg$f166 = function(name) { return '#' + name; }; - var peg$f167 = function(value) { return { value: value, unit: 'ex' }; }; - var peg$f168 = function(value) { return value; }; - var peg$f169 = function(value) { return { value: value, unit: 'cm' }; }; - var peg$f170 = function(value) { return { value: value, unit: 'mm' }; }; - var peg$f171 = function(value) { return { value: value, unit: 'in' }; }; - var peg$f172 = function(value) { return { value: value, unit: 'pt' }; }; - var peg$f173 = function(value) { return { value: value, unit: 'pc' }; }; - var peg$f174 = function(value) { return { value: value, unit: 'em' }; }; - var peg$f175 = function() { return 0; }; - var peg$f176 = function(value) { return { value: value, unit: 'deg' }; }; - var peg$f177 = function(value) { return { value: value, unit: 'rad' }; }; - var peg$f178 = function(value) { return { value: value, unit: 'grad' }; }; - var peg$f179 = function(value) { return { value: value, unit: 'ms' }; }; - var peg$f180 = function(value) { return { value: value, unit: 's' }; }; - var peg$f181 = function(value) { return { value: value, unit: 'hz' }; }; - var peg$f182 = function(value) { return { value: value, unit: 'kh' }; }; - var peg$f183 = function(value) { return { value: value, unit: '%' }; }; - var peg$f184 = function(value) { return value; }; - var peg$f185 = function(value) { return { value: value, unit: null }; }; - var peg$f186 = function(url) { return url; }; - var peg$f187 = function(url) { return url; }; - var peg$f188 = function(name) { return name; }; + var peg$f146 = function() { return 'b'; }; + var peg$f147 = function() { return 'c'; }; + var peg$f148 = function() { return 'd'; }; + var peg$f149 = function() { return 'e'; }; + var peg$f150 = function() { return 'f'; }; + var peg$f151 = function() { return 'g'; }; + var peg$f152 = function() { return 'h'; }; + var peg$f153 = function() { return 'i'; }; + var peg$f154 = function() { return 'j'; }; + var peg$f155 = function() { return 'k'; }; + var peg$f156 = function() { return 'l'; }; + var peg$f157 = function() { return 'm'; }; + var peg$f158 = function() { return 'n'; }; + var peg$f159 = function() { return 'o'; }; + var peg$f160 = function() { return 'p'; }; + var peg$f161 = function() { return 'q'; }; + var peg$f162 = function() { return 'r'; }; + var peg$f163 = function() { return 's'; }; + var peg$f164 = function() { return 't'; }; + var peg$f165 = function() { return 'u'; }; + var peg$f166 = function() { return 'v'; }; + var peg$f167 = function() { return 'w'; }; + var peg$f168 = function() { return 'x'; }; + var peg$f169 = function() { return 'y'; }; + var peg$f170 = function() { return 'z'; }; + var peg$f171 = function(string) { return string; }; + var peg$f172 = function(ident) { return ident; }; + var peg$f173 = function(name) { return '#' + name; }; + var peg$f174 = function(value) { return { value: value, unit: 'ex' }; }; + var peg$f175 = function(value) { return value; }; + var peg$f176 = function(value) { return { value: value, unit: 'cm' }; }; + var peg$f177 = function(value) { return { value: value, unit: 'mm' }; }; + var peg$f178 = function(value) { return { value: value, unit: 'in' }; }; + var peg$f179 = function(value) { return { value: value, unit: 'pt' }; }; + var peg$f180 = function(value) { return { value: value, unit: 'pc' }; }; + var peg$f181 = function(value) { return { value: value, unit: 'em' }; }; + var peg$f182 = function(value) { return { value: value, unit: 'Q' }; }; + var peg$f183 = function() { return 0; }; + var peg$f184 = function(value) { return { value: value, unit: 'deg' }; }; + var peg$f185 = function(value) { return { value: value, unit: 'rad' }; }; + var peg$f186 = function(value) { return { value: value, unit: 'grad' }; }; + var peg$f187 = function(value) { return { value: value, unit: 'ms' }; }; + var peg$f188 = function(value) { return { value: value, unit: 's' }; }; + var peg$f189 = function(value) { return { value: value, unit: 'hz' }; }; + var peg$f190 = function(value) { return { value: value, unit: 'kh' }; }; + var peg$f191 = function(value) { return { value: value, unit: '%' }; }; + var peg$f192 = function(value) { return value; }; + var peg$f193 = function(value) { return { value: value, unit: null }; }; + var peg$f194 = function(url) { return url; }; + var peg$f195 = function(url) { return url; }; + var peg$f196 = function(name) { return name; }; var peg$currPos = 0; var peg$savedPos = 0; var peg$posDetailsCache = [{ line: 1, column: 1 }]; @@ -10615,7 +10665,7 @@ function peg$parse(input, options) { return s0; } - function peg$parseC() { + function peg$parseB() { var s0, s1, s2, s3, s4, s5, s6, s7; if (input.substr(peg$currPos, 1).toLowerCase() === peg$c178) { @@ -10682,6 +10732,123 @@ function peg$parse(input, options) { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e201); } } + if (s6 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c166) { + s7 = peg$c166; + peg$currPos += 2; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e177); } + } + if (s7 === peg$FAILED) { + if (peg$r7.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e178); } + } + } + if (s7 === peg$FAILED) { + s7 = null; + } + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c179) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e202); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f146(); + } + s0 = s1; + } + } + + return s0; + } + + function peg$parseC() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c180) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e203); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c165; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e176); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s3 = peg$c177; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s4 = peg$c177; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s5 = peg$c177; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (peg$r19.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e204); } + } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { s7 = peg$c166; @@ -10703,7 +10870,7 @@ function peg$parse(input, options) { s7 = null; } peg$savedPos = s0; - s0 = peg$f146(); + s0 = peg$f147(); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -10720,12 +10887,12 @@ function peg$parse(input, options) { function peg$parseD() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c179) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c181) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e202); } + if (peg$silentFails === 0) { peg$fail(peg$e205); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -10777,12 +10944,114 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r19.test(input.charAt(peg$currPos))) { + if (peg$r20.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e206); } + } + if (s6 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c166) { + s7 = peg$c166; + peg$currPos += 2; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e177); } + } + if (s7 === peg$FAILED) { + if (peg$r7.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e178); } + } + } + if (s7 === peg$FAILED) { + s7 = null; + } + peg$savedPos = s0; + s0 = peg$f148(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseE() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c172) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e207); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c165; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e176); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s3 = peg$c177; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s4 = peg$c177; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s5 = peg$c177; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (peg$r21.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e203); } + if (peg$silentFails === 0) { peg$fail(peg$e208); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -10805,29 +11074,614 @@ function peg$parse(input, options) { s7 = null; } peg$savedPos = s0; - s0 = peg$f147(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; + s0 = peg$f149(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } + + return s0; + } + + function peg$parseF() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c182) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e209); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c165; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e176); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s3 = peg$c177; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s4 = peg$c177; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s5 = peg$c177; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (peg$r22.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e210); } + } + if (s6 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c166) { + s7 = peg$c166; + peg$currPos += 2; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e177); } + } + if (s7 === peg$FAILED) { + if (peg$r7.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e178); } + } + } + if (s7 === peg$FAILED) { + s7 = null; + } + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c183) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e211); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f150(); + } + s0 = s1; + } + } + + return s0; + } + + function peg$parseG() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c184) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e212); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c165; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e176); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s3 = peg$c177; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s4 = peg$c177; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s5 = peg$c177; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (peg$r23.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e213); } + } + if (s6 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c166) { + s7 = peg$c166; + peg$currPos += 2; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e177); } + } + if (s7 === peg$FAILED) { + if (peg$r7.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e178); } + } + } + if (s7 === peg$FAILED) { + s7 = null; + } + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c185) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e214); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f151(); + } + s0 = s1; + } + } + + return s0; + } + + function peg$parseH() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c186) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e215); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c165; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e176); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s3 = peg$c177; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s4 = peg$c177; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s5 = peg$c177; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (peg$r24.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e216); } + } + if (s6 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c166) { + s7 = peg$c166; + peg$currPos += 2; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e177); } + } + if (s7 === peg$FAILED) { + if (peg$r7.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e178); } + } + } + if (s7 === peg$FAILED) { + s7 = null; + } + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c187) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e217); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f152(); + } + s0 = s1; + } + } + + return s0; + } + + function peg$parseI() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c188) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e218); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c165; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e176); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s3 = peg$c177; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s4 = peg$c177; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s5 = peg$c177; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (peg$r25.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e219); } + } + if (s6 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c166) { + s7 = peg$c166; + peg$currPos += 2; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e177); } + } + if (s7 === peg$FAILED) { + if (peg$r7.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e178); } + } + } + if (s7 === peg$FAILED) { + s7 = null; + } + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c189) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e220); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f153(); + } + s0 = s1; + } + } + + return s0; + } + + function peg$parseJ() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c190) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e221); } + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c165; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e176); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 === peg$FAILED) { + s2 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s3 = peg$c177; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s4 = peg$c177; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s4 === peg$FAILED) { + s4 = null; + } + if (input.charCodeAt(peg$currPos) === 48) { + s5 = peg$c177; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (peg$r26.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e222); } + } + if (s6 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c166) { + s7 = peg$c166; + peg$currPos += 2; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e177); } + } + if (s7 === peg$FAILED) { + if (peg$r7.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e178); } + } + } + if (s7 === peg$FAILED) { + s7 = null; + } + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c191) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e223); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f154(); } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + s0 = s1; } } return s0; } - function peg$parseE() { + function peg$parseK() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c172) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c192) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e204); } + if (peg$silentFails === 0) { peg$fail(peg$e224); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -10879,12 +11733,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r20.test(input.charAt(peg$currPos))) { + if (peg$r27.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e205); } + if (peg$silentFails === 0) { peg$fail(peg$e225); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -10906,8 +11760,8 @@ function peg$parse(input, options) { if (s7 === peg$FAILED) { s7 = null; } - peg$savedPos = s0; - s0 = peg$f148(); + s1 = [s1, s2, s3, s4, s5, s6, s7]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -10916,20 +11770,35 @@ function peg$parse(input, options) { peg$currPos = s0; s0 = peg$FAILED; } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c193) { + s1 = input.substr(peg$currPos, 2); + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e226); } + } + if (s1 !== peg$FAILED) { + peg$savedPos = s0; + s1 = peg$f155(); + } + s0 = s1; + } } return s0; } - function peg$parseG() { + function peg$parseL() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c180) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c194) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e206); } + if (peg$silentFails === 0) { peg$fail(peg$e227); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -10981,12 +11850,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r21.test(input.charAt(peg$currPos))) { + if (peg$r28.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e207); } + if (peg$silentFails === 0) { peg$fail(peg$e228); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11020,16 +11889,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c181) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c195) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e208); } + if (peg$silentFails === 0) { peg$fail(peg$e229); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f149(); + s1 = peg$f156(); } s0 = s1; } @@ -11038,15 +11907,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseH() { + function peg$parseM() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c182) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c196) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e209); } + if (peg$silentFails === 0) { peg$fail(peg$e230); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11098,12 +11967,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r22.test(input.charAt(peg$currPos))) { + if (peg$r29.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e210); } + if (peg$silentFails === 0) { peg$fail(peg$e231); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11137,16 +12006,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c183) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c197) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e211); } + if (peg$silentFails === 0) { peg$fail(peg$e232); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f150(); + s1 = peg$f157(); } s0 = s1; } @@ -11155,15 +12024,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseI() { + function peg$parseN() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c184) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c198) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e212); } + if (peg$silentFails === 0) { peg$fail(peg$e233); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11215,12 +12084,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r23.test(input.charAt(peg$currPos))) { + if (peg$r30.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e213); } + if (peg$silentFails === 0) { peg$fail(peg$e234); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11254,16 +12123,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c185) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c199) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e214); } + if (peg$silentFails === 0) { peg$fail(peg$e235); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f151(); + s1 = peg$f158(); } s0 = s1; } @@ -11272,15 +12141,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseK() { + function peg$parseO() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c186) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c200) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e215); } + if (peg$silentFails === 0) { peg$fail(peg$e236); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11332,12 +12201,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r24.test(input.charAt(peg$currPos))) { + if (peg$r31.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e216); } + if (peg$silentFails === 0) { peg$fail(peg$e237); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11371,16 +12240,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c187) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c201) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e217); } + if (peg$silentFails === 0) { peg$fail(peg$e238); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f152(); + s1 = peg$f159(); } s0 = s1; } @@ -11389,15 +12258,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseL() { + function peg$parseP() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c188) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c202) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e218); } + if (peg$silentFails === 0) { peg$fail(peg$e239); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11449,12 +12318,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r25.test(input.charAt(peg$currPos))) { + if (peg$r32.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e219); } + if (peg$silentFails === 0) { peg$fail(peg$e240); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11488,16 +12357,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c189) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c203) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e220); } + if (peg$silentFails === 0) { peg$fail(peg$e241); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f153(); + s1 = peg$f160(); } s0 = s1; } @@ -11506,15 +12375,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseM() { + function peg$parseQ() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c190) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c204) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e221); } + if (peg$silentFails === 0) { peg$fail(peg$e242); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11566,12 +12435,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r26.test(input.charAt(peg$currPos))) { + if (peg$r33.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e222); } + if (peg$silentFails === 0) { peg$fail(peg$e243); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11605,16 +12474,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c191) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c205) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e223); } + if (peg$silentFails === 0) { peg$fail(peg$e244); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f154(); + s1 = peg$f161(); } s0 = s1; } @@ -11623,15 +12492,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseN() { + function peg$parseR() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c192) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c206) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e224); } + if (peg$silentFails === 0) { peg$fail(peg$e245); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11683,12 +12552,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r27.test(input.charAt(peg$currPos))) { + if (peg$r34.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e225); } + if (peg$silentFails === 0) { peg$fail(peg$e246); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11722,16 +12591,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c193) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c207) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e226); } + if (peg$silentFails === 0) { peg$fail(peg$e247); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f155(); + s1 = peg$f162(); } s0 = s1; } @@ -11740,15 +12609,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseO() { + function peg$parseS_() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c194) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c208) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e227); } + if (peg$silentFails === 0) { peg$fail(peg$e248); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11800,12 +12669,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r28.test(input.charAt(peg$currPos))) { + if (peg$r35.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e228); } + if (peg$silentFails === 0) { peg$fail(peg$e249); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11839,16 +12708,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c195) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c209) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e229); } + if (peg$silentFails === 0) { peg$fail(peg$e250); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f156(); + s1 = peg$f163(); } s0 = s1; } @@ -11857,15 +12726,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseP() { + function peg$parseT() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c196) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c210) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e230); } + if (peg$silentFails === 0) { peg$fail(peg$e251); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -11917,12 +12786,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r29.test(input.charAt(peg$currPos))) { + if (peg$r36.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e231); } + if (peg$silentFails === 0) { peg$fail(peg$e252); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -11956,16 +12825,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c197) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c211) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e232); } + if (peg$silentFails === 0) { peg$fail(peg$e253); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f157(); + s1 = peg$f164(); } s0 = s1; } @@ -11974,15 +12843,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseR() { + function peg$parseU() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c198) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c212) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e233); } + if (peg$silentFails === 0) { peg$fail(peg$e254); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -12034,12 +12903,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r30.test(input.charAt(peg$currPos))) { + if (peg$r37.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e234); } + if (peg$silentFails === 0) { peg$fail(peg$e255); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -12073,16 +12942,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c199) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c213) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e235); } + if (peg$silentFails === 0) { peg$fail(peg$e256); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f158(); + s1 = peg$f165(); } s0 = s1; } @@ -12091,15 +12960,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseS_() { + function peg$parseV() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c200) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c214) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e236); } + if (peg$silentFails === 0) { peg$fail(peg$e257); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -12151,12 +13020,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r31.test(input.charAt(peg$currPos))) { + if (peg$r38.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e237); } + if (peg$silentFails === 0) { peg$fail(peg$e258); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -12190,16 +13059,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c201) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c215) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e238); } + if (peg$silentFails === 0) { peg$fail(peg$e259); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f159(); + s1 = peg$f166(); } s0 = s1; } @@ -12208,15 +13077,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseT() { + function peg$parseW() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c202) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c216) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e239); } + if (peg$silentFails === 0) { peg$fail(peg$e260); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -12268,12 +13137,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r32.test(input.charAt(peg$currPos))) { + if (peg$r39.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e240); } + if (peg$silentFails === 0) { peg$fail(peg$e261); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -12307,16 +13176,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c203) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c217) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e241); } + if (peg$silentFails === 0) { peg$fail(peg$e262); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f160(); + s1 = peg$f167(); } s0 = s1; } @@ -12325,15 +13194,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseU() { + function peg$parseX() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c204) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c218) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e242); } + if (peg$silentFails === 0) { peg$fail(peg$e263); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -12385,12 +13254,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r33.test(input.charAt(peg$currPos))) { + if (peg$r40.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e243); } + if (peg$silentFails === 0) { peg$fail(peg$e264); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -12424,16 +13293,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c205) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c219) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e244); } + if (peg$silentFails === 0) { peg$fail(peg$e265); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f161(); + s1 = peg$f168(); } s0 = s1; } @@ -12442,15 +13311,15 @@ function peg$parse(input, options) { return s0; } - function peg$parseX() { + function peg$parseY() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c206) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c220) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e245); } + if (peg$silentFails === 0) { peg$fail(peg$e266); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -12502,12 +13371,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r34.test(input.charAt(peg$currPos))) { + if (peg$r41.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e246); } + if (peg$silentFails === 0) { peg$fail(peg$e267); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -12541,16 +13410,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c207) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c221) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e247); } + if (peg$silentFails === 0) { peg$fail(peg$e268); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f162(); + s1 = peg$f169(); } s0 = s1; } @@ -12562,12 +13431,12 @@ function peg$parse(input, options) { function peg$parseZ() { var s0, s1, s2, s3, s4, s5, s6, s7; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c208) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c222) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e248); } + if (peg$silentFails === 0) { peg$fail(peg$e269); } } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -12619,12 +13488,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = null; } - if (peg$r35.test(input.charAt(peg$currPos))) { + if (peg$r42.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e249); } + if (peg$silentFails === 0) { peg$fail(peg$e270); } } if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c166) { @@ -12658,16 +13527,16 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c209) { + if (input.substr(peg$currPos, 2).toLowerCase() === peg$c223) { s1 = input.substr(peg$currPos, 2); peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e250); } + if (peg$silentFails === 0) { peg$fail(peg$e271); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$f163(); + s1 = peg$f170(); } s0 = s1; } @@ -12698,7 +13567,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e251); } + if (peg$silentFails === 0) { peg$fail(peg$e272); } } return s0; @@ -12718,7 +13587,7 @@ function peg$parse(input, options) { s2 = peg$parsestring(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f164(s2); + s0 = peg$f171(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12726,7 +13595,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e252); } + if (peg$silentFails === 0) { peg$fail(peg$e273); } } return s0; @@ -12746,7 +13615,7 @@ function peg$parse(input, options) { s2 = peg$parseident(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f165(s2); + s0 = peg$f172(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12754,7 +13623,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e253); } + if (peg$silentFails === 0) { peg$fail(peg$e274); } } return s0; @@ -12782,7 +13651,7 @@ function peg$parse(input, options) { s3 = peg$parsename(); if (s3 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f166(s3); + s0 = peg$f173(s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12794,7 +13663,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e254); } + if (peg$silentFails === 0) { peg$fail(peg$e275); } } return s0; @@ -12818,7 +13687,7 @@ function peg$parse(input, options) { s4 = peg$parseX(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f167(s2); + s0 = peg$f174(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12834,7 +13703,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e255); } + if (peg$silentFails === 0) { peg$fail(peg$e276); } } return s0; @@ -12858,7 +13727,7 @@ function peg$parse(input, options) { s4 = peg$parseX(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f168(s2); + s0 = peg$f175(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12886,7 +13755,7 @@ function peg$parse(input, options) { s4 = peg$parseM(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f169(s2); + s0 = peg$f176(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12914,7 +13783,7 @@ function peg$parse(input, options) { s4 = peg$parseM(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f170(s2); + s0 = peg$f177(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12942,7 +13811,7 @@ function peg$parse(input, options) { s4 = peg$parseN(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f171(s2); + s0 = peg$f178(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12970,7 +13839,7 @@ function peg$parse(input, options) { s4 = peg$parseT(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f172(s2); + s0 = peg$f179(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -12998,7 +13867,7 @@ function peg$parse(input, options) { s4 = peg$parseC(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f173(s2); + s0 = peg$f180(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13026,7 +13895,7 @@ function peg$parse(input, options) { s4 = peg$parseM(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f174(s2); + s0 = peg$f181(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13047,20 +13916,43 @@ function peg$parse(input, options) { s1.push(s2); s2 = peg$parsecomment(); } - if (input.charCodeAt(peg$currPos) === 48) { - s2 = peg$c177; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e198); } - } + s2 = peg$parsenum(); if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f175(); + s3 = peg$parseQ(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f182(s2); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } } else { peg$currPos = s0; s0 = peg$FAILED; } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = []; + s2 = peg$parsecomment(); + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parsecomment(); + } + if (input.charCodeAt(peg$currPos) === 48) { + s2 = peg$c177; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e198); } + } + if (s2 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f183(); + } else { + peg$currPos = s0; + s0 = peg$FAILED; + } + } } } } @@ -13071,7 +13963,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e255); } + if (peg$silentFails === 0) { peg$fail(peg$e276); } } return s0; @@ -13097,7 +13989,7 @@ function peg$parse(input, options) { s5 = peg$parseG(); if (s5 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f176(s2); + s0 = peg$f184(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13131,7 +14023,7 @@ function peg$parse(input, options) { s5 = peg$parseD(); if (s5 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f177(s2); + s0 = peg$f185(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13167,7 +14059,7 @@ function peg$parse(input, options) { s6 = peg$parseD(); if (s6 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f178(s2); + s0 = peg$f186(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13193,7 +14085,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e256); } + if (peg$silentFails === 0) { peg$fail(peg$e277); } } return s0; @@ -13217,7 +14109,7 @@ function peg$parse(input, options) { s4 = peg$parseS_(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f179(s2); + s0 = peg$f187(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13243,7 +14135,7 @@ function peg$parse(input, options) { s3 = peg$parseS_(); if (s3 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f180(s2); + s0 = peg$f188(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13256,7 +14148,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e257); } + if (peg$silentFails === 0) { peg$fail(peg$e278); } } return s0; @@ -13280,7 +14172,7 @@ function peg$parse(input, options) { s4 = peg$parseZ(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f181(s2); + s0 = peg$f189(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13310,7 +14202,7 @@ function peg$parse(input, options) { s5 = peg$parseZ(); if (s5 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f182(s2); + s0 = peg$f190(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13331,7 +14223,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e258); } + if (peg$silentFails === 0) { peg$fail(peg$e279); } } return s0; @@ -13359,7 +14251,7 @@ function peg$parse(input, options) { } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f183(s2); + s0 = peg$f191(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13371,7 +14263,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e259); } + if (peg$silentFails === 0) { peg$fail(peg$e280); } } return s0; @@ -13391,7 +14283,7 @@ function peg$parse(input, options) { s2 = peg$parsenum(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f184(s2); + s0 = peg$f192(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13399,7 +14291,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e260); } + if (peg$silentFails === 0) { peg$fail(peg$e281); } } return s0; @@ -13419,7 +14311,7 @@ function peg$parse(input, options) { s2 = peg$parsenum(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f185(s2); + s0 = peg$f193(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13427,7 +14319,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e260); } + if (peg$silentFails === 0) { peg$fail(peg$e281); } } return s0; @@ -13450,12 +14342,12 @@ function peg$parse(input, options) { if (s3 !== peg$FAILED) { s4 = peg$parseL(); if (s4 !== peg$FAILED) { - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c210) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c224) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e262); } + if (peg$silentFails === 0) { peg$fail(peg$e283); } } if (s5 !== peg$FAILED) { s6 = peg$parsew(); @@ -13471,7 +14363,7 @@ function peg$parse(input, options) { } if (s9 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f186(s7); + s0 = peg$f194(s7); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13510,12 +14402,12 @@ function peg$parse(input, options) { if (s3 !== peg$FAILED) { s4 = peg$parseL(); if (s4 !== peg$FAILED) { - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c210) { + if (input.substr(peg$currPos, 1).toLowerCase() === peg$c224) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e262); } + if (peg$silentFails === 0) { peg$fail(peg$e283); } } if (s5 !== peg$FAILED) { s6 = peg$parsew(); @@ -13530,7 +14422,7 @@ function peg$parse(input, options) { } if (s9 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f187(s7); + s0 = peg$f195(s7); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13555,7 +14447,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e261); } + if (peg$silentFails === 0) { peg$fail(peg$e282); } } return s0; @@ -13575,15 +14467,15 @@ function peg$parse(input, options) { s2 = peg$parseident(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c210; + s3 = peg$c224; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e264); } + if (peg$silentFails === 0) { peg$fail(peg$e285); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; - s0 = peg$f188(s2); + s0 = peg$f196(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -13595,7 +14487,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e263); } + if (peg$silentFails === 0) { peg$fail(peg$e284); } } return s0; diff --git a/src/parse-css.pegjs b/src/parse-css.pegjs index 9f7d972..b191a4c 100644 --- a/src/parse-css.pegjs +++ b/src/parse-css.pegjs @@ -886,25 +886,32 @@ nl / '\r' / '\f' -A = 'a'i / '\\' '0'? '0'? '0'? '0'? [\x41\x61] ('\r\n' / [ \t\r\n\f])? { return 'a'; } -C = 'c'i / '\\' '0'? '0'? '0'? '0'? [\x43\x63] ('\r\n' / [ \t\r\n\f])? { return 'c'; } -D = 'd'i / '\\' '0'? '0'? '0'? '0'? [\x44\x64] ('\r\n' / [ \t\r\n\f])? { return 'd'; } -E = 'e'i / '\\' '0'? '0'? '0'? '0'? [\x45\x65] ('\r\n' / [ \t\r\n\f])? { return 'e'; } -G = 'g'i / '\\' '0'? '0'? '0'? '0'? [\x47\x67] ('\r\n' / [ \t\r\n\f])? / '\\g'i { return 'g'; } -H = 'h'i / '\\' '0'? '0'? '0'? '0'? [\x48\x68] ('\r\n' / [ \t\r\n\f])? / '\\h'i { return 'h'; } -I = 'i'i / '\\' '0'? '0'? '0'? '0'? [\x49\x69] ('\r\n' / [ \t\r\n\f])? / '\\i'i { return 'i'; } -K = 'k'i / '\\' '0'? '0'? '0'? '0'? [\x4b\x6b] ('\r\n' / [ \t\r\n\f])? / '\\k'i { return 'k'; } -L = 'l'i / '\\' '0'? '0'? '0'? '0'? [\x4c\x6c] ('\r\n' / [ \t\r\n\f])? / '\\l'i { return 'l'; } -M = 'm'i / '\\' '0'? '0'? '0'? '0'? [\x4d\x6d] ('\r\n' / [ \t\r\n\f])? / '\\m'i { return 'm'; } -N = 'n'i / '\\' '0'? '0'? '0'? '0'? [\x4e\x6e] ('\r\n' / [ \t\r\n\f])? / '\\n'i { return 'n'; } -O = 'o'i / '\\' '0'? '0'? '0'? '0'? [\x4f\x6f] ('\r\n' / [ \t\r\n\f])? / '\\o'i { return 'o'; } -P = 'p'i / '\\' '0'? '0'? '0'? '0'? [\x50\x70] ('\r\n' / [ \t\r\n\f])? / '\\p'i { return 'p'; } -R = 'r'i / '\\' '0'? '0'? '0'? '0'? [\x52\x72] ('\r\n' / [ \t\r\n\f])? / '\\r'i { return 'r'; } +A = 'a'i / '\\' '0'? '0'? '0'? '0'? [\x41\x61] ('\r\n' / [ \t\r\n\f])? { return 'a'; } +B = 'b'i / '\\' '0'? '0'? '0'? '0'? [\x42\x62] ('\r\n' / [ \t\r\n\f])? / '\\b'i { return 'b'; } +C = 'c'i / '\\' '0'? '0'? '0'? '0'? [\x43\x63] ('\r\n' / [ \t\r\n\f])? { return 'c'; } +D = 'd'i / '\\' '0'? '0'? '0'? '0'? [\x44\x64] ('\r\n' / [ \t\r\n\f])? { return 'd'; } +E = 'e'i / '\\' '0'? '0'? '0'? '0'? [\x45\x65] ('\r\n' / [ \t\r\n\f])? { return 'e'; } +F = 'f'i / '\\' '0'? '0'? '0'? '0'? [\x46\x66] ('\r\n' / [ \t\r\n\f])? / '\\f'i { return 'f'; } +G = 'g'i / '\\' '0'? '0'? '0'? '0'? [\x47\x67] ('\r\n' / [ \t\r\n\f])? / '\\g'i { return 'g'; } +H = 'h'i / '\\' '0'? '0'? '0'? '0'? [\x48\x68] ('\r\n' / [ \t\r\n\f])? / '\\h'i { return 'h'; } +I = 'i'i / '\\' '0'? '0'? '0'? '0'? [\x49\x69] ('\r\n' / [ \t\r\n\f])? / '\\i'i { return 'i'; } +J = 'j'i / '\\' '0'? '0'? '0'? '0'? [\x4A\x6A] ('\r\n' / [ \t\r\n\f])? / '\\j'i { return 'j'; } +K = 'k'i / '\\' '0'? '0'? '0'? '0'? [\x4B\x6B] ('\r\n' / [ \t\r\n\f])? / '\\k'i { return 'k'; } +L = 'l'i / '\\' '0'? '0'? '0'? '0'? [\x4C\x6C] ('\r\n' / [ \t\r\n\f])? / '\\l'i { return 'l'; } +M = 'm'i / '\\' '0'? '0'? '0'? '0'? [\x4D\x6D] ('\r\n' / [ \t\r\n\f])? / '\\m'i { return 'm'; } +N = 'n'i / '\\' '0'? '0'? '0'? '0'? [\x4E\x6E] ('\r\n' / [ \t\r\n\f])? / '\\n'i { return 'n'; } +O = 'o'i / '\\' '0'? '0'? '0'? '0'? [\x4F\x6F] ('\r\n' / [ \t\r\n\f])? / '\\o'i { return 'o'; } +P = 'p'i / '\\' '0'? '0'? '0'? '0'? [\x50\x70] ('\r\n' / [ \t\r\n\f])? / '\\p'i { return 'p'; } +Q = 'q'i / '\\' '0'? '0'? '0'? '0'? [\x51\x71] ('\r\n' / [ \t\r\n\f])? / '\\q'i { return 'q'; } +R = 'r'i / '\\' '0'? '0'? '0'? '0'? [\x52\x72] ('\r\n' / [ \t\r\n\f])? / '\\r'i { return 'r'; } S_ = 's'i / '\\' '0'? '0'? '0'? '0'? [\x53\x73] ('\r\n' / [ \t\r\n\f])? / '\\s'i { return 's'; } -T = 't'i / '\\' '0'? '0'? '0'? '0'? [\x54\x74] ('\r\n' / [ \t\r\n\f])? / '\\t'i { return 't'; } -U = 'u'i / '\\' '0'? '0'? '0'? '0'? [\x55\x75] ('\r\n' / [ \t\r\n\f])? / '\\u'i { return 'u'; } -X = 'x'i / '\\' '0'? '0'? '0'? '0'? [\x58\x78] ('\r\n' / [ \t\r\n\f])? / '\\x'i { return 'x'; } -Z = 'z'i / '\\' '0'? '0'? '0'? '0'? [\x5a\x7a] ('\r\n' / [ \t\r\n\f])? / '\\z'i { return 'z'; } +T = 't'i / '\\' '0'? '0'? '0'? '0'? [\x54\x74] ('\r\n' / [ \t\r\n\f])? / '\\t'i { return 't'; } +U = 'u'i / '\\' '0'? '0'? '0'? '0'? [\x55\x75] ('\r\n' / [ \t\r\n\f])? / '\\u'i { return 'u'; } +V = 'v'i / '\\' '0'? '0'? '0'? '0'? [\x56\x76] ('\r\n' / [ \t\r\n\f])? / '\\v'i { return 'v'; } +W = 'w'i / '\\' '0'? '0'? '0'? '0'? [\x57\x77] ('\r\n' / [ \t\r\n\f])? / '\\w'i { return 'w'; } +X = 'x'i / '\\' '0'? '0'? '0'? '0'? [\x58\x78] ('\r\n' / [ \t\r\n\f])? / '\\x'i { return 'x'; } +Y = 'y'i / '\\' '0'? '0'? '0'? '0'? [\x59\x79] ('\r\n' / [ \t\r\n\f])? / '\\y'i { return 'y'; } +Z = 'z'i / '\\' '0'? '0'? '0'? '0'? [\x5A\x7A] ('\r\n' / [ \t\r\n\f])? / '\\z'i { return 'z'; } // Tokens @@ -931,6 +938,7 @@ LENGTH "length" / comment* value:num P T { return { value: value, unit: 'pt' }; } / comment* value:num P C { return { value: value, unit: 'pc' }; } / comment* value:num E M { return { value: value, unit: 'em' }; } + / comment* value:num Q { return { value: value, unit: 'Q' }; } / comment* '0' { return 0; } ANGLE "angle" diff --git a/src/style.ts b/src/style.ts index 1fdc32a..0c5257a 100644 --- a/src/style.ts +++ b/src/style.ts @@ -74,7 +74,7 @@ const LogicalMaps = Object.freeze({ export type WhiteSpace = 'normal' | 'nowrap' | 'pre-wrap' | 'pre-line' | 'pre'; -type Length = number | {value: number, unit: 'em'}; +type Length = number | {value: number, unit: 'cm' | 'mm' | 'Q' | 'in' | 'pc' | 'pt' | 'px' | 'em'}; type Percentage = {value: number, unit: '%'}; @@ -941,12 +941,28 @@ function defaultProperty( } } -function resolveEm( +function resolveUnit( value: DeclaredStyleProperties[keyof DeclaredStyleProperties], fontSize: number ) { - if (typeof value === 'object' && 'unit' in value && value.unit === 'em') { - return fontSize * value.value; + if (typeof value === 'object' && 'unit' in value ) { + // see https://www.w3.org/TR/css-values-3/#absolute-lengths + if (value.unit === 'em') + return fontSize * value.value; + else if (value.unit === 'cm') + return (value.value / 2.54) * 96; + else if (value.unit === 'mm') + return (value.value / 25.4) * 96; + else if (value.unit === 'Q') + return (value.value / 40 / 25.4) * 96; + else if (value.unit === 'in') + return value.value * 96; + else if (value.unit === 'pc') + return (value.value / 6) * 96; + else if (value.unit === 'pt') + return (value.value / 72) * 96; + else // assume it's px + return value.value; } else { return value; } @@ -959,7 +975,7 @@ function computeStyle(parentStyle: Style, cascadedStyle: DeclaredStyle) { // Compute fontSize first since em values depend on it const specifiedFontSize = defaultProperty(parentStyle, cascadedStyle, 'fontSize'); - let fontSize = resolveEm(specifiedFontSize, parentFontSize) as number | Percentage; + let fontSize = resolveUnit(specifiedFontSize, parentFontSize) as number | Percentage; if (typeof fontSize === 'object') { fontSize = fontSize.value / 100 * parentFontSize; @@ -969,9 +985,9 @@ function computeStyle(parentStyle: Style, cascadedStyle: DeclaredStyle) { for (const _ in initialPlainStyle) { const p = _ as keyof ComputedStyle; const specifiedValue = defaultProperty(parentStyle, cascadedStyle, p); - // as any because TS does not know that resolveEm will only reduce the union + // as any because TS does not know that resolveUnit will only reduce the union // of possible values at a per-property level - (working as any)[p] = resolveEm(specifiedValue, fontSize)!; + (working as any)[p] = resolveUnit(specifiedValue, fontSize)!; } working.fontSize = fontSize; From 4b3abb81d6d9c1a5166ed01368add46a8630755b Mon Sep 17 00:00:00 2001 From: Bob Pritchett Date: Sun, 7 Dec 2025 12:29:04 -0700 Subject: [PATCH 2/4] fix: standardize character handling in CSS parser --- src/parse-css.pegjs | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/parse-css.pegjs b/src/parse-css.pegjs index b191a4c..959c355 100644 --- a/src/parse-css.pegjs +++ b/src/parse-css.pegjs @@ -886,32 +886,32 @@ nl / '\r' / '\f' -A = 'a'i / '\\' '0'? '0'? '0'? '0'? [\x41\x61] ('\r\n' / [ \t\r\n\f])? { return 'a'; } -B = 'b'i / '\\' '0'? '0'? '0'? '0'? [\x42\x62] ('\r\n' / [ \t\r\n\f])? / '\\b'i { return 'b'; } -C = 'c'i / '\\' '0'? '0'? '0'? '0'? [\x43\x63] ('\r\n' / [ \t\r\n\f])? { return 'c'; } -D = 'd'i / '\\' '0'? '0'? '0'? '0'? [\x44\x64] ('\r\n' / [ \t\r\n\f])? { return 'd'; } -E = 'e'i / '\\' '0'? '0'? '0'? '0'? [\x45\x65] ('\r\n' / [ \t\r\n\f])? { return 'e'; } -F = 'f'i / '\\' '0'? '0'? '0'? '0'? [\x46\x66] ('\r\n' / [ \t\r\n\f])? / '\\f'i { return 'f'; } -G = 'g'i / '\\' '0'? '0'? '0'? '0'? [\x47\x67] ('\r\n' / [ \t\r\n\f])? / '\\g'i { return 'g'; } -H = 'h'i / '\\' '0'? '0'? '0'? '0'? [\x48\x68] ('\r\n' / [ \t\r\n\f])? / '\\h'i { return 'h'; } -I = 'i'i / '\\' '0'? '0'? '0'? '0'? [\x49\x69] ('\r\n' / [ \t\r\n\f])? / '\\i'i { return 'i'; } -J = 'j'i / '\\' '0'? '0'? '0'? '0'? [\x4A\x6A] ('\r\n' / [ \t\r\n\f])? / '\\j'i { return 'j'; } -K = 'k'i / '\\' '0'? '0'? '0'? '0'? [\x4B\x6B] ('\r\n' / [ \t\r\n\f])? / '\\k'i { return 'k'; } -L = 'l'i / '\\' '0'? '0'? '0'? '0'? [\x4C\x6C] ('\r\n' / [ \t\r\n\f])? / '\\l'i { return 'l'; } -M = 'm'i / '\\' '0'? '0'? '0'? '0'? [\x4D\x6D] ('\r\n' / [ \t\r\n\f])? / '\\m'i { return 'm'; } -N = 'n'i / '\\' '0'? '0'? '0'? '0'? [\x4E\x6E] ('\r\n' / [ \t\r\n\f])? / '\\n'i { return 'n'; } -O = 'o'i / '\\' '0'? '0'? '0'? '0'? [\x4F\x6F] ('\r\n' / [ \t\r\n\f])? / '\\o'i { return 'o'; } -P = 'p'i / '\\' '0'? '0'? '0'? '0'? [\x50\x70] ('\r\n' / [ \t\r\n\f])? / '\\p'i { return 'p'; } -Q = 'q'i / '\\' '0'? '0'? '0'? '0'? [\x51\x71] ('\r\n' / [ \t\r\n\f])? / '\\q'i { return 'q'; } -R = 'r'i / '\\' '0'? '0'? '0'? '0'? [\x52\x72] ('\r\n' / [ \t\r\n\f])? / '\\r'i { return 'r'; } +A = 'a'i / '\\' '0'? '0'? '0'? '0'? [\x41\x61] ('\r\n' / [ \t\r\n\f])? { return 'a'; } +B = 'b'i / '\\' '0'? '0'? '0'? '0'? [\x42\x62] ('\r\n' / [ \t\r\n\f])? / '\\b'i { return 'b'; } +C = 'c'i / '\\' '0'? '0'? '0'? '0'? [\x43\x63] ('\r\n' / [ \t\r\n\f])? { return 'c'; } +D = 'd'i / '\\' '0'? '0'? '0'? '0'? [\x44\x64] ('\r\n' / [ \t\r\n\f])? { return 'd'; } +E = 'e'i / '\\' '0'? '0'? '0'? '0'? [\x45\x65] ('\r\n' / [ \t\r\n\f])? { return 'e'; } +F = 'f'i / '\\' '0'? '0'? '0'? '0'? [\x46\x66] ('\r\n' / [ \t\r\n\f])? / '\\f'i { return 'f'; } +G = 'g'i / '\\' '0'? '0'? '0'? '0'? [\x47\x67] ('\r\n' / [ \t\r\n\f])? / '\\g'i { return 'g'; } +H = 'h'i / '\\' '0'? '0'? '0'? '0'? [\x48\x68] ('\r\n' / [ \t\r\n\f])? / '\\h'i { return 'h'; } +I = 'i'i / '\\' '0'? '0'? '0'? '0'? [\x49\x69] ('\r\n' / [ \t\r\n\f])? / '\\i'i { return 'i'; } +J = 'j'i / '\\' '0'? '0'? '0'? '0'? [\x4A\x6A] ('\r\n' / [ \t\r\n\f])? / '\\j'i { return 'j'; } +K = 'k'i / '\\' '0'? '0'? '0'? '0'? [\x4B\x6B] ('\r\n' / [ \t\r\n\f])? / '\\k'i { return 'k'; } +L = 'l'i / '\\' '0'? '0'? '0'? '0'? [\x4C\x6C] ('\r\n' / [ \t\r\n\f])? / '\\l'i { return 'l'; } +M = 'm'i / '\\' '0'? '0'? '0'? '0'? [\x4D\x6D] ('\r\n' / [ \t\r\n\f])? / '\\m'i { return 'm'; } +N = 'n'i / '\\' '0'? '0'? '0'? '0'? [\x4E\x6E] ('\r\n' / [ \t\r\n\f])? / '\\n'i { return 'n'; } +O = 'o'i / '\\' '0'? '0'? '0'? '0'? [\x4F\x6F] ('\r\n' / [ \t\r\n\f])? / '\\o'i { return 'o'; } +P = 'p'i / '\\' '0'? '0'? '0'? '0'? [\x50\x70] ('\r\n' / [ \t\r\n\f])? / '\\p'i { return 'p'; } +Q = 'q'i / '\\' '0'? '0'? '0'? '0'? [\x51\x71] ('\r\n' / [ \t\r\n\f])? / '\\q'i { return 'q'; } +R = 'r'i / '\\' '0'? '0'? '0'? '0'? [\x52\x72] ('\r\n' / [ \t\r\n\f])? / '\\r'i { return 'r'; } S_ = 's'i / '\\' '0'? '0'? '0'? '0'? [\x53\x73] ('\r\n' / [ \t\r\n\f])? / '\\s'i { return 's'; } -T = 't'i / '\\' '0'? '0'? '0'? '0'? [\x54\x74] ('\r\n' / [ \t\r\n\f])? / '\\t'i { return 't'; } -U = 'u'i / '\\' '0'? '0'? '0'? '0'? [\x55\x75] ('\r\n' / [ \t\r\n\f])? / '\\u'i { return 'u'; } -V = 'v'i / '\\' '0'? '0'? '0'? '0'? [\x56\x76] ('\r\n' / [ \t\r\n\f])? / '\\v'i { return 'v'; } -W = 'w'i / '\\' '0'? '0'? '0'? '0'? [\x57\x77] ('\r\n' / [ \t\r\n\f])? / '\\w'i { return 'w'; } -X = 'x'i / '\\' '0'? '0'? '0'? '0'? [\x58\x78] ('\r\n' / [ \t\r\n\f])? / '\\x'i { return 'x'; } -Y = 'y'i / '\\' '0'? '0'? '0'? '0'? [\x59\x79] ('\r\n' / [ \t\r\n\f])? / '\\y'i { return 'y'; } -Z = 'z'i / '\\' '0'? '0'? '0'? '0'? [\x5A\x7A] ('\r\n' / [ \t\r\n\f])? / '\\z'i { return 'z'; } +T = 't'i / '\\' '0'? '0'? '0'? '0'? [\x54\x74] ('\r\n' / [ \t\r\n\f])? / '\\t'i { return 't'; } +U = 'u'i / '\\' '0'? '0'? '0'? '0'? [\x55\x75] ('\r\n' / [ \t\r\n\f])? / '\\u'i { return 'u'; } +V = 'v'i / '\\' '0'? '0'? '0'? '0'? [\x56\x76] ('\r\n' / [ \t\r\n\f])? / '\\v'i { return 'v'; } +W = 'w'i / '\\' '0'? '0'? '0'? '0'? [\x57\x77] ('\r\n' / [ \t\r\n\f])? / '\\w'i { return 'w'; } +X = 'x'i / '\\' '0'? '0'? '0'? '0'? [\x58\x78] ('\r\n' / [ \t\r\n\f])? / '\\x'i { return 'x'; } +Y = 'y'i / '\\' '0'? '0'? '0'? '0'? [\x59\x79] ('\r\n' / [ \t\r\n\f])? / '\\y'i { return 'y'; } +Z = 'z'i / '\\' '0'? '0'? '0'? '0'? [\x5A\x7A] ('\r\n' / [ \t\r\n\f])? / '\\z'i { return 'z'; } // Tokens From 1065e1eb55453595567be6f1a1e5e6ae2a82a89f Mon Sep 17 00:00:00 2001 From: Bob Pritchett Date: Sun, 7 Dec 2025 12:32:09 -0700 Subject: [PATCH 3/4] cleaning up formatting --- src/parse-css.pegjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/parse-css.pegjs b/src/parse-css.pegjs index 959c355..a3803f6 100644 --- a/src/parse-css.pegjs +++ b/src/parse-css.pegjs @@ -895,12 +895,12 @@ F = 'f'i / '\\' '0'? '0'? '0'? '0'? [\x46\x66] ('\r\n' / [ \t\r\n\f])? / '\\f'i G = 'g'i / '\\' '0'? '0'? '0'? '0'? [\x47\x67] ('\r\n' / [ \t\r\n\f])? / '\\g'i { return 'g'; } H = 'h'i / '\\' '0'? '0'? '0'? '0'? [\x48\x68] ('\r\n' / [ \t\r\n\f])? / '\\h'i { return 'h'; } I = 'i'i / '\\' '0'? '0'? '0'? '0'? [\x49\x69] ('\r\n' / [ \t\r\n\f])? / '\\i'i { return 'i'; } -J = 'j'i / '\\' '0'? '0'? '0'? '0'? [\x4A\x6A] ('\r\n' / [ \t\r\n\f])? / '\\j'i { return 'j'; } -K = 'k'i / '\\' '0'? '0'? '0'? '0'? [\x4B\x6B] ('\r\n' / [ \t\r\n\f])? / '\\k'i { return 'k'; } -L = 'l'i / '\\' '0'? '0'? '0'? '0'? [\x4C\x6C] ('\r\n' / [ \t\r\n\f])? / '\\l'i { return 'l'; } -M = 'm'i / '\\' '0'? '0'? '0'? '0'? [\x4D\x6D] ('\r\n' / [ \t\r\n\f])? / '\\m'i { return 'm'; } -N = 'n'i / '\\' '0'? '0'? '0'? '0'? [\x4E\x6E] ('\r\n' / [ \t\r\n\f])? / '\\n'i { return 'n'; } -O = 'o'i / '\\' '0'? '0'? '0'? '0'? [\x4F\x6F] ('\r\n' / [ \t\r\n\f])? / '\\o'i { return 'o'; } +J = 'j'i / '\\' '0'? '0'? '0'? '0'? [\x4a\x6a] ('\r\n' / [ \t\r\n\f])? / '\\j'i { return 'j'; } +K = 'k'i / '\\' '0'? '0'? '0'? '0'? [\x4b\x6b] ('\r\n' / [ \t\r\n\f])? / '\\k'i { return 'k'; } +L = 'l'i / '\\' '0'? '0'? '0'? '0'? [\x4c\x6c] ('\r\n' / [ \t\r\n\f])? / '\\l'i { return 'l'; } +M = 'm'i / '\\' '0'? '0'? '0'? '0'? [\x4d\x6d] ('\r\n' / [ \t\r\n\f])? / '\\m'i { return 'm'; } +N = 'n'i / '\\' '0'? '0'? '0'? '0'? [\x4e\x6e] ('\r\n' / [ \t\r\n\f])? / '\\n'i { return 'n'; } +O = 'o'i / '\\' '0'? '0'? '0'? '0'? [\x4f\x6f] ('\r\n' / [ \t\r\n\f])? / '\\o'i { return 'o'; } P = 'p'i / '\\' '0'? '0'? '0'? '0'? [\x50\x70] ('\r\n' / [ \t\r\n\f])? / '\\p'i { return 'p'; } Q = 'q'i / '\\' '0'? '0'? '0'? '0'? [\x51\x71] ('\r\n' / [ \t\r\n\f])? / '\\q'i { return 'q'; } R = 'r'i / '\\' '0'? '0'? '0'? '0'? [\x52\x72] ('\r\n' / [ \t\r\n\f])? / '\\r'i { return 'r'; } @@ -911,7 +911,7 @@ V = 'v'i / '\\' '0'? '0'? '0'? '0'? [\x56\x76] ('\r\n' / [ \t\r\n\f])? / '\\v'i W = 'w'i / '\\' '0'? '0'? '0'? '0'? [\x57\x77] ('\r\n' / [ \t\r\n\f])? / '\\w'i { return 'w'; } X = 'x'i / '\\' '0'? '0'? '0'? '0'? [\x58\x78] ('\r\n' / [ \t\r\n\f])? / '\\x'i { return 'x'; } Y = 'y'i / '\\' '0'? '0'? '0'? '0'? [\x59\x79] ('\r\n' / [ \t\r\n\f])? / '\\y'i { return 'y'; } -Z = 'z'i / '\\' '0'? '0'? '0'? '0'? [\x5A\x7A] ('\r\n' / [ \t\r\n\f])? / '\\z'i { return 'z'; } +Z = 'z'i / '\\' '0'? '0'? '0'? '0'? [\x5a\x7a] ('\r\n' / [ \t\r\n\f])? / '\\z'i { return 'z'; } // Tokens From 947dd9522d33e9d1abd7212e92bbc5193314b284 Mon Sep 17 00:00:00 2001 From: Bob Pritchett Date: Sun, 7 Dec 2025 14:21:05 -0700 Subject: [PATCH 4/4] feat: add example HTML templates for demonstration --- site/examples.js | 150 +++++++++++++++++++ site/index.html | 7 +- site/index.js | 381 ++++++++++++++++++++++++----------------------- 3 files changed, 346 insertions(+), 192 deletions(-) create mode 100644 site/examples.js diff --git a/site/examples.js b/site/examples.js new file mode 100644 index 0000000..0e4f5f3 --- /dev/null +++ b/site/examples.js @@ -0,0 +1,150 @@ +export const examples = [ + { + name: 'Default', + html: ` +

+ + playground +

+

this is all being rendered to a canvas

+

edit the html to the left to see live updates

+ +
+
NOTE
+ Using dropflow to render to a browser canvas is rarely better than + native HTML and CSS (but there are cases for it). This is a demo to + show the capabilities you could use for server-generated images and PDFs. +
+ +
+ To the left! +
+
+ To the right! +
+

+ To the left and right are examples of floats. + Floats are placed as they are encountered + in text, so text that comes after them won't collide with them. + If this text doesn't go underneath the floats, resize your browser window. +

+ +
+ +
+ Another difficult feature is inline-blocks. +
+ Here's one right here. +
+ That's what they do: the "inline" part means that + it's inline-level, and + the "block" part is short for block container. +
+ +
+ +
+ You may want to have some text in a paragraph to be raised or + lowered. That's done with vertical-align. + + alignment is relative to the + parent, except top + and bottom, + which are broken out and aligned to the line + as an atomic unit. +
+ +
+ +
+ The + zoom + property makes everything bigger! (or smaller) +
+ +
+ +
+ Finally, when + painting inline backgrounds, the inline element must not interrupt + font shaping features like ligatures, or kerning, such as the text + "AV". When an inline is + + relatively positioned, + + this does interrupt shaping boundaries. +
+` + }, + { + name: 'Units', + html: ` +

Absolute CSS Units Demo

+
1 in (inches)
+
2 in (inches)
+
192 px (pixels)
+
5.08 cm (centimeters)
+
50.8 mm (millimeters)
+
2032 Q (quarter millimeters)
+
12 pc (picas)
+
144 pt (points)
+` + }, +{ + name: 'Text Formatting', + html: ` +

Text Formatting & Scripts Demo

+ +
+ Hello, world. (Bold / Latin) +
+ + + +
+ Привет, мир. (Italic / Cyrillic) +
+ +
+ Γεια σου κόσμε. (Greek) +
+ +
+ Hello, world. (Latin) +
+ +
+ こんにちは、世界。 (Japanese) +
+ +
+ مرحبا بالعالم. (Right-to-Left / Arabic) +
+` + } +]; diff --git a/site/index.html b/site/index.html index d09d9d7..1a97c29 100644 --- a/site/index.html +++ b/site/index.html @@ -4,9 +4,10 @@ Dropflow Playground - -
-
+ +
+
+
diff --git a/site/index.js b/site/index.js index 584ab38..7362a97 100644 --- a/site/index.js +++ b/site/index.js @@ -1,4 +1,4 @@ -// @ts-check +// @ts-nocheck import './config.js'; import * as flow from 'dropflow'; import parse from 'dropflow/parse.js'; @@ -7,163 +7,183 @@ import {EditorView, basicSetup} from 'codemirror'; import {EditorState} from '@codemirror/state'; import {html} from '@codemirror/lang-html'; import {solarizedDark} from '@ddietr/codemirror-themes/solarized-dark.js' +import {examples} from './examples.js'; + +// --- Global State & DOM Elements --- +let currentExampleIndex = 0; +let flowTree; // Renamed from documentElement to avoid DOM conflict +let blockContainer = {}; +let isDragging = false; +let divider = +localStorage['divider'] || 50; const [canvas] = document.getElementsByTagName('canvas'); const twinview = document.getElementById('twinview'); const wrap = document.getElementById('wrap'); const editor = document.querySelector('#editor'); +const exampleBar = document.getElementById('example-bar'); const canvasLabel = document.getElementById('canvas-label'); +if (!canvas || !twinview || !wrap || !editor || !exampleBar || !canvasLabel) { + throw new Error('Required DOM elements not found'); +} + +// --- Utilities --- + +function debounce(func, wait) { + let timeout; + return function(...args) { + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(this, args), wait); + }; +} + +// --- Editor Setup --- + +const triggerRender = debounce(() => { + parseGenerate(); + loadLayoutPaint(); +}, 200); + +const watch = EditorView.updateListener.of(update => { + if (update.docChanged) { + triggerRender(); + } +}); + +let state = EditorState.create({ + doc: examples[currentExampleIndex].html, + extensions: [basicSetup, html(), watch, solarizedDark] +}); + +let view = new EditorView({ + state, + parent: editor +}); + +// --- Logic & Rendering --- + flow.setOriginStyle({zoom: window.devicePixelRatio}); registerNotoFonts(); async function loadLayoutPaint() { + if (!wrap || !canvas) return; + const ctx = canvas.getContext('2d'); + if (!ctx) return; + const cssWidth = wrap.getBoundingClientRect().width; const cssHeight = wrap.getBoundingClientRect().height; const dpxWidth = Math.ceil(cssWidth * window.devicePixelRatio); const dpxHeight = Math.ceil(cssHeight * window.devicePixelRatio); - await flow.load(documentElement); - canvas.style.width = `${dpxWidth / window.devicePixelRatio}px`; - canvas.style.height = `${dpxHeight / window.devicePixelRatio}px`; - canvas.width = dpxWidth; - canvas.height = dpxHeight; + if (canvas.width !== dpxWidth || canvas.height !== dpxHeight) { + canvas.style.width = `${dpxWidth / window.devicePixelRatio}px`; + canvas.style.height = `${dpxHeight / window.devicePixelRatio}px`; + canvas.width = dpxWidth; + canvas.height = dpxHeight; + } - const {r, g, b, a} = documentElement.style.backgroundColor; - canvasLabel.style.backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`; + // Use the parsed flowTree, not the browser DOM + if (flowTree) { + await flow.load(flowTree); + + // RESTORED: Sync label color + if (flowTree.style && flowTree.style.backgroundColor) { + const {r, g, b, a} = flowTree.style.backgroundColor; + canvasLabel.style.backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`; + } + } ctx.save(); ctx.clearRect(0, 0, canvas.width, canvas.height); - flow.layout(blockContainer, canvas.width, canvas.height); - flow.paintToCanvas(blockContainer, canvas.getContext('2d')); + + if (blockContainer && Object.keys(blockContainer).length > 0) { + flow.layout(blockContainer, canvas.width, canvas.height); + flow.paintToCanvas(blockContainer, ctx); + } ctx.restore(); } -const watch = EditorView.updateListener.of(update => { - if (update.docChanged) { - parseGenerate(); - loadLayoutPaint(); - } -}); +function parseGenerate() { + flowTree = parse(view.state.doc.toString()); + blockContainer = flow.generate(flowTree); + window['blockContainer'] = blockContainer; + window['documentElement'] = flowTree; +} -const state = EditorState.create({ - doc: ` -

- - playground -

-

this is all being rendered to a canvas

-

edit the html to the left to see live updates

- -
-
NOTE
- Using dropflow to render to a browser canvas is rarely better than - native HTML and CSS (but there are cases for it). This is a demo to - show the capabilities you could use for server-generated images and PDFs. -
- -
- To the left! -
-
- To the right! -
-

- To the left and right are examples of floats. - Floats are placed as they are encountered - in text, so text that comes after them won't collide with them. - If this text doesn't go underneath the floats, resize your browser window. -

- -
- -
- Another difficult feature is inline-blocks. -
- Here's one right here. -
- That's what they do: the "inline" part means that - it's inline-level, and - the "block" part is short for block container. -
- -
- -
- You may want to have some text in a paragraph to be raised or - lowered. That's done with vertical-align. - - alignment is relative to the - parent, except top - and bottom, - which are broken out and aligned to the line - as an atomic unit. -
- -
- -
- The - zoom - property makes everything bigger! (or smaller) -
- -
- -
- Finally, when - painting inline backgrounds, the inline element must not interrupt - font shaping features like ligatures, or kerning, such as the text - "AV". When an inline is - - relatively positioned, - - this does interrupt shaping boundaries. -
-`, - extensions: [basicSetup, html(), watch, solarizedDark] +function setExample(index) { + currentExampleIndex = index; + state = EditorState.create({ + doc: examples[index].html, + extensions: [basicSetup, html(), watch, solarizedDark] + }); + view.setState(state); + + renderWidth(); + updateExampleButtons(index); + + parseGenerate(); + loadLayoutPaint(); +} + +function updateExampleButtons(activeIndex) { + Array.from(exampleBar.children).forEach((btn, idx) => { + if (btn instanceof HTMLButtonElement) { + btn.style.background = idx === activeIndex ? '#444' : '#222'; + } + }); +} + +// --- Initialization --- + +exampleBar.innerHTML = ''; +examples.forEach((ex, i) => { + const btn = document.createElement('button'); + btn.textContent = ex.name; + Object.assign(btn.style, { + marginRight: '8px', + padding: '6px 16px', + background: i === currentExampleIndex ? '#444' : '#222', + color: 'white', + border: 'none', + borderRadius: '4px', + cursor: 'pointer' + }); + + btn.onclick = () => setExample(i); + exampleBar.appendChild(btn); }); -const view = new EditorView({state, parent: editor}); +parseGenerate(); +loadLayoutPaint(); +renderWidth(); -let documentElement; -let blockContainer; +// RESTORED: CodeMirror sizing +view.dom.style.height = '100%'; +view.scrollDOM.style.overflow = 'auto'; -function parseGenerate() { - documentElement = parse(view.state.doc.toString()); - blockContainer = flow.generate(documentElement); - window.blockContainer = blockContainer; - window.documentElement = documentElement; +// RESTORED: Debug export +window.flow = flow; + +// RESTORED: Animate only if no preference saved +if (localStorage['divider'] == null && editor instanceof HTMLElement) { + setTimeout(() => { + editor.animate([ + {width: '50%', easing: 'cubic-bezier(0.82,-0.67,0.07,0.92)'}, + {width: '55%', easing: 'cubic-bezier(0.61,0.17,0.07,0.86)'}, + {width: '50%'} + ], {duration: 2000}); + }, 2000); } +// --- Resize Handling --- + const observer = new ResizeObserver(function () { - loadLayoutPaint(); + triggerRender(); }); +observer.observe(wrap); let lastDevicePixelRatio = window.devicePixelRatio; - window.addEventListener('resize', function () { if (window.devicePixelRatio !== lastDevicePixelRatio) { lastDevicePixelRatio = window.devicePixelRatio; @@ -173,87 +193,70 @@ window.addEventListener('resize', function () { } }); -observer.observe(wrap); - -let divider = +localStorage['divider'] || 50; -let animationTimer = localStorage['divider'] == null ? setTimeout(animate, 2e3) : null; -let isDragging = false; - -function animate() { - editor.animate([ - {width: '50%', easing: 'cubic-bezier(0.82,-0.67,0.07,0.92)'}, - {width: '55%', easing: 'cubic-bezier(0.61,0.17,0.07,0.86)'}, - {width: '50%'} - ], {duration: 2000}); - animationTimer = null; -} +// --- Drag Handle Logic --- function getEffectiveDivider() { return Math.min(90, Math.max(10, divider)); } function renderWidth() { - editor.style.width = getEffectiveDivider() + '%'; + if (editor instanceof HTMLElement) { + editor.style.width = getEffectiveDivider() + '%'; + } } function getState(e) { + if (!twinview) return { mouse: 0, divider: 0, total: 0 }; const rect = twinview.getBoundingClientRect(); const total = rect.width; - const divider = total * getEffectiveDivider() / 100; + const currentDivider = total * getEffectiveDivider() / 100; const mouse = e.clientX - rect.x; - return {mouse, divider, total}; + return {mouse, divider: currentDivider, total}; } function isInHandle(state) { return Math.abs(state.divider - state.mouse) < 10; } -twinview.addEventListener('pointermove', e => { - const state = getState(e); - const inHandle = isInHandle(state); - if (inHandle) { - isDragging ||= e.buttons === 1 && Boolean(e.movementX || e.movementY) - if (animationTimer != null) { - clearTimeout(animationTimer); - animationTimer = null; - } - } - if (isDragging) { - divider = 100 * state.mouse / state.total; - renderWidth(); - } else { - twinview.style.cursor = inHandle ? "ew-resize" : ""; - } -}); - -twinview.addEventListener('pointerdown', e => { - if (isInHandle(getState(e)) && e.buttons === 1) { - e.preventDefault(); - twinview.setPointerCapture(e.pointerId); - } -}); - -twinview.addEventListener('dblclick', e => { - if (isInHandle(getState(e))) { - divider = 50; - delete localStorage['divider']; - renderWidth(); - } -}); - -twinview.addEventListener('pointerup', e => { - if (isDragging) { - isDragging = false; - localStorage['divider'] = divider; - } -}); - -window.flow = flow; - -view.dom.style.height = '100%'; -view.scrollDOM.style.overflow = 'auto'; - -// init -parseGenerate(); -renderWidth(); -loadLayoutPaint(); +if (twinview) { + twinview.addEventListener('pointerdown', function(e) { + const state = getState(e); + if (isInHandle(state)) { + isDragging = true; + twinview.setPointerCapture(e.pointerId); + e.preventDefault(); + } + }); + + twinview.addEventListener('pointermove', function(e) { + const state = getState(e); + // RESTORED: Use 'ew-resize' which is more standard + if (isInHandle(state)) { + twinview.style.cursor = 'ew-resize'; + } else { + twinview.style.cursor = 'default'; + } + + if (isDragging) { + divider = Math.round(state.mouse * 100 / state.total); + renderWidth(); + localStorage['divider'] = divider; + } + }); + + twinview.addEventListener('pointerup', function(e) { + isDragging = false; + twinview.releasePointerCapture(e.pointerId); + }); + + // RESTORED: Double-click to reset + twinview.addEventListener('dblclick', function(e) { + const state = getState(e); + if (isInHandle(state)) { + divider = 50; + delete localStorage['divider']; + renderWidth(); + isDragging = false; + } + }); +} \ No newline at end of file