
    Mi!                        S SK rS SKJrJrJr  SSKJr  \R                  R                  5        V Vs0 s H'  u  pU S:w  d  M  \R                  R                  U    U_M)     snn rS\S\4S jrS	\S\\\4   4S
 jrS\S\\\\\4   4   4S jrS\\\\   4   S\\\\\4   4   S\\\4   S\\\4   4S jrS	\\\4   S\4S jrS	\\\4   S\4S jrS	\\\4   S\\   4S jrS	\\\4   S\4S jrS\\\\   4   S\4S jrS\S\S\S\S\4
S jrS\S\4S jr     S'S\S\S\S\S \S!\S\4S" jjrS#\\   S$\S\\   4S% jrS(S\S$\S\4S& jjrgs  snn f ))    N)DictListOptional   )confignbsptagreturnc                 t    U S   S:X  a/  [        U 5      S:X  a   U S   nSUs=:  a  S::  a  O  g[        U5      $ g)Nr   h   r   09)lenint)r	   ns     r/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/crawl4ai/html2text/utils.pyhnr      s<    
1v}SQF>c> q6M    stylec                 (   U R                  S5       Vs/ s H  nSU;   d  M  UR                  SS5      PM     sn VVs0 s H@  u  p#UR                  5       R                  5       UR                  5       R                  5       _MB     snn$ s  snf s  snnf )z$
:returns: A hash of css attributes
;:r   )splitstriplower)r   zxys       r   dumb_property_dictr       sy     /4kk#.>K.>#(_QWWS!_.>KKDA 	
	1779??,,K Ks   
B	B	ABdatac                    U S-  n U R                  S5      nUS:w  a6  U SU X R                  SU5      S-   S -   n U R                  S5      nUS:w  a  M6  U R                  S5       Vs/ s H*  nSUR                  5       ;   d  M  UR                  S5      PM,     nn U VVs0 s H  u  pEUR                  5       [        U5      _M!     nnnU$ s  snf s  snnf ! [         a    0 n U$ f = f)	zs
:type data: str

:returns: A hash of css selectors, each of which contains a hash of
css attributes.
:rtype: dict
r   z@importr   r   N}{)findr   r   r    
ValueError)r!   importIndexr   pairsabelementss          r   dumb_css_parserr-      s     	CKD))I&K

Ak"T))C*E*I*K%LLii	* 
 $(::c?G?acQWWY6F\QWWS\?EGAFGAGGI1!44G O HG Os0   &C
C
C &CC C C%$C%attrs	style_defparent_stylec                    UR                  5       nSU ;   aH  U S   c   eU S   R                  5        H)  nUR                  SU-   0 5      nUR                  U5        M+     SU ;   a'  U S   c   e[	        U S   5      nUR                  U5        U$ )z
:type attrs: dict
:type style_def: dict
:type style_def: dict

:returns: A hash of the 'final' style attributes of the element
:rtype: dict
class.r   )copyr   getupdater    )r.   r/   r0   r   	css_class	css_styleimmediate_styles          r   element_styler:   9   s     E%W~)))w--/I!cIor:ILL# 0 %W~))),U7^<_%Lr   c                 (    SU ;   a  U S   nUS;   a  gg)zX
Finds out whether this is an ordered or unordered list

:type style: dict

:rtype: str
zlist-style-type)disccirclesquarenoneulol )r   
list_styles     r   google_list_stylerD   T   s&     E!,-
==r   c                     SU ;   $ )zr
Check if the style of the element has the 'height' attribute
explicitly defined

:type style: dict

:rtype: bool
heightrB   )r   s    r   google_has_heightrG   d   s     ur   c                     / nSU ;   a  UR                  U S   5        SU ;   a  UR                  U S   5        SU ;   a  UR                  U S   5        U$ )z[
:type style: dict

:returns: A list of all emphasis modifiers of the element
:rtype: list
ztext-decorationz
font-stylezfont-weight)append)r   emphasiss     r   google_text_emphasisrK   p   sZ     HE!/01ul+,m,-Or   c                 >    SnSU ;   a  U S   nSU:H  =(       d    SU:H  $ )ze
Check if the css of the current element defines a fixed width font

:type style: dict

:rtype: bool
 zfont-familyzcourier newconsolasrB   )r   font_familys     r   google_fixed_width_fontrP      s0     KM*K'D:+DDr   c                 d    SU ;   a  U S   c   e [        U S   5      S-
  $ g! [         a     gf = f)zX
Extract numbering from list element attributes

:type attrs: dict

