# `Issho.Text`
[🔗](https://github.com/hattoriai/issho/blob/v0.4.2/lib/issho/text.ex#L1)

What people write, made safe to keep, to show and to give a model:
their words, without what no one sees.

Text in a room comes from people's browsers, apps and agents: comments,
names, statuses, an agent's task. Some of what a string can hold is
invisible on the page and still read by a model, or turns what is shown
around: control characters, bidirectional overrides, zero-width
characters, Unicode's tag characters (U+E0000–U+E007F, which spell
text no one sees), the variation selectors beyond the sixteen emoji use,
and private-use characters. `clean/2` takes them out and keeps the
words: letters of every script, emoji (with their joiners and their
variation selectors), line breaks where they belong.

    iex> Issho.Text.clean("Ship it\u202Eon Friday")
    "Ship iton Friday"
    iex> Issho.Text.clean("Ada\nLovelace", line: true)
    "Ada Lovelace"
    iex> Issho.Text.clean("A long title", max: 6)
    "A lon…"

Issho cleans what it keeps (a comment's body, a name, a status, a task)
and what its tools give a model (`for_model/1`), so a page cannot slip a
model instructions no person sees. Clean is not trusted: what people
wrote is still theirs, for an agent to weigh, never instructions to it.

# `clean`

```elixir
@spec clean(String.t() | nil, keyword()) :: String.t() | nil
```

The text without what no one sees, or `nil` for `nil`. Options:
`:line` (`true`: one line, its breaks and runs of spaces as one space),
`:max` (at most this many characters, the last of them "…").

# `clean?`

```elixir
@spec clean?(String.t()) :: boolean()
```

Whether the text is already clean (`clean/1` would not change it).

# `for_model`

```elixir
@spec for_model(term()) :: term()
```

A tool's result for a model: every string in it cleaned (`clean/1`),
through maps and lists, keys too. For what people wrote and an agent
reads (comments, names, statuses, events), not for a document whose
offsets an agent edits by.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
