ó
öÀ„\c           @@ sÈ  d  Z  d d l m Z m Z d d l Z d d l m Z d d l m Z	 e
 rm d d l m Z m Z m Z n  iJ d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d d! 6d d" 6d# d$ 6d% d& 6dp d+ 6dq d. 6d d/ 6dr d2 6d d3 6d4 d5 6d	 d6 6d7 d8 6d d9 6d d: 6d d; 6d< d= 6d d> 6d d? 6d d@ 6d dA 6dB dC 6d dD 6d dE 6d dF 6d dG 6d	 dH 6dI dJ 6dI dK 6dL dM 6dI dN 6dL dO 6d< dP 6dQ dR 6d dS 6d dT 6d< dU 6dV dW 6d	 dX 6d dY 6d dZ 6d d[ 6d d\ 6d d] 6d d^ 6d_ d` 6da db 6d dc 6d# dd 6d% de 6d df 6d dg 6dV dh 6d di 6d dj 6dB dk 6Z d dl „ Z e j d dm „ Z e	 ds k  rÄe e _ e e _ e e j _ n  d S(t   uP  
    sphinx.util.smartypants
    ~~~~~~~~~~~~~~~~~~~~~~~

    This is extracted (with minor adaptations for flake8 compliance) from
    docutilsâ€™ docutils/utils/smartquotes.py as of revision 8097 (30 May 2017),
    in order to backport for Sphinx usage with Docutils < 0.14 extra language
    configurations and fixes. Replaces earlier smartypants version as used up
    to Sphinx 1.5.6.

    :copyright: Â© 2010 GÃ¼nter Milde,
                original `SmartyPants`_: Â© 2003 John Gruber
                smartypants.py:          Â© 2004, 2007 Chad Miller
    :license: Released under the terms of the `2-Clause BSD license`_, in short:

       Copying and distribution of this file, with or without modification,
       are permitted in any medium without royalty provided the copyright
       notices and this notice are preserved.
       This file is offered as-is, without any warranty.

    .. _SmartyPants: https://daringfireball.net/projects/smartypants/
    .. _2-Clause BSD license: https://spdx.org/licenses/BSD-2-Clause

    See the LICENSE file and the original docutils code for details.

