mò
1W˙=c           @   sE   d  k  Z  d k l Z l Z l Z l Z d e  i f d     YZ d  S(   N(   s   lowers   replaces   splits   joint	   HTML2Textc           B   sf   t  Z d k l Z f  d d d  Z d   Z d   Z d   Z d   Z d	   Z	 d
   Z
 d   Z RS(   N(   s
   entitydefsi   iP   c         C   s\   t  i i |   d |  _ d |  _ d |  _ | |  _ | |  _	 g  |  _
 g  |  _ | |  _ d  S(   Nt    i    (   t   sgmllibt
   SGMLParsert   __init__t   selft   resultt   indentt	   ol_numbert
   page_widtht   indent_widtht
   inde_widtht   linest   linet   ignore_tags(   R   R   R
   R	   (    (    tM   /home2/kennisonb/webapps/zope/Zope/Products/Squishdot/stripogram/html2text.pyR      s    							c         C   s,   t  t | d d   } |  i i |  d  S(   Ns   
t    (   t   splitt   replacet   textt   wordsR   R   t   extend(   R   R   R   (    (    R   t   add_text   s    c         C   s)   |  i i |  i |  i f  g  |  _ d  S(   N(   R   R   t   appendR   R   (   R   (    (    R   t	   add_break    s    c         C   s"  |  i } |  i } g  } xñ |  i |  i |  i f g D]Ó \ } } | | } | d }
 | | } d } g  } d }	 xp | D]h } t |  } |	 | | j  o | i |  |	 | }	 qx | |
 t | d  d } | g } | }	 qx W| |
 t | d  } | i |  q5 Wt | d  |  _ d  S(   NR   R   i    s   
s   

(   R   R   R
   R	   t	   out_parasR   R   R   t   it   indent_stringt
   line_widtht   out_parat   out_linet   len_out_linet   wordt   lent   len_wordR   t   joinR   (   R   R"   R   R	   R
   R   R   R   R   R   R   R    R   R   (    (    R   t   generate$   s.    		 


 	
c         C   s1   |  i | |  _ |  i d j  o d |  _ n d  S(   Ni    (   R   R   R   (   R   R   (    (    R   t
   mod_indentB   s    c         C   s   | o |  i |  n d  S(   N(   t   dataR   R   (   R   R&   (    (    R   t   handle_dataG   s    c         C   s  t  |  } | |  i j oq| d d j p | d d d d g j o |  i   q| d j oY d } x1 | D]) \ } } t  |  d	 j o
 | } qn qn W|  i   |  i	 d
 |  q| d j oS |  i   |  i
 o. |  i	 t |  i
  d  |  i
 d |  _
 q|  i	 d  q| d d g j o |  i   |  i d  q| d d d g j o+ |  i d  | d j o d |  _
 qqn d S(   s4    Convert HTML to something meaningful in plain text i    t   ht   brt   pret   pt   hrt   imgR   t   srcs   Image: t   lis    - i   s   - t   ddt   dtt   ult   dlt   olN(   t   lowert   tagR   R   R   R.   t   attrst   kt   vR   R   t   strR%   (   R   R6   R7   R.   R9   R8   (    (    R   t   unknown_starttagK   s4     * 



c         C   sÖ   t  |  } | |  i j oĥ | d d j p | d g j o |  i   qÒ | d j o |  i   qÒ | d d g j o |  i   |  i d  qÒ | d d	 d
 g j o$ |  i   |  i d  d |  _ qÒ n d S(   s4    Convert HTML to something meaningful in plain text i    R(   R*   R/   R0   R1   i˙˙˙˙R2   R3   R4   N(   R5   R6   R   R   R   R%   R   (   R   R6   (    (    R   t   unknown_endtagu   s     !

(   t   __name__t
   __module__t   htmlentitydefst
   entitydefsR   R   R   R$   R%   R'   R;   R<   (    (    (    R   R       s   						*(   R   t   stringR5   R   R   R#   R   R    (   R   R5   R#   R   R    R   (    (    R   t   ?	   s   	