a
    /3e!                     @   s  d Z ddlZddlZddlmZ ddddZeedd	d
ZeedddZd4eee	 edddZ
d5eee	 edddZd6eee	 edddZd7eee	 edddZd8eee	 edddZd9eee	 edddZd:eee	 edddZd;eee	 edddZd<eee	 eddd Zd=eee	 edd!d"Zd>eeee	 ed#d$d%Zd?eeee	 ed#d&d'Zd@eeee	 ed)d*d+ZdAeee	 edd,d-ZdBeee	 eed.d/d0Zeed1d2d3ZdS )Cz@
Markdown & HTML formatting functions.

.. versionadded:: 4.5.1
    N)Optional
)	separatorc                 G   s
   |  |S )a  
    Formats a list of strings into a single string.

    .. code:: python3

        format_text( # just an example
            mbold('Hello'),
            mitalic('World')
        )

    :param args: Strings to format.
    :type args: :obj:`str`

    :param separator: The separator to use between each string.
    :type separator: :obj:`str`

    :return: The formatted string.
    :rtype: :obj:`str`
    )join)r   args r   E/home/pi/bot/my_env/lib/python3.9/site-packages/telebot/formatting.pyformat_text   s    r	   )contentreturnc                 C   s
   t | S )z
    Escapes HTML characters in a string of HTML.

    :param content: The string of HTML to escape.
    :type content: :obj:`str`

    :return: The escaped string.
    :rtype: :obj:`str`
    )htmlescape)r
   r   r   r   escape_html&   s    
r   c                 C   s    t dd| }t dd|}|S )z
    Escapes Markdown characters in a string of Markdown.

    Credits to: simonsmh

    :param content: The string of Markdown to escape.
    :type content: :obj:`str`

    :return: The escaped string.
    :rtype: :obj:`str`
    z ([_*\[\]()~`>\#\+\-=|\.!\{\}\\])z\\\1z$\\\\([_*\[\]()~`>\#\+\-=|\.!\{\}\\])z\1)resub)r
   parseZreparser   r   r   escape_markdown3   s    r   T)r
   r   r   c                 C   s   d |rt| n| S )a(  
    Returns a Markdown-formatted bold string.

    :param content: The string to bold.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z*{}*formatr   r
   r   r   r   r   mboldE   s    r   c                 C   s   d |rt| n| S )a%  
    Returns an HTML-formatted bold string.

    :param content: The string to bold.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z	<b>{}</b>r   r   r   r   r   r   hboldU   s    r   c                 C   s   d |rt| n| S )a/  
    Returns a Markdown-formatted italic string.

    :param content: The string to italicize.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z_{}_r   r   r   r   r   mitalice   s    r   c                 C   s   d |rt| n| S )a,  
    Returns an HTML-formatted italic string.

    :param content: The string to italicize.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z	<i>{}</i>r   r   r   r   r   hitalicu   s    r   c                 C   s   d |rt| n| S )a2  
    Returns a Markdown-formatted underline string.

    :param content: The string to underline.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z__{}__r   r   r   r   r   
munderline   s    r   c                 C   s   d |rt| n| S )a0  
    Returns an HTML-formatted underline string.

    :param content: The string to underline.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`

    z	<u>{}</u>r   r   r   r   r   
hunderline   s    r   c                 C   s   d |rt| n| S )a:  
    Returns a Markdown-formatted strikethrough string.

    :param content: The string to strikethrough.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z~{}~r   r   r   r   r   mstrikethrough   s    r   c                 C   s   d |rt| n| S )a7  
    Returns an HTML-formatted strikethrough string.

    :param content: The string to strikethrough.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z	<s>{}</s>r   r   r   r   r   hstrikethrough   s    r   c                 C   s   d |rt| n| S )a.  
    Returns a Markdown-formatted spoiler string.

    :param content: The string to spoiler.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z||{}||r   r   r   r   r   mspoiler   s    r   c                 C   s   d |rt| n| S )a+  
    Returns an HTML-formatted spoiler string.

    :param content: The string to spoiler.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z<tg-spoiler>{}</tg-spoiler>r   r   r   r   r   hspoiler   s    r    )r
   urlr   r   c                 C   s   d t| |rt|n| S )a`  
    Returns a Markdown-formatted link string.

    :param content: The string to link.
    :type content: :obj:`str`

    :param url: The URL to link to.
    :type url: str

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z[{}]({})r   r
   r!   r   r   r   r   mlink   s    r#   c                 C   s   d t||rt| n| S )ad  
    Returns an HTML-formatted link string.

    :param content: The string to link.
    :type content: :obj:`str`

    :param url: The URL to link to.
    :type url: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z<a href="{}">{}</a>r   r"   r   r   r   hlink   s    r$    )r
   languager   r   c                 C   s   d ||rt| n| S )a(  
    Returns a Markdown-formatted code string.

    :param content: The string to code.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z```{}
{}```r   )r
   r&   r   r   r   r   mcode  s    r'   c                 C   s   d |rt| n| S )a%  
    Returns an HTML-formatted code string.

    :param content: The string to code.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z<code>{}</code>r   r   r   r   r   hcode  s    r(   )r
   r   r&   r   c                 C   s   d ||rt| n| S )a5  
    Returns an HTML-formatted preformatted string.

    :param content: The string to preformatted.
    :type content: :obj:`str`

    :param escape: True if you need to escape special characters. Defaults to True.
    :type escape: :obj:`bool`

    :return: The formatted string.
    :rtype: :obj:`str`
    z%<pre><code class="{}">{}</code></pre>r   )r
   r   r&   r   r   r   hpre,  s    r)   )r!   r   c                 C   s   d|  dS )z
    Hide url of an image.

    :param url: The url of the image.
    :type url: :obj:`str`
    
    :return: The hidden url.
    :rtype: :obj:`str`
    z	<a href="z">&#8288;</a>r   )r!   r   r   r   	hide_link<  s    
r*   )T)T)T)T)T)T)T)T)T)T)T)T)r%   T)T)Tr%   )__doc__r   r   typingr   r	   strr   r   boolr   r   r   r   r   r   r   r   r   r    r#   r$   r'   r(   r)   r*   r   r   r   r   <module>   s,   