# Directionality

Part of the HebrewCore documentation. Web: https://hc.itsbaba.com/docs#directionality · Whole docs: https://hc.itsbaba.com/docs.md · Index: https://hc.itsbaba.com/llms.txt

The defining feature of HebrewCore is structured directionality. For any string, the API returns:

| Field | Description |
| --- | --- |
| `dir` | Paragraph base direction, `"rtl"` or `"ltr"`. With `base:"auto"` this follows the Unicode first-strong rule, matching CSS `dir="auto"`. |
| `mixed` | `true` when the text contains both strong RTL and strong LTR characters (invisible bidi marks and digits do not count). |
| `lang` | Best-effort BCP-47 language from the dominant script (e.g. `he`, `en`). |
| `script` | Dominant ISO-15924 script (`Hebr`, `Latn`, `Arab`, …). |
| `runs[]` | Maximal same-direction segments in logical order. Each run has `text`, `dir`, `script`, `lang`, `start`, and `end` (UTF-16 offsets, `end` exclusive, so `text.slice(start,end)` reproduces the run). |

Example: `"שלום world"` resolves to two runs you can render independently:

- `שלום`: rtl · he · Hebr · 0–5
- `world`: ltr · en · Latn · 5–10

For display, use `display_runs` or `/v1/wrap`. They keep every left-to-right unit whole, so a price, a range such as "10–20%", a date, a model number or a comparison such as "<5" never splits or mirrors inside a Hebrew line.

`/v1/analyze`, `/v1/detect`, `/v1/wrap`, and `/v1/strip-nikud` are deterministic, run with no language model, and do not consume your character quota.
