# `MishkaDocument.ContentText`
[🔗](https://github.com/mishka-group/mishka_document/blob/v0.0.1/lib/mishka_document/content_text.ex#L5)

The text a page's or a note's HTML content reads as, without its markup: what its card, its row
and its drafts preview, what its words are counted in, and what its search description is cut
from (`MishkaDocument.Plugins.PageSeo`).

Every tag reads as a space, so two paragraphs stay two words apart, and the entities the
sanitizer writes are read back.

    iex> MishkaDocument.ContentText.text(~s(<p dir="auto">Tom &amp; Jerry</p><p>ran</p>))
    "Tom & Jerry ran"

# `preview`

```elixir
@spec preview(term(), pos_integer()) :: String.t() | nil
```

The first `length` characters of `text/1`; `nil` when the content reads as nothing.

    iex> MishkaDocument.ContentText.preview("<p>Getting started</p>", 7)
    "Getting"

    iex> MishkaDocument.ContentText.preview("<p> </p>", 7)
    nil

# `text`

```elixir
@spec text(term()) :: String.t()
```

`html` without its tags, its entities read and its whitespace run into single spaces, on one line.
`""` for no content.

    iex> MishkaDocument.ContentText.text(nil)
    ""

# `word_count`

```elixir
@spec word_count(term()) :: non_neg_integer()
```

How many words `text/1` holds.

    iex> MishkaDocument.ContentText.word_count(~s(<p dir="auto">One two</p><p>three</p>))
    3

---

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