1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! # ArabicReshaper
//! 
//! Reconstruct Arabic sentences to be used in applications that don't support Arabic script.
//! 
//! ## Usage:
//! ```
//! use ar_reshaper::{ArabicReshaper, reshape_line};
//! 
//! let reshaper = ArabicReshaper::default();
//! 
//! // You can reshape just a single string using
//! println!("{}", reshaper.reshape("سلام دنیا"));
//! // or [`reshape_line`] method if you dont want to construct the [ArabicReshaper]
//! // and you just want to reshape a line with default settings
//! println!("{}", reshape_line("سلام دنیا"));
//! // Both will reconstruct the string and print `ﺳﻼﻡ ﺩﻧﯿﺎ`
//! 
//! // Or a slice of strings
//! println!("{:#?}", reshaper.reshape_lines(&["سلام خوبی؟", "عالیم ممنون"]));
//! // this will reconstruct the string and print  ["ﺳﻼﻡ ﺧﻮﺑﯽ؟", "ﻋﺎﻟﯿﻢ ﻣﻤﻨﻮﻥ"]
//! ```
//! 
//! A rusty rewrite of [python-arabic-reshaper](https://github.com/mpcabd/python-arabic-reshaper)
//! You can check the original repository for more information.

pub use config::*;
pub use ligatures::LigatureNames;
pub use reshaper::ArabicReshaper;

mod config;
mod letters;
mod ligatures;
mod reshaper;
#[cfg(test)]
mod tests;

/// Reshape the given text with the default [ArabicReshaper] configuration.\
/// Keep in mind that if you want to reshape a large amount of lines its better
/// to first create a [ArabicReshaper] and use the [`ArabicReshaper::reshape`]
/// instead.
/// 
/// [`reshape`]: ArabicReshaper::reshape
pub fn reshape_line<S>(text: S) -> String
where
    S: AsRef<str>,
{
    let reshaper = ArabicReshaper::default();

    reshaper.reshape(text)
}