From b277ad9020b37335f49c4f0af0dcfb59b62b6420 Mon Sep 17 00:00:00 2001 From: Steven Levithan Date: Fri, 25 Oct 2024 12:16:10 +0200 Subject: [PATCH] Demo tweaks --- README.md | 8 +++++++- demo/demo.js | 2 +- demo/index.html | 14 +++++++------- demo/styles.css | 4 ++++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 399ff62..1c39ec3 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ If `null`, any use of recursion throws. If an integer between `2` and `100` (and *Default: `6`.* +### `optimize` + +Simplify the generated pattern when it doesn't change the meaning. + +*Default: `true`.* + ### `target` Sets the JavaScript language version for generated patterns and flags. Later targets allow faster processing, simpler generated source, and support for additional Oniguruma features. @@ -55,7 +61,7 @@ Sets the JavaScript language version for generated patterns and flags. Later tar ## Unicode, mixed case sensitivity -Oniguruma-To-ES fully supports mixed case sensitivity (and handles its Unicode edge cases) regardless of JavaScript [target](#target). It also restricts Unicode properties to those supported by Oniguruma and the target JavaScript version. +Oniguruma-To-ES fully supports mixed case sensitivity (and handles the Unicode edge cases) regardless of JavaScript [target](#target). It also restricts Unicode properties to those supported by Oniguruma and the target JavaScript version. Oniguruma-To-ES focuses on being lightweight to make it better for use in browsers. This is partly achieved by not including heavyweight Unicode character data, which imposes a couple of minor/rare restrictions: diff --git a/demo/demo.js b/demo/demo.js index c222835..61c89d6 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -28,7 +28,7 @@ function showOutput(el) { optimize: optionOptimizeValue, target: optionTargetValue, }); - output = `/${re.source}/${re.flags}`; + output = String(re); } catch (e) { outputEl.classList.add('error'); output = `Error: ${e.message}`; diff --git a/demo/index.html b/demo/index.html index 3f5cc33..fa66ad8 100644 --- a/demo/index.html +++ b/demo/index.html @@ -19,7 +19,7 @@

Try it

- Flags: + Flags:

Try it

- Target: + target: allowBestEffort - +


+    

The output shows the result of calling toRegExp. Oniguruma-To-ES includes functions to generate additional formats: compile (returns an object with pattern and flags strings), toOnigurumaAst, and toRegexAst (for an AST based on regex). You can run all of these from the console on this page. compile and toRegExp accept pattern and flags strings and an options object. toOnigurumaAst and toRegexAst accept a pattern and flags.

diff --git a/demo/styles.css b/demo/styles.css index a24ff79..609ae1a 100644 --- a/demo/styles.css +++ b/demo/styles.css @@ -40,6 +40,10 @@ small { font-size: 0.8em; } +label, .label { + margin-right: 0.4em; +} + textarea { width: 100%; min-height: 80px;