
Je|Mc           @   s  d  Z  d d d d f Z d Z d d k Z d d k Z d d k Z d d k l Z l Z l	 Z	 l
 Z
 l Z l Z l Z l Z e Z e d	  Z e i e
  e   a e	 d
  Z t i e  t i e  e i t  d   Z d Z e Z d Z d Z d d f d d f f Z h  e i f d <e i e i f d <Z  d   Z! d Z" d Z# e# d Z$ d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* g Z% d+   Z& e i' d,  d- f e i' d.  d/ f e i' d0  d1 f g Z( e i' d2  d- f e i' d.  d/ f e i' d0  d1 f e i' d3  d4 f g Z) d5   Z* d6 f  d7     YZ+ d8 f  d9     YZ, d: f  d;     YZ- d< f  d=     YZ. d> f  d?     YZ/ d@ f  dA     YZ0 dB f  dC     YZ1 dD e0 f dE     YZ2 e2   Z3 dF e1 f dG     YZ4 e4   Z5 dH e1 f dI     YZ6 e6   Z7 dJ e1 f dK     YZ8 e8   Z9 dL Z: dM e: dN dO e: dP dO e: dQ Z; dR Z< dS Z= dT Z> dU Z? dV Z@ dW ZA dX ZB e o
 dY ZC n dZ ZC d[ ZD d\ ZE e< e; d] ZF e< e; d^ ZG d_ e; d] ZH e< e; d` ZI d_ e; d` ZJ da ZK db ZL dc ZM dd ZN de ZO df ZP dg ZQ dh f  di     YZR eR ZS dj eR f dk     YZT dl eR f dm     YZU dn eU f do     YZV dp eR f dq     YZW dr eU f ds     YZX dt eR f du     YZY dv eR f dw     YZZ dx eR f dy     YZ[ dz eR f d{     YZ\ d| e\ f d}     YZ] d~ eR f d     YZ^ d eR f d     YZ_ eT e?  Z` eT eK  Za eW e=  Zb eW e>  Zc eU eA d  Zd eU eD d  Ze eU e@ d  Zf eU eC d  Zg eX eB d  Zh eX eE d  Zi eV eP d  Zj eV eQ d  Zk eZ eF  Zl eZ eG  Zm e[ eH  Zn e] eJ  Zo e\ eI  Zp eY eN  Zq eY eO  Zr e^ eL  Zs e_ eM  Zt d f  d     YZu d f  d     YZv d ev f d     YZw ew   Zx d f  d     YZy d f  d     YZz d   Z{ d   Z| d f  d     YZ} e}   Z~ d f  d     YZ e e g  e e e d  Z g  e d  Z d f  d     YZ d e" Z d   Z e d j o0 e   Z e o e i d  n e e   n d S(   s   1.7i   i   i    s   rc-2s
   $Rev: 72 $iN(   t	   getLoggert   StreamHandlert	   Formattert   DEBUGt   INFOt   WARNt   ERRORt   CRITICALt   MARKDOWNs%   %(name)s-%(levelname)s: "%(message)s"c         C   s   t  i |  |  d S(   s.    A wrapper method for logging debug messages. N(   t   loggert   log(   t   levelt   text(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   message5   s    i   s   [HTML_REMOVED]u   ֐u   ߿u   ⴰu   ⵿s   utf-8s   utf-16c         C   sf   t  |  t  } xP t | D]D } | o | i |  p | } |  i |  o |  i |  Sq q W|  S(   N(   t
   isinstancet   unicodet   BOMSt   decodet
   startswitht   lstrip(   R   t   encodingt   convertt   bom(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt	   removeBOMT   s     s   python markdown.pyt   qaodmasdkwaspemass   %dajkqlsmdqpakldnzsdflst   pt   divt
   blockquotet   pret   tablet   dlt   olt   ult   scriptt   noscriptt   formt   fieldsett   iframet   matht   inst   delt   hrs   hr/t   stylec         C   s,   |  t  j p |  d d j o |  d d j S(   Ni    t   hi   t
   0123456789(   t   BLOCK_LEVEL_ELEMENTS(   t   tag(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   isBlockLevelo   s    t   &s   &amp;t   <s   &lt;t   >s   &gt;s   &(?!\#)s   "s   &quot;c         C   s   |  p d  Sn |  d } t | t  p | i   o d  Sn> x: t D]. \ } } | | j o | | j o d SqG qG Wd Sd  S(   Ni    t   rtlt   ltr(   t   NoneR   R   t   isalphat   RTL_BIDI_RANGES(   R   t   cht   mint   max(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   getBidiType   s     
 t   Documentc           B   sq   e  Z d    Z d   Z d   Z d d  Z d   Z d   Z d   Z	 d   Z
 e d  Z d	   Z d
   Z RS(   c         C   s   d |  _  d  S(   NR4   (   t   bidi(   t   self(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   __init__   s    c         C   s(   | |  _  t | _ |  | _ h  |  _ d  S(   N(   t   documentElementt   Truet   isDocumentElementt   parentt   entities(   R>   t   child(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   appendChild   s    			c         C   s   | o | |  _  n d  S(   N(   R=   (   R>   R=   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   setBidi   s    c         C   s:   t  |  } |  | _ | o | i |  i |   n | S(   N(   t   Elementt   docRF   t   createTextNode(   R>   R.   t   textNodet   el(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   createElement   s
    	c         C   s   t  |  } |  | _ | S(   N(   t   TextNodeRI   (   R>   R   t   node(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRJ      s    	c         C   s2   | |  i  j o t |  |  i  | <n |  i  | S(   N(   RD   t   EntityReference(   R>   t   entity(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   createEntityReference   s    c         C   s   t  |  } |  | _ | S(   N(   t   CDATARI   (   R>   R   RO   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   createCDATA   s    	c         C   s   |  i  i   S(   N(   R@   t   toxml(   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRU      s    c         C   sD   | o
 t  } n t } x& | D] \ } } | i | |  } q W| S(   N(   t%   ENTITY_NORMALIZATION_EXPRESSIONS_SOFTt    ENTITY_NORMALIZATION_EXPRESSIONSt   sub(   R>   R   t   avoidDoubleNormalizingt   regexpst   regexpt   substitution(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   normalizeEntities   s    
 c         C   s   |  i  i |  S(   N(   R@   t   find(   R>   t   test(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR^      s    c         C   s   |  i  i   d  |  _  d  S(   N(   R@   t   unlinkR5   (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR`      s    N(   t   __name__t
   __module__R?   RF   RG   R5   RM   RJ   RR   RT   RU   t   FalseR]   R^   R`   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR<      s   								RS   c           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   t   cdatac         C   s   | |  _  d  S(   N(   R   (   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?      s    c         C   s   d  S(   N(    (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   handleAttributes   s    c         C   s   d |  i  d S(   Ns	   <![CDATA[s   ]]>(   R   (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRU      s    (   Ra   Rb   t   typeR?   Re   RU   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRS      s   		RH   c           B   st   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
 d  Z d   Z RS(   t   elementc         C   s:   | |  _  g  |  _ h  |  _ g  |  _ d  |  _ t |  _ d  S(   N(   t   nodeNamet
   attributest   attribute_valuest
   childNodesR5   R=   Rc   RB   (   R>   R.   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?      s    					c         C   sJ   | o? |  i  } |  i  p
 |  i o | |  _  |  i i |  qF n d  S(   N(   R=   RB   RC   RG   (   R>   R=   t	   orig_bidi(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRG      s
    		c         C   s?   x/ |  i  D]$ } | i d j o | i   q
 q
 Wd  |  _  d  S(   NRg   (   Rk   Rf   R`   R5   (   R>   RE   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR`      s
    
 c         C   s5   | |  i  j o |  i  i |  n | |  i | <d  S(   N(   Ri   t   appendRj   (   R>   t   attrt   value(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   setAttribute  s    c         C   s    |  i  i | |  |  | _ d  S(   N(   Rk   t   insertRC   (   R>   t   positionRE   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   insertChild	  s    c         C   s   |  i  i |  d  S(   N(   Rk   t   remove(   R>   RE   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   removeChild  s    c         C   s3   |  i  i |  } |  i |  |  i | |  d  S(   N(   Rk   t   indexRu   Rs   (   R>   t   oldChildt   newChildRr   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   replaceChild  s    c         C   s   |  i  i |  |  | _ d  S(   N(   Rk   Rm   RC   (   R>   RE   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRF     s    c         C   s   d  S(   N(    (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRe     s    i    c         C   sj   g  } x] |  i  D]R } | |  o | i |  n | i d j o | | i | | d  7} q q W| S(   s;    Returns a list of descendants that pass the test function Rg   i   (   Rk   Rm   Rf   R^   (   R>   R_   t   deptht   matched_nodesRE   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR^     s    
 "c         C   s  t  o" x |  i D] } | i   q Wn d } |  i d j o | d 7} n |  i d j o | d 7} n d } |  i p |  i d j o | d
 7} x! |  i D] } | | i   7} q W|  i d j o | d 7} n |  i d j o | d 7} n | d |  i 7} n | d 7} | d |  i 7} |  i d j o_ |  i i d  pH |  i o |  i } n |  i i } | d j o |  i	 d d  qqn xJ |  i
 D]? } |  i | } |  i i | d t } | d | | f 7} qW| | 7} |  i d j o | d 7} n | S(   Nt    t   h1t   h2t   h3t   h4s   
t   lis   
 R   R2   R   s   </%s>s   />R1   R    R   t   h5t   h6t   dirR3   RY   s    %s="%s"s   br (   R}   s   h2R   R   (   s   li(   s
   blockquote(
   R   s   lis   ulR   R}   s   h2R   R   R   R   (	   R   s   br s   lis   ulR   R}   s   h2R   R   (   t   ENABLE_ATTRIBUTESRk   Re   Rh   RU   Rj   t   has_keyR=   RI   Rp   Ri   R]   RA   (   R>   RE   t   buffert   childBufferR=   Rn   Ro   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRU   &  sR    
 

 



 	

(   Ra   Rb   Rf   R?   RG   R`   Rp   Rs   Ru   Ry   RF   Re   R^   RU   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRH      s   										
RN   c           B   sA   e  Z d  Z e i d  Z d   Z d   Z d   Z d   Z	 RS(   R   s   \{@([^\}]*)=([^\}]*)}c         C   s   | |  _  d  S(   N(   Ro   (   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?   h  s    c         C   s)   |  i  i | i d  | i d   d  S(   Ni   i   (   RC   Rp   t   group(   R>   t   match(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   attributeCallbackk  s    c         C   s"   |  i  i |  i |  i  |  _ d  S(   N(   t
   attrRegExpRX   R   Ro   (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRe   o  s    c         C   s   |  i  } |  i i t |   | i t  pq |  i i d j o | i d d  } q |  i i d j o1 |  i i d |  j o d | i d d  } q n |  i	 i
 |  } | S(   NR   s   
s   
   R   i    s   
     (   Ro   RC   RG   R;   R   t   HTML_PLACEHOLDER_PREFIXRh   t   replaceRk   RI   R]   (   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRU   r  s    	(
   Ra   Rb   Rf   t   ret   compileR   R?   R   Re   RU   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRN   c  s   			RP   c           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   t
   entity_refc         C   s   | |  _  d  S(   N(   RQ   (   R>   RQ   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?     s    c         C   s   d  S(   N(    (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRe     s    c         C   s   d |  i  d S(   NR0   t   ;(   RQ   (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRU     s    (   Ra   Rb   Rf   R?   Re   RU   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRP     s   		t   TextPreprocessorc           B   s   e  Z d  Z d   Z RS(   s`  
    TextPreprocessors are run before the text is broken into lines.
    
    Each TextPreprocessor implements a "run" method that takes a pointer to a
    text string of the document, modifies it as necessary and returns
    either the same pointer or a pointer to a new string.  
    
    TextPreprocessors must extend markdown.TextPreprocessor.
    c         C   s   d  S(   N(    (   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   run  s    (   Ra   Rb   t   __doc__R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   	t   Preprocessorc           B   s   e  Z d  Z d   Z RS(   sK  
    Preprocessors are run after the text is broken into lines.

    Each preprocessor implements a "run" method that takes a pointer to a
    list of lines of the document, modifies it as necessary and returns
    either the same pointer or a pointer to a new list.  
    
    Preprocessors must extend markdown.Preprocessor.
    c         C   s   d  S(   N(    (   R>   t   lines(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   	t   HtmlBlockPreprocessorc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s7   Removes html blocks from the source text and stores it.c         C   s'   | d i  d d d  i   d i   S(   Ni   R2   t    i    (   R   t   splitt   lower(   R>   t   block(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   _get_left_tag  s    c         C   s"   | i    t |  d d !i   S(   Ni   i(   t   rstript   lenR   (   R>   t   left_tagR   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   _get_right_tag  s    c         C   s   | d j p | d d
 j o t  Sn d | | j o t  Sn | d j o | d j o t  Sn/ | | d j o | d d	 j o t  Sn t Sd  S(   NR   i    t   ?t   @t   %t   /s   --i   R1   (   R   R   R   (   RA   Rc   (   R>   R   t	   right_tag(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   _equal_tags  s    c         C   s
   | d j S(   NR)   s   hr/(   R)   s   hr/(    (   R>   R.   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   _is_oneliner  s    c         C   sN  g  } | i  d  } g  } d } d } t } x| D]} | i d  o | d } n | p:| i d  o|  i |  } |  i | |  } t |  p | d d j p | i |  q4 n |  i |  o | i | i    q4 n | d d j o d
 } |  i | |  } n | i	   i
 d  o9 |  i | |  o& | i |  i i | i     q4 q| i | i    t } q4 n | i |  q4 | i | i    |  i | |  } |  i | |  o2 t } | i |  i i d i |    g  } q4 q4 W| o3 | i |  i i d i |    | i d  n d i |  S(   Ns   

R|   s   
i   R1   t   !R   R   R   s   --R2   (   R   R   R   R   (   R   Rc   R   R   R   R/   Rm   R   t   stripR   t   endswithR   t   stasht   storeRA   t   join(   R>   R   t
   new_blockst   itemsR   R   t   in_tagR   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     sX     "(   Ra   Rb   R   R   R   R   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   				t   HeaderPreprocessorc           B   s   e  Z d  Z d   Z RS(   sj   
       Replaces underlined headers with hashed headers to avoid
       the nead for lookahead later.
    c         C   sP  d } xC| d t  |  j  o+| d } | | i   p q	 n | | i d  o | i | d d  n | d t  |  j o | | d o | | d d d j o | | d i   } | d t  |  j o* d | | i   | | <d	 | | d <qG| d t  |  j o* d
 | | i   | | <d	 | | d <qGq	 q	 W| S(   Nii   t   #s   
i    t   -t   =s   # R|   s   ## (   R   R   (   R   R   R   Rq   (   R>   R   t   it	   underline(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   $  s&     
(   Ra   Rb   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   LinePreprocessorc           B   s/   e  Z d  Z e i d  Z d   Z d   Z RS(   s>   Deals with HR lines (needs to be done before processing lists)s   ^(> )+c         C   s   x t  t |   D]~ } d } |  i i | |  } | o | i d  } n |  i | | t |   o$ | |  i i d d t | | <q q W| S(   NR|   i    s   <hr />t   safe(	   t   rangeR   t   blockquote_ret   searchR   t   _isLineR   R   RA   (   R>   R   R   t   prefixt   m(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   F  s      (c         C   s   | i  d  o d Sn d i g  } | D] } | i   p | | q) q) ~  } t |  d j o d Sn xP d d d g D]; } t i | i |  } | o | i d  o d Sq~ q~ Wd Sd	 S(
   s5   Determines if a block should be replaced with an <HR>s       i    R|   i   t   isline1t   isline2t   isline3i   N(   R   R   t   isspaceR   t   REt   regExpR   R   (   R>   R   t   _[1]t   xR   t   patternR   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   O  s     ; (   Ra   Rb   R   R   R   R   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   A  s   		t   ReferencePreprocessorc           B   s   e  Z d  Z d   Z RS(   sU    
    Removes reference definitions from the text and stores them for later use.
    c         C   sU  g  } xH| D]@} t  i d i |  } | o| i d  i   i   } | i d  i   } | p  | i d  | f |  i | <qMt |  d j o | d | d j o
 d j n pH | d | d j o
 d j n p" | d d	 j o8 | d d
 j o' | i d  | d d !f |  i | <qM| i |  q | i |  q W| S(   Ns   reference-defi   i   i   i    is   "s   't   (t   )i   (	   R   R   R   R   R   R   t
   referencesR   Rm   (   R>   R   t   new_textt   lineR   t   idt   t(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   d  s"      &&"'(   Ra   Rb   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   _  s   s   [^\]\[]*s   \[(s   (\[i   s   \])*s   )\]s   (?<!\!)s   \`([^\`]*)\`s   \`\`(.*)\`\`s   \\(.)s   \*([^\*]*)\*s   \*\*(.*)\*\*s   \*\*\*([^_]*)\*\*\*s   (?<!\S)_(\S[^_]*)_s	   _([^_]*)_s   __([^_]*)__s   ___([^_]*)___s   \s*\(([^\)]*)\)s   \s*\(<([^\)]*)>\)s   \!s   \s*\[([^\]]*)\]s   ( \* )s   <(http://[^>]*)>s   <([^> \!]*@[^> ]*)>s   (\<[a-zA-Z/][^\>]*\>)s   (&[\#a-zA-Z0-9]*;)s     \ns     $t   Patternc           B   s   e  Z d    Z d   Z RS(   c         C   s)   | |  _  t i d | t i  |  _ d  S(   Ns   ^(.*)%s(.*)$(   R   R   R   t   DOTALLt   compiled_re(   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?     s    	c         C   s   |  i  S(   N(   R   (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   getCompiledRegExp  s    (   Ra   Rb   R?   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   	t   SimpleTextPatternc           B   s   e  Z d    Z RS(   c         C   s   | i  | i d   S(   Ni   (   RJ   R   (   R>   R   RI   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   handleMatch  s    (   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   SimpleTagPatternc           B   s   e  Z d    Z d   Z RS(   c         C   s   t  i |  |  | |  _ d  S(   N(   R   R?   R.   (   R>   R   R.   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?     s    c         C   s5   | i  |  i  } | i | i | i d    | S(   Ni   (   RM   R.   RF   RJ   R   (   R>   R   RI   RL   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R?   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   	t   SubstituteTagPatternc           B   s   e  Z d    Z RS(   c         C   s   | i  |  i  S(   N(   RM   R.   (   R>   R   RI   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   BacktickPatternc           B   s   e  Z d    Z d   Z RS(   c         C   s   t  i |  |  d |  _ d  S(   Nt   code(   R   R?   R.   (   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?     s    c         C   sA   | i  |  i  } | i d  i   } | i | i |   | S(   Ni   (   RM   R.   R   R   RF   RJ   (   R>   R   RI   RL   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R?   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   	t   DoubleTagPatternc           B   s   e  Z d    Z RS(   c         C   sf   |  i  i d  \ } } | i |  } | i |  } | i |  | i | i | i d    | S(   Nt   ,i   (   R.   R   RM   RF   RJ   R   (   R>   R   RI   t   tag1t   tag2t   el1t   el2(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   HtmlPatternc           B   s   e  Z d    Z RS(   c         C   s4   | i  d  } t } |  i i |  } | i |  S(   Ni   (   R   RA   R   R   RJ   (   R>   R   RI   t   rawhtmlt   inlinet   place_holder(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   LinkPatternc           B   s   e  Z d    Z RS(   c         C   s   | i  d  } | i | i | i d    | i d  i d  } | o | i d | d i    n | i d d  t |  d j o= d d i | d  i   } t	 |  } | i d	 |  n | S(
   Nt   ai   i	   t   "t   hrefi    R|   i   t   title(
   RM   RF   RJ   R   R   Rp   R   R   R   t   dequote(   R>   R   RI   RL   t   partsR   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   ImagePatternc           B   s   e  Z d    Z RS(   c         C   s  | i  d  } | i d  i   } | o | i d | d  n | i d d  t |  d j o' | i d t d i | d    n t oL | i | i d	   } | i	 |  | i
   | i } | i i |  n | i d	  } | i d
 |  | S(   Nt   imgi	   t   srci    R|   i   R   R   i   t   alt(   RM   R   R   Rp   R   R   R   R   RJ   RF   Re   Ro   Rk   Rt   (   R>   R   RI   RL   t	   src_partsR   t   truealt(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   $  s     '
	(   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   "  s   t   ReferencePatternc           B   s   e  Z d    Z d   Z RS(   c         C   s   | i  d  o | i  d  i   } n | i  d  i   } |  i i |  p d  Sn |  i | \ } } | i  d  } |  i | | | |  S(   Ni	   i   (   R   R   R   R   R5   t   makeTag(   R>   R   RI   R   R   R   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   :  s    c         C   sT   | i  d  } | i d |  | o | i d |  n | i | i |   | S(   NR   R   R   (   RM   Rp   RF   RJ   (   R>   R   R   R   RI   RL   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   I  s    (   Ra   Rb   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   8  s   	t   ImageReferencePatternc           B   s   e  Z d    Z RS(   c         C   sN   | i  d  } | i d |  | o | i d |  n | i d |  | S(   NR   R   R   R   (   RM   Rp   (   R>   R   R   R   RI   RL   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   T  s    (   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   R  s   t   AutolinkPatternc           B   s   e  Z d    Z RS(   c         C   sK   | i  d  } | i d | i d   | i | i | i d    | S(   NR   R   i   (   RM   Rp   R   RF   RJ   (   R>   R   RI   RL   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   _  s    (   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   ]  s   t   AutomailPatternc           B   s   e  Z d    Z RS(   c   	   
   C   s   | i  d  } | i d  } | i d  o | t d  } n x4 | D], } | i d t |   } | i |  qI Wd | } d i g  } | D] } | d t |  q ~  } | i d |  | S(   NR   i   s   mailto:s   #%dR|   s   &#%d;R   (	   RM   R   R   R   RR   t   ordRF   R   Rp   (	   R>   R   RI   RL   t   emailt   letterRQ   t   mailtoR   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   g  s     
4(   Ra   Rb   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   e  s   t   strongt   ems	   strong,ems   br t   Postprocessorc           B   s   e  Z d  Z d   Z RS(   s  
    Postprocessors are run before the dom it converted back into text.
    
    Each Postprocessor implements a "run" method that takes a pointer to a
    NanoDom document, modifies it as necessary and returns a NanoDom 
    document.
    
    Postprocessors must extend markdown.Postprocessor.

    There are currently no standard post-processors, but the footnote
    extension uses one.
    c         C   s   d  S(   N(    (   R>   t   dom(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   TextPostprocessorc           B   s   e  Z d  Z d   Z RS(   s,  
    TextPostprocessors are run after the dom it converted back into text.
    
    Each TextPostprocessor implements a "run" method that takes a pointer to a
    text string, modifies it as necessary and returns a text string.
    
    TextPostprocessors must extend markdown.TextPostprocessor.
    c         C   s   d  S(   N(    (   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    (   Ra   Rb   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   t   RawHtmlTextPostprocessorc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   d  S(   N(    (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?     s    c         C   s   x t  |  i i  D] } |  i i | \ } } |  i og | o_ t |  i  i   d j o |  i |  } q t |  i  i   d j o
 d } q t } n | i	 d t
 | | d  } | i	 t
 | |  } q W| S(   Nt   escapeRt   R|   s
   <p>%s
</p>s   
(   R   R   t   html_countert   rawHtmlBlockst   safeModet   strR   R  t   HTML_REMOVED_TEXTR   t   HTML_PLACEHOLDER(   R>   R   R   t   htmlR   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s     

c         C   sF   | i  d d  } | i  d d  } | i  d d  } | i  d d  S(	   s    Basic html escaping R0   s   &amp;R1   s   &lt;R2   s   &gt;R   s   &quot;(   R   (   R>   R  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR    s    (   Ra   Rb   R?   R   R  (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s   		t	   HtmlStashc           B   s#   e  Z d  Z d   Z e d  Z RS(   su   This class is used for stashing HTML objects that we extract
        in the beginning and replace with place-holders.c         C   s   d |  _  g  |  _ d  S(   Ni    (   R  R  (   R>   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?     s    	c         C   s6   |  i  i | | f  t |  i } |  i d 7_ | S(   s^  Saves an HTML segment for later reinsertion.  Returns a
           placeholder string that needs to be inserted into the
           document.

           @param html: an html segment
           @param safe: label an html segment as safe for safemode
           @param inline: label a segmant as inline html
           @returns : a placeholder string i   (   R  Rm   R  R  (   R>   R  R   t   placeholder(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s    	(   Ra   Rb   R   R?   Rc   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR	    s   	t	   BlockGuruc           B   s&   e  Z d  d  Z d   Z d   Z RS(   i    c         C   s.  g  } d } d } x| D] } | i    o | o | | | f Sn | i    o~ | ow | d 7} x> t | t |   D]& } | | i    o | | }	 Pq| q| WP| |	  }
 |
 o | i d  q q Pn | |  }
 |
 o | i |
  | d 7} q q | | | f Sq W| d 7} | | | f S(   s  Functional magic to help determine boundaries of indented
           blocks.

           @param lines: an array of strings
           @param fn: a function that returns a substring of a string
                      if the string matches the necessary criteria
           @param allowBlank: specifies whether it's ok to have blank
                      lines between matching functions
           @returns: a list of post processes items and the unused
                      remainder of the original listii    i   R|   (   R   R   R   Rm   (   R>   R   t   fnt
   allowBlankR   t   itemR   R   t   jt   nextt   part(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt	   _findHead  s8     
 
	

c         C   s6   t  i d i |  } | o | i d  Sn d Sd S(   s/    An auxiliary method to be passed to _findHead t   tabbedi   N(   R   R   R   R   R5   (   R>   R   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   detabbed_fn8  s    c         C   s   |  i  | |  i d d S(   NR  i   (   R  R  (   R>   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   detectTabbedA  s    (   Ra   Rb   R  R  R  (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR    s   <		c         C   s   t  i i |  d  d S(   s   Print an error string to stderrs   
N(   t   syst   stderrt   write(   t   string(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   print_errorG  s    c         C   sW   |  i  d  o |  i d  p  |  i  d  o |  i d  o |  d d !Sn |  Sd S(   s%    Removes quotes from around a string R   t   'i   iN(   R   R   (   R  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR   L  s      t   CorePatternsc           B   sw   e  Z d  Z h  d d <d d <d d <d d <d	 d
 <d d <d d <d d <d d <d d <Z d   Z RS(   sL   This class is scheduled for removal as part of a refactoring
        effort.s   (#*)([^#]*)(#*)t   headers&   (\ ?\ ?\ ?)\[([^\]]*)\]:\s*([^ ]*)(.*)s   reference-defs   ([-]*)$|^([=]*)t   containslines   [ ]{0,3}[\d]*\.\s+(.*)R   s   [ ]{0,3}[*+-]\s+(.*)R    s   (\**)R   s   (\-*)R   s   (\_*)R   s   ((\t)|(    ))(.*)R  s   > ?(.*)t   quotedc         C   sj   h  |  _  x> |  i i   D]- } t i d |  i | t i  |  i  | <q Wt i d t i  |  i  d <d  S(   Ns   ^%s$s   ^([-]*)$|^([=]*)$R  (   R   t   patternst   keysR   R   R   t   M(   R>   t   key(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?   p  s    	 (   Ra   Rb   R   R   R?   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR  ^  s   									t   Markdownc           B   s   e  Z d  Z d g  d e d  Z d   Z d   Z d   Z d   Z	 d d d  Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z d d  Z d   Z e Z RS(   sS    Markdown formatter class for creating an html document from
        Markdown text c         C   s   | |  _  | d j	 o t t d  n | |  _ t   |  _ g  |  _ d |  _ d |  _	 t
 g |  _ t t t g |  _ g  |  _ t g |  _ g  |  _ t t t t t t t t t t t t t  t! t" t# t$ t% t& t' t( g |  _) |  i* d | d |  |  i+   d S(   s  Creates a new Markdown instance.

           @param source: The text in Markdown format. Depreciated!
           @param extensions: A list if extensions.
           @param extension-configs: Configuration setting for extensions.
           @param safe_mode: Disallow raw html. s   The `source` arg of Markdown.__init__() is depreciated and will be removed in the future. Use `instance.convert(source)` instead.i   R|   t
   extensionst   configsN(,   t   sourceR5   R   R   R  R  t	   blockGurut   registeredExtensionst   stripTopLevelTagst   docTypet   HTML_BLOCK_PREPROCESSORt   textPreprocessorst   HEADER_PREPROCESSORt   LINE_PREPROCESSORt   REFERENCE_PREPROCESSORt   preprocessorst   postprocessorst   RAWHTMLTEXTPOSTPROCESSORt   textPostprocessorst   prePatternst   DOUBLE_BACKTICK_PATTERNt   BACKTICK_PATTERNt   ESCAPE_PATTERNt   REFERENCE_PATTERNt   LINK_ANGLED_PATTERNt   LINK_PATTERNt   IMAGE_LINK_PATTERNt   IMAGE_REFERENCE_PATTERNt   AUTOLINK_PATTERNt   AUTOMAIL_PATTERNt   LINE_BREAK_PATTERN_2t   LINE_BREAK_PATTERNt   HTML_PATTERNt   ENTITY_PATTERNt   NOT_STRONG_PATTERNt   STRONG_EM_PATTERNt   STRONG_EM_PATTERN_2t   STRONG_PATTERNt   STRONG_PATTERN_2t   EMPHASIS_PATTERNt   EMPHASIS_PATTERN_2t   inlinePatternst   registerExtensionst   reset(   R>   R'  R%  t   extension_configst	   safe_mode(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?     sN    							c         C   s   | p
 h  } n x | D] } d | } y t  |  } Wn t t d | | f  q X| i |  o | | } n g  } | i |  } | i |  t    q Wd  S(   Nt   mdx_s2   couldn't load extension %s (looking for %s module)(   t
   __import__R   R   R   t   makeExtensiont   extendMarkdownt   globals(   R>   R%  R&  t   extt   extension_module_namet   modulet   configs_for_extt	   extension(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRL    s     
 
c         C   s   |  i  i |  d S(   s#    This gets called by the extension N(   R)  Rm   (   R>   RY  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   registerExtension  s    c         C   s   h  |  _  t   |  _ |  i t _ |  i t _ |  i  t _  |  i t _ |  i t _ |  i  t	 _  |  i  t
 _  |  i t _ |  i t _ x |  i D] } | i   q Wd S(   sL   Resets all state variables so that we can start
            with a new text.N(   R   R	  t	   htmlStashR,  R   R/  R0  RB  RC  R9  R=  R3  R  R)  RM  (   R>   RY  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRM    s    	
 c         C   s  t    |  _ |  i i d  |  _ |  i i |  i i d   |  i i d d  |  i i |  i  |  i } | i d d  i d d  } | d 7} | i	 t
  } | i d  |  _ x& |  i D] } | i |  i  |  _ q Wg  } xN |  i D]C } | i d  o  |  i |  i |  | g } q | i |  q W|  i |  i |  |  i i |  i i d   x! |  i D] } | i |  i  qnW|  i S(	   sa   Transforms the Markdown text into a XHTML body document

           @returns: A NanoDom Document t   spans   
t   classt   markdowns   
s   s   

R   (   R<   RI   RM   t   top_elementRF   RJ   Rp   R'  R   t
   expandtabst
   TAB_LENGTHR   R   R1  R   R   t   _processSectionRm   R2  (   R>   R   t   prepR   R   t   postprocessor(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt
   _transform  s4    	

 
 
 i    c   
      C   s  x| oyh  |  i  d <|  i d <|  i d <|  i d <} xW d d d d g D]C } t i | i | d  } | o | | | | |  d SqS qS W| oF |  i | d    \ } } |  i | | | d d	 | | d } nr |  i | d
    \ }	 } t	 |	  o( |	 d i
 d  o |  i | |	  n" |	 o |  i | |	 | |  n | o  | d i   o | d } q q Wd S(   s  Process a section of a source document, looking for high
           level structural elements like lists, block quotes, code
           segments, html blocks, etc.  Some those then get stripped
           of their high level markup (e.g. get unindented) and the
           lower-level markup is processed recursively.

           @param parent_elem: A NanoDom element to which the content
                               will be added
           @param lines: a list of lines
           @param inList: a level
           @returns: NoneR    R   R  R  i    Nc         S   s9   t  i d  i |   p" t  i d i |   p |  i   S(   R    R   (   R   R   R   R   (   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   <lambda>_  s    i   t	   looseListc         S   s   |  i    S(    (   R   (   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRf  j  s    R   (   t   _processUListt   _processOListt   _processQuotet   _processCodeBlockR   R   R   t   _linesUntilRb  R   R   t   _processHeadert   _processParagraphR   (
   R>   t   parent_elemR   t   inListRg  t	   processFnR[   R   t   startt	   paragraph(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRb  .  s2      !c         C   s   t  i d i | d  } | or t | i d   } |  i i d |  } | i |  xD |  i | i d  i	    D] } | i |  qx Wn t
 t d  d  S(   NR  i    i   s   h%di   s   We've got a problem header!(   R   R   R   R   R   RI   RM   RF   t   _handleInlineR   R   R   (   R>   Ro  Rs  R   R   R+   R  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRm  x  s     c         C   s   |  i  d i |   } | i d j o | p | i o
 | } n  |  i i d  } | i |  x | D] } | i |  qj Wd  S(   Ns   
R   R   (   Rt  R   Rh   Rk   RI   RM   RF   (   R>   Ro  Rs  Rp  Rg  t   listRL   R  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRn    s    
 c         C   s#   |  i  | | | d d d d d  S(   Nt   listexprR    R.   (   t   _processList(   R>   Ro  R   Rp  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRh    s    c         C   s#   |  i  | | | d d d d d  S(   NRv  R   R.   (   Rw  (   R>   Ro  R   Rp  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRi    s    c      	   C   sS  |  i  i |  } | i |  d } g  } d }	 d }
 x| D]} d } | i   p |
 d 7}
 d } x> t |
 t |   D]& } | | i   o | | } Pq} q} WPt i d i |  p. t i d i |  p t i d i |  o+ | |	 i	 | i    | p | } q> qPn x d d d g D] } t i | i |  } | on | d j o' | i	 | i
 d  g  |	 d 7}	 n, | d j o | |	 i	 | i
 d   n |
 d 7}
 Pq-q-W| |	 i	 |  |
 d 7}
 q> W|
 d 7}
 xJ | D]B }	 |  i  i d  } | i |  |  i | |	 | d d	 | qW|  i | | |
 |  d
 S(   s{  Given a list of document lines starting with a list item,
           finds the end of the list, breaks it up, and recursively
           processes each list item and the remainder of the text file.

           @param parent_elem: A dom element to which the content will be added
           @param lines: a list of lines
           @param inList: a level
           @returns: Nonei    ii   R    R   R  i   R   Rg  N(   s   uls   ol(   RI   RM   RF   R   R   R   R   R   R   Rm   R   Rb  (   R>   Ro  R   Rp  Rv  R.   R    Rg  R   R  R   R   t   looseR  R  t   exprR   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRw    sZ    
 
 
	 
	
 !c         C   sO   d } x4 | D]" } | d 7} | |  o Pq q W| d 7} | |  | | f S(   s    A utility function to break a list of lines upon the
            first line that satisfied a condition.  The condition
            argument should be a predicate function.
            ii   (    (   R>   R   t	   conditionR   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRl    s     
 	
c   
      C   s*  g  } d } t  } x | D] } t i d i |  } | o* | i | i d   | d 7} t  } q | o. | i   d j o | i |  | d 7} q | o4 | i   d j o! | i |  | d 7} t } q Pq W|  i i	 d  }	 | i
 |	  |  i |	 | |  |  i | | | |  d S(   s  Given a list of document lines starting with a quote finds
           the end of the quote, unindents it and recursively
           processes the body of the quote and the remainder of the
           text file.

           @param parent_elem: DOM element to which the content will be added
           @param lines: a list of lines
           @param inList: a level
           @returns: None i    R  i   R|   R   N(   Rc   R   R   R   Rm   R   R   RA   RI   RM   RF   Rb  (
   R>   Ro  R   Rp  t   dequotedR   t
   blank_lineR   R   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRj    s,     



c   	      C   s   |  i  i |  \ } } |  i i d  } |  i i d  } | i |  | i |  d i |  i   d } | i |  i i |   |  i | | |  d S(   s  Given a list of document lines starting with a code block
           finds the end of the block, puts it into the dom verbatim
           wrapped in ("<pre><code>") and recursively processes the
           the remainder of the text file.

           @param parent_elem: DOM element to which the content will be added
           @param lines: a list of lines
           @param inList: a level
           @returns: NoneR   R   s   
N(	   R(  R  RI   RM   RF   R   R   RJ   Rb  (	   R>   Ro  R   Rp  t   detabbedt   theRestR   R   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRk  *  s    c         C   s>  | g } x | t  |  i  j  o d } x | t  |  j  o | | } t | t t f  og |  i | |  i | |  } | o@ | d 8} | i |  x& | D] } | i | d |  q Wq n | d 7} q+ W| d 7} q WxT t t  |   D]@ } | | } t | t t f  o |  i	 i
 |  | | <q q W| S(   s`  Transform a Markdown line with inline elements to an XHTML
        fragment.

        This function uses auxiliary objects called inline patterns.
        See notes on inline patterns above.

        @param line: A line of Markdown text
        @param patternIndex: The index of the inlinePattern to start with
        @return: A list of NanoDom nodes i    i   (   R   RK  R   R  R   t   _applyPatternRt   Rq   R   RI   RJ   (   R>   R   t   patternIndexR   R   R   t   resultt   y(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyRt  B  s2    	  
	
	
   
c   
      C   s  | i    i |  } | p d Sn | i | |  i  } t | t  o| i d j o x | i D] } t | t	  o |  i
 | i | d  } | o | | g j o qc n | i   | i i |  } | i |  xo | D]c }	 t |	 t t f  o7 t |	  d j o  | i | |  i i |	   qCq | i | |	  q WqOqc qc Wq[n | o$ | i   d | | i d  f Sn d Sd S(   s   Given a pattern name, this function checks if the line
        fits the pattern, creates the necessary elements, and returns
        back a list consisting of NanoDom elements and/or strings.
        
        @param line: the text to be processed
        @param pattern: the pattern to be checked

        @returns: the appropriate newly created NanoDom element if the
                  pattern matches, None otherwise.
        R   R   i   i    iN(   s   codes   pre(   R   R   R5   R   RI   R   RH   Rh   Rk   RN   Rt  Ro   t   reverseRv   Ru   R  R   R   Rs   RJ   t   groupsR   (
   R>   R   R   R  R   RO   RE   R  Rr   R  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR  n  s8    
 
 	(c      
   C   s  | d j	 o | |  _ n |  i p d Sn y t |  i  |  _ Wn$ t j
 o t t d  d Sn Xx& |  i D] } | i |  i  |  _ qs W|  i   } | i	   } |  i
 o | i   d d !d } n x  |  i D] } | i |  } q W|  i | i   S(   sP   Return the document in XHTML format.

        @returns: A serialized XHTML body.u    sB   UnicodeDecodeError: Markdown only accepts unicode or ascii  input.i   is   
N(   R5   R'  R   t   UnicodeDecodeErrorR   R   R-  R   Re  RU   R*  R   R4  R+  (   R>   R'  t   ppRI   t   xml(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR     s(    
	
 

 c         C   sT   |  i  d j o
 d } n* d t |  i   |  i  i d  d f } d |  i | f S(   s>    Report info about instance. Markdown always returns unicode. s*   in which no source text has been assinged.s1   which contains %d chars and %d line(s) of source.s   
i   s   An instance of "%s" %sN(   R'  R5   R   t   countt	   __class__(   R>   t   status(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   __str__  s
    
&N(   Ra   Rb   R   R5   Rc   R?   RL  RZ  RM  Re  Rb  Rm  Rn  Rh  Ri  Rw  Rl  Rj  Rk  Rt  R  R   R  t   __unicode__(    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR$  |  s.   B				5I					U		'	,	E#		c   
      C   s   t  i |  t t d |   | p
 d } n t i |  d d d | } | i   } | i   t | |  } t	 | | d | } | o3 t i | d d | }	 |	 i
 |  |	 i   n t i i
 | i |   d  S(   Ns   input file: %ss   utf-8t   modet   rR   RO  t   w(   t   console_hndlrt   setLevelR   R   t   codecst   opent   readt   closeR   R^  R  R  t   stdoutt   encode(
   t   inputt   outputR%  R   t   message_thresholdR   t
   input_fileR   R   t   output_file(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   markdownFromFile  s    

c      
   C   s  t  t d |   g  } h  } x | D] } | i d  } | d j o | i |  q$ | |  } | i |  g  } | | d d !i d  D] }	 | |	 i d  q ~ }
 g  } |
 D]% \ }	 } | |	 i   | i   f q ~ } | | | <q$ Wt d | d | d	 |  } | i |   S(
   Ns)   in markdown.markdown(), received text:
