Skip to content

Commit 931e2bb

Browse files
committed
Fix stylesheet priority, updated readme
1 parent b33fb8d commit 931e2bb

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# javascript-regex
22
[![](https://img.shields.io/apm/v/javascript-regex)](https://atom.io/packages/javascript-regex) [![](https://img.shields.io/apm/dm/javascript-regex)](https://atom.io/packages/javascript-regex)
33

4-
Improved syntax for JavaScript regular expressions.
4+
Improved syntax for JavaScript regular expressions, with syntax highlighting.
55

6-
Check out the [One Dark for Regex](https://atom.io/packages/one-dark-regex-syntax) theme for a practical use.
6+
![regex2](https://user-images.githubusercontent.com/695638/192731283-82db8798-d9b9-4f3f-8f13-7a90fb581810.gif)
77

88
This package implements two tree-sitter parsers:
99
- [tree-sitter-regex-unicode-js](https://github.com/wizard04wsu/tree-sitter-regex-unicode-js) for regular expressions that have the Unicode flag set
1010
- [tree-sitter-regex-js](https://github.com/wizard04wsu/tree-sitter-regex-js) for the rest
1111

12-
# Troubleshooting
13-
### Unable to install on Windows
12+
## Troubleshooting
13+
#### If you're unable to install the package on Windows:
1414
Instead of installing it from within Atom, close Atom and try from the command line.
1515

1616
cd /d %USERPROFILE%\.atom\packages
1717
rmdir /s /q javascript-regex
1818
apm install javascript-regex
1919

20-
### Failure to load package grammars when I open Atom
20+
#### If there's a failure loading the grammars when you open Atom:
2121
Whenever Atom is updated, this package needs to be rebuilt. Either click the red bug icon in the bottom-right corner of the window, or execute `Incompatible Packages: View` via the command palette. Then, click "Rebuild Packages". You'll have to restart Atom.
2222

2323
If anyone has a better solution, please [let me know](https://github.com/wizard04wsu/javascript-regex/issues/9).

lib/javascript-regex.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,16 @@ module.exports = {
146146
"javascript-regex:toggle-group-outlines": ()=>toggleConfig("showGroupOutlines"),
147147
}));
148148

149-
// Initialize per the configurations.
149+
// Load the main syntax highlighting stylesheet.
150+
let path = `${package.path}/styles/javascript-regex.less`,
151+
css = package.themeManager.loadStylesheet(path);
152+
disposableStyleSheets["main"] = package.styleManager.addStyleSheet(css, { sourcePath: path, priority: 1 });
153+
154+
// Load stylesheets per the package settings.
150155
updateStyleSheet("showCharacterSetBackgrounds", "charset-backgrounds");
151156
updateStyleSheet("showGroupOutlines", "group-outlines");
152157

153-
// Observe changes to the configurations.
158+
// Observe changes to the package settings.
154159
atom.config.onDidChange(`${thisPackage.name}.showCharacterSetBackgrounds`, {}, ()=>updateStyleSheet("showCharacterSetBackgrounds", "charset-backgrounds"));
155160
atom.config.onDidChange(`${thisPackage.name}.showGroupOutlines`, {}, ()=>updateStyleSheet("showGroupOutlines", "group-outlines"));
156161
},
@@ -160,6 +165,7 @@ module.exports = {
160165
deactivate(){
161166
disposableStyleSheets["showCharacterSetBackgrounds"]?.dispose();
162167
disposableStyleSheets["showGroupOutlines"]?.dispose();
168+
disposableStyleSheets["main"].dispose();
163169
this.subscriptions.dispose();
164170
},
165171

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"license": "MIT",
1313
"main": "lib/javascript-regex.js",
1414
"styleSheets": [
15-
"javascript-regex"
1615
],
1716
"activationHooks": [
1817
"source.js:root-scope-used",

test/examples/RegExp unicode.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,6 @@ new RegExp('*', 'u');
477477

478478
/^(?=(?<scheme>[a-z][a-z\d+.-]*))\1:(?:\/\/(?<authority>(?:(?=(?<userinfo>(?:[-\w.~!$&'()*+,;=:]|%[\dA-F]{2})*))\3@)?(?=(?<host>\[[\dA-F:.]{2,}\]|(?:[-\w.~!$&'()*+,;=]|%[\dA-F]{2})*))\4(?::(?=(?<port>\d*))\5)?)(?<path1>\/(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\7)?|(?<path2>\/?(?!\/)(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\9)?)(?:\?(?=(?<query>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\10)?(?:#(?=(?<fragment>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\11)?$/ui;
479479

480+
/^(?=(?<scheme>[a-z][a-z\d+.-]*))\k<scheme>:(?:\/\/(?<authority>(?:(?=(?<userinfo>(?:[-\w.~!$&'()*+,;=:]|%[\dA-F]{2})*))\k<userinfo>@)?(?=(?<host>\[[\dA-F:.]{2,}\]|(?:[-\w.~!$&'()*+,;=]|%[\dA-F]{2})*))\k<host>(?::(?=(?<port>\d*))\k<port>)?)(?<path1>\/(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\7)?|(?<path2>\/?(?!\/)(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\9)?)(?:\?(?=(?<query>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<query>)?(?:#(?=(?<fragment>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<fragment>)?$/ui;
481+
480482
/^(?=(?<scheme>[a-z][a-z\d+.-]*))\k<scheme>:(?:\/\/(?<authority>(?:(?=(?<userinfo>(?:[-\w.~!$&'()*+,;=:]|%[\dA-F]{2})*))\k<userinfo>@)?(?=(?<host>\[[\dA-F:.]{2,}\]|(?:[-\w.~!$&'()*+,;=]|%[\dA-F]{2})*))\k<host>(?::(?=(?<port>\d*))\k<port>)?)(?<path1>\/(?=(?<_path1>(?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\k<_path1>)?|(?<path2>\/?(?!\/)(?=(?<_path2>(?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\k<_path2>)?)(?:\?(?=(?<query>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<query>)?(?:#(?=(?<fragment>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<fragment>)?$/ui;

test/examples/RegExp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,6 @@ new RegExp('*');
343343

344344
/^(?=(?<scheme>[a-z][a-z\d+.-]*))\1:(?:\/\/(?<authority>(?:(?=(?<userinfo>(?:[-\w.~!$&'()*+,;=:]|%[\dA-F]{2})*))\3@)?(?=(?<host>\[[\dA-F:.]{2,}\]|(?:[-\w.~!$&'()*+,;=]|%[\dA-F]{2})*))\4(?::(?=(?<port>\d*))\5)?)(?<path1>\/(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\7)?|(?<path2>\/?(?!\/)(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\9)?)(?:\?(?=(?<query>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\10)?(?:#(?=(?<fragment>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\11)?$/i;
345345

346+
/^(?=(?<scheme>[a-z][a-z\d+.-]*))\k<scheme>:(?:\/\/(?<authority>(?:(?=(?<userinfo>(?:[-\w.~!$&'()*+,;=:]|%[\dA-F]{2})*))\k<userinfo>@)?(?=(?<host>\[[\dA-F:.]{2,}\]|(?:[-\w.~!$&'()*+,;=]|%[\dA-F]{2})*))\k<host>(?::(?=(?<port>\d*))\k<port>)?)(?<path1>\/(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\7)?|(?<path2>\/?(?!\/)(?=((?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\9)?)(?:\?(?=(?<query>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<query>)?(?:#(?=(?<fragment>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<fragment>)?$/i;
347+
346348
/^(?=(?<scheme>[a-z][a-z\d+.-]*))\k<scheme>:(?:\/\/(?<authority>(?:(?=(?<userinfo>(?:[-\w.~!$&'()*+,;=:]|%[\dA-F]{2})*))\k<userinfo>@)?(?=(?<host>\[[\dA-F:.]{2,}\]|(?:[-\w.~!$&'()*+,;=]|%[\dA-F]{2})*))\k<host>(?::(?=(?<port>\d*))\k<port>)?)(?<path1>\/(?=(?<_path1>(?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\k<_path1>)?|(?<path2>\/?(?!\/)(?=(?<_path2>(?:[-\w.~!$&'()*+,;=:@/]|%[\dA-F]{2})*))\k<_path2>)?)(?:\?(?=(?<query>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<query>)?(?:#(?=(?<fragment>(?:[-\w.~!$&'()*+,;=:@/?]|%[\dA-F]{2})*))\k<fragment>)?$/i;

0 commit comments

Comments
 (0)