{"action":"created","comment":{"url":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/comments/57523472","id":57523472,"diff_hunk":"@@ -49,37 +79,89 @@ function reloadStyles(): void {\n  */\n export function detokenize(styles: string): string {\n   if (styles) {\n-    styles = styles.replace(\n-      /[\\'\\\"]\\[theme:\\s*(\\w+)\\s*(?:\\,\\s*default:\\s*([\\\\\"\\']?[\\.\\,\\(\\)\\#\\-\\s\\w]*[\\.\\,\\(\\)\\#\\-\\w][\\\"\\']?))?\\s*\\][\\'\\\"]/g,\n-      (\n-        match: string,\n-        themeVariable: string,\n-        defaultValue: string\n-      ): string => {\n-        let themedValue = _theme ? _theme[themeVariable] : null;\n+    styles = resolveThemableArray(splitStyles(styles));\n+  }\n+\n+  return styles;\n+}\n+\n+/**\n+ * Resolves ThemingInstruction objects in an array and joins the result into a string.\n+ * @param {ThemableArray} splitStyleArray ThemableArray to resolve and join.\n+ */\n+function resolveThemableArray(splitStyleArray: ThemableArray): string {\n+  let resolvedCss: string;\n+  if (splitStyleArray) {\n+    let resolvedArray = splitStyleArray.map((currentValue: IThemingInstruction) => {\n+      let themeSlot = currentValue.theme;\n+      if (themeSlot != null) {\n+        // A theming annotation. Resolve it.\n+        let themedValue = _theme ? _theme[themeSlot] : null;\n+        let defaultValue = currentValue.default;\n \n         // Warn to console if we hit an unthemed value even when themes are provided.\n         if (_theme && !themedValue && console) {\n-          console.warn(`Themed style value not provided for \"${ themeVariable }\". Falling back to \"${ defaultValue || 'inherit' }\".`);\n+          console.warn(`Theming value not provided for \"${themeSlot}\". Falling back to \"${defaultValue || 'inherit'}\".`);\n         }\n \n         return themedValue || defaultValue || 'inherit';\n+      } else {\n+        // A non-themable string. Preserve it.\n+        return currentValue.rawString;\n+      }\n+    });\n+\n+    resolvedCss = resolvedArray.join('');\n+  }\n+\n+  return resolvedCss;\n+}\n+\n+/**\n+ * Split tokenized CSS into an array of strings and theme specification objects\n+ * @param {string} styles Tokenized styles to split.\n+ */\n+export function splitStyles(styles: string): ThemableArray {","path":"src/index.ts","position":122,"original_position":122,"commit_id":"531b20ea9a6b164d07e2fc2a49c891d84aea707d","original_commit_id":"61ee310e41a1dbef9ff60f22b8f257f6c065cd69","user":{"login":"MBSilverstein","id":18015289,"avatar_url":"https://avatars.githubusercontent.com/u/18015289?v=3","gravatar_id":"","url":"https://api.github.com/users/MBSilverstein","html_url":"https://github.com/MBSilverstein","followers_url":"https://api.github.com/users/MBSilverstein/followers","following_url":"https://api.github.com/users/MBSilverstein/following{/other_user}","gists_url":"https://api.github.com/users/MBSilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/MBSilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MBSilverstein/subscriptions","organizations_url":"https://api.github.com/users/MBSilverstein/orgs","repos_url":"https://api.github.com/users/MBSilverstein/repos","events_url":"https://api.github.com/users/MBSilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/MBSilverstein/received_events","type":"User","site_admin":false},"body":"Let me know if there's a way I could clarify this in the code (or whether I should add some comments).","created_at":"2016-03-27T05:00:45Z","updated_at":"2016-03-27T05:00:45Z","html_url":"https://github.com/dzearing/load-themed-styles/pull/2#discussion_r57523472","pull_request_url":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/comments/57523472"},"html":{"href":"https://github.com/dzearing/load-themed-styles/pull/2#discussion_r57523472"},"pull_request":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2","id":64204559,"html_url":"https://github.com/dzearing/load-themed-styles/pull/2","diff_url":"https://github.com/dzearing/load-themed-styles/pull/2.diff","patch_url":"https://github.com/dzearing/load-themed-styles/pull/2.patch","issue_url":"https://api.github.com/repos/dzearing/load-themed-styles/issues/2","number":2,"state":"open","locked":false,"title":"Splitting CSS into operations for runtime regex support","user":{"login":"MBSilverstein","id":18015289,"avatar_url":"https://avatars.githubusercontent.com/u/18015289?v=3","gravatar_id":"","url":"https://api.github.com/users/MBSilverstein","html_url":"https://github.com/MBSilverstein","followers_url":"https://api.github.com/users/MBSilverstein/followers","following_url":"https://api.github.com/users/MBSilverstein/following{/other_user}","gists_url":"https://api.github.com/users/MBSilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/MBSilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MBSilverstein/subscriptions","organizations_url":"https://api.github.com/users/MBSilverstein/orgs","repos_url":"https://api.github.com/users/MBSilverstein/repos","events_url":"https://api.github.com/users/MBSilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/MBSilverstein/received_events","type":"User","site_admin":false},"body":"Updates build system as well.","created_at":"2016-03-25T20:34:53Z","updated_at":"2016-03-27T05:00:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"29788149b98f0500e6366fb1f7bf03428f8e006a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2/commits","review_comments_url":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2/comments","review_comment_url":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dzearing/load-themed-styles/issues/2/comments","statuses_url":"https://api.github.com/repos/dzearing/load-themed-styles/statuses/531b20ea9a6b164d07e2fc2a49c891d84aea707d","head":{"label":"MBSilverstein:msilver/split-styles","ref":"msilver/split-styles","sha":"531b20ea9a6b164d07e2fc2a49c891d84aea707d","user":{"login":"MBSilverstein","id":18015289,"avatar_url":"https://avatars.githubusercontent.com/u/18015289?v=3","gravatar_id":"","url":"https://api.github.com/users/MBSilverstein","html_url":"https://github.com/MBSilverstein","followers_url":"https://api.github.com/users/MBSilverstein/followers","following_url":"https://api.github.com/users/MBSilverstein/following{/other_user}","gists_url":"https://api.github.com/users/MBSilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/MBSilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MBSilverstein/subscriptions","organizations_url":"https://api.github.com/users/MBSilverstein/orgs","repos_url":"https://api.github.com/users/MBSilverstein/repos","events_url":"https://api.github.com/users/MBSilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/MBSilverstein/received_events","type":"User","site_admin":false},"repo":{"id":54513920,"name":"load-themed-styles","full_name":"MBSilverstein/load-themed-styles","owner":{"login":"MBSilverstein","id":18015289,"avatar_url":"https://avatars.githubusercontent.com/u/18015289?v=3","gravatar_id":"","url":"https://api.github.com/users/MBSilverstein","html_url":"https://github.com/MBSilverstein","followers_url":"https://api.github.com/users/MBSilverstein/followers","following_url":"https://api.github.com/users/MBSilverstein/following{/other_user}","gists_url":"https://api.github.com/users/MBSilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/MBSilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MBSilverstein/subscriptions","organizations_url":"https://api.github.com/users/MBSilverstein/orgs","repos_url":"https://api.github.com/users/MBSilverstein/repos","events_url":"https://api.github.com/users/MBSilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/MBSilverstein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MBSilverstein/load-themed-styles","description":"","fork":true,"url":"https://api.github.com/repos/MBSilverstein/load-themed-styles","forks_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/forks","keys_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/teams","hooks_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/hooks","issue_events_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/issues/events{/number}","events_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/events","assignees_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/assignees{/user}","branches_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/branches{/branch}","tags_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/tags","blobs_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/git/refs{/sha}","trees_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/statuses/{sha}","languages_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/languages","stargazers_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/stargazers","contributors_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/contributors","subscribers_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/subscribers","subscription_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/subscription","commits_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/commits{/sha}","git_commits_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/git/commits{/sha}","comments_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/comments{/number}","issue_comment_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/issues/comments{/number}","contents_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/contents/{+path}","compare_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/merges","archive_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/downloads","issues_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/issues{/number}","pulls_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/pulls{/number}","milestones_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/milestones{/number}","notifications_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/labels{/name}","releases_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/releases{/id}","deployments_url":"https://api.github.com/repos/MBSilverstein/load-themed-styles/deployments","created_at":"2016-03-22T22:49:28Z","updated_at":"2016-03-22T22:49:28Z","pushed_at":"2016-03-27T00:49:15Z","git_url":"git://github.com/MBSilverstein/load-themed-styles.git","ssh_url":"git@github.com:MBSilverstein/load-themed-styles.git","clone_url":"https://github.com/MBSilverstein/load-themed-styles.git","svn_url":"https://github.com/MBSilverstein/load-themed-styles","homepage":null,"size":16,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dzearing:master","ref":"master","sha":"9c85b6c94fbe75157442f69f2deeb2aa9a47ea86","user":{"login":"dzearing","id":1110944,"avatar_url":"https://avatars.githubusercontent.com/u/1110944?v=3","gravatar_id":"","url":"https://api.github.com/users/dzearing","html_url":"https://github.com/dzearing","followers_url":"https://api.github.com/users/dzearing/followers","following_url":"https://api.github.com/users/dzearing/following{/other_user}","gists_url":"https://api.github.com/users/dzearing/gists{/gist_id}","starred_url":"https://api.github.com/users/dzearing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzearing/subscriptions","organizations_url":"https://api.github.com/users/dzearing/orgs","repos_url":"https://api.github.com/users/dzearing/repos","events_url":"https://api.github.com/users/dzearing/events{/privacy}","received_events_url":"https://api.github.com/users/dzearing/received_events","type":"User","site_admin":false},"repo":{"id":52473388,"name":"load-themed-styles","full_name":"dzearing/load-themed-styles","owner":{"login":"dzearing","id":1110944,"avatar_url":"https://avatars.githubusercontent.com/u/1110944?v=3","gravatar_id":"","url":"https://api.github.com/users/dzearing","html_url":"https://github.com/dzearing","followers_url":"https://api.github.com/users/dzearing/followers","following_url":"https://api.github.com/users/dzearing/following{/other_user}","gists_url":"https://api.github.com/users/dzearing/gists{/gist_id}","starred_url":"https://api.github.com/users/dzearing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dzearing/subscriptions","organizations_url":"https://api.github.com/users/dzearing/orgs","repos_url":"https://api.github.com/users/dzearing/repos","events_url":"https://api.github.com/users/dzearing/events{/privacy}","received_events_url":"https://api.github.com/users/dzearing/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dzearing/load-themed-styles","description":"","fork":false,"url":"https://api.github.com/repos/dzearing/load-themed-styles","forks_url":"https://api.github.com/repos/dzearing/load-themed-styles/forks","keys_url":"https://api.github.com/repos/dzearing/load-themed-styles/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dzearing/load-themed-styles/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dzearing/load-themed-styles/teams","hooks_url":"https://api.github.com/repos/dzearing/load-themed-styles/hooks","issue_events_url":"https://api.github.com/repos/dzearing/load-themed-styles/issues/events{/number}","events_url":"https://api.github.com/repos/dzearing/load-themed-styles/events","assignees_url":"https://api.github.com/repos/dzearing/load-themed-styles/assignees{/user}","branches_url":"https://api.github.com/repos/dzearing/load-themed-styles/branches{/branch}","tags_url":"https://api.github.com/repos/dzearing/load-themed-styles/tags","blobs_url":"https://api.github.com/repos/dzearing/load-themed-styles/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dzearing/load-themed-styles/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dzearing/load-themed-styles/git/refs{/sha}","trees_url":"https://api.github.com/repos/dzearing/load-themed-styles/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dzearing/load-themed-styles/statuses/{sha}","languages_url":"https://api.github.com/repos/dzearing/load-themed-styles/languages","stargazers_url":"https://api.github.com/repos/dzearing/load-themed-styles/stargazers","contributors_url":"https://api.github.com/repos/dzearing/load-themed-styles/contributors","subscribers_url":"https://api.github.com/repos/dzearing/load-themed-styles/subscribers","subscription_url":"https://api.github.com/repos/dzearing/load-themed-styles/subscription","commits_url":"https://api.github.com/repos/dzearing/load-themed-styles/commits{/sha}","git_commits_url":"https://api.github.com/repos/dzearing/load-themed-styles/git/commits{/sha}","comments_url":"https://api.github.com/repos/dzearing/load-themed-styles/comments{/number}","issue_comment_url":"https://api.github.com/repos/dzearing/load-themed-styles/issues/comments{/number}","contents_url":"https://api.github.com/repos/dzearing/load-themed-styles/contents/{+path}","compare_url":"https://api.github.com/repos/dzearing/load-themed-styles/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dzearing/load-themed-styles/merges","archive_url":"https://api.github.com/repos/dzearing/load-themed-styles/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dzearing/load-themed-styles/downloads","issues_url":"https://api.github.com/repos/dzearing/load-themed-styles/issues{/number}","pulls_url":"https://api.github.com/repos/dzearing/load-themed-styles/pulls{/number}","milestones_url":"https://api.github.com/repos/dzearing/load-themed-styles/milestones{/number}","notifications_url":"https://api.github.com/repos/dzearing/load-themed-styles/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dzearing/load-themed-styles/labels{/name}","releases_url":"https://api.github.com/repos/dzearing/load-themed-styles/releases{/id}","deployments_url":"https://api.github.com/repos/dzearing/load-themed-styles/deployments","created_at":"2016-02-24T20:49:14Z","updated_at":"2016-02-27T16:53:57Z","pushed_at":"2016-03-27T00:49:16Z","git_url":"git://github.com/dzearing/load-themed-styles.git","ssh_url":"git@github.com:dzearing/load-themed-styles.git","clone_url":"https://github.com/dzearing/load-themed-styles.git","svn_url":"https://github.com/dzearing/load-themed-styles","homepage":null,"size":16,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2"},"html":{"href":"https://github.com/dzearing/load-themed-styles/pull/2"},"issue":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/issues/2"},"comments":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/dzearing/load-themed-styles/statuses/531b20ea9a6b164d07e2fc2a49c891d84aea707d"}}}}