Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/turbohtml/extract/_links.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

12 statements  

1""" 

2The Link record :meth:`turbohtml.Node.links` yields. 

3 

4The enumeration and rewriting all live in the C core (``turbohtml._html``), exposed as the 

5:meth:`~turbohtml.Node.links`, :meth:`~turbohtml.Node.rewrite_links`, and :meth:`~turbohtml.Node.resolve_links` methods. 

6The core builds one :class:`Link` per link it finds; importing this module registers the record type with it. 

7""" 

8 

9from __future__ import annotations 

10 

11from typing import NamedTuple 

12 

13from turbohtml._html import Element, _register_links # Element stays importable so autodoc resolves it 

14 

15 

16class Link(NamedTuple): 

17 """ 

18 One link found in a document. 

19 

20 :param element: the element the link was found on. 

21 :param attribute: the attribute carrying the link, or ``None`` for a ``<style>`` sheet's text. 

22 :param url: the link exactly as it appears in the source, before any resolution. 

23 """ 

24 

25 element: Element 

26 """the element the link was found on.""" 

27 attribute: str | None 

28 """the attribute carrying the link, or ``None`` for a ``<style>`` sheet's text.""" 

29 url: str 

30 """the link exactly as it appears in the source, before any resolution.""" 

31 

32 

33_register_links(Link)