slevithan / regex-colorizer Goto Github PK
View Code? Open in Web Editor NEWHighlighter for JavaScript regex syntax
Home Page: https://slevithan.github.io/regex-colorizer/demo/
License: MIT License
Highlighter for JavaScript regex syntax
Home Page: https://slevithan.github.io/regex-colorizer/demo/
License: MIT License
It would be nice to be able to highlight regex comments explicitly with this, since I'm using this lib to highlight a regex that I split into parts, and indent and comment to explain. Something like the #
character perhaps.
Thanks for the awesome library! I might even just do it myself and send a PR, we'll see :)
I'd prefer not to minify this library myself, especially since minifiers can introduce their own issues.
Could you provide a minified version of your code in the code base?
When using flag u
, Regex Colorizer (as of v1.0.0) uses a simplistic regex to identify Unicode properties with \p{...}
and \P{...}
. It would be better to flag any values that are not actually supported by ECMAScript.
@mathiasbynens has a bunch of great, related libraries. See:
Not yet sure which of these are the most relevant.
v
(ES2024).options
argument used by colorizeAll
and colorizePattern
:
flavor
- Ex: 'JavaScript'
, 'EMCAScript'
(alternative name: 'JavaScript-WithoutWebReality'
), 'PCRE'
, 'XRegExp'
.
'JavaScript'
.version
is not provided.version
- Regex flavor version. Ex: JavaScript/ECMAScript: '3'
, '5'
, '2024'
; PCRE: '8.45'
, '10.39'
.
'latest'
.flavor
is not provided.'JavaScript'
+'2024'
, it sets of bunch of feature flags, and parsing code can check for the feature flags rather than flavor/version. New flavor versions can then just augment existing objects of feature flags.format
- Options: '...'
(default), '/.../flags'
, and maybe others.
'/.../flags'
allows:
/
in regex literals. Note: ES5 included a change to allow unescaped [/]
in regex literals.format
and flags
are provided.warningsOn
- On by default? Ex: ||
at top level, range overflow, quantified lookaround, incomplete tokens \c
,\x
,\u
.compatibilityOn
- For differences in behavior for the same syntax across regex flavors (not for when some flavors don't support a feature). Ex: Empty char classes []
, [^]
(JS), leading unescaped ]
in char classes (non-JS).suggestionsOn
- Ex: Use of octals, escaped literals, [0-9]
โ \d
(for flavors where \d
is ASCII only), [\S\s]
โ dot with /s
(if /s
is active or no existing dots).options
argument, with flavor
, version
, format
).The named group is the most required part.
http://xregexp.com/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.