-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Welcome to the API Reference for rtl-text-tools.
This section provides comprehensive documentation for every function available in the library. Click on any function name to view its detailed parameters, return types, and usage examples.
The main entry points for text detection, normalization, and all-in-one processing.
- hasRTL() — Detect if text contains Right-to-Left characters.
- hasHebrew() — Specifically detect Hebrew characters.
- fixRTL() — The main function that applies all RTL text fixes at once. (Features strict TypeScript intellisense that adapts options based on the selected language).
Detect specific RTL languages and regional scripts beyond standard Arabic and Hebrew.
- hasKurdish() — Detect Kurdish (Sorani/Kurmanji) characters.
- hasPashto() — Detect Pashto characters.
- hasSindhi() — Detect Sindhi characters.
- hasUyghur() — Detect Uyghur characters.
- hasPunjabi() — Detect Punjabi (Shahmukhi) characters.
Utilities for converting standard Latin numerals (0-9) into localized digit formats, including smart decimal handling.
-
toArabicDigits() — Convert to Arabic-Indic numerals (
٠–٩). -
toPersianDigits() — Convert to Extended Persian numerals (
۰–۹). -
toPersianDecimal() — Smart decimal conversion that safely ignores IP addresses and version numbers (e.g.,
192.168.1.1,1.2.0) to prevent unwanted conversions.
Tools for fixing, converting, and repositioning punctuation marks and brackets for proper RTL rendering.
-
convertPunctuation() — Convert
, ; ?to RTL equivalents، ؛ ؟. (Smart: Automatically skips Hebrew text to preserve Western punctuation). - fixBracket() — Convert and fix brackets for general RTL or specific Arabic contexts.
-
moveEllipsis() — Move trailing
...or…to the start of RTL text. -
toQuranicBrackets() — Convert standard brackets to Quranic brackets
﴿ ﴾for Arabic text.
Deep normalization utilities tailored for the unique typographic rules of specific RTL languages.
- normalizeArabicAlef() — Normalize various forms of Alef to the standard Alef.
- normalizeArabicYeh() — Normalize Persian/Urdu Yeh to Arabic Yeh.
- expandArabicHonorifics() — Expand common Arabic honorifics (e.g., PBUH, SWT).
- normalizePersianChars() — Fix common Persian character typos (e.g., Arabic Kaf/Yeh to Persian).
-
normalizeTehMarbuta() — Convert Arabic Teh Marbuta to Persian Heh (
ه). - removePersianDiacritics() — Strip Persian-specific diacritics (Fatha, Kasra, etc.).
- normalizeMaqaf() — Normalize Hebrew hyphens (Maqaf) to the correct Unicode character.
- fixHebrewFinalForms() — Ensure correct usage of Hebrew final letter forms (ך, ם, ן, etc.).
- normalizeHebrewQuotes() — Convert standard quotes to proper Hebrew quotation marks.
- normalizeUrduTehMarbuta() — Normalize Teh Marbuta for Urdu context.
- expandUrduHonorifics() — Expand common Urdu honorifics and abbreviations.
- removeUrduDiacritics() — Strip Urdu-specific diacritics.
Helpers for managing bidirectional (bidi) text rendering in plain-text contexts, applying CSS styles, and manipulating DOM attributes.
- wrapRTL() — Wrap text with Unicode bidi control characters to force RTL rendering.
- wrapLTR() — Wrap text with Unicode bidi control characters to force LTR rendering.
-
getRTLStyles() — Get a ready-to-use
{ direction, unicodeBidi }style object for RTL. -
getLTRStyles() — Get a ready-to-use
{ direction, unicodeBidi }style object for LTR. -
setDirAttribute() — Set
dirandlangattributes directly on DOM elements.
If you can't find what you're looking for in the API documentation, check out the FAQ & Troubleshooting page or open an issue on GitHub.
🏠 Home • 🚀 Getting Started • 📖 API Reference • 🐛 Report Issue
Made with ❤️ by Homayoun Mohammadi
If you find this project useful, please consider ⭐ starring the repo to show your support!
- 🏠 Home
- 🚀 Getting Started
- 🧩 API Overview
- 🛠️ Framework Guides
- 💡 Use Cases
- 🖥️ Browser Compatibility
- ❓ FAQ & Troubleshooting
Homayoun Mohammadi
🔗 GitHub • ✉️ Email
⭐ Love this project? Star it on GitHub to show your support!