o
    äeë  ã                   @  sŽ   d Z ddlmZ ddlZddlmZmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZmZ ddlmZ e
d	ƒ e	ƒ G d
d„ deeeƒƒZdS )zgr.Markdown() component.é    )ÚannotationsN)ÚAnyÚCallableÚLiteral)ÚdocumentÚset_documentation_group)ÚStringSerializable)Ú	ComponentÚIOComponentÚ	_Keywords)Ú
ChangeableÚ	componentc                   @  sf   e Zd ZdZ	d#dddddddœd$dd„Zd%dd„Zdd„ Zeej	ddddfd&dd„ƒZ
d'd!d"„ZdS )(ÚMarkdowna/  
    Used to render arbitrary Markdown output. Can also render latex enclosed by dollar signs.
    Preprocessing: this component does *not* accept input.
    Postprocessing: expects a valid {str} that can be rendered as Markdown.

    Demos: blocks_hello, blocks_kinematics
    Guides: key-features
    Ú FNT)ÚrtlÚlatex_delimitersÚvisibleÚelem_idÚelem_classesÚsanitize_htmlÚvalueústr | Callabler   Úboolr   ú"list[dict[str, str | bool]] | Noner   r   ú
str | Noner   úlist[str] | str | Noner   c          	      K  sH   || _ |du rddddœg}|| _|| _tj| f||||dœ|¤Ž dS )a}  
        Parameters:
            value: Value to show in Markdown component. If callable, the function will be called whenever the app loads to set the initial value of the component.
            rtl: If True, sets the direction of the rendered text to right-to-left. Default is False, which renders text left-to-right.
            latex_delimiters: A list of dicts of the form {"left": open delimiter (str), "right": close delimiter (str), "display": whether to display in newline (bool)} that will be used to render LaTeX expressions. If not provided, `latex_delimiters` is set to `[{ "left": "$", "right": "$", "display": False }]`, so only expressions enclosed in $ delimiters will be rendered as LaTeX, and in the same line. Pass in an empty list to disable LaTeX rendering. For more information, see the [KaTeX documentation](https://katex.org/docs/autorender.html).
            visible: If False, component will be hidden.
            elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
            elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
            sanitize_html: If False, will disable HTML sanitization when converted from markdown. This is not recommended, as it can lead to security vulnerabilities.
        Nú$F)ÚleftÚrightÚdisplay)r   r   r   r   )r   r   r   r
   Ú__init__)	Úselfr   r   r   r   r   r   r   Úkwargs© r#   úJD:\Projects\ConvertPro\env\Lib\site-packages\gradio/components/markdown.pyr       s   ÿû
úzMarkdown.__init__ÚyÚreturnc                 C  s   |du rdS t  |¡}|S )z|
        Parameters:
            y: markdown representation
        Returns:
            HTML rendering of markdown
        N)ÚinspectÚcleandoc)r!   r%   Zunindented_yr#   r#   r$   ÚpostprocessC   s   
zMarkdown.postprocessc                 C  s    | j | j| j| jdœt | ¡¥S )N)r   r   r   r   )r   r   r   r   r	   Ú
get_config)r!   r#   r#   r$   r*   O   s   üûzMarkdown.get_configú(Any | Literal[_Keywords.NO_VALUE] | Noneúbool | Nonec                 C  s   || |||ddœ}|S )NÚupdate)r   r   r   r   r   Z__type__r#   )r   r   r   r   r   Zupdated_configr#   r#   r$   r-   X   s   	úzMarkdown.updateÚ
input_dataÚstrc                 C  s   |   |¡}|r	|S dS )Nr   )r)   )r!   r.   Zpostprocessedr#   r#   r$   Ú
as_examplej   s   
zMarkdown.as_example)r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r%   r   r&   r   )
r   r+   r   r,   r   r,   r   r   r   r,   )r.   r   r&   r/   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r)   r*   Ústaticmethodr   ZNO_VALUEr-   r0   r#   r#   r#   r$   r      s*    þ÷
%	ûr   )r4   Ú
__future__r   r'   Útypingr   r   r   Zgradio_client.documentationr   r   Zgradio_client.serializingr   Zgradio.components.baser	   r
   r   Zgradio.eventsr   r   r#   r#   r#   r$   Ú<module>   s    