eaiovnaovbqoebvqoeavibavo 3 v:U](@sddlZddlmZddejjDZddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZd#ddZddZd$d!d"ZdS)%N)configcCs&i|]\}}|dkr|tjj|qS)Znbsp)htmlZentitiesZname2codepoint).0kvr/usr/lib/python3.6/utils.py sr cCsD|ddkr@t|dkr@|d}d|ko2dknr@t|SdS)Nrh09)lenint)tagnrrrhn s rcCsdddd|jdDDS)z, :returns: A hash of css attributes cSs&i|]\}}|jj|jjqSr)striplower)rxyrrrr sz&dumb_property_dict..cSs g|]}d|kr|jddqS):r )split)rzrrr sz&dumb_property_dict..;)r)stylerrrdumb_property_dictsrc Cs|d7}|jd}x:|d krL|d|||jd|dd}|jd}qWdd|jdD}yd d |D}Wntk ri}YnX|S) z :type data: str :returns: A hash of css selectors, each of which contains a hash of css attributes. :rtype: dict rz@importr rNcSs"g|]}d|jkr|jdqS){)rr)rrrrrr/sz#dumb_css_parser..}cSsi|]\}}t||jqSr)rr)rabrrrr 1sz#dumb_css_parser..)findr ValueError)dataZ importIndexelementsrrrdumb_css_parsers   $ r(cCsb|j}d|kr@x.|djD]}|jd|i}|j|qWd|kr^t|d}|j||S)z :type attrs: dict :type style_def: dict :type style_def: dict :returns: A hash of the 'final' style attributes of the element :rtype: dict class.r)copyrgetupdater)attrsZ style_defZ parent_stylerZ css_classZ css_styleZimmediate_stylerrr element_style8s   r/cCs d|kr|d}|dkrdSdS) zh Finds out whether this is an ordered or unordered list :type style: dict :rtype: str zlist-style-typedisccirclesquarenoneZulZol)r0r1r2r3r)rZ list_stylerrrgoogle_list_styleMs r4cCsd|kS)z Check if the style of the element has the 'height' attribute explicitly defined :type style: dict :rtype: bool Zheightr)rrrrgoogle_has_height]s r5cCsJg}d|kr|j|dd|kr0|j|dd|krF|j|d|S)zk :type style: dict :returns: A list of all emphasis modifiers of the element :rtype: list ztext-decorationz font-stylez font-weight)append)rZemphasisrrrgoogle_text_emphasisisr7cCs$d}d|kr|d}d|kp"d|kS)zu Check if the css of the current element defines a fixed width font :type style: dict :rtype: bool z font-familyz courier newZconsolasr)rZ font_familyrrrgoogle_fixed_width_font{sr9c Cs2d|kr.yt|ddStk r,YnXdS)zh Extract numbering from list element attributes :type attrs: dict :rtype: int or None startr r)rr%)r.rrrlist_numbering_starts r;cCsttjj|dkr| rdS|dddks:|ddkr>dS|j}|dddkrrt|dkrr|ddkrrd S|dd d kr|ddd k r| Sttjj|ptjj|S)NrTz  r z---Fr *z**)r>r?) rrZRE_LINKfindalllstripboolZRE_ORDERED_LIST_MATCHERmatchZRE_UNORDERED_LIST_MATCHER)ZparaZ wrap_linksZwrap_list_itemsstrippedrrrskipwraps(" rEcCstjjd|S)zU Escapes markdown-sensitive characters within other markdown constructs. z\\\1)rZRE_MD_CHARS_MATCHERsub)textrrr escape_mdsrHFcCsNtjjd|}|r tjjd|}tjjd|}tjjd|}tjjd|}|S)zO Escapes markdown-sensitive characters across whole document sections. z\\\1z\1\\\2)rZRE_MD_BACKSLASH_MATCHERrFZRE_MD_CHARS_MATCHER_ALLZRE_MD_DOT_MATCHERZRE_MD_PLUS_MATCHERZRE_MD_DASH_MATCHER)rGZsnobrrrescape_md_sectionsrIc s<fdd|djdD}t|}x|D]}dd|jdD}t|}||krf|dg||7}n0||kr|fdd||| dD7}|}fd dt||D}q*Wg}x|D]x}d d|jdD}t|jtd krd fd dt||D}ndfddt||D}|jdj|qW|S)zR Given the lines of a table padds the cells and returns the new lines csg|]}t|jqSr)rrstrip)rr) right_marginrrrsz"reformat_table..r|cSsg|] }|jqSr)rJ)rrrrrrsr8csg|]}t|qSr)r)rr)rKrrrsNcs"g|]\}}tt||qSr)maxr)rrZold_len)rKrrrscSsg|] }|jqSr)rJ)rrrrrrsz-|r>cs,g|]$\}}|j|t|jqSr)rJr)rrM)fillerrrrs cs,g|]$\}}|j|t|jqSr)rJr)rrrN)rOrrrs)rrzipsetrr6join) linesrKZ max_widthZmax_colslineZcolsZnum_cols new_linesZnew_colsr)rOrKrreformat_tables. $   rWr cCs|jd}gd}}g}x^|D]V}tj|krZ| }|st||}|j|g}|jdq|rj|j|q|j|qWdj|S)z0 Provide padding for tables in the text  Fr8)rrZTABLE_MARKER_FOR_PADrWextendr6rS)rGrKrTZ table_bufferZ table_startedrVrUtablerrrpad_tables_in_texts         r[)F)r )Z html.entitiesrZ html2textrZ UNIFIABLEitemsZ unifiable_nrrr(r/r4r5r7r9r;rErHrIrWr[rrrrs"    +