+
    f0i'"                        R t ^ RIHt ^RIHt ^RIHt ^ RIHu H	t ^ RI
t
^ RIHtHtHt ]'       d   ^RIHt ^ t^t^t ! R R]4      t ! R	 R
]4      tR tR# )z
Adds parsing of tables to Python-Markdown.

See the [documentation](https://Python-Markdown.github.io/extensions/tables)
for details.
)annotations)	Extension)BlockProcessorN)TYPE_CHECKINGAnySequence)blockparserc                     a  ] tR t^&tRt]P                  ! R4      t]P                  ! R4      tR V 3R llt	R R lt
R R	 ltR
 R ltR R ltR R ltR R ltRtV ;t# )TableProcessorzProcess Tables. z"(?:(\\\\)|(\\`+)|(`+)|(\\\|)|(\|))z(?<!\\)(?:\\\\)*\|$c                    V ^8  d   QhRRRR/# )   parserzblockparser.BlockParserconfigzdict[str, Any] )formats   "`/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/markdown/extensions/tables.py__annotate__TableProcessor.__annotate__,   s     ! !6 ! !    c                	N   < R V n         RV n        W n        \        SV `  V4       R# )F N)border	separatorr   super__init__)selfr   r   	__class__s   &&&r   r   TableProcessor.__init__,   s#    "'(* r   c               $    V ^8  d   QhRRRRRR/# )r   parentetree.Elementblockstrreturnboolr   )r   s   "r   r   r   3   s!     " "= " " "r   c                   RpVP                  R4       Uu. uF  qDP                  R4      NK  	  pp\        V4      ^8  Ed   V^ ,          p\        V n        VP                  R4      '       d   V ;P                  \        ,          un        V P                  P                  V4      e   V ;P                  \        ,          un        V P                  V4      p\        V4      pV^8  pV'       g   V^8X  d{   V P                  '       di   \        ^\        V4      4       FO  pWX,          P                  R4      pV'       g$   V P                  P                  WX,          4      RJpV'       d   KO   M	  V'       dc   V P                  V^,          4      p\        V4      V8H  ;'       d'    \        RP                  V4      4      \        R4      8*  pV'       d   W@n        V# u upi )z
Ensure first two rows (column header and separator row) are valid table rows.

Keep border check and separator row do avoid repeating the work.
F
 |Nr   z|:- )splitstriplen	PIPE_NONEr   
startswith	PIPE_LEFTRE_END_BORDERsearch
PIPE_RIGHT
_split_rowrangesetjoinr   )	r   r   r!   is_tablerowrowsheader0row0_lenindexs	   &&&      r   testTableProcessor.test3   se    */++d*;<*;3		#*;<t9q=1gG#DK!!#&&y(!!((1=z)//'*C3xH!|H A$+++"1c$i0E#{55c:H##'#5#5#<#<T[#IQU#U#8 1 ood1g.H0VVc"''#,6G3v;6V%(N7 =s   Gc               $    V ^8  d   QhRRRRRR/# )r   r   r    blocks	list[str]r#   Noner   )r   s   "r   r   r   W   s!     > >- > >t >r   c                   VP                  ^ 4      P                  R4      pV^ ,          P                  R4      p\        V4      ^8  d   . MVR,          p. pV P                   F  pVP                  R4      pVP                  R4      '       d+   VP                  R4      '       d   VP                  R4       KU  VP                  R4      '       d   VP                  R4       K  VP                  R4      '       d   VP                  R4       K  VP                  R4       K  	  \        P                  ! VR	4      p\        P                  ! VR
4      p	V P                  WIV4       \        P                  ! VR4      p
\        V4      ^ 8X  d   V P                  W4       R# V F$  pV P                  VP                  R4      W4       K&  	  R# )z%Parse a table block and build table. r&   r'   :r   NN:centerleftrightNtabletheadtbody)popr)   r*   r+   r   r-   endswithappendetree
SubElement
_build_row_build_empty_row)r   r   r?   r!   headerr8   aligncrG   rH   rI   r7   s   &&&         r   runTableProcessor.runW   sI   

