U
    ˜ARd”	  ã                   @   sf   d dl mZmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ erTd dlmZ G dd„ dƒZd	S )
é    )ÚTYPE_CHECKINGÚOptionalÚcast)ÚCode)Úgather_metrics)Ú
clean_text)ÚSupportsStr)ÚDeltaGeneratorc                   @   s@   e Zd Zedƒdeee eddœdd„ƒZe	ddœd	d
„ƒZ
dS )Ú	CodeMixinÚcodeÚpythonFr	   )ÚbodyÚlanguageÚline_numbersÚreturnc                 C   s.   t ƒ }t|ƒ|_|pd|_||_| j d|¡S )a’  Display a code block with optional syntax highlighting.

        Parameters
        ----------
        body : str
            The string to display as code.

        language : str or None
            The language that the code is written in, for syntax highlighting.
            If ``None``, the code will be unstyled. Defaults to ``"python"``.

            For a list of available ``language`` values, see:

            https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_PRISM.MD

        line_numbers : bool
            An optional boolean indicating whether to show line numbers to the
            left of the code block. Defaults to ``False``.

        Example
        -------
        >>> import streamlit as st
        >>>
        >>> code = '''def hello():
        ...     print("Hello, Streamlit!")'''
        >>> st.code(code, language='python')

        Ú	plaintextr   )Ú	CodeProtor   Z	code_textr   Zshow_line_numbersÚdgZ_enqueue)Úselfr   r   r   Z
code_proto© r   ú;/tmp/pip-unpacked-wheel-b9et7o5g/streamlit/elements/code.pyr      s
    #

zCodeMixin.code)r   c                 C   s
   t d| ƒS )zGet our DeltaGenerator.r	   )r   )r   r   r   r   r   D   s    zCodeMixin.dgN)r   F)Ú__name__Ú
__module__Ú__qualname__r   r   r   ÚstrÚboolr   Úpropertyr   r   r   r   r   r
      s     üû(r
   N)Útypingr   r   r   Zstreamlit.proto.Code_pb2r   r   Zstreamlit.runtime.metrics_utilr   Zstreamlit.string_utilr   Zstreamlit.type_utilr   Zstreamlit.delta_generatorr	   r
   r   r   r   r   Ú<module>   s   