From f5bca8ddacd9e2edfd68a549518daff9f43c5bb3 Mon Sep 17 00:00:00 2001 From: Steven Levithan Date: Thu, 21 Nov 2024 22:49:26 +0100 Subject: [PATCH] Add flag S; Unicode \s by default --- README.md | 16 +++++++++-- demo/demo.js | 3 ++ demo/index.html | 5 ++++ src/options.js | 2 +- src/parse.js | 3 +- src/tokenize.js | 6 ++-- src/transform.js | 75 ++++++++++++++++++++++++++++++------------------ src/unicode.js | 10 ++----- 8 files changed, 77 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 47fe626..e645889 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ Disables advanced emulation that relies on returning a `RegExp` subclass, result ### `flags` -Oniguruma flags; a string with `i`, `m`, `x`, and `W` in any order (all optional). +Oniguruma flags; a string with `i`, `m`, `x`, `D`, `S`, and `W` in any order (all optional). Flags can also be specified via modifiers in the pattern. @@ -265,7 +265,7 @@ Notice that nearly every feature below has at least subtle differences from Java - Flags + Flags Supported in top-level flags and pattern modifiers @@ -312,6 +312,15 @@ Notice that nearly every feature below has at least subtle differences from Java ✔ ASCII \d, \p{Digit}, [[:digit:]]
+ + Space is ASCII + S + ✅ + ✅ + + ✔ ASCII \s, \p{Space}, [[:space:]]
+ + Word is ASCII W @@ -471,7 +480,8 @@ Notice that nearly every feature below has at least subtle differences from Java ✅ ✅ - ✔ ASCII (≠ JS)
+ ✔ Unicode by default
+ ✔ Compared to JS's Unicode \s: excludes \uFEFF, includes \x85
diff --git a/demo/demo.js b/demo/demo.js index 1880522..9a83ef6 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -11,6 +11,7 @@ const state = { m: getValue('flag-m'), x: getValue('flag-x'), D: getValue('flag-D'), + S: getValue('flag-S'), W: getValue('flag-W'), }, opts: { @@ -76,6 +77,8 @@ function showTranspiled() { state.flags.x ? 'x' : '' }${ state.flags.D ? 'D' : '' + }${ + state.flags.S ? 'S' : '' }${ state.flags.W ? 'W' : '' }`, diff --git a/demo/index.html b/demo/index.html index 3fb2a36..352132b 100644 --- a/demo/index.html +++ b/demo/index.html @@ -40,6 +40,11 @@

Try it

D Digit is ASCII +