Ë
     2ÚiYn  ã                   ó  — d Z ddlmZ ddlZddlZddlZ	 ddlmZ ddlm	Z	 ddlmZ ddlmZ dd	lmZmZ dd
lmZmZ 	 e 	 e 	 e g d¢Z ej8                  dej:                  ej<                  z  «      j>                  Z  ej8                  dej<                  «      j>                  Z! ej8                  dgejD                  d   dk\  rejF                  fnd¢­Ž jH                  Z% ej8                  dej<                  «      jL                  Z' ej8                  dej<                  «      jL                  Z( ej8                  dej<                  «      jH                  Z)d„ Z* ej8                  d«      j>                  Z+ ej8                  dej<                  ej:                  z  «      Z, ejZ                  d«      Z. ejZ                  ddei¬«      Z/ G d„ de0«      Z1 e1«       Z2e2jf                  Z3 ej8                  dej<                  «       ej8                  dej<                  «      gZ4g d¢Z5 ej8                  d ej<                  «       ej8                  d!ej<                  «       ej8                  d"«      gZ6d#gZ7e4e5e6e7fd$„Z8d%„ Z9d&„ Z:e8j                   e:_         g d'¢Z;d(gZ<d)e;e< ed*«      fd+„Z=d,„ Z>d-„ Z? ej8                  d.ej<                  «      Z@d/„ ZAy# e
$ r ddlmZm	Z	 Y �Œ»w xY w# e$ r eZY �Œªw xY w# e$ r eZY �Œµw xY w# e$ r eefZY �ŒÂw xY w)0zcA cleanup tool for HTML.

Removes unwanted tags and content.  See the `Cleaner` class for
details.
é    )Úabsolute_importN)Úurlsplit)Úunquote_plus)r   r   )Úetree)Údefs)Ú
fromstringÚXHTML_NAMESPACE)Úxhtml_to_htmlÚ_transform_result)Ú
clean_htmlÚcleanÚCleanerÚautolinkÚautolink_htmlÚ
word_breakÚword_break_htmlzexpression\s*\(.*?\)z
@\s*importz</?[a-zA-Z]+|\son[a-zA-Z]+\s*=é   © zdata:image/(.+);base64,z:(javascript|jscript|livescript|vbscript|data|about|mocha):z	(xml|svg)c                 óx   — d}t        | «      D ]  }t        |«      r y|dz  }Œ t        t        | «      «      |kD  S )Nr   Té   )Ú_find_image_dataurlsÚ_is_unsafe_image_typeÚlenÚ_possibly_malicious_schemes)ÚsÚsafe_image_urlsÚ
image_types      úF/var/www/html/acx/venv/lib/python3.12/site-packages/lxml/html/clean.pyÚ_has_javascript_schemer   V   sH   € Ø€OÜ*¨1Ó-ò ˆ
Ü  Ô,ÙØ˜1Ñ‰ðô Ô*¨1Ó-Ó.°Ñ@Ð@ó    z[\s\x00-\x08\x0B\x0C\x0E-\x19]+z\[if[\s\n\r]+.*?][\s\n\r]*>zdescendant-or-self::*[@style]zÂdescendant-or-self::a  [normalize-space(@href) and substring(normalize-space(@href),1,1) != '#'] |descendant-or-self::x:a[normalize-space(@href) and substring(normalize-space(@href),1,1) != '#']Úx)Ú
namespacesc            	       ó.  — e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZdZej.                  ZdZdZddhZd„ Z ed	d
ddgd	d	d	d
¬«      Zd„ Zd„ Zd„ Z d„ Z!d„ Z"dd„Z#d„ Z$ e%jL                  de%jN                  «      jP                  Z)d„ Z*d„ Z+y)r   a  
    Instances cleans the document of each of the possible offending
    elements.  The cleaning is controlled by attributes; you can
    override attributes in a subclass, or set them in the constructor.

    ``scripts``:
        Removes any ``<script>`` tags.

    ``javascript``:
        Removes any Javascript, like an ``onclick`` attribute. Also removes stylesheets
        as they could contain Javascript.

    ``comments``:
        Removes any comments.

    ``style``:
        Removes any style tags.

    ``inline_style``
        Removes any style attributes.  Defaults to the value of the ``style`` option.

    ``links``:
        Removes any ``<link>`` tags

    ``meta``:
        Removes any ``<meta>`` tags

    ``page_structure``:
        Structural parts of a page: ``<head>``, ``<html>``, ``<title>``.

    ``processing_instructions``:
        Removes any processing instructions.

    ``embedded``:
        Removes any embedded objects (flash, iframes)

    ``frames``:
        Removes any frame-related tags

    ``forms``:
        Removes any form tags

    ``annoying_tags``:
        Tags that aren't *wrong*, but are annoying.  ``<blink>`` and ``<marquee>``

    ``remove_tags``:
        A list of tags to remove.  Only the tags will be removed,
        their content will get pulled up into the parent tag.

    ``kill_tags``:
        A list of tags to kill.  Killing also removes the tag's content,
        i.e. the whole subtree, not just the tag itself.

    ``allow_tags``:
        A list of tags to include (default include all).

    ``remove_unknown_tags``:
        Remove any tags that aren't standard parts of HTML.

    ``safe_attrs_only``:
        If true, only include 'safe' attributes (specifically the list
        from the feedparser HTML sanitisation web site).

    ``safe_attrs``:
        A set of attribute names to override the default list of attributes
        considered 'safe' (when safe_attrs_only=True).

    ``add_nofollow``:
        If true, then any <a> tags will have ``rel="nofollow"`` added to them.

    ``host_whitelist``:
        A list or set of hosts that you can use for embedded content
        (for content like ``<object>``, ``<link rel="stylesheet">``, etc).
        You can also implement/override the method
        ``allow_embedded_url(el, url)`` or ``allow_element(el)`` to
        implement more complex rules for what can be embedded.
        Anything that passes this test will be shown, regardless of
        the value of (for instance) ``embedded``.

        Note that this parameter might not work as intended if you do not
        make the links absolute before doing the cleaning.

        Note that you may also need to set ``whitelist_tags``.

    ``whitelist_tags``:
        A set of tags that can be included with ``host_whitelist``.
        The default is ``iframe`` and ``embed``; you may wish to
        include other tags like ``script``, or you may want to
        implement ``allow_embedded_url`` for more control.  Set to None to
        include all tags.

    This modifies the document *in place*.
    TFNr   ÚiframeÚembedc                 óž  — t        «       }|j                  «       D ]Z  \  }}t        | ||«      }|�9|dur5|dur1t        |t        t
        t        t        f«      st        d|›d|›�«      ‚t        | ||«       Œ\ | j                  €d|vr| j                  | _
        |j                  d«      r$|j                  d«      rt        d«      ‚d| _        y y )	NTFzUnknown parameter: ú=Úinline_styleÚ
