Skip to content

Commit

Permalink
Made the code no-std and also made most of the code const!
Browse files Browse the repository at this point in the history
this crate is now no-std and also so many of the functions now are const, you can even create a ArabicReshaper fully const now!
1.5.0 changes:
    - no-std
    - const as much functions as possible.
    - switched to BTreeMap from HashMap in reshaper because alloc dont have a HashMap.
    - added a new field named default_ligatures to LigaturesFlags for adding just default ones if needed.
    - updated all the dependecies.
  • Loading branch information
YouKnow-sys committed Jan 20, 2024
1 parent 357f86b commit 4b686af
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 83 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Build
run: cargo build --verbose
run: cargo build --all-features --verbose
- name: Run tests
run: cargo test --verbose
run: cargo test --all-features --verbose
- name: Clippy
run: cargo clippy --verbose -- -D warnings
run: cargo clippy --all-features --verbose -- -D warnings
- name: Audit
run: cargo audit
run: cargo audit --all-features
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
[package]
name = "ar-reshaper"
version = "1.3.1"
version = "1.5.0"
authors = ["Saeid Ghafari <[email protected]>"]
edition = "2021"
description = "Reconstruct Arabic sentences to be used in applications that don't support Arabic script."
description = "A no-std crate to reconstruct Arabic, turkish and persian sentences to be used in applications that don't support Arabic script."
repository = "https://github.com/YouKnow-sys/ar-reshaper"
documentation = "https://docs.rs/ar-reshaper"
license = "MIT"
keywords = ["arabic", "persian", "turkish", "reshape"]
keywords = ["arabic", "persian", "turkish", "reshape", "no-std", "no_std"]
readme = "README.md"
categories = ["algorithms"]

[features]
default = []
default = ["ttf-parser"]

[dependencies]
serde = { version = "1.0", features = ["derive"], optional = true }
ttf-parser = { version = "0.19", optional = true }
ttf-parser = { version = "0.20", optional = true }

[[example]]
name = "reshape_line"
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Arabic Reshaper Rust

[![Latest version](https://img.shields.io/crates/v/ar-reshaper)](https://crates.io/crates/ar-reshaper)
[![Documentation](https://docs.rs/ar-reshaper/badge.svg)](https://docs.rs/ar-reshaper)
[![Build Status](https://github.com/YouKnow-sys/ar-reshaper/actions/workflows/rust.yml/badge.svg)](https://github.com/YouKnow-sys/ar-reshaper/actions?workflow=Rust%20CI)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
[![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/YouKnow-sys/ar-reshaper/blob/master/LICENSE)

Reconstruct Arabic sentences to be used in applications that don't support Arabic script.
A **no-std** crate to reconstruct Arabic, Turkish and Persian sentences to be used in applications that don't support Arabic script.

# Usage:

resahpe a single line of string

```rust
use ar_reshaper::{ArabicReshaper, reshape_line};

Expand All @@ -21,7 +24,9 @@ println!("{}", reshaper.reshape("سلام دنیا"));
println!("{}", reshape_line("سلام دنیا"));
// Both will reconstruct the string and print `ﺳﻼﻡ ﺩﻧﯿﺎ`
```

reshape a slice of strings

```rust
use ar_reshaper::ArabicReshaper;

Expand All @@ -35,20 +40,29 @@ let lines = [
println!("{:#?}", reshaper.reshape_lines(lines));
// or you can just use reshape method in a loop... the choice is yours.
```

reshape strings on a iterator

```rust
use ar_reshaper::prelude::*;

for line in ["یک", "دو"].iter().reshape_default() {
println!("{line}");
}
```
You can check **example** or **test** directory for more examples.

You can check [**examples**](https://github.com/YouKnow-sys/ar-reshaper/examples) or [**tests**](https://github.com/YouKnow-sys/ar-reshaper/tests) directory for more examples.

# features:

- **serde**: if this feature is enabled the `ReshaperConfig` can be serialized and de-serialized using serde.
- **ttf-parser**: if you enable this feature the `ReshaperConfig` method will have another extra
method named `from_font` that can be used to enable ligatures only if they exist in the input font.
method named `from_font` that can be used to enable ligatures only if they exist in the input font.

## notes:

- keep in mind that this crate need a allocator to work, because we depend on `alloc` internally.

## Credits:
this project is based on the awesome [`python-arabic-reshaper`](https://github.com/mpcabd/python-arabic-reshaper).

this project is based on the awesome [`python-arabic-reshaper`](https://github.com/mpcabd/python-arabic-reshaper).
Loading

0 comments on commit 4b686af

Please sign in to comment.