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 & Jerry</p><p>ran</p>))
"Tom & Jerry ran"
Summary
Functions
@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
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)
""
@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