allow_tagsÚremove_unknown_tagsúIIt does not make sense to pass in both allow_tags and remove_unknown_tags)ÚobjectÚitemsÚgetattrÚ
isinstanceÚ	frozensetÚsetÚtupleÚlistÚ	TypeErrorÚsetattrr(   ÚstyleÚgetÚ
ValueErrorr*   )ÚselfÚkwÚnot_an_attributeÚnameÚvalueÚdefaults         r   Ú__init__zCleaner.__init__ã   sØ   € Ü!›8ÐØŸ8™8›:ò 	'‰KˆD�%Ü˜d DÐ*:Ó;ˆGØÐ#¨°tÑ(;ÀÈuÑ@TÜ& w´¼CÄÌÐ0MÔNÝÚ26¹Ð>ó@ð @ä�D˜$ Õ&ð	'ð ×ÑÐ$¨¸rÑ)AØ $§
¡
ˆDÔà�6‰6�,ÔØ�v‰vÐ+Ô,Ü ð "Fó Gð Gà',ˆDÕ$ð	  r    ÚsrcÚhrefÚcoder,   )ÚscriptÚlinkÚappletr$   r%   ÚlayerÚac                 ó²  — 	 |j                   } |«       }t        |«       |j                  d«      D ]	  }d|_        Œ | j
                  s| j                  |«       t        | j                  xs d«      }t        | j                  xs d«      }t        | j                  xs d«      }| j                  r|j                  d«       | j                  rbt        | j                  «      }|j                  t        j                   «      D ]+  }|j"                  }|j%                  «       D ]
  }	|	|vsŒ||	= Œ Œ- | j&                  �r×| j                  r| j                  t(        j                  k(  sZ|j                  t        j                   «      D ]8  }|j"                  }|j%                  «       D ]  }	|	j+                  d«      sŒ||	= Œ Œ: |j-                  | j.                  d¬«       | j0                  spt3        |«      D ]b  }|j5                  d«      }
