gemini_text_line (gemini_text v3.0.2)
Classify a single line of Gemini text.
This module is internal to gemini_text: it knows nothing about
documents, line endings or preformatted state. Only tag/1,
pref_marker/1 and alt_text/1 are public.
Summary
Types
What tag/1 returns: any element except a preformatted block, that is
{h1 | h2 | h3 | para | list_item | quote, Text}, {link, Url, Label}
or blank.
A link: {link, Url, Label}. Label may be empty.
Functions
Return the alt text following the opening fence of a preformatted block, trimmed of spaces and tabs.
Is the line a preformatted-block fence (does it start with three backticks)?
Classify a single line.
Types
-type line_element() :: simple_line() | link_line() | blank.
What tag/1 returns: any element except a preformatted block, that is
{h1 | h2 | h3 | para | list_item | quote, Text}, {link, Url, Label}
or blank.
A link: {link, Url, Label}. Label may be empty.
-type simple_line() :: {simple_tag(), binary()}.
-type simple_tag() :: h1 | h2 | h3 | para | list_item | quote.
Functions
Return the alt text following the opening fence of a preformatted block, trimmed of spaces and tabs.
The line must start with three backticks.
Is the line a preformatted-block fence (does it start with three backticks)?
True for both the opening and the closing fence.
-spec tag(Arg) -> Result when Arg :: binary(), Result :: line_element().
Classify a single line.
Returns blank, {h1 | h2 | h3 | para | list_item | quote, Text} or
{link, Url, Label}.
Heading captions and link labels are trimmed of spaces and tabs, and
the space after # or => is optional. A fourth # is part of an h3
caption. Leading whitespace is significant, so an indented # or =>
line is a para.
A list item needs * (with the space); its text is what follows,
trimmed of spaces and tabs. A quote is > followed by its text, trimmed
likewise, so one optional space after the > is dropped; a lone > is
{quote, <<>>}. A lone * is a para.
The preformatted state is not known here, so a fence line is returned as
a para.