:rtype: int or None
startr   r   )r   r'   )r.   s    r   list_numbering_startrS      sQ     %W~)))	uW~&**   		s   " 
//para
wrap_linkswrap_list_itemswrap_tablesc                 
   U(       d%  [         R                  R                  U 5      (       a  gU SS S:X  d	  U S   S:X  a  gU R                  5       nUSS S:X  a  [	        U5      S:  a
  US   S:w  a  g	USS
 S;   a  USS S:X  d  U(       + $ U(       d%  [         R
                  R                  U 5      (       a  g[        [         R                  R                  U5      =(       d    [         R                  R                  U5      5      $ )NTr      z    	r   z---Fr   )r[   *z**)
r   RE_LINKsearchlstripr   RE_TABLEboolRE_ORDERED_LIST_MATCHERmatchRE_UNORDERED_LIST_MATCHER)rT   rU   rV   rW   strippeds        r   skipwraprf      s    
 &..//55 AayFd1go {{}H!}X!2x{c7I
 !}
"8Aa=D+@""" 6??11$77
 &&,,X6 	<++11(; r   textc                 B    [         R                  R                  SU 5      $ )zI
Escapes markdown-sensitive characters within other markdown
constructs.
\\\1)r   RE_MD_CHARS_MATCHERsub)rg   s    r   	escape_mdrl      s    
 %%))'488r   escape_backslashsnob
escape_dotescape_plusescape_dashc                    U(       a   [         R                  R                  SU 5      n U(       a   [         R                  R                  SU 5      n U(       a   [         R                  R                  SU 5      n U(       a   [         R
                  R                  SU 5      n U(       a   [         R                  R                  SU 5      n U $ )z
Escapes markdown-sensitive characters across whole document sections.
Each escaping operation can be controlled individually.
ri   z\1\\\2)r   RE_MD_BACKSLASH_MATCHERrk   RE_MD_CHARS_MATCHER_ALLRE_MD_DOT_MATCHERRE_MD_PLUS_MATCHERRE_MD_DASH_MATCHER)rg   rm   rn   ro   rp   rq   s         r   escape_md_sectionrx      s     --11'4@--11'4@''++It<((,,Y=((,,Y=Kr   linesright_marginc                    U S   R                  S5       Vs/ s H  n[        UR                  5       5      U-   PM!     nn[        U5      nU  H  nUR                  S5       Vs/ s H  o"R                  5       PM     nn[        U5      nXt:  a  US/XG-
  -  -  nO.XG:  a)  X6Xt-
  * S  Vs/ s H  n[        U5      U-   PM     sn-  nUn[        Xc5       VVs/ s H  u  p([	        [        U5      U-   U5      PM     nnnM     / n	U  GHB  nUR                  S5       Vs/ s H  o"R                  5       PM     nn[        UR                  5       5      [        S5      :X  av  Sn
[        Xc5       VVs/ s H4  u  p+UR                  5       X[        UR                  5       5      -
  -  -   PM6     nnnU	R                  SSR                  U5      -   S-   5        M  Sn
[        Xc5       VVs/ s H4  u  p+UR                  5       X[        UR                  5       5      -
  -  -   PM6     nnnU	R                  S	SR                  U5      -   S-   5        GME     U	$ s  snf s  snf s  snf s  snnf s  snf s  snnf s  snnf )
zF
Given the lines of a table
padds the cells and returns the new lines
r   |rM   Nz-|r[   z|- z| )	r   r   rstripzipmaxsetr   rI   join)ry   rz   r   	max_widthmax_colslinecolsnum_colsold_len	new_linesfillerMnew_colss                r   reformat_tabler      sU    :?q9LM9LAQXXZ</9LIM9~H$(JJsO4Oq
O4t9 RDH/00D @S>T>V9WX9WA#a&</9WXXIH CFdBV
BVJACA%w/BV 	 
	   I$(JJsO4Oq
O4tzz|D	)F  00DA 
fC
O(;<=0   TCHHX$66<=F  00DA 
fC
O(;<=0   TCHHX$66<=   G N 5 Y
 5s)   &I"I(I$II",;I'";I-c                 `   U R                  S5      n/ nSn/ nU H  n[        R                  U;   a?  U(       + nU(       d/  [        X15      nUR	                  U5        / nUR                  S5        MV  U(       a  UR                  U5        Mp  UR                  U5        M     SR                  U5      $ )z(
Provide padding for tables in the text

FrM   )r   r   TABLE_MARKER_FOR_PADr   extendrI   r   )rg   rz   ry   table_buffertable_startedr   r   tables           r   pad_tables_in_textr     s     JJtELMI&&$. --M &|B  '!  $%T"  99Yr   )TFTTT)r   )html.entitieshtmltypingr   r   r   rM   r   	UNIFIABLEitemsentitiesname2codepointunifiable_nstrr   r   r    r-   r:   rD   ra   rG   rK   rP   rS   rf   rl   rx   r   r   )kvs   00r   <module>r      sz    ' '    &&((F{ 'DMM  #Q&(C C c d38n # $sDcN':"; 4Xc]"#Cc3h'( sCx. 
#s(^	6T#s(^   	T#s(^ 	 	S#X 49 $E4S> Ed ES(3-%7 8 S $"
""26"EI"	"J9C 9C 9 "
  	
   	<)$s) )3 )49 )X S    C  gs   EE