t7        d	|
«      }t9        d	|«      }| j;                  |«      r|j"                  d= ŒK||
k7  sŒQ|j                  d|«       Œd | j<                  s¯t?        |j                  d«      «      D ]’  }|j5                  d
d	«      jA                  «       jC                  «       dk(  r|jE                  «        ŒE|jF                  xs d	}
t7        d	|
«      }t9        d	|«      }| j;                  |«      rd|_#        Œ†||
k7  sŒŒ||_#        Œ” | j
                  r|j                  t        jH                  «       | jJ                  r|j                  t        jL                  «       | j<                  r|j                  d«       | j0                  rt        jN                  |d«       | jP                  r|j                  d«       n|| j<                  s| j&                  rdt?        |j                  d«      «      D ]G  }d|j5                  dd	«      jA                  «       v sŒ&| jS                  |«      rŒ8|jE                  «        ŒI | jT                  r|j                  d«       | jV                  r|jY                  d«       | jZ                  r•t?        |j                  d«      «      D ]V  }|j]                  «       }|�/|j                  dvr!|j]                  «       }|�|j                  dvrŒ!|�ŒG|jE                  «        ŒX |jY                  d«       |jY                  d«       | j^                  r|jY                  t(        j`                  «       | jb                  r"|j                  d«       |jY                  d«       | jd                  r|jY                  d«       g }g }|j                  «       D ]f  }|j                  |v r$| jS                  |«      rŒ#|jg                  |«       Œ5|j                  |v sŒD| jS                  |«      rŒV|jg                  |«       Œh |r;|d   |k(  r3|ji                  d«      }d|_        |j"                  jk                  «        nA|r?|d   |k(  r7|ji                  d«      }|j                  dk7  rd|_        |jk                  «        |jm                  «        |D ]  }|jE                  «        Œ |D ]  }|jo                  «        Œ | jp                  r&|rts        d«      ‚t        t(        jt                  «      }|rß| j
                  s|j                  t        jH                  «       | jJ                  s|j                  t        jL                  «       g }|j                  «       D ]"  }|j                  |vsŒ|jg                  |«       Œ$ |rP|d   |u r2|ji                  d«      }d|_        |j"                  jk                  «        |D ]  }|jo                  «        Œ | jv                  r\ty        |«      D ]M  }| j{                  |«      rŒ|j5                  d«      }|rd|v rdd |z  v rŒ4d!|z  }nd}|j                  d|«       ŒO yy# t        $ r Y �Œ@w xY w)"z&
        Cleans the document.
        ÚimageÚimgr   rC   ÚonF)Úresolve_base_hrefr6   Ú Útypeztext/javascriptz/* deleted */rD   Ú
stylesheetÚrelÚmeta)ÚheadÚhtmlÚtitleÚparamN)rE   r,   )rE   )r$   r%   rF   r,   rU   Úform)ÚbuttonÚinputÚselectÚtextarea)ÚblinkÚmarqueer   ÚdivrS   r+   Únofollowz
 nofollow z %s z%s nofollow)>ÚgetrootÚAttributeErrorr
   ÚiterÚtagÚcommentsÚkill_conditional_commentsr1   Ú	kill_tagsÚremove_tagsr)   ÚscriptsÚaddÚsafe_attrs_onlyÚ
safe_attrsr   ÚElementÚattribÚkeysÚ
javascriptr   Ú
startswithÚrewrite_linksÚ_remove_javascript_linkr(   Ú_find_styled_elementsr7   Ú_replace_css_javascriptÚ_replace_css_importÚ_has_sneaky_javascriptr6   r3   ÚlowerÚstripÚ	drop_treeÚtextÚCommentÚprocessing_instructionsÚProcessingInstructionÚstrip_attributesÚlinksÚallow_elementrQ   Úpage_structureÚupdateÚembeddedÚ	getparentÚframesÚ
frame_tagsÚformsÚannoying_tagsÚappendÚpopÚclearÚreverseÚdrop_tagr*   r8   ÚtagsÚadd_nofollowÚ_find_external_linksÚallow_follow)r9   Údocr_   Úelre   rf   r)   rj   rl   ÚanameÚoldÚnewÚparentÚ_removeÚ_killÚbadrP   s                    r   Ú__call__zCleaner.__call__  s  € ð	Ø—k‘kˆGñ “)ˆCä�cÔð —(‘(˜7Ó#ò 	ˆBØˆB�Fð	à�}Š}ð ×*Ñ*¨3Ô/ä˜Ÿ™Ò,¨"Ó-ˆ	Ü˜$×*Ñ*Ò0¨bÓ1ˆÜ˜Ÿ™Ò.¨BÓ/ˆ
à�<Š<Ø�M‰M˜(Ô#Ø×ÒÜ˜TŸ_™_Ó-ˆJØ—h‘hœuŸ}™}Ó-ò *�ØŸ™�Ø#Ÿ[™[›]ò *�EØ JÒ.Ø" 5™Mñ*ð*ð
 �?‹?Ø×(Ò(Ø—O‘O¤t§¡Ò6àŸ(™(¤5§=¡=Ó1ò .�BØŸY™Y�FØ!'§¡£ò .˜Ø ×+Ñ+¨DÕ1Ø & u¡ñ.ð.ð
 ×Ñ˜d×:Ñ:Ø05ð ô 7ð ×$Ò$Ü/°Ó4ò -�BØŸ&™& ›/�CÜ1°"°cÓ:�CÜ-¨b°#Ó6�CØ×2Ñ2°3Ô7àŸI™I gÑ.Ø ›ØŸ™˜w¨Õ,ð-ð —:’:Ü˜sŸx™x¨Ó0Ó1ò &�BØ—v‘v˜f bÓ)×/Ñ/Ó1×7Ñ7Ó9Ð=NÒNØŸ™œØ ØŸ'™'š- R�CÜ1°"°cÓ:�Cä-¨b°#Ó6�CØ×2Ñ2°3Ô7à"1˜�Ø ›Ø"%˜�ð&ð �=Š=Ø�M‰Mœ%Ÿ-™-Ô(Ø×'Ò'Ø�M‰Mœ%×5Ñ5Ô6Ø�:Š:Ø�M‰M˜'Ô"Ø×ÒÜ×"Ñ" 3¨Ô0Ø�:Š:Ø�M‰M˜&Õ!Ø�ZŠZ˜4Ÿ?š?ô ˜3Ÿ8™8 FÓ+Ó,ò '�Ø 2§6¡6¨%°Ó#4×#:Ñ#:Ó#<Ò<à×-Ñ-¨bÕ1ØŸ™�ð	'ð
 �9Š9Ø�M‰M˜&Ô!Ø×ÒØ×ÑÐ8Ô9Ø�=Š=ô ˜3Ÿ8™8 GÓ,Ó-ò #�ØŸ™›�ØÐ(¨V¯Z©ZÐ?SÑ-SØ#×-Ñ-Ó/�Fð Ð(¨V¯Z©ZÐ?SÒ-Sà‘>Ø—L‘L•Nð#ð ×Ñ˜[Ô)à×ÑÐNÔOØ�;Š;ð ×ÑœTŸ_™_Ô-Ø�:Š:Ø�O‰O˜FÔ#Ø×ÑÐFÔGØ×ÒØ×ÑÐ3Ô4àˆØˆØ—(‘(“*ò 	#ˆBØ�v‰v˜Ñ"Ø×%Ñ% bÔ)ØØ—‘˜RÕ Ø—‘˜;Ò&Ø×%Ñ% bÔ)ØØ—‘˜rÕ"ð	#ñ �w˜q‘z SÒ(ð —‘˜Q“ˆBØˆBŒFØ�I‰I�O‰OÕÙ�u˜Q‘x 3’ð —‘˜1“ˆBØ�v‰v˜ÒØ�”Ø�H‰HŒJà�‰ŒØò 	ˆBØ�L‰L�Nð	àò 	ˆBØ�K‰K�Mð	ð ×#Ò#ÙÜ Ø_óað aäœTŸY™Y›ˆJÙà—=’=Ø—‘œuŸ}™}Ô-Ø×/Ò/Ø—‘œu×:Ñ:Ô;àˆCØ—h‘h“jò #�Ø—6‘6 Ò+Ø—J‘J˜r•Nð#ñ Ø�q‘6˜S‘=ØŸ™ ›�BØ"�B”FØ—I‘I—O‘OÔ%Øò "�BØ—K‘K•Mð"à×ÒÜ*¨3Ó/ò 
'�Ø×(Ñ(¨Õ,ØŸ&™& ›-�CÙØ&¨#Ñ-Ø$0°V¸c±\Ñ$BØ$Ø+¨cÑ1™à(˜Ø—F‘F˜5 #Õ&ñ
'ð øôM ò 	Úð	ús   ‚a	 á		aáac                  ó   — y)zF
        Override to suppress rel="nofollow" on some anchors.
        Fr   )r9   Úanchors     r   r�   zCleaner.allow_followÄ  s   € ð r    c                 ó@  — |j                   | j                  vry| j                  |j                      }t        |t        t        f«      r1|D ]+  }|j                  |«      }|s y| j                  ||«      rŒ+ y y|j                  |«      }|sy| j                  ||«      S )zÀ
        Decide whether an element is configured to be accepted or rejected.

        :param el: an element.
        :return: true to accept the element or false to reject/discard it.
        FT)rb   Ú_tag_link_attrsr/   r3   r2   r7   Úallow_embedded_url)r9   r’   ÚattrÚone_attrÚurls        r   r   zCleaner.allow_elementÊ  sœ   € ð �6‰6˜×-Ñ-Ñ-ØØ×#Ñ# B§F¡FÑ+ˆÜ�dœT¤5˜MÔ*Ø ò !�Ø—f‘f˜XÓ&�ÙÙ Ø×.Ñ.¨r°3Õ7Ù ð!ð à—&‘&˜“,ˆCÙØØ×*Ñ*¨2¨sÓ3Ð3r    c                 ó´   — | j                   �|j                  | j                   vryt        |«      }|j                  dvry|j                  | j
                  v ryy)a  
        Decide whether a URL that was found in an element's attributes or text
        if configured to be accepted or rejected.

        :param el: an element.
        :param url: a URL found on the element.
        :return: true to accept the URL and false to reject it.
        F)ÚhttpÚhttpsT)Úwhitelist_tagsrb   r   ÚschemeÚhostnameÚhost_whitelist)r9   r’   r¢   Úpartss       r   rŸ   zCleaner.allow_embedded_urlâ  sU   € ð ×ÑÐ*¨r¯v©v¸T×=PÑ=PÑ/PØÜ˜“ˆØ�<‰<Ð0Ñ0ØØ�>‰>˜T×0Ñ0Ñ0ØØr    c                 ón   ‡— t         j                  Š| j                  |ˆfd„t        j                  «       y)zÎ
        IE conditional comments basically embed HTML that the parser
        doesn't normally see.  We can't allow anything like that, so
        we'll kill any comments that could be conditional.
        c                 ó(   •—  ‰| j                   «      S ©N)ry   )r’   Úhas_conditional_comments    €r   ú<lambda>z3Cleaner.kill_conditional_comments.<locals>.<lambda>ü  s   ø€ Ñ3°B·G±GÓ<€ r    N)Ú_conditional_comment_reÚsearchÚ_kill_elementsr   rz   )r9   r‘   r®   s     @r   rd   z!Cleaner.kill_conditional_commentsô  s,   ø€ ô #:×"@Ñ"@ÐØ×ÑØÓ<Ü�M‰Mõ	r    c                 ó–   — g }|j                  |«      D ]  } ||«      sŒ|j                  |«       Œ |D ]  }|j                  «        Œ y r­   )ra   rˆ   rx   )r9   r‘   Ú	conditionÚiterater™   r’   s         r   r²   zCleaner._kill_elementsÿ  sK   € ØˆØ—(‘(˜7Ó#ò 	ˆBÙ˜�}Ø—
‘
˜2•ð	ð ò 	ˆBØ�L‰L�Nñ	r    c                 óH   — t        dt        |«      «      }t        |«      ry|S )NrM   )Ú_substitute_whitespacer   r   )r9   rD   r•   s      r   rq   zCleaner._remove_javascript_link  s#   € ä$ R¬°dÓ);Ó<ˆÜ! #Ô&àØˆr    z	/\*.*?\*/c                 óÒ   — | j                  d|«      }|j                  dd«      }t        d|«      }|j                  «       }t	        |«      ryd|v ryd|v ryd|v ryt        |«      ryy)aÆ  
        Depending on the browser, stuff like ``e x p r e s s i o n(...)``
        can get interpreted, or ``expre/* stuff */ssion(...)``.  This
        checks for attempt to do stuff like this.

        Typically the response will be to kill the entire style; if you
        have just a bit of Javascript in the style another rule will catch
        that and remove only the Javascript from the style; this catches
        more sneaky attempts.
        rM   ú\Tzexpression(z@importz
</noscriptF)Ú_substitute_commentsÚreplacer·   rv   r   Ú_looks_like_tag_content)r9   r6   s     r   ru   zCleaner._has_sneaky_javascript  sw   € ð ×)Ñ)¨"¨eÓ4ˆØ—‘˜d BÓ'ˆÜ& r¨5Ó1ˆØ—‘“ˆÜ! %Ô(ØØ˜EÑ!ØØ˜ÑØØ˜5Ñ àÜ" 5Ô)àØr    c                 ó¢   — t        |«      }t        |t        «      rt        |«      }nt	        j
                  |«      } | |«       t        ||«      S r­   )rN   r/   Ú
basestringr   ÚcopyÚdeepcopyr   )r9   rS   Úresult_typer‘   s       r   r   zCleaner.clean_html.  sA   € Ü˜4“jˆÜ�dœJÔ'Ü˜TÓ"‰Cä—-‘- Ó%ˆCÙˆSŒ	Ü  ¨cÓ2Ð2r    r­   ),Ú__name__Ú
__module__Ú__qualname__Ú__doc__rg   rn   rc   r6   r(   r~   rQ   r€   r{   r‚   r„   r†   r‡   rf   r)   re   r*   ri   r   rj   rŽ   r©   r¦   r?   Údictrž   rš   r�   r   rŸ   rd   r²   rq   ÚreÚcompileÚSÚsubrº   ru   r   r   r    r   r   r   m   s  „ ñ\ð| €GØ€JØ€HØ€EØ€LØ€EØ€DØ€NØ"ÐØ€HØ€FØ€EØ€MØ€KØ€JØ€IØÐØ€OØ—‘€JØ€LØ€NØ Ð(€Nò-ñ( ØØð ˜Ð!ØØØð ô#
€Oò(w'òrò4ò0ò$	óòð &˜2Ÿ:™: l°B·D±DÓ9×=Ñ=Ðòó:3r    r   zb(?P<body>https?://(?P<host>[a-z0-9._-]+)(?:/[/\-_.,a-z0-9%&?;=~]*)?(?:\([/\-_.,a-z0-9%&?;=~]*\))?)z9mailto:(?P<body>[a-z0-9._-]+@(?P<host>[a-z0-9_.-]+[a-z])))rZ   ÚprerB   rR   rY   rG   z
^localhostz\bexample\.(?:com|org|net)$z^127\.0\.0\.1$Únolinkc                 óø  — | j                   |v ry| j                  d«      }|r|j                  «       }|D ]  }||v sŒ y t        | «      D ]k  }t	        |||||¬«       |j
                  sŒ t        |j
                  ||| j                  ¬«      \  }}	|	sŒI||_        | j                  |«      }
|	| |
dz   |
dz    Œm | j                  r6t        | j                  ||| j                  ¬«      \  }}|r|| _	        || dd yyy)a  
    Turn any URLs into links.

    It will search for links identified by the given regular
    expressions (by default mailto and http(s) links).

    It won't link text in an element in avoid_elements, or an element
    with a class in avoid_classes.  It won't link to anything with a
    host that matches one of the regular expressions in avoid_hosts
    (default localhost and 127.0.0.1).

    If you pass in an element, the element's tail will not be
    substituted, only the contents of the element.
    NÚclass)Úlink_regexesÚavoid_elementsÚavoid_hostsÚavoid_classes)Úfactoryr   r   )
rb   r7   Úsplitr3   r   ÚtailÚ
_link_textÚmakeelementÚindexry   )r’   rÏ   rÐ   rÑ   rÒ   Ú
class_nameÚmatch_classÚchildry   Útail_childrenrØ   Úpre_childrens               r   r   r   N  s  € ð$ 
‡v�v�ÑØØ—‘˜“€JÙØ×%Ñ%Ó'ˆ
Ø(ò 	ˆKØ˜jÒ(Ùð	ô �b“ò 4ˆÜ� \Ø .Ø(Ø,õ	.ð �:‹:Ü",Ø—
‘
˜L¨+¸r¿~¹~ô#OÑˆD�-âØ!�”
ØŸ™ ›�Ø&3��5˜‘7˜5 ™7Ñ#ð4ð 
‡w‚wÜ'Ø�G‰G�\ ;¸¿¹ôHÑˆˆláØˆBŒGØ!ˆBˆr�‰Fð ð r    c                 ór  — d}g }d}	 d\  }}|D ]ƒ  }	|}
	 |	j                  | |
¬«      }|€n=|j                  d«      }|D ]%  }|j                  |«      sŒ|j                  «       }
 n nŒS|€Œ\|�|j                  «       |k  sŒr|}|j                  «       }Œ… |€)|r|d   j                  rJ ‚| |d   _        n|rJ ‚| }	 ||fS |j                  d«      }|j                  «       }|j                  d«      s|j                  d	«      r
|dz  }|d d }| d |j                  «        }|r|d   j                  rJ ‚||d   _        n|rJ ‚|} |d
«      }|j                  d|«       |j                  d«      }|s|}|j                  d«      s|j                  d	«      r|d d }||_        |j                  |«       | |d  } �Œ±)NrM   r   r   )NN)ÚposÚhostéÿÿÿÿú.ú,rG   rA   Úbody)	r±   ÚgroupÚendÚstartrÕ   Úendswithr1   ry   rˆ   )ry   rÏ   rÑ   rÓ   Úleading_textr~   Úlast_posÚ
best_matchÚbest_posÚregexÚ	regex_posÚmatchrà   Ú
host_regexrD   ræ   Ú	prev_textrœ   rä   s                      r   rÖ   rÖ   {  s  € Ø€LØ€EØ€HØ
Ø)Ñˆ
�HØ!ò 	)ˆEØ ˆIØØŸ™ T¨y˜Ó9�Ø�=ØØ—{‘{ 6Ó*�Ø"-ò �JØ!×(Ñ(¨Õ.Ø$)§I¡I£K˜	Ùðð
 ð ð ˆ}ØØÐ 5§;¡;£=°8Ó#;Ø"�
Ø Ÿ;™;›=‘ð#	)ð$ ÐáØ  ™9Ÿ>š>Ð)Ð)Ø!%��b‘	•á'Ð'Ð'Ø#�Øð0 ˜ÐÐð/ ×Ñ Ó"ˆØ�n‰nÓˆØ�=‰=˜Ô §¡¨sÔ!3à�1‰HˆCØ˜˜�9ˆDØÐ,˜*×*Ñ*Ó,Ð-ˆ	ÙØ˜R‘y—~’~Ð%Ð%Ø&ˆE�"‰I�Ná#Ð#Ð#Ø$ˆLÙ˜“ˆØ�
‰
�6˜4Ô Ø×Ñ Ó'ˆÙØˆDØ�=‰=˜Ô §¡¨sÔ!3Ø˜˜�9ˆDØˆŒØ�‰�VÔØ�C�Dˆzˆñg r    c                 ó°   — t        | «      }t        | t        «      rt        | «      }nt	        j
                  | «      }t        |g|¢­i |¤Ž t        ||«      S r­   )rN   r/   r¾   r   r¿   rÀ   r   r   ©rS   Úargsr:   rÁ   r‘   s        r   r   r   µ  sL   € Ü�t“*€KÜ�$œ
Ô#Ü˜Ó‰ä�m‰m˜DÓ!ˆÜˆSÐ�4Ò˜2ÒÜ˜[¨#Ó.Ð.r    )rË   rZ   rB   Únobreaké(   i   c                 óh  — | j                   t        v ry| j                  d«      }|r$d}|j                  «       }|D ]
  }||v sŒd} n |ry| j                  rt        | j                  ||«      | _        | D ];  }t        |||||¬«       |j                  sŒ t        |j                  ||«      |_        Œ= y)aç  
    Breaks any long words found in the body of the text (not attributes).

    Doesn't effect any of the tags in avoid_elements, by default
    ``<textarea>`` and ``<pre>``

    Breaks words by inserting &#8203;, which is a unicode character
    for Zero Width Space character.  This generally takes up no space
    in rendering, but does copy as a space, and in monospace contexts
    usually takes up space.

    See http://www.cs.tut.fi/~jkorpela/html/nobr.html for a discussion
    NrÎ   FT)Ú	max_widthrÐ   rÒ   Úbreak_character)rb   Ú_avoid_word_break_elementsr7   rÔ   ry   Ú_break_textr   rÕ   )	r’   rø   rÐ   rÒ   rù   rÙ   Ú
dont_breakÚavoidrÛ   s	            r   r   r   Ç  s¼   € ð& 
‡v�vÔ+Ñ+ØØ—‘˜“€JÙØˆ
Ø×%Ñ%Ó'ˆ
Ø"ò 	ˆEØ˜
Ò"Ø!�
Ùð	ñ ØØ	‡w‚wÜ˜bŸg™g y°/ÓBˆŒØò MˆÜ�5 IØ"0Ø!.Ø#2õ	4ð �:‹:Ü$ U§Z¡Z°¸OÓLˆE�JñMr    c                 ód   — t        | «      }t        | «      }t        |g|¢­i |¤Ž t        ||«      S r­   )rN   r   r   r   ró   s        r   r   r   ð  s4   € Ü�t“*€KÜ
�TÓ
€CÜˆsÐ �TÒ ˜RÒ Ü˜[¨#Ó.Ð.r    c                 ó�   — | j                  «       }|D ]0  }t        |«      |kD  sŒt        |||«      }| j                  ||«      } Œ2 | S r­   )rÔ   r   Ú_insert_breakr»   )ry   rø   rù   ÚwordsÚwordÚreplacements         r   rû   rû   ö  sM   € Ø�J‰J‹L€EØò 3ˆÜˆt‹9�yÓ Ü'¨¨i¸ÓIˆKØ—<‘<  kÓ2‰Dð3ð €Kr    z[^a-z]c                 ó$  — | }d}t        | «      |kD  rx| d | }t        t        j                  |«      «      }|r.|d   }|j	                  «       |dz
  kD  r| d |j	                  «        }|||z   z  }| t        |«      d  } t        | «      |kD  rŒx|| z  }|S )NrM   rá   é
   )r   r3   Ú_break_prefer_reÚfinditerræ   )r  Úwidthrù   Ú	orig_wordÚresultrç   ÚbreaksÚ
last_breaks           r   r   r      s«   € Ø€IØ€FÜ
ˆd‹)�eÒ
Ø�V�e�ˆÜÔ&×/Ñ/°Ó6Ó7ˆÙØ ™ˆJà�~‰~Ó %¨¡(Ò*ð Ð.˜jŸn™nÓ.Ð/�Ø�%˜/Ñ)Ñ)ˆØ”C˜“J�KÐ ˆô ˆd‹)�eÓ
ð ˆd�N€FØ€Mr    )BrÅ   Ú
__future__r   r¿   rÇ   ÚsysÚurlparser   Úurllibr   ÚImportErrorÚurllib.parseÚlxmlr   Ú	lxml.htmlr   r   r	   r
   r   ÚunichrÚ	NameErrorÚchrÚunicodeÚstrr¾   ÚbytesÚ__all__rÈ   rÉ   ÚIrÊ   rs   rt   Úversion_infoÚASCIIr±   r¼   Úfindallr   r   r   r   r·   r°   ÚXPathrr   r�   r,   r   r   r   Ú_link_regexesÚ_avoid_elementsÚ_avoid_hostsÚ_avoid_classesr   rÖ   r   rú   Ú_avoid_word_break_classesr   r   rû   r  r   r   r    r   ú<module>r&     s>  ðñõ 'ã Û 	Û 
ð4Ý!Ý#õ Ý ß 1ß 6ðÙ
ðÙðÙò
,€ð0 %˜"Ÿ*™*Ø˜RŸT™T "§$¡$™Yó(ß(+©ð ð !�b—j‘jØ�2—4‘4óß™ð ð %˜"Ÿ*™*Ø%ð8à×%Ñ% aÑ(¨AÒ-€r‡x�x�k°2ò8ç8>¹ð ð "�r—z‘zØ §¡ó&ß&-¡gð à(˜bŸj™jØAØ‡D�Dó
ç
‰'ð ð #˜Ÿ
™
 <°·±Ó6×=Ñ=Ð òAð $˜Ÿ™Ð$FÓG×KÑKÐ ð %˜"Ÿ*™*Ø" B§D¡D¨¯©¡Ió/Ð ð $˜Ÿ™Ø#ó%Ð ð #�u—{‘{ðhà�OÐ$ô&Ð ôH3ˆfô H3ñT 	‹	€Ø×Ñ€
ð €B‡J�JÐtÐvx×vzÑvzÓ{à€B‡J�JÐKÈRÏTÉTÓRð€ò E€ð €B‡J�Jˆ}˜bŸd™dÓ#Ø€B‡J�JÐ-¨r¯t©tÓ4Ø€B‡J�JÐ Ó!ð€ð �€à+Ø+Ø%Ø)ó+"òZ8òt/ð !×(Ñ(€Ô ò 9Ð Ø&˜KÐ àØ8Ø6Ù% f›~ó'MòR/òð �2—:‘:˜i¨¯©Ó.Ð óøð_ ò 4ç3Ò3ð4ûð ò àƒFðûð
 ò àƒGðûð
 ò Ø�u�ƒJðúsF   –K ¿K! ÁK/ ÁK= ËKËKË!K,Ë+K,Ë/K:Ë9K:Ë=	L
Ì	L
