File: //home/arjun/projects/env/lib/python3.10/site-packages/weasyprint/__pycache__/html.cpython-310.pyc
o
&we�, � @ s� d Z zddlmZ W n ey ddlmZ Y nw dd� ZddlZddlmZmZ dd lm Z dd
l
mZ ddlm
Z
ddlmZ dd
lmZ ddlmZ e� Zeed�Zeed�Zeed�Zeeed�Zeeed�Zeed�ZdZe�de� d��Zdd� Zdd� Zi Z dd� Z!dd� Z"dd � Z#e"d!�d"d#� �Z$e"d$�d%d&� �Z%e"d'�d(d)� �Z&e"d*�d+d,� �Z'e"d-�d.d/� �Z(e"d0�d1d2� �Z)d3d4� Z*d5d6� Z+e�d7ej,�Z-d8d9� Z.dS ):aV Specific handling for some HTML elements, especially replaced elements.
Replaced elements (eg. <img> elements) are rendered externally and behave as an
atomic opaque box in CSS. In general, they may or may not have intrinsic
dimensions. But the only replaced elements currently supported in WeasyPrint
are images with intrinsic dimensions.
� )�files)� read_textc C s t | �| �d�S )Nzutf-8)r r )�package�resource� r �H/home/arjun/projects/env/lib/python3.10/site-packages/weasyprint/html.pyr s r N� )�CSS�css)�get_child_text)�CounterStyle)�boxes)�SVGImage)�LOGGER)�get_url_attributezhtml5_ua.csszhtml5_ua_form.csszhtml5_ph.css)�string�
counter_style�r z
z[^z]+c C s | � � �� �� S )a4 Transform (only) ASCII letters to lower case: A-Z is mapped to a-z.
This is used for `ASCII case-insensitive
<https://whatwg.org/C#ascii-case-insensitive>`_ matching.
This is different from the :meth:`str.lower` method of Unicode strings
which also affect non-ASCII characters,
sometimes mapping them into the ASCII range:
>>> keyword = 'Bac\N{KELVIN SIGN}ground'
>>> assert keyword.lower() == 'background'
>>> assert ascii_lower(keyword) != keyword.lower()
>>> assert ascii_lower(keyword) == 'bac\N{KELVIN SIGN}ground'
)�encode�lower�decoder r r r �ascii_lower- s r c s( t �| �dd��}t� fdd�|D ��S )zDReturn whether element has a ``rel`` attribute with given link type.�rel� c 3 s � | ] }t |�� kV qd S )N)r )�.0�token�� link_typer r � <genexpr>D s � z(element_has_link_type.<locals>.<genexpr>)�HTML_SPACE_SEPARATED_TOKENS_RE�findall�get�any)�elementr �tokensr r r �element_has_link_typeA s r% c C s$ |j tv rt| j | |||�S |gS )zbHandle HTML elements that need special care.
:returns: a (possibly empty) list of boxes.
)�element_tag�
HTML_HANDLERS�tag)r# �box�get_image_from_uri�base_urlr r r �handle_elementK s
�r, c s � fdd�}|S )zDReturn a decorator registering a function handling ``tag`` elements.c s | t � <