XjjdZddlmZddlmZddlmZddlmZer ddl m Z ddl m Z Gdd eZy) aNHyperlink-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_HyperlinkceZdZdZd fd Zed dZed dZed dZed dZ ed dZ ed dZ xZ S) HyperlinkzProxy object wrapping a `` 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. cNt||||_|x|_|_y)N)super__init___parent _hyperlink_element)self hyperlinkparent __class__s g/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/docx/text/hyperlink.pyr zHyperlink.__init__s%   *33$-c|jj}|r-|jjj|j SdS)aThe "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. )rrIdr partrels target_ref)rrs raddresszHyperlink.address!s;oo!!9`) 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)ranchorr s rfragmentzHyperlink.fragment:s,%%++rc||jjDcgc]}t||jc}Scc}w)aQList 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. )rr_lstrr )rrs rrunszHyperlink.runsRs-/3oo.C.CDAt||$DDDs9c.|jjS)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. )rtextr s rr*zHyperlink.text]s###rcN|j|j}}|sy|r|d|S|S)aConvenience 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#)rr$)rrr$s rurlz Hyperlink.urlgs3!LL$--*2'!H:&??r)rrrzt.ProvidesStoryPart)returnstr)r.r)r.z list[Run]) __name__ __module__ __qualname____doc__r propertyrr!r$r(r*r- __classcell__)rs@rr r s4  E E < <,,.EE$$@@rr )r3 __future__rtypingr docx.sharedr docx.text.runr docx.typestypestdocx.oxml.text.hyperlinkrr rrr?s1# 5e@e@r