Enum teloxide::types::ParseMode[][src]

pub enum ParseMode {
    MarkdownV2,
    Html,
    Markdown,
}

Formatting options.

The Bot API supports basic formatting for messages. You can use bold, italic, underlined and strikethrough text, as well as inline links and pre-formatted code in your bots’ messages. Telegram clients will render them accordingly. You can use either markdown-style or HTML-style formatting.

Note that Telegram clients will display an alert to the user before opening an inline link (‘Open this link?’ together with the full URL).

Links tg://user?id=<user_id> can be used to mention a user by their ID without using a username. Please note:

  • These links will work only if they are used inside an inline link. For example, they will not work, when used in an inline keyboard button or in a message text.
  • These mentions are only guaranteed to work if the user has contacted the bot in the past, has sent a callback query to the bot via inline button or is a member in the group where he was mentioned.

MarkdownV2 style

To use this mode, pass MarkdownV2 in the parse_mode field. Use the following syntax in your message:

*bold \*text*
_italic \*text_
__underline__
~strikethrough~
*bold _italic bold ~italic bold strikethrough~ __underline italic bold___ bold*
[inline URL](http://www.example.com/)
[inline mention of a user](tg://user?id=123456789)
`inline fixed-width code`
```
pre-formatted fixed-width code block
```
```rust
pre-formatted fixed-width code block written in the Rust programming
language ```

Please note:

  • Any character between 1 and 126 inclusively can be escaped anywhere with a preceding ’' character, in which case it is treated as an ordinary character and not a part of the markup.
  • Inside pre and code entities, all ’`‘ and ’\‘ characters must be escaped with a preceding ’' character.
  • Inside (...) part of inline link definition, all ’)‘ and ’\‘ must be escaped with a preceding ’' character.
  • In all other places characters ’_‘, ’*‘, ’[‘, ’]‘, ’(‘, ’)‘, ’~‘, ’`‘, ’>‘, ’#‘, ’+‘, ’+‘, ’-‘, ’|‘, ’{‘, ’}‘, ’.‘, ’!‘ must be escaped with the preceding character ’'.
  • In case of ambiguity between italic and underline entities ‘__’ is always greadily treated from left to right as beginning or end of underline entity, so instead of ___italic underline___ use ___italic underline_\r__, where \r is a character with code 13, which will be ignored.

HTML style

To use this mode, pass Html in the parse_mode field. The following tags are currently supported:

<b>bold</b>, <strong>bold</strong>
<i>italic</i>, <em>italic</em>
<u>underline</u>, <ins>underline</ins>
<s>strikethrough</s>, <strike>strikethrough</strike>,
<del>strikethrough</del> <b>bold <i>italic bold <s>italic bold
strikethrough</s> <u>underline italic bold</u></i> bold</b> <a href="http:// www.example.com/">inline URL</a>
<a href="tg:// user?id=123456789">inline mention of a user</a>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
<pre><code class="language-rust">pre-formatted fixed-width code block
written in the Rust programming language</code></pre> ````

Please note:

- Only the tags mentioned above are currently supported.
- All `<`, `>` and `&` symbols that are not a part of a tag or an HTML
  entity must be replaced with the corresponding HTML entities (`<` with
  `&lt;`, `>` with `&gt;` and `&` with `&amp;`).
- All numerical HTML entities are supported.
- The API currently supports only the following named HTML entities: `&lt;`,
  `&gt;`, `&amp;` and `&quot;`.
- Use nested `pre` and `code` tags, to define programming language for `pre`
  entity.
- Programming language can't be specified for standalone `code` tags.

## Markdown style
This is a legacy mode, retained for backward compatibility. To use this
mode, pass [`Markdown`] in the `parse_mode` field.
Use the following syntax in your message:
````text
*bold text*
_italic text_
[inline URL](http://www.example.com/)
[inline mention of a user](tg://user?id=123456789)
`inline fixed-width code`
```rust
pre-formatted fixed-width code block written in the Rust programming
language ```

Please note:

  • Entities must not be nested, use parse mode MarkdownV2 instead.
  • There is no way to specify underline and strikethrough entities, use parse mode MarkdownV2 instead.
  • To escape characters ’_‘, ’*‘, ’`‘, ’[‘ outside of an entity, prepend the characters ’' before them.
  • Escaping inside entities is not allowed, so entity must be closed first and reopened again: use _snake_\__case_ for italic snake_case and *2*\**2=4* for bold 2*2=4.

Variants

MarkdownV2
Html
Markdown
👎 Deprecated:

This is a legacy mode, retained for backward compatibility. Use MarkdownV2 instead.

Trait Implementations

impl Clone for ParseMode[src]

impl Copy for ParseMode[src]

impl Debug for ParseMode[src]

impl<'de> Deserialize<'de> for ParseMode[src]

impl Eq for ParseMode[src]

impl FromStr for ParseMode[src]

type Err = ()

The associated error which can be returned from parsing.

impl Hash for ParseMode[src]

impl PartialEq<ParseMode> for ParseMode[src]

impl Serialize for ParseMode[src]

impl StructuralEq for ParseMode[src]

impl StructuralPartialEq for ParseMode[src]

impl<'_> TryFrom<&'_ str> for ParseMode[src]

type Error = ()

The type returned in the event of a conversion error.

impl TryFrom<String> for ParseMode[src]

type Error = ()

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CallHasher for T where
    T: Hash

impl<T> CallHasher for T where
    T: Hash + ?Sized

impl<T> Conv for T

impl<T> Conv for T

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

type Remainder = Choices

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U, I> LiftInto<U, I> for T where
    U: LiftFrom<T, I>, 

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<Source> Sculptor<HNil, HNil> for Source

type Remainder = Source

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.