
    ,h                    j    d Z ddlmZ ddlmZ ddlmZ ddlmZ erddl	m
Z ddlmZ  G d d	e      Zy)
aN  Hyperlink-related proxy objects for python-docx, Hyperlink in particular.

A hyperlink occurs in a paragraph, at the same level as a Run, and a hyperlink itself
contains runs, which is where the visible text of the hyperlink is stored. So it's kind
of in-between, less than a paragraph and more than a run. So it gets its own module.
    )annotations)TYPE_CHECKING)Parented)RunN)CT_Hyperlinkc                       e Zd ZdZd	 fdZed
d       Zedd       Zed
d       Zedd       Z	ed
d       Z
ed
d       Z xZS )	HyperlinkzProxy object wrapping a `<w:hyperlink>` element.

    A hyperlink occurs as a child of a paragraph, at the same level as a Run. A
    hyperlink itself contains runs, which is where the visible text of the hyperlink is
    stored.
    c                N    t         |   |       || _        |x| _        | _        y )N)super__init___parent
_hyperlink_element)self	hyperlinkparent	__class__s      U/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/docx/text/hyperlink.pyr   zHyperlink.__init__   s%     *33$-    c                    | j                   j                  }|r-| j                  j                  j                  |   j
                  S dS )a  The "URL" of the hyperlink (but not necessarily a web link).

        While commonly a web link like "https://google.com" the hyperlink address can
        take a variety of forms including "internal links" to bookmarked locations
        within the document. When this hyperlink is an internal "jump" to for example a
        heading from the table-of-contents (TOC), the address is blank. The bookmark
        reference (like "_Toc147925734") is stored in the `.fragment` property.
         )r   rIdr   partrels
target_ref)r   r   s     r   addresszHyperlink.address!   s;     oo!!9<t||  %%c*55D"Dr   c                @    t        | j                  j                        S )a  True when the text of this hyperlink is broken across page boundaries.

        This is not uncommon and can happen for example when the hyperlink text is
        multiple words and occurs in the last line of a page. Theoretically, a hyperlink
        can contain more than one page break but that would be extremely uncommon in
        practice. Still, this value should be understood to mean that "one-or-more"
        rendered page breaks are present.
        )boolr   lastRenderedPageBreaksr   s    r   contains_page_breakzHyperlink.contains_page_break.   s     DOO::;;r   c                6    | j                   j                  xs dS )a?  Reference like `#glossary` at end of URL that refers to a sub-resource.

        Note that this value does not include the fragment-separator character ("#").

        This value is known as a "named anchor" in an HTML context and "anchor" in the
        MS API, but an "anchor" element (`<a>`) represents a full hyperlink in HTML so
        we avoid confusion by using the more precise RFC 3986 naming "URI fragment".

        These are also used to refer to bookmarks within the same document, in which
        case the `.address` value with be blank ("") and this property will hold a
        value like "_Toc147925734".

        To reliably get an entire web URL you will need to concatenate this with the
        `.address` value, separated by "#" when both are present. Consider using the
        `.url` property for that purpose.

        Word sometimes stores a fragment in this property (an XML attribute) and
        sometimes with the address, depending on how the URL is inserted, so don't
        depend on this field being empty to indicate no fragment is present.
        r   )r   anchorr    s    r   fragmentzHyperlink.fragment:   s    , %%++r   c                |    | j                   j                  D cg c]  }t        || j                         c}S c c}w )aQ  List of |Run| instances in this hyperlink.

        Together these define the visible text of the hyperlink. The text of a hyperlink
        is typically contained in a single run will be broken into multiple runs if for
        example part of the hyperlink is bold or the text was changed after the document
        was saved.
        )r   r_lstr   r   )r   rs     r   runszHyperlink.runsR   s-     /3oo.C.CDAt||$DDDs   9c                .    | j                   j                  S )a%  String formed by concatenating the text of each run in the hyperlink.

        Tabs and line breaks in the XML are mapped to ``\t`` and ``\n`` characters
        respectively. Note that rendered page-breaks can occur within a hyperlink but
        they are not reflected in this text.
        )r   textr    s    r   r*   zHyperlink.text]   s     ###r   c                N    | j                   | j                  }}|sy|r| d| S |S )a  Convenience property to get web URLs from hyperlinks that contain them.

        This value is the empty string ("") when there is no address portion, so its
        boolean value can also be used to distinguish external URIs from internal "jump"
        hyperlinks like those found in a table-of-contents.

        Note that this value may also be a link to a file, so if you only want web-urls
        you'll need to check for a protocol prefix like `https://`.

        When both an address and fragment are present, the return value joins the two
        separated by the fragment-separator hash ("#"). Otherwise this value is the same
        as that of the `.address` property.
        r   #)r   r$   )r   r   r$   s      r   urlzHyperlink.urlg   s3     !LL$--*2'!H:&??r   )r   r   r   zt.ProvidesStoryPart)returnstr)r.   r   )r.   z	list[Run])__name__
__module____qualname____doc__r   propertyr   r!   r$   r(   r*   r-   __classcell__)r   s   @r   r	   r	      s    4
 
E 
E 	< 	< , ,. E E $ $ @ @r   r	   )r3   
__future__r   typingr   docx.sharedr   docx.text.runr   
docx.typestypestdocx.oxml.text.hyperlinkr   r	    r   r   <module>r?      s1    #     5e@ e@r   