1- from _typeshed import Incomplete , SupportsKeysAndGetItem , Unused
2- from collections .abc import Callable , Iterable
1+ from _typeshed import Incomplete , SupportsItemAccess , SupportsKeysAndGetItem , Unused
2+ from collections .abc import Callable , Iterable , Mapping
33from html .parser import HTMLParser
44from logging import Logger
5- from typing import ClassVar , Final
5+ from typing import ClassVar , Final , Literal , TypedDict , type_check_only
6+ from typing_extensions import TypeAlias
67
78from fpdf import FPDF
89
10+ from .fonts import FontFace
11+ from .table import Row , Table
12+
913__author__ : Final [str ]
1014__copyright__ : Final [str ]
1115
16+ _OLType : TypeAlias = Literal ["1" , "a" , "A" , "I" , "i" ]
17+
1218LOGGER : Logger
1319BULLET_WIN1252 : Final [str ]
14- DEFAULT_HEADING_SIZES : dict [str , int ]
20+ DEGREE_WIN1252 : Final [str ]
21+ HEADING_TAGS : Final [tuple [str , ...]]
22+ DEFAULT_TAG_STYLES : Final [dict [str , FontFace ]]
23+ DEFAULT_TAG_INDENTS : Final [dict [str , int ]]
1524
1625COLOR_DICT : Final [dict [str , str ]]
1726
1827def color_as_decimal (color : str | None = "#000000" ) -> tuple [int , int , int ] | None : ...
28+ def parse_style (elem_attrs : SupportsItemAccess [str , str ]) -> None : ...
29+ @type_check_only
30+ class _Emphasis (TypedDict ):
31+ b : bool
32+ i : bool
33+ u : bool
1934
2035class HTML2FPDF (HTMLParser ):
2136 HTML_UNCLOSED_TAGS : ClassVar [tuple [str , ...]]
37+ TABLE_LINE_HEIGHT : ClassVar [float ]
2238
2339 pdf : FPDF
24- image_map : Incomplete
25- li_tag_indent : int
26- dd_tag_indent : int
40+ image_map : Callable [[str ], str ]
2741 ul_bullet_char : str
28- heading_sizes : dict [str , int ]
29- pre_code_font : str
42+ li_prefix_color : tuple [int , int , int ]
3043 warn_on_tags_not_matching : bool
31- style : Incomplete
32- font_size : Incomplete
44+ emphasis : _Emphasis
45+ font_size : float
3346 follows_trailing_space : bool
3447 follows_heading : bool
3548 href : str
3649 align : str
37- page_links : Incomplete
38- font_stack : Incomplete
50+ style_stack : list [FontFace ]
3951 indent : int
40- bullet : Incomplete
41- font_color : Incomplete
42- table : Incomplete
43- table_col_width : Incomplete
44- table_col_index : Incomplete
45- td : Incomplete
46- th : Incomplete
47- tr : Incomplete
48- thead : Incomplete
49- tfoot : Incomplete
50- tr_index : Incomplete
51- theader : Incomplete
52- tfooter : Incomplete
53- theader_out : bool
54- table_row_height : int
55- heading_level : Incomplete
52+ ol_type : list [_OLType ]
53+ bullet : list [Incomplete ]
54+ font_color : tuple [int , int , int ]
55+ heading_level : Incomplete | None
5656 heading_above : float
5757 heading_below : float
58+ table_line_separators : bool
59+ table : Table | None
60+ table_row : Row | None
61+ tr : dict [str , str ] | None
62+ td_th : dict [str , str ] | None
63+ tag_indents : dict [str , int ]
64+ tag_styles : dict [str , FontFace ]
5865
5966 # Not initialized in __init__:
60- font_face : Incomplete
67+ font_family : str
6168 h : float
6269
6370 def __init__ (
@@ -68,20 +75,26 @@ class HTML2FPDF(HTMLParser):
6875 dd_tag_indent : int = 10 ,
6976 table_line_separators : bool = False ,
7077 ul_bullet_char : str = "\x95 " ,
78+ li_prefix_color : tuple [int , int , int ] = (190 , 0 , 0 ),
7179 heading_sizes : SupportsKeysAndGetItem [str , int ] | Iterable [tuple [str , int ]] | None = None ,
72- pre_code_font : str = "courier" ,
80+ pre_code_font : str = ... ,
7381 warn_on_tags_not_matching : bool = True ,
82+ tag_indents : dict [str , int ] | None = None ,
83+ tag_styles : Mapping [str , FontFace ] | None = None ,
7484 ** _ : Unused ,
7585 ): ...
7686 def handle_data (self , data ) -> None : ...
7787 def handle_starttag (self , tag , attrs ) -> None : ...
7888 def handle_endtag (self , tag ) -> None : ...
79- def set_font (self , face : Incomplete | None = None , size : Incomplete | None = None , set_default : bool = False ) -> None : ...
89+ def set_font (self , family : str | None = None , size : float | None = None , set_default : bool = False ) -> None : ...
8090 def set_style (self , tag : Incomplete | None = None , enable : bool = False ) -> None : ...
8191 def set_text_color (self , r : Incomplete | None = None , g : int = 0 , b : int = 0 ) -> None : ...
8292 def put_link (self , text ) -> None : ...
8393 def render_toc (self , pdf , outline ) -> None : ...
8494 def error (self , message : str ) -> None : ...
8595
96+ def ul_prefix (ul_type : str ) -> str : ...
97+ def ol_prefix (ol_type : _OLType , index : int ) -> str : ...
98+
8699class HTMLMixin :
87100 def __init__ (self , * args , ** kwargs ) -> None : ...
0 commit comments