%sR   ii   R   R   R%  RN  RO  (   R   R   R^   Rm   R   R   R$  R   (   R   R%  RO  t   extension_namesRN  RU  t   post   nameR   R   t   pairst   _[2]R  R&  t   md(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR^    s"     
>9	t	   Extensionc           B   s/   e  Z h  d   Z d   Z d   Z d   Z RS(   c         C   s   | |  _  d  S(   N(   t   config(   R>   R&  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR?   #  s    c         C   s.   |  i  i |  o |  i  | d Sn d Sd  S(   Ni    R|   (   R  R   (   R>   R#  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt	   getConfig&  s    c         C   s9   g  } |  i  i   D] } | | |  i  | d f q ~ S(   Ni   (   R  R!  (   R>   R   R#  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   getConfigInfo,  s    c         C   s   | |  i  | d <d  S(   Ni    (   R  (   R>   R#  Ro   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt	   setConfig/  s    (   Ra   Rb   R?   R  R  R  (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyR  !  s   		s   
Python 2.3 or higher required for advanced command line options.
For lower versions of Python use:

      %s INPUT_FILE > OUTPUT_FILE
    
c          C   s:  y t  d  }  Wnk t t i  d j oE h  t i d d <d  d <t d <t d <g  d <d  d	 <Sq~ t GHd  Sn X|  i d
 d  } | i	 d d d d d d d d | i	 d d d d	 d d | i	 d d d t d d d d d d d d | i	 d  d! d d d t
 d d d d" | i	 d# d$ d d d t d d% d d& | i	 d' d d d t d d d d( | i	 d) d* d d+ d d d d, d d- | i   \ } } t |  d j p | i   d  Sn | d. } | i p g  | _ n h  | d <| i d <| i d <| i d <| i d <| i d	 <S(/   Nt   optparsei   i   R  R  R  R   R%  R   t   usages   %prog INPUTFILE [options]s   -fs   --filet   destt   filenamet   helps   write output to OUTPUT_FILEt   metavart   OUTPUT_FILEs   -es
   --encodings#   encoding for input and output filess   -qs   --quiett   defaultt   actiont   store_constt   consti<   t   verboses   suppress all messagess   -vs	   --verboses   print info messagess   -ss   --safet	   SAFE_MODEs<   same mode ('replace', 'remove' or 'escape'  user's HTML tag)s   --noisys   print debug messagess   -xs   --extensionRm   s   load extension EXTENSIONt	   EXTENSIONi    (   RQ  R   R  t   argvR5   R   Rc   t   OPTPARSE_WARNINGt   OptionParsert
   add_optionR   R   t
   parse_argst
   print_helpR%  R  R  R   R   (   R  t   parsert   optionst   argsR  (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pyt   parse_options;  sZ    				


t   __main__(   t   versiont   version_infot   __revision__R   R  R  t   loggingR    R   R   R   R   R   R   R   t   MESSAGE_THRESHOLDR	   R  R  t	   formattert   setFormattert
   addHandlerR   Ra  RA   R   t   SMART_EMPHASISR  R7   t   BOM_UTF8t   BOM_UTF16_LEt   BOM_UTF16_BER   R   t   EXECUTABLE_NAME_FOR_USAGER   R  R-   R/   R   RW   RV   R;   R<   RS   RH   RN   RP   R   R   R   R,  R   R.  R   R/  R   R0  t	   NOBRACKETt   BRKt   NOIMGt   BACKTICK_REt   DOUBLE_BACKTICK_REt	   ESCAPE_REt   EMPHASIS_REt	   STRONG_REt   STRONG_EM_REt   EMPHASIS_2_REt   STRONG_2_REt   STRONG_EM_2_REt   LINK_REt   LINK_ANGLED_REt   IMAGE_LINK_REt   REFERENCE_REt   IMAGE_REFERENCE_REt   NOT_STRONG_REt   AUTOLINK_REt   AUTOMAIL_REt   HTML_REt	   ENTITY_REt   LINE_BREAK_REt   LINE_BREAK_2_RER   t   BasePatternR   R   R   R   R   R   R   R   R   R   R   R   R8  RD  R7  R6  RG  RH  RI  RJ  RE  RF  RA  R@  R;  R:  R<  R=  R9  RB  RC  R>  R?  R   R   R   R3  R	  R  R  R   R  R   R$  R5   Rc   R  R^  R  R  R  Ra   R  t   exit(    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/WebHelpers-1.2-py2.5.egg/webhelpers/markdown.pys   <module>   s  $:				
		;_	!			/&
			M			  m
	:	