1##D)q$Z!^rr #%AA||C  QZZ__X&c""V$CW%T"     1  0u-  0t9>!!%/		#= r   c               $    V ^8  d   QhRRRRRR/# )r   r   r    rR   Sequence[str | None]r#   rA   r   )r   s   "r   r   r   v   s#      } =Q VZ r   c                    \         P                  ! VR4      p\        V4      pV'       d#   \         P                  ! VR4       V^,          pK*  R# )zBuild an empty row.trtdN)rM   rN   r+   )r   r   rR   rY   counts   &&&  r   rP   TableProcessor._build_empty_rowv   s>    fd+E
R&QJE r   c               (    V ^8  d   QhRRRRRRRR/# )	r   r7   r"   r   r    rR   rW   r#   rA   r   )r   s   "r   r   r   ~   s*     8 8c 8= 8AU 8Z^ 8r   c                   \         P                  ! VR4      pRpVP                  R8X  d   RpV P                  V4      p\	        V4       F  w  rx\         P                  ! WE4      p	 Wg,          P                  R4      V	n        V'       g   KB  V P                  R,          '       d   V	P                  RV4       Ko  V	P                  R	R
V R24       K  	  R#   \         d    RT	n         Lgi ; i)z(Given a row of text, build table cells. rY   rZ   rH   thr'   r   use_align_attributerR   styleztext-align: ;N)
rM   rN   tagr2   	enumerater*   text
IndexErrorr   r4   )
r   r7   r   rR   rY   rc   cellsiarS   s
   &&&&      r   rO   TableProcessor._build_row~   s    fd+:: C$ e$DA  )A, q;;455EE'1%EE'\!A#67 %  s   %CC)(C)c                    V ^8  d   QhRRRR/# r   r7   r"   r#   r@   r   )r   s   "r   r   r      s        c  i  r   c                    V P                   '       d=   VP                  R4      '       d
   VR,          pV P                  P                  RV4      pV P	                  V4      # )z(split a row of text into list of cells. r(   :   NNr   )r   r-   r/   sub_split)r   r7   s   &&r   r2   TableProcessor._split_row   sJ    ;;;~~c"""g$$((S1C{{3r   c                    V ^8  d   QhRRRR/# rl   r   )r   s   "r   r   r      s     F F# F) Fr   c                   . p. p. p. p. p. pV P                   P                  V4       EF<  pVP                  ^4      '       dl   VP                  \	        VP                  ^4      4      ^,
          4       VP                  VP                  ^4      VP                  ^4      ^,
          ^34       K  VP                  ^4      '       df   VP                  \	        VP                  ^4      4      4       VP                  VP                  ^4      VP                  ^4      ^,
          ^ 34       EK  VP                  ^4      '       g   EK  VP                  VP                  ^4      4       EK?  	  ^ p	\	        V4      p
W8  d    WI,          WY,          ^,          ,
          pV^ 8X  d   \        hWI^,           R P                  V4      ^,           pVP                  WY,          ^ ,          WYV,           ,          ^,          34       W^,           ,          p	K  V F]  pRpV F7  pW^ ,          8  d    M)V^ ,          Tu;8:  d   V^,          8:  g   K1  M K5  Rp M	  V'       d   KL  VP                  V4       K_  	  ^ p	V F  pVP                  WV 4       V^,           p	K!  	  VP                  WR 4       V#   \         d    T	^,          p	 EKM  i ; i)z9split a row of text with some code into a list of cells. NFT)	RE_CODE_PIPESfinditergrouprL   r+   startend
ValueErrorr;   )r   r7   elementspipestics
tic_points
tic_region
good_pipesmpostic_lentic_sizer;   pipe	throw_outregions   &&              r   rp   TableProcessor._split   sD   


 ##,,S1Awwqzz C
Oa/0!!1771:quuQx!|Q"?@ C
O,!!1771:quuQx!|Q"?@QWWQZ(! 2, d)m9zq'99q=$$1WX,,X6:!!:?1#5z+7Nq7Q"RSqy  DI$)#AY$3&)33 $I % 9!!$'  DOOCDM*(C  	D	"7  qs   =BJ+ +KK)r   r   r   )__name__
__module____qualname____firstlineno____doc__recompilert   r/   r   r<   rT   rP   rO   r2   rp   __static_attributes____classcell__r   s   @r   r
   r
   &   sT    JJDEMJJ56M! !"H>>8* F Fr   r
   c                  2   a  ] tR t^tRtV 3R ltR tRtV ;t# )TableExtensionzAdd tables to Markdown. c                	@   < R RR./V n          \        SV `  ! R/ VB  R# )r`   Fz-True to use align attribute instead of style.Nr   )r   r   r   )r   kwargsr   s   &,r   r   TableExtension.__init__   s,    !E+Z#[
 	/"6"r   c                    RVP                   9  d   VP                   P                  R4       \        VP                  V P	                  4       4      pVP                  P
                  P                  VR^K4       R# )z6Add an instance of `TableProcessor` to `BlockParser`. r(   rG   N)ESCAPED_CHARSrL   r
   r   
getConfigsblockprocessorsregister)r   md	processors   && r   extendMarkdownTableExtension.extendMarkdown   sW    b&&&##C("299doo.?@	
		!!**9grBr   )r   )	r   r   r   r   r   r   r   r   r   r   s   @r   r   r      s    ##C Cr   r   c                     \        R/ V B # )Nr   )r   )r   s   ,r   makeExtensionr      s    #F##r   )r   
__future__r   r   r   r   r   xml.etree.ElementTreerM   ElementTreer   typingr   r   r   r   r,   r.   r1   r
   r   r   r   r   r   <module>r      s[    #  , % % 	 / /		
{^ {|CY C&$r   