Skip to content

Commit

Permalink
Update docs and release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
pemistahl committed Jul 26, 2023
1 parent f0a3e3c commit 65ba51a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 48 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ keywords = ["pattern", "regex", "regexp"]
crate-type = ["cdylib", "rlib"]

[dependencies]
clap = { version = "4.3.19", features = ["derive", "wrap_help"], optional = true }
itertools = "0.11.0"
lazy_static = "1.4.0"
ndarray = "0.15.6"
Expand All @@ -42,6 +41,9 @@ unic-char-range = "0.9.0"
unic-ucd-category = "0.9.0"
unicode-segmentation = "1.10.1"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
clap = { version = "4.3.19", features = ["derive", "wrap_help"], optional = true }

[target.'cfg(target_family = "wasm")'.dependencies]
wasm-bindgen = "0.2.87"

Expand Down
78 changes: 34 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
![grex](logo.png)
<div align="center">

<br>
![grex](https://raw.githubusercontent.com/pemistahl/grex/main/logo.png)

[![build](https://github.com/pemistahl/grex/actions/workflows/build.yml/badge.svg)](https://github.com/pemistahl/grex/actions/workflows/build.yml)
[![dependency status](https://deps.rs/crate/grex/1.4.1/status.svg)](https://deps.rs/crate/grex/1.4.1)
[![codecov](https://codecov.io/gh/pemistahl/grex/branch/main/graph/badge.svg)](https://codecov.io/gh/pemistahl/grex)
[![lines of code](https://tokei.rs/b1/github/pemistahl/grex?category=code)](https://github.com/XAMPPRocky/tokei)
[![Downloads](https://img.shields.io/crates/d/grex.svg)](https://crates.io/crates/grex)
<br>

[![Docs.rs](https://docs.rs/grex/badge.svg)](https://docs.rs/grex)
[![Crates.io](https://img.shields.io/crates/v/grex.svg)](https://crates.io/crates/grex)
[![Lib.rs](https://img.shields.io/badge/lib.rs-v1.4.1-blue)](https://lib.rs/crates/grex)
[![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![build status](https://github.com/pemistahl/grex/actions/workflows/build.yml/badge.svg)](https://github.com/pemistahl/grex/actions/workflows/build.yml)
[![docs.rs](https://docs.rs/grex/badge.svg)](https://docs.rs/grex)
[![codecov](https://codecov.io/gh/pemistahl/grex/branch/main/graph/badge.svg)](https://codecov.io/gh/pemistahl/grex)
[![dependency status](https://deps.rs/crate/grex/1.4.2/status.svg)](https://deps.rs/crate/grex/1.4.2)
[![demo](https://img.shields.io/badge/-Demo%20Website-orange?logo=HTML5&labelColor=white)](https://pemistahl.github.io/grex-js/)

[![downloads](https://img.shields.io/crates/d/grex.svg)](https://crates.io/crates/grex)
[![crates.io](https://img.shields.io/crates/v/grex.svg)](https://crates.io/crates/grex)
[![lib.rs](https://img.shields.io/badge/lib.rs-v1.4.2-blue)](https://lib.rs/crates/grex)
[![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

[![Linux Download](https://img.shields.io/badge/Linux%20Download-v1.4.1-blue?logo=Linux)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-x86_64-unknown-linux-musl.tar.gz)
[![MacOS Download](https://img.shields.io/badge/macOS%20x86%20Download-v1.4.1-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-x86_64-apple-darwin.tar.gz)
[![MacOS ARM Download](https://img.shields.io/badge/macOS%20ARM%20Download-v1.4.1-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-aarch64-apple-darwin.tar.gz)
[![Windows Download](https://img.shields.io/badge/Windows%20Download-v1.4.1-blue?logo=Windows)](https://github.com/pemistahl/grex/releases/download/v1.4.1/grex-v1.4.1-x86_64-pc-windows-msvc.zip)
[![Linux Download](https://img.shields.io/badge/Linux%20Download-v1.4.2-blue?logo=Linux)](https://github.com/pemistahl/grex/releases/download/v1.4.2/grex-v1.4.2-x86_64-unknown-linux-musl.tar.gz)
[![MacOS Download](https://img.shields.io/badge/macOS%20x86%20Download-v1.4.2-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.2/grex-v1.4.2-x86_64-apple-darwin.tar.gz)
[![MacOS ARM Download](https://img.shields.io/badge/macOS%20ARM%20Download-v1.4.2-blue?logo=Apple)](https://github.com/pemistahl/grex/releases/download/v1.4.2/grex-v1.4.2-aarch64-apple-darwin.tar.gz)
[![Windows Download](https://img.shields.io/badge/Windows%20Download-v1.4.2-blue?logo=Windows)](https://github.com/pemistahl/grex/releases/download/v1.4.2/grex-v1.4.2-x86_64-pc-windows-msvc.zip)
</div>

<br>

![grex demo](demo.gif)
![grex demo](https://raw.githubusercontent.com/pemistahl/grex/main/demo.gif)

<br>

Expand Down Expand Up @@ -77,8 +80,8 @@ an initial correct regex which should be inspected by hand if further optimizati
- case-sensitive or case-insensitive matching
- capturing or non-capturing groups
- optional anchors `^` and `$`
- fully compliant to newest [Unicode Standard 14.0](https://unicode.org/versions/Unicode14.0.0)
- fully compatible with [*regex* crate 1.6.0+](https://crates.io/crates/regex)
- fully compliant to [Unicode Standard 15.0](https://unicode.org/versions/Unicode15.0.0)
- fully compatible with [*regex* crate 1.9.0+](https://crates.io/crates/regex)
- correctly handles graphemes consisting of multiple Unicode symbols
- reads input strings from the command-line or from a file
- produces more readable expressions indented on multiple using optional verbose mode
Expand Down Expand Up @@ -109,11 +112,11 @@ In order to use *grex* as a library, simply add it as a dependency to your `Carg

```toml
[dependencies]
grex = { version = "1.4.1", default-features = false }
grex = { version = "1.4.2", default-features = false }
```

The dependencies `clap` and `atty` are only needed for the command-line tool.
By disabling the default features, the download and compilation of these dependencies is prevented for the library.
The dependency *clap* is only needed for the command-line tool.
By disabling the default features, the download and compilation of clap is prevented for the library.

## 5. How to use?

Expand All @@ -130,7 +133,7 @@ The following table shows all available flags and options:
```
$ grex -h
grex 1.4.1
grex 1.4.2
© 2019-today Peter M. Stahl <pemistahl@gmail.com>
Licensed under the Apache License, Version 2.0
Downloadable from https://crates.io/crates/grex
Expand Down Expand Up @@ -194,8 +197,8 @@ Miscellaneous Options:

#### 5.2.1 Default settings

Test cases are passed either from a collection via [`RegExpBuilder::from()`](https://docs.rs/grex/1.4.1/grex/struct.RegExpBuilder.html#method.from)
or from a file via [`RegExpBuilder::from_file()`](https://docs.rs/grex/1.4.1/grex/struct.RegExpBuilder.html#method.from_file).
Test cases are passed either from a collection via [`RegExpBuilder::from()`](https://docs.rs/grex/1.4.2/grex/struct.RegExpBuilder.html#method.from)
or from a file via [`RegExpBuilder::from_file()`](https://docs.rs/grex/1.4.2/grex/struct.RegExpBuilder.html#method.from_file).
If read from a file, each test case must be on a separate line. Lines may be ended with either a newline `\n` or a carriage
return with a line feed `\r\n`.

Expand Down Expand Up @@ -357,21 +360,6 @@ let regexp = RegExpBuilder::from(&["a", "aa", "aaa"])
assert_eq!(regexp, "a(?:aa?)?");
```

#### 5.2.9 Syntax highlighting

⚠ The method `with_syntax_highlighting()` may only be used if the resulting regular expression is meant to
be printed to the console. It is mainly meant to be used for the command-line tool output.
The regex string representation returned from enabling this setting cannot be fed into the
[*regex* crate](https://crates.io/crates/regex).

```rust
use grex::RegExpBuilder;

let regexp = RegExpBuilder::from(&["a", "aa", "123"])
.with_syntax_highlighting()
.build();
```

### 5.3 Examples

The following examples show the various supported regex syntax features:
Expand Down Expand Up @@ -487,6 +475,7 @@ $ grex -drswW <INPUT>
In order to build the source code yourself, you need the
[stable Rust toolchain](https://www.rust-lang.org/tools/install) installed on your machine
so that [*cargo*](https://doc.rust-lang.org/cargo/), the Rust package manager is available.
**Please note**: Rust >= 1.70.0 is required to build the CLI. For the library part, Rust < 1.70.0 is sufficient.

```shell
git clone https://github.com/pemistahl/grex.git
Expand Down Expand Up @@ -515,7 +504,7 @@ in any JavaScript-based project, be it in the browser or in the back end running
The easiest way to compile is to use [`wasm-pack`](https://rustwasm.github.io/wasm-pack). After the installation,
you can, for instance, build the library with the web target so that it can be directly used in the browser:

wasm-pack build --target web -- --no-default-features
wasm-pack build --target web

This creates a directory named `pkg` on the top-level of this repository, containing the compiled wasm files
and JavaScript and TypeScript bindings. In an HTML file, you can then call *grex* like the following, for instance:
Expand All @@ -533,7 +522,7 @@ and JavaScript and TypeScript bindings. In an HTML file, you can then call *grex
There are also some integration tests available both for Node.js and for the browsers Chrome, Firefox and Safari.
To run them, simply say:

wasm-pack test --node --headless --chrome --firefox --safari -- --no-default-features
wasm-pack test --node --headless --chrome --firefox --safari

If the tests fail to start in Safari, you need to enable Safari's web driver first by running:

Expand All @@ -544,6 +533,10 @@ allows to add further JavaScript-related configuration, tests and documentation.
[npm registry](https://www.npmjs.com) as well, allowing for an easy download and installation within every JavaScript
or TypeScript project.

There is a [demo website](https://pemistahl.github.io/grex-js/) available where you can give grex a try.

![demo website](https://raw.githubusercontent.com/pemistahl/grex/main/website.jpg)

## 8. How does it work?

1. A [deterministic finite automaton](https://en.wikipedia.org/wiki/Deterministic_finite_automaton) (DFA)
Expand All @@ -562,9 +555,6 @@ Take a look at the [planned issues](https://github.com/pemistahl/grex/milestone/

## 10. Contributions

- [Krzysztof Zawisła](https://github.com/KrzysztofZawisla) has written JavaScript bindings. Check out [grex.js](https://github.com/KrzysztofZawisla/grex.js).
- [Maciej Gryka](https://github.com/maciejgryka) has created [https://regex.help](https://regex.help) where you can try out *grex* in your browser.

In case you want to contribute something to *grex*, I encourage you to do so.
Do you have ideas for cool features? Or have you found any bugs so far?
Feel free to open an issue or send a pull request. It's very much appreciated. :-)
17 changes: 17 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## grex 1.4.2 (released on 26 Jul 2023)

### Improvements
- All characters from the current Unicode standard 15.0 are now fully supported. (#128)
- A proper exit code is now returned if the provided user input cannot be handled by the CLI.
Big thanks to @spenserblack for the respective pull request. (#165)

### Changes
- It is not possible anymore to call `RegExpBuilder.with_syntax_highlighting()` in the library
as it only makes sense for the CLI.
- The dependency `atty` has been removed in favor of `std::io::IsTerminal` in Rust >= 1.70.0.
As a result, Rust >= 1.70.0 is now needed to compile the CLI.
- All remaining dependencies have been updated to their latest versions.

### Bug Fixes
- Several bugs have been fixed that caused incorrect expressions to be generated in rare cases.

## grex 1.4.1 (released on 21 Oct 2022)

### Changes
Expand Down
2 changes: 2 additions & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ impl RegExpBuilder {
/// ⚠ This method may only be used if the resulting regular expression is meant to
/// be printed to the console. The regex string representation returned from enabling
/// this setting cannot be fed into the [*regex*](https://crates.io/crates/regex) crate.
#[cfg(feature = "cli")]
#[doc(hidden)]
pub fn with_syntax_highlighting(&mut self) -> &mut Self {
self.config.is_output_colorized = true;
self
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@
//! - case-sensitive or case-insensitive matching
//! - capturing or non-capturing groups
//! - optional anchors `^` and `$`
//! - fully compliant to newest [Unicode Standard 14.0](https://unicode.org/versions/Unicode14.0.0)
//! - fully compatible with [*regex* crate 1.6.0+](https://crates.io/crates/regex)
//! - fully compliant to [Unicode Standard 15.0](https://unicode.org/versions/Unicode15.0.0)
//! - fully compatible with [*regex* crate 1.9.0+](https://crates.io/crates/regex)
//! - correctly handles graphemes consisting of multiple Unicode symbols
//! - reads input strings from the command-line or from a file
//! - produces more readable expressions indented on multiple using optional verbose mode
//! - optional syntax highlighting for nicer output in supported terminals
//!
//! ## 4. How to use?
//!
Expand Down
9 changes: 9 additions & 0 deletions tests/cli_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ mod digit_conversion {
.success()
.stdout(predicate::eq("^(abc|def)$\n"));
}

#[test]
fn succeeds_with_syntax_highlighting() {
let mut grex = init_command();
grex.args(&["--colorize", "abc", "def"]);
grex.assert()
.success()
.stdout(predicate::eq("\u{1b}[1;33m^\u{1b}[0m\u{1b}[1;32m(?:\u{1b}[0mabc\u{1b}[1;31m|\u{1b}[0mdef\u{1b}[1;32m)\u{1b}[0m\u{1b}[1;33m$\u{1b}[0m\n"));
}
}

mod repetition {
Expand Down
Binary file added website.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 65ba51a

Please sign in to comment.