View Source Mobilizon.Service.Formatter (Mobilizon v5.0.0-beta.1)

Formats input text to structured data, extracts mentions and hashtags.

Summary

Functions

Parses a text and replace plain text links with HTML. Returns a tuple with a result text, mentions, and hashtags.

Escapes a special characters in mention names.

Functions

Link to this function

hashtag_handler(tag_text, buffer, opts, acc)

View Source
@spec hashtag_handler(String.t(), String.t(), any(), map()) :: {String.t(), map()}
@spec html_escape(
  {text :: String.t(), mentions :: list(), hashtags :: list()},
  type :: String.t()
) :: {String.t(), list(), list()}
@spec html_escape(text :: String.t(), type :: String.t()) :: String.t()
Link to this function

linkify(text, options \\ [])

View Source
@spec linkify(
  String.t(),
  keyword()
) ::
  {String.t(), [{String.t(), Mobilizon.Actors.Actor.t()}],
   [{String.t(), String.t()}]}

Parses a text and replace plain text links with HTML. Returns a tuple with a result text, mentions, and hashtags.

Link to this function

mention_handler(arg, buffer, opts, acc)

View Source
@spec mention_handler(String.t(), String.t(), any(), map()) :: {String.t(), map()}
Link to this function

mentions_escape(text, options \\ [])

View Source
@spec mentions_escape(String.t(), Keyword.t()) :: String.t()

Escapes a special characters in mention names.

Link to this function

truncate(text, max_length \\ 200, omission \\ "...")

View Source
@spec truncate(String.t(), non_neg_integer(), String.t()) :: String.t()