� J�g�(��p�UddlmZddlmZmZmZmZmZmZm Z m Z ddl m Z ddl mZe rddlmZGd�de��ZGd�d e��ZGd �d e��Zeej� ��ejd <eejdd���ejd<eejdd���ejd<eej� ��ejd<ed� ��ejd<eej� ��ejd <eej� ��ejd<ed� ��ejd<eegefZded<e eefZdS)�)� annotations)�Callable�Dict�Iterable�Optional�Set�Tuple� TYPE_CHECKING�Union)� TypeAlias)�EntitySubstitution)�_AttributeValuec���eZdZUdZdZded<dZded<eeddg��� ��Z d ed <d ed <ded<ded<ded<ded<ded<d(d�Z d)d*d �Z d+d"�Z d,d#�Z d-d'�ZdS).� FormatteraDescribes a strategy to use when outputting a parse tree to a string. Some parts of this strategy come from the distinction between HTML4, HTML5, and XML. Others are configurable by the user. Formatters are passed in as the `formatter` argument to methods like `bs4.element.Tag.encode`. Most people won't need to think about formatters, and most people who need to think about them can pass in one of these predefined strings as `formatter` rather than making a new Formatter object: For HTML documents: * 'html' - HTML entity substitution for generic HTML documents. (default) * 'html5' - HTML entity substitution for HTML5 documents, as well as some optimizations in the way tags are rendered. * 'html5-4.12.0' - The version of the 'html5' formatter used prior to Beautiful Soup 4.13.0. * 'minimal' - Only make the substitutions necessary to guarantee valid HTML. * None - Do not perform any substitution. This will be faster but may result in invalid markup. For XML documents: * 'html' - Entity substitution for XHTML documents. * 'minimal' - Only make the substitutions necessary to guarantee valid XML. (default) * None - Do not perform any substitution. This will be faster but may result in invalid markup. �html�str�HTML�xml�XML�script�style)�cdata_containing_tagszDict[str, Set[str]]� HTML_DEFAULTS� Optional[str]�language�%Optional[_EntitySubstitutionFunction]�entity_substitution�void_element_close_prefix�Set[str]r�indent�bool�empty_attributes_are_booleans�value�Optional[Set[str]]�kwarg�returnc�V�|�|S||jkrt��S|j|S)N)r�setr)�selfrr#r%s �]/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/bs4/formatter.py�_defaultzFormatter._defaultBs7�� � ��L� �t�x� � ��5�5�L��!�%�(�(�N�/F��Union[int, str]c��|p|j|_||_||_|�|j|d��|_||_|�d}t|t��r|dkrd}d|z}nt|t��r|}nd}||_ dS)a�Constructor. :param language: This should be `Formatter.XML` if you are formatting XML markup and `Formatter.HTML` if you are formatting HTML markup. :param entity_substitution: A function to call to replace special characters with XML/HTML entities. For examples, see bs4.dammit.EntitySubstitution.substitute_html and substitute_xml. :param void_element_close_prefix: By default, void elements are represented as <tag/> (XML rules) rather than <tag> (HTML rules). To get <tag>, pass in the empty string. :param cdata_containing_tags: The set of tags that are defined as containing CDATA in this dialect. For example, in HTML, <script> and <style> tags are defined as containing CDATA, and their contents should not be formatted. :param empty_attributes_are_booleans: If this is set to true, then attributes whose values are sent to the empty string will be treated as `HTML boolean attributes<https://dev.w3.org/html5/spec-LC/common-microsyntaxes.html#boolean-attributes>`_. (Attributes whose value is None are always rendered this way.) :param indent: If indent is a non-negative integer or string, then the contents of elements will be indented appropriately when pretty-printing. An indent level of 0, negative, or "" will only insert newlines. Using a positive integer indent indents that many spaces per level. If indent is a string (such as "\t"), that string is used to indent each level. The default behavior is to indent one space per level. rNr� ) rrrrr+rr"� isinstance�intrr )r)rrrrr"r � indent_strs r*�__init__zFormatter.__init__Os���N!�-�D�I�� �#6�� �)B��&�%)�]�]� �M�0�2I�& �& ��"�.K��*� �>��F� �f�c� "� "� ���z�z����v��J�J� ��� $� $� ��J�J��J� �� � � r,�nsc��|js|Sddlm}t||��r|j�|jj|jvr|S|�|��S)a$Process a string that needs to undergo entity substitution. This may be a string encountered in an attribute value or as text. :param ns: A string. :return: The same string but with certain characters replaced by named or numeric entities. r.)�NavigableString)r�elementr8r2�parent�namer)r)r6r8s r*� substitutezFormatter.substitute�so���'� ��I�,�,�,�,�,�,� �r�?� +� +� �� �%�� ��$�"<�<�<��I��'�'��+�+�+r,c�,�|�|��S)z�Process the value of an attribute. :param ns: A string. :return: A string with certain characters replaced by named or numeric entities. )r<)r)r#s r*�attribute_valuezFormatter.attribute_value�s�����u�%�%�%r,�tag�bs4.element.Tag�/Iterable[Tuple[str, Optional[_AttributeValue]]]c���|j�gSt|j�����}t�fd�|D����S)a�Reorder a tag's attributes however you want. By default, attributes are sorted alphabetically. This makes behavior consistent between Python 2 and Python 3, and preserves backwards compatibility with older versions of Beautiful Soup. If `empty_attributes_are_booleans` is True, then attributes whose values are set to the empty string will be treated as boolean attributes. Nc3�D�K�|]\}}|�jr|dkrdn|fV��dS)�N)r")�.0�k�vr)s �r*� <genexpr>z'Formatter.attributes.<locals>.<genexpr>�sT����� � ���1���;�N��R�����Q� P� � � � � � r,)�attrs�list�items�sorted)r)r?rKs` r*� attributeszFormatter.attributes�sc��� �9� ��I�7;�C�I�O�O�<M�<M�7N�7N��� � � � �� � � � � � r,)rrr#r$r%rr&r)NNr-NFr.) rrrrrrrr$r"r!r r/)r6rr&r)r#rr&r)r?r@r&rA)�__name__� __module__� __qualname__�__doc__r�__annotations__r�dictr(rr+r5r<r>rM�r,r*rr sL���������@�D������C�����*.��!�c�8�W�"5�6�6�*�*�*�M���������>�>�>�>�"�"�"�"�#�#�#�#��K�K�K� (�'�'�'� )� )� )� )�#'�EI�),�48�.3�!"�9!�9!�9!�9!�9!�v,�,�,�,�.&�&�&�&� � � � � � r,rc�@��eZdZUdZiZded< dd�fd� Z�xZS)� HTMLFormatterzA generic Formatter for HTML.z"Dict[Optional[str], HTMLFormatter]�REGISTRYNr-Fr.rrrrrr$r"r!r r/c�n��tt|���|j|||||���dS�N)r )�superrVr5r�r)rrrr"r � __class__s �r*r5zHTMLFormatter.__init__�sJ��� �m�T�"�"�+�+� �I� � %� !� )�� ,� � � � � r,�Nr-NFr.� rrrrrr$r"r!r r/�rNrOrPrQrWrRr5� __classcell__�r\s@r*rVrV�sn��������'�'�35�H�5�5�5�5�FJ�),�48�.3�!"�  � � � � � � � � � � r,rVc�@��eZdZUdZiZded< dd�fd� Z�xZS)� XMLFormatterzA generic Formatter for XML.z!Dict[Optional[str], XMLFormatter]rWNr-Fr.rrrrrr$r"r!r r/c�n��tt|���|j|||||���dSrY)rZrcr5rr[s �r*r5zXMLFormatter.__init__�sJ��� �l�D�!�!�*�*� �H� � %� !� )�� +� � � � � r,r]r^r_ras@r*rcrc�sn��������&�&�24�H�4�4�4�4�FJ�),�48�.3�!"�  � � � � � � � � � � r,rc)rrrDT)rrr"�html5z html5-4.12�minimalNr �_EntitySubstitutionFunction)� __future__r�typingrrrrrr r r �typing_extensionsr � bs4.dammitr � bs4._typingrrrVrc�substitute_htmlrW�substitute_html5�substitute_xmlrrgrR�_FormatterOrNamerTr,r*�<module>rqsx��"�"�"�"�"�"�"�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�W�'�'�'�'�'�'�)�)�)�)�)�)��,�+�+�+�+�+�+�t �t �t �t �t �"�t �t �t �n � � � � �I� � � �. � � � � �9� � � �0"/��*�:�"�"�"� ��v��#0�-�*�;� �"&�#�#�#� ��w�� (5�}�*�:� �"&�(�(�(� ��|�$� %2�M�*�9�%�%�%� ��y�!� -�}��F�F�F� ��t�� ,� �*�:�!�!�!� ��f��$0�<�*�9�$�$�$� ��i� �+�l�t�D�D�D� ��d��*2�3�%��*�)=��=�=�=�=���C��(���r,
Memory