i    (   t   absolute_importt   unicode_literalsN(   t   smartquotes(   t   __version_info__(   t   Iterablet   Iteratort   Tupleu   â€œâ€â€˜â€™u   afu   â€žâ€â€šâ€™u   af-x-altquotu   â€žâ€œâ€šâ€˜u   bgu
   Â«Â»â€œâ€u   cau   ca-x-altquotu   csu
   Â»Â«â€ºâ€¹u   cs-x-altquotu   dau   da-x-altquotu   deu   de-x-altquotu
   Â«Â»â€¹â€ºu   de-chu   elu   enu   â€˜â€™â€œâ€u   en-uk-x-altquotu   eou   esu   es-x-altquotu   etu   et-x-altquotu   euu   â€â€â€™â€™u   fiu
   Â»Â»â€ºâ€ºu   fi-x-altquotu   Â«Â u   Â Â»u   â€œu   â€u   fru   Â«â€¯u   â€¯Â»u   fr-x-altquotu   fr-chu   â€¹â€¯u   â€¯â€ºu   fr-ch-x-altquotu   glu
   â€â€œÂ»Â«u   heu   he-x-altquotu   â€žâ€â€˜â€™u   hru   hr-x-altquotu   hsbu   hsb-x-altquotu
   â€žâ€Â«Â»u   huu   isu   itu   it-chu   it-x-altquotu   ã€Œã€ã€Žã€u   jau   ltu   lvu   mku   nlu   nl-x-altquotu
   Â«Â»â€™â€™u   nbu   nnu
   Â«Â»â€˜â€™u   nn-x-altquotu   nou   no-x-altquotu   plu
   Â«Â»â€šâ€™u   pl-x-altquotu   ptu   pt-bru   rou
   Â«Â»â€žâ€œu   ruu   shu   sh-x-altquotu   sku   sk-x-altquotu   slu   sl-x-altquotu   squ   â€œâ€žâ€˜â€šu   sq-x-altquotu   â€žâ€â€™â€™u   sru   sr-x-altquotu   svu   sv-x-altquotu   tru   tr-x-altquotu   uku   uk-x-altquotu   zh-cnu   zh-twc         C@ s­  t  j | ƒ } y | j } Wn t k
 r5 d } n Xd } t j d | f | j |  ƒ }  t j d | f | j |  ƒ }  t j d | j | j	 |  ƒ }  t j d | j	 | j |  ƒ }  | j
 d ƒ rå t j d | |  t j ƒ }  n  d	 } d
 } t j d | f t j t j Bƒ } | j d | j	 |  ƒ }  | j | k rft j d t j ƒ } | j | |  ƒ }  n  t j d | f t j t j Bƒ }	 |	 j d | j |  ƒ }  t j d | f t j t j Bƒ }	 |	 j d | j |  ƒ }  t j d | j	 |  ƒ }  t j d | f t j ƒ }
 |
 j d | j |  ƒ }  t j d | f t j ƒ } | j | j |  ƒ }  t j d | f t j ƒ } | j d | j |  ƒ }  t j d | j |  ƒ }  |  S(   u  
    Parameter:  - text string (unicode or bytes).
                - language (`BCP 47` language tag.)
    Returns:    The `text`, with "educated" curly quote characters.

    Example input:  "Isn't this fun?"
    Example output: â€œIsnâ€™t this fun?â€œ;
    u   â€™u)   [!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]u   ^'(?=%s\\B)u   ^"(?=%s\\B)u   "'(?=\w)u   '"(?=\w)u   enu   '(?=\d{2}s)u   [^\ \t\r\n\[\{\(\-]u   &#8211;|&#8212;u<  
                    (
                            \s          |   # a whitespace char, or
                            &nbsp;      |   # a non-breaking space entity, or
                            --          |   # dashes, or
                            &[mn]dash;  |   # named dash entities
                            %s          |   # or decimal entities
                            &\#x201[34];    # or hex
                    )
                    '                 # the quote
                    (?=\w)            # followed by a word character
                    u   \1u   (?<=(\w|\d))'(?=\w)uÜ   
                    (%s)
                    '
                    (?!\s  |       # whitespace
                       s\b |
                        \d         # digits   ('80s)
                    )
                    uc   
                    (%s)
                    '
                    (\s | s\b)
                    u   \1%s\2u   'u<  
                    (
                            \s          |   # a whitespace char, or
                            &nbsp;      |   # a non-breaking space entity, or
                            --          |   # dashes, or
                            &[mn]dash;  |   # named dash entities
                            %s          |   # or decimal entities
                            &\#x201[34];    # or hex
                    )
                    "                 # the quote
                    (?=\w)            # followed by a word character
                    uš   
                    #(%s)?   # character that indicates the quote should be closing
                    "
                    (?=\s)
                    u}   
                    (%s)   # character that indicates the quote should be closing
                    "
                    u   "(   R   t
   smartcharst
   apostrophet	   Exceptiont   ret   subt   csquotet   cpquotet   opquotet   osquotet
   startswitht   UNICODEt   compilet   VERBOSE(   t   textt   languaget   smartR   t   punct_classt   close_classt
   dec_dashest   opening_single_quotes_regext   apostrophe_regext   closing_single_quotes_regext   opening_double_quotes_regext   closing_double_quotes_regex(    (    s6   lib/python2.7/site-packages/sphinx/util/smartypants.pyt   educateQuotes‚   sL    
c         c@ s  t  } d } d } t  } t  } t  } | d k rE t } d } t } n| d k rf t } d } t } nä | d k r t } d } d } t } n½ | d k r¢ t } n¨ d	 | k r· t } n  d
 | k rÌ d } n  d | k rá d } n  d | k rö d } n  d | k rd } n  d | k r d } n  d | k r5t } n  d | k rJt } n  d }	 x±|  D]©\ }
 } |
 d k sv| r| VqWn  |
 d k r¢| d }	 | VqWn  | d } t j | ƒ } | rÙt j d d | ƒ } n  | d k r÷t j | ƒ } n< | d k rt j | ƒ } n | d k r3t j | ƒ } n  | rKt j	 | ƒ } n  | rft j
 | | ƒ } n  | d k r‡t j | | ƒ } n  | rÅ|	 j d d ƒ j d d ƒ } t | | | ƒ d } n  | ràt j | | ƒ } n  | }	 t j | d t ƒ} | VqWWd S(   u5  Return iterator that "educates" the items of `text_tokens`.

    This is modified to intercept the ``attr='2'`` as it was used by the
    Docutils 0.13.1 SmartQuotes transform in a hard coded way. Docutils 0.14
    uses ``'qDe'``` and is configurable, and its choice is backported here
    for use by Sphinx with earlier Docutils releases. Similarly ``'1'`` is
    replaced by ``'qde'``.

    Use ``attr='qDbe'``, resp. ``'qdbe'`` to recover Docutils effect of ``'2'``,
    resp. ``'1'``.

    refs: https://sourceforge.net/p/docutils/mailman/message/35869025/
    i    u   1i   u   2i   u   3i   u   -1u   qu   bu   Bu   du   Du   iu   eu   wu    u   tagu   literaliÿÿÿÿu   &quot;u   "u   ;u   't   restoreN(   t   Falset   TrueR   t   processEscapesR
   R   t   educateDashest   educateDashesOldSchoolt   educateDashesOldSchoolInvertedt   educateEllipsest   educateBacktickst   educateSingleBacktickst   replaceR   t   stupefyEntities(   t   text_tokenst   attrR   t   convert_quott	   do_dashest   do_backtickst	   do_quotest   do_ellipsest
   do_stupefyt   prev_token_last_chart   ttypeR   t	   last_chart   context(    (    s6   lib/python2.7/site-packages/sphinx/util/smartypants.pyt   educate_tokensõ   sŒ    												

i   i   (   u   Â«Â u   Â Â»u   â€œu   â€(   u   Â«â€¯u   â€¯Â»u   â€œu   â€(   u   Â«â€¯u   â€¯Â»u   â€¹â€¯u   â€¯â€º(   i    i   i   (   t   __doc__t
   __future__R    R   R
   t   docutils.utilsR   t   sphinx.util.docutilsR   t   docutils_versionR!   t   typingR   R   R   t
   langquotesR   t   default_smartypants_attrR8   R   t   quotes(    (    (    s6   lib/python2.7/site-packages/sphinx/util/smartypants.pyt   <module>   s¬   

s†		