View Source Telegex.Tools (Telegex v1.8.0)
Some utility functions.
Summary
Types
@type markdown_from() :: :text | :inline_link | :pre | :code | :pre_or_code
Functions
@spec gen_secret_token(non_neg_integer()) :: String.t()
Generate a secret token string.
By default, it generates 16 bytes of data and converts it to a 16-digit hexadecimal string (32 characters long).
The bytes_count
parameter can be passed to control the length of the generated string.
@spec safe_markdown(String.t(), markdown_from()) :: String.t()
Generate safe Markdown content.
Examples
iex> Telegex.Tools.safe_markdown("'_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'")
~S"'\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'"
iex> Telegex.Tools.safe_markdown(~S{https://t.me\)}, :inline_link)
~S|https://t.me\\\)|
iex> Telegex.Tools.safe_markdown(~S{IO.puts `Hello`}, :pre_or_code)
~S|IO.puts \`Hello\`|