a
    þdm  ã                   @  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                	   @  s„   e Zd ZdZdddddddœddd	dd
ddœdd„Zd
d
dœdd„Zdd„ Zeej	dddfdddd	dœdd„ƒZ
d
d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_classeszstr | CallableÚboolz"list[dict[str, str | bool]] | Nonez
str | Nonezlist[str] | str | None)Úvaluer   r   r   r   r   c                K  sB   || _ |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.
        Nú$F)ÚleftÚrightZdisplay)r   r   r   r   )r   r   r
   Ú__init__)Úselfr   r   r   r   r   r   Úkwargs© r   úc/var/www/html/stable-diffusion-webui/venv/lib/python3.9/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   Úpostprocess@   s    
zMarkdown.postprocessc                 C  s   | j | j| jdœt | ¡¥S )N)r   r   r   )r   r   r   r	   Ú
get_config)r   r   r   r   r$   L   s    ýüzMarkdown.get_configz(Any | Literal[_Keywords.NO_VALUE] | Nonezbool | None)r   r   r   r   c                 C  s   || ||ddœ}|S )NÚupdate)r   r   r   r   Z__type__r   )r   r   r   r   Zupdated_configr   r   r   r%   T   s    ûzMarkdown.updateÚstr)Ú
input_datar    c                 C  s   |   |¡}|r|S dS )Nr   )r#   )r   r'   Zpostprocessedr   r   r   Ú
as_exampled   s    
zMarkdown.as_example)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r#   r$   Ústaticmethodr   ZNO_VALUEr%   r(   r   r   r   r   r      s$    þø"ür   )r,   Ú
__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   