ó Šē\c@@s’dZddlmZddlmZddlmZddlmZddlm Z d efd „ƒYZ d efd „ƒYZ id „Z dS(uL Tables Extension for Python-Markdown ==================================== Added parsing of tables to Python-Markdown. A simple example: First Header | Second Header ------------- | ------------- Content Cell | Content Cell Content Cell | Content Cell Copyright 2009 - [Waylan Limberg](http://achinghead.com) i(tabsolute_import(tunicode_literalsi(t Extensioni(tBlockProcessor(tetreetTableProcessorcB@s2eZdZd„Zd„Zd„Zd„ZRS(u Process Tables. cC@si|jdƒ}t|ƒdkohd|dkohd|dkohd|dkoh|djƒddkS( Nu iu|iiu-u:(u|u:u-(tsplittlentstrip(tselftparenttblocktrows((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pyttests" cC@sy|jdƒjdƒ}|djƒ}|djƒ}|d}t}|jdƒr`t}ng}x“|j||ƒD]} | jdƒr­| jdƒr­|jdƒqy| jdƒrĢ|jdƒqy| jdƒrė|jd ƒqy|jd ƒqyWt j |d ƒ} t j | d ƒ} |j || ||ƒt j | d ƒ} x*|D]"} |j | jƒ| ||ƒqOWd S(u& Parse a table block and build table. iu iiu|u:ucenterulefturightutableutheadutbodyN( tpopRRtFalset startswithtTruet _split_rowtendswithtappendtNoneRt SubElementt _build_row(R R tblocksR theadert seperatorR tbordertaligntcttablettheadttbodytrow((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pytrun s,   c C@sĀtj|dƒ}d}|jdkr0d}n|j||ƒ}xyt|ƒD]k\}} tj||ƒ} y||jƒ| _Wntk r d| _nX| rO| jd| ƒqOqOWdS(u) Given a row of text, build table cells. utrutdutheaduthuualignN( RRttagRt enumerateRttextt IndexErrortset( R R!R RRttrR#tcellstitaR((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pyR=s   cC@sN|rA|jdƒr"|d}n|jdƒrA|d }qAn|jdƒS(u) split a row of text into list of cells. u|ii’’’’(RRR(R R!R((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pyROs  (t__name__t __module__t__doc__R R"RR(((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pyRs    tTableExtensioncB@seZdZd„ZRS(u Add tables to Markdown. cC@s&|jjjdt|jƒdƒdS(u3 Add an instance of TableProcessor to BlockParser. utableu /usr/lib/python2.7/site-packages/markdown/extensions/tables.pytextendMarkdown\s (R,R-R.R5(((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pyR/YscC@s td|ƒS(Ntconfigs(R/(R6((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pyt makeExtensioncsN( R.t __future__RRtRR1RtutilRRR/R7(((s>/usr/lib/python2.7/site-packages/markdown/extensions/tables.pytsB