ó
17Rc           @   si  d  Z  d Z d d l Z d e f d „  ƒ  YZ e d d „ Z e d d „ Z d d	 „ Z d d
 „ Z d d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d d „ Z e d „ Z d „  Z e d k rMd d l Z y e j e j d ƒ Wn n Xd d l m Z e e  d d ƒZ e GHd d l Z e Z d e j f d „  ƒ  YZ e j ƒ  n  d Z d Z d Z  d Z! d S(   sQ4  
========================
SmartyPants for Docutils
========================

Synopsis
========

Smart-quotes for Docutils.

The original "SmartyPants" is a free web publishing plug-in for Movable Type,
Blosxom, and BBEdit that easily translates plain ASCII punctuation characters
into "smart" typographic punctuation characters.

`smartypants.py`, endeavours to be a functional port of
SmartyPants to Python, for use with Pyblosxom_.

`smartquotes.py` is an adaption of Smartypants to Docutils_. By using Unicode
characters instead of HTML entities for typographic quotes, it works for any
output format that supports Unicode.

Authors
=======

`John Gruber`_ did all of the hard work of writing this software in Perl for
`Movable Type`_ and almost all of this useful documentation.  `Chad Miller`_
ported it to Python to use with Pyblosxom_.
Adapted to Docutils_ by GÃ¼nter Milde

Additional Credits
==================

Portions of the SmartyPants original work are based on Brad Choate's nifty
MTRegex plug-in.  `Brad Choate`_ also contributed a few bits of source code to
this plug-in.  Brad Choate is a fine hacker indeed.

`Jeremy Hedley`_ and `Charles Wiltgen`_ deserve mention for exemplary beta
testing of the original SmartyPants.

`Rael Dornfest`_ ported SmartyPants to Blosxom.

.. _Brad Choate: http://bradchoate.com/
.. _Jeremy Hedley: http://antipixel.com/
.. _Charles Wiltgen: http://playbacktime.com/
.. _Rael Dornfest: http://raelity.org/


Copyright and License
=====================

SmartyPants_ license (3-Clause BSD license):

  Copyright (c) 2003 John Gruber (http://daringfireball.net/)
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are
  met:

  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the
    distribution.

  * Neither the name "SmartyPants" nor the names of its contributors
    may be used to endorse or promote products derived from this
    software without specific prior written permission.

  This software is provided by the copyright holders and contributors
  "as is" and any express or implied warranties, including, but not
  limited to, the implied warranties of merchantability and fitness for
  a particular purpose are disclaimed. In no event shall the copyright
  owner or contributors be liable for any direct, indirect, incidental,
  special, exemplary, or consequential damages (including, but not
  limited to, procurement of substitute goods or services; loss of use,
  data, or profits; or business interruption) however caused and on any
  theory of liability, whether in contract, strict liability, or tort
  (including negligence or otherwise) arising in any way out of the use
  of this software, even if advised of the possibility of such damage.

smartypants.py license (2-Clause BSD license):

  smartypants.py is a derivative work of SmartyPants.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are
  met:

  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in
    the documentation and/or other materials provided with the
    distribution.

  This software is provided by the copyright holders and contributors
  "as is" and any express or implied warranties, including, but not
  limited to, the implied warranties of merchantability and fitness for
  a particular purpose are disclaimed. In no event shall the copyright
  owner or contributors be liable for any direct, indirect, incidental,
  special, exemplary, or consequential damages (including, but not
  limited to, procurement of substitute goods or services; loss of use,
  data, or profits; or business interruption) however caused and on any
  theory of liability, whether in contract, strict liability, or tort
  (including negligence or otherwise) arising in any way out of the use
  of this software, even if advised of the possibility of such damage.

.. _John Gruber: http://daringfireball.net/
.. _Chad Miller: http://web.chad.org/

.. _Pyblosxom: http://pyblosxom.bluesock.org/
.. _SmartyPants: http://daringfireball.net/projects/smartypants/
.. _Movable Type: http://www.movabletype.org/
.. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
.. _Docutils: http://docutils.sf.net/

Description
===========

SmartyPants can perform the following transformations:

- Straight quotes ( " and ' ) into "curly" quote characters
- Backticks-style quotes (\`\`like this'') into "curly" quote characters
- Dashes (``--`` and ``---``) into en- and em-dash entities
- Three consecutive dots (``...`` or ``. . .``) into an ellipsis entity

This means you can write, edit, and save your posts using plain old
ASCII straight quotes, plain dashes, and plain dots, but your published
posts (and final HTML output) will appear with smart quotes, em-dashes,
and proper ellipses.

SmartyPants does not modify characters within ``<pre>``, ``<code>``, ``<kbd>``,
``<math>`` or ``<script>`` tag blocks. Typically, these tags are used to
display text where smart quotes and other "smart punctuation" would not be
appropriate, such as source code or example markup.


Backslash Escapes
=================

If you need to use literal straight quotes (or plain hyphens and
periods), SmartyPants accepts the following backslash escape sequences
to force non-smart punctuation. It does so by transforming the escape
sequence into a character:

========  =====  =========
Escape    Value  Character
========  =====  =========
``\\\\``  &#92;  \\
\\"       &#34;  "
\\'       &#39;  '
\\.       &#46;  .
\\-       &#45;  \-
\\`       &#96;  \`
========  =====  =========

This is useful, for example, when you want to use straight quotes as
foot and inch marks: 6\\'2\\" tall; a 17\\" iMac.

Options
=======

For Pyblosxom users, the ``smartypants_attributes`` attribute is where you
specify configuration options.

Numeric values are the easiest way to configure SmartyPants' behavior:

"0"
        Suppress all transformations. (Do nothing.)
"1"
        Performs default SmartyPants transformations: quotes (including
        \`\`backticks'' -style), em-dashes, and ellipses. "``--``" (dash dash)
        is used to signify an em-dash; there is no support for en-dashes.

"2"
        Same as smarty_pants="1", except that it uses the old-school typewriter
        shorthand for dashes:  "``--``" (dash dash) for en-dashes, "``---``"
        (dash dash dash)
        for em-dashes.

"3"
        Same as smarty_pants="2", but inverts the shorthand for dashes:
        "``--``" (dash dash) for em-dashes, and "``---``" (dash dash dash) for
        en-dashes.

"-1"
        Stupefy mode. Reverses the SmartyPants transformation process, turning
        the characters produced by SmartyPants into their ASCII equivalents.
        E.g.  "â€œ" is turned into a simple double-quote (\"), "â€”" is
        turned into two dashes, etc.


The following single-character attribute values can be combined to toggle
individual transformations from within the smarty_pants attribute. For
example, to educate normal quotes and em-dashes, but not ellipses or
\`\`backticks'' -style quotes:

``py['smartypants_attributes'] = "1"``

"q"
        Educates normal quote characters: (") and (').

"b"
        Educates \`\`backticks'' -style double quotes.

"B"
        Educates \`\`backticks'' -style double quotes and \`single' quotes.

"d"
        Educates em-dashes.

"D"
        Educates em-dashes and en-dashes, using old-school typewriter shorthand:
        (dash dash) for en-dashes, (dash dash dash) for em-dashes.

"i"
        Educates em-dashes and en-dashes, using inverted old-school typewriter
        shorthand: (dash dash) for em-dashes, (dash dash dash) for en-dashes.

"e"
        Educates ellipses.

"w"
        Translates any instance of ``&quot;`` into a normal double-quote character.
        This should be of no interest to most people, but of particular interest
        to anyone who writes their posts using Dreamweaver, as Dreamweaver
        inexplicably uses this entity to represent a literal double-quote
        character. SmartyPants only educates normal quotes, not entities (because
        ordinarily, entities are used for the explicit purpose of representing the
        specific character they represent). The "w" option must be used in
        conjunction with one (or both) of the other quote options ("q" or "b").
        Thus, if you wish to apply all SmartyPants transformations (quotes, en-
        and em-dashes, and ellipses) and also translate ``&quot;`` entities into
        regular quotes so SmartyPants can educate them, you should pass the
        following to the smarty_pants attribute:


Caveats
=======

Why You Might Not Want to Use Smart Quotes in Your Weblog
---------------------------------------------------------

For one thing, you might not care.

Most normal, mentally stable individuals do not take notice of proper
typographic punctuation. Many design and typography nerds, however, break
out in a nasty rash when they encounter, say, a restaurant sign that uses
a straight apostrophe to spell "Joe's".

If you're the sort of person who just doesn't care, you might well want to
continue not caring. Using straight quotes -- and sticking to the 7-bit
ASCII character set in general -- is certainly a simpler way to live.

Even if you I *do* care about accurate typography, you still might want to
think twice before educating the quote characters in your weblog. One side
effect of publishing curly quote characters is that it makes your
weblog a bit harder for others to quote from using copy-and-paste. What
happens is that when someone copies text from your blog, the copied text
contains the 8-bit curly quote characters (as well as the 8-bit characters
for em-dashes and ellipses, if you use these options). These characters
are not standard across different text encoding methods, which is why they
need to be encoded as characters.

People copying text from your weblog, however, may not notice that you're
using curly quotes, and they'll go ahead and paste the unencoded 8-bit
characters copied from their browser into an email message or their own
weblog. When pasted as raw "smart quotes", these characters are likely to
get mangled beyond recognition.

That said, my own opinion is that any decent text editor or email client
makes it easy to stupefy smart quote characters into their 7-bit
equivalents, and I don't consider it my problem if you're using an
indecent text editor or email client.


Algorithmic Shortcomings
------------------------

One situation in which quotes will get curled the wrong way is when
apostrophes are used at the start of leading contractions. For example:

``'Twas the night before Christmas.``

In the case above, SmartyPants will turn the apostrophe into an opening
single-quote, when in fact it should be a closing one. I don't think
this problem can be solved in the general case -- every word processor
I've tried gets this wrong as well. In such cases, it's best to use the
proper character for closing single-quotes (``â€™``) by hand.


Version History
===============

1.7     2012-11-19
        - Internationalization: language-dependent quotes.

1.6.1:  2012-11-06
        - Refactor code, code cleanup,
        - `educate_tokens()` generator as interface for Docutils.

1.6:    2010-08-26
        - Adaption to Docutils:
          - Use Unicode instead of HTML entities,
          - Remove code special to pyblosxom.

1.5_1.6: Fri, 27 Jul 2007 07:06:40 -0400
        - Fixed bug where blocks of precious unalterable text was instead
          interpreted.  Thanks to Le Roux and Dirk van Oosterbosch.

1.5_1.5: Sat, 13 Aug 2005 15:50:24 -0400
        - Fix bogus magical quotation when there is no hint that the
          user wants it, e.g., in "21st century".  Thanks to Nathan Hamblen.
        - Be smarter about quotes before terminating numbers in an en-dash'ed
          range.

1.5_1.4: Thu, 10 Feb 2005 20:24:36 -0500
        - Fix a date-processing bug, as reported by jacob childress.
        - Begin a test-suite for ensuring correct output.
        - Removed import of "string", since I didn't really need it.
          (This was my first every Python program.  Sue me!)

1.5_1.3: Wed, 15 Sep 2004 18:25:58 -0400
        - Abort processing if the flavour is in forbidden-list.  Default of
          [ "rss" ]   (Idea of Wolfgang SCHNERRING.)
        - Remove stray virgules from en-dashes.  Patch by Wolfgang SCHNERRING.

1.5_1.2: Mon, 24 May 2004 08:14:54 -0400
        - Some single quotes weren't replaced properly.  Diff-tesuji played
          by Benjamin GEIGER.

1.5_1.1: Sun, 14 Mar 2004 14:38:28 -0500
        - Support upcoming pyblosxom 0.9 plugin verification feature.

1.5_1.0: Tue, 09 Mar 2004 08:08:35 -0500
        - Initial release
t   1iÿÿÿÿNt
   smartcharsc           B   s‰  e  Z d  Z d Z d Z d Z i1 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# 6dH d( 6d d) 6d d* 6d d+ 6d, d- 6d d. 6d d/ 6d d0 6d d1 6d2 d3 6d d4 6d d5 6d d6 6d7 d8 6d d9 6d d: 6d d; 6d7 d< 6d= d> 6d? d@ 6d dA 6d dB 6d dC 6d dD 6d dE 6d d/ 6d2 dF 6Z d dG „ Z RS(I   s   Smart quotes and dashes
    u   â€“u   â€”u   â€¦u   â€œâ€â€˜â€™t   afu   â€žâ€â€šâ€™s   af-x-altquotu
   Â«Â»â€œâ€t   cas   ca-x-altquotu   â€žâ€œâ€šâ€˜t   csu
   Â»Â«â€ºâ€¹s   cs-x-altquotu
   Â»Â«â€˜â€™t   das   da-x-altquott   des   de-x-altquotu
   Â«Â»â€¹â€ºs   de-CHt   elt   enu   â€˜â€™â€œâ€s   en-UKt   eot   est   ets   et-x-altquott   eus   es-x-altquotu   â€â€â€™â€™t   fiu
   Â»Â»â€™â€™s   fi-x-altquotu   Â«â€¯u   â€¯Â»u   â€¹â€¯u   â€¯â€ºt   frs   fr-x-altquots   fr-CHt   glu
   â€â€œÂ»Â«t   hes   he-x-altquott   its   it-CHs   it-x-altquotu   ã€Œã€ã€Žã€t   jat   ltt   nls   nl-x-altquotu
   â€žâ€Â«Â»t   pls   pl-x-altquott   pts   pt-BRt   rou
   Â«Â»â€žâ€s   ro-x-altquotu
   Â«Â»â€žâ€œt   rut   sks   sk-x-altquott   svs   sv-x-altquots   zh-CNs   zh-TWc         C   sh   | |  _  y) |  j | \ |  _ |  _ |  _ |  _ Wn/ t k
 rc d \ |  _ |  _ |  _ |  _ n Xd  S(   Nu   ""''(   t   languaget   quotest   opquotet   cpquotet   osquotet   csquotet   KeyError(   t   selfR   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyt   __init__µ  s
    	)(   u   Â«â€¯u   â€¯Â»u   â€¹â€¯u   â€¯â€º(   t   __name__t
   __module__t   __doc__t   endasht   emdasht   ellipsisR   R#   (    (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyR   n  sl   

R   c         C   s2   d j  g  t t |  ƒ | | ƒ D] } | ^ q ƒ S(   s$   Main function for "traditional" use.t    (   t   joint   educate_tokenst   tokenize(   t   textt   attrR   t   t(    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyt   smartyPants¾  s    c         c   sï  t  } t  } t  } t  } t  } t  } | d k r8 |	 Vn2| d k r_ t } t } d } t } n| d k r† t } t } d } t } nä | d k r­ t } t } d } t } n½ | d k rÂ 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 rUt } n  d | k rjt } n  d }
 xx|  D]p\ } }	 | d k s–|	 r¡|	 Vqwn  | d k rÂ|	 d }
 |	 Vqwn  |	 d } t |	 ƒ }	 | röt j d d |	 ƒ }	 n  | d k rt |	 ƒ }	 n6 | d k r,t |	 ƒ }	 n | d k rGt |	 ƒ }	 n  | r\t |	 ƒ }	 n  | rtt	 |	 | ƒ }	 n  | d k r’t
 |	 | ƒ }	 n  | r²t |
 |	 | ƒ d }	 n  | rÊt |	 | ƒ }	 n  | }
 t |	 d t ƒ}	 |	 VqwWd S(   s@   Return iterator that "educates" the items of `text_tokens`.
    t   0R    i   t   2i   t   3i   s   -1t   qt   bt   Bt   dt   Dt   it   et   wt    t   tagt   literaliÿÿÿÿs   &quot;t   "t   restoreN(   t   Falset   Truet   processEscapest   ret   subt   educateDashest   educateDashesOldSchoolt   educateDashesOldSchoolInvertedt   educateEllipsest   educateBacktickst   educateSingleBacktickst   educateQuotest   stupefyEntities(   t   text_tokensR/   R   t   convert_quott	   do_dashest   do_backtickst	   do_quotest   do_ellipsest
   do_stupefyR.   t   prev_token_last_chart   ttypet	   last_char(    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyR,   Å  s’    				 	 	 	 	 	 	 	 	

c   
      C   s   t  | ƒ } d } t j d | f | j |  ƒ }  t j d | f | j |  ƒ }  t j d | j | j |  ƒ }  t j d | j | j |  ƒ }  t j d | j |  ƒ }  d } d } t j d	 | f t j ƒ } | j d
 | j |  ƒ }  t j d | f t j ƒ } | j d
 | j |  ƒ }  t j d | f t j ƒ } | 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(   s  
    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?â€œ;
    s)   [!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]s   ^'(?=%s\\B)s   ^"(?=%s\\B)s   "'(?=\w)s   '"(?=\w)s   \b'(?=\d{2}s)s   [^\ \t\r\n\[\{\(\-]s   &#8211;|&#8212;s<  
                    (
                            \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
                    s   \1sj   
                    (%s)
                    '
                    (?!\s | s\b | \d)
                    sc   
                    (%s)
                    '
                    (\s | s\b)
                    s   \1%s\2t   's<  
                    (
                            \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
                    sš   
                    #(%s)?   # character that indicates the quote should be closing
                    "
                    (?=\s)
                    s}   
                    (%s)   # character that indicates the quote should be closing
                    "
                    R@   (	   R   RE   RF   R    R   R   R   t   compilet   VERBOSE(
   R.   R   t   smartt   punct_classt   close_classt
   dec_dashest   opening_single_quotes_regext   closing_single_quotes_regext   opening_double_quotes_regext   closing_double_quotes_regex(    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRM   7  s<    
c         C   s@   t  | ƒ } t j d | j |  ƒ }  t j d | j |  ƒ }  |  S(   s  
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with ``backticks'' -style double quotes
                translated into HTML curly quote entities.
    Example input:  ``Isn't this fun?''
    Example output: â€œIsn't this fun?â€œ;
    s   ``s   ''(   R   RE   RF   R   R   (   R.   R   R\   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRK   š  s    c         C   s@   t  | ƒ } t j d | j |  ƒ }  t j d | j |  ƒ }  |  S(   s   
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with `backticks' -style single quotes
                translated into HTML curly quote entities.

    Example input:  `Isn't this fun?'
    Example output: â€˜Isnâ€™t this fun?â€™
    t   `RY   (   R   RE   RF   R   R    (   R.   R   R\   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRL   ©  s    	c         C   s4   t  j d t j |  ƒ }  t  j d t j |  ƒ }  |  S(   s›   
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with each instance of "--" translated to
                an em-dash character.
    s   ---s   --(   RE   RF   R   R'   R(   (   R.   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRG   ¹  s    c         C   s4   t  j d t j |  ƒ }  t  j d t j |  ƒ }  |  S(   sÞ   
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with each instance of "--" translated to
                an en-dash character, and each "---" translated to
                an em-dash character.
    s   ---s   --(   RE   RF   R   R(   R'   (   R.   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRH   Å  s    c         C   s4   t  j d t j |  ƒ }  t  j d t j |  ƒ }  |  S(   sÆ  
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with each instance of "--" translated to
                an em-dash character, and each "---" translated to
                an en-dash character. Two reasons why: First, unlike the
                en- and em-dash syntax supported by
                EducateDashesOldSchool(), it's compatible with existing
                entries written before SmartyPants 1.1, back when "--" was
                only used for em-dashes.  Second, em-dashes are more
                common than en-dashes, and so it sort of makes sense that
                the shortcut should be shorter to type. (Thanks to Aaron
                Swartz for the idea.)
    s   ---s   --(   RE   RF   R   R'   R(   (   R.   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRI   Ò  s    c         C   s4   t  j d t j |  ƒ }  t  j d t j |  ƒ }  |  S(   sÚ   
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with each instance of "..." translated to
                an ellipsis character.

    Example input:  Huh...?
    Example output: Huh&#8230;?
    s   \.\.\.s   \. \. \.(   RE   RF   R   R)   (   R.   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRJ   æ  s    
c         C   s¸   t  | ƒ } t j | j d |  ƒ }  t j | j d |  ƒ }  t j | j d |  ƒ }  t j | j d |  ƒ }  t j | j d |  ƒ }  t j | j d |  ƒ }  t j | j	 d |  ƒ }  |  S(   só   
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with each SmartyPants character translated to
                its ASCII counterpart.

    Example input:  â€œHello â€” world.â€
    Example output: "Hello -- world."
    t   -s   --RY   R@   s   ...(
   R   RE   RF   R'   R(   R   R    R   R   R)   (   R.   R   R\   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRN   õ  s    	c         C   s{   d d d d d d f } | rN xV | D]" \ } } |  j  | | d ƒ }  q% Wn) x& | D] \ } } |  j  | | ƒ }  qU W|  S(   sî  
    Parameter:  String (unicode or bytes).
    Returns:    The `text`, with after processing the following backslash
                escape sequences. This is useful if you want to force a "dumb"
                quote or other character to appear.

                Escape  Value
                ------  -----
                \\      &#92;
                \"      &#34;
                \'      &#39;
                \.      &#46;
                \-      &#45;
                \`      &#96;
    s   \\s   &#92;s   \"s   &#34;s   \'s   &#39;s   \.s   &#46;s   \-s   &#45;s   \`s   &#96;i   (   s   \\s   &#92;(   s   \"s   &#34;(   s   \'s   &#39;(   s   \.s   &#46;(   s   \-s   &#45;(   s   \`s   &#96;(   t   replace(   R.   RA   t   replacementst   cht   rep(    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyRD     s    	c         c   só   d } t  |  ƒ } d } d j d g | ƒ d | } t j d ƒ } | j |  ƒ } d } xn | d k	 rÊ | j d ƒ r d | j d ƒ f Vn  d	 | j d
 ƒ f V| j ƒ  } | j |  | j ƒ  ƒ } q] W| t  |  ƒ k  rï d |  | f Vn  d S(   sL  
    Parameter:  String containing HTML markup.
    Returns:    An iterator that yields the tokens comprising the input
                string. Each token is either a tag (possibly with nested,
                tags contained therein, such as <a href="<MTFoo>">, or a
                run of text between tags. Each yielded element is a
                two-element tuple; the first is either 'tag' or 'text';
                the second is the actual value.

    Based on the _tokenize() subroutine from Brad Choate's MTRegex plugin.
        <http://www.bradchoate.com/past/mtregex.php>
    i    i   t   |s   (?:<(?:[^<>]s   )*>)s   ([^<]*)(<[^>]*>)i   R.   R>   i   N(   t   lenR+   RE   RZ   t   searcht   Nonet   groupt   end(   R.   t   post   lengtht   deptht   nested_tagst   tag_soupt   token_matcht   previous_end(    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyR-   .  s    t   __main__R*   (   t   publish_stringt   writer_namet   htmlt   TestSmartypantsAllAttributesc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   sž   |  j  t d ƒ d ƒ |  j  t d ƒ d ƒ |  j  t d ƒ d ƒ |  j  t d ƒ d ƒ |  j  t d ƒ d	 ƒ |  j  t d
 ƒ d ƒ |  j  t d ƒ d ƒ d  S(   Ns	   1440-80'su   1440-80â€™ss	   1440-'80su   1440-â€˜80ss   1440---'80su   1440â€“â€˜80st   1960ss   1960'su   1960â€™ss   one two '60su   one two â€˜60ss   '60su   â€˜60s(   t   assertEqualt   sp(   R"   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyt
   test_datesn  s    c         C   s0   |  j  t d ƒ d ƒ |  j  t d ƒ d ƒ d  S(   Ns   21st centuryt   3rd(   R}   R~   (   R"   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyt   test_ordinal_numbersw  s    c         C   s   |  j  t d ƒ d ƒ d  S(   Ns   "Isn't this fun?"u   â€œIsnâ€™t this fun?â€(   R}   R~   (   R"   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyt   test_educated_quotes{  s    c         C   s    d } |  j  t | ƒ | ƒ d  S(   Ns   <a src="foo">more</a>(   R}   R~   (   R"   R.   (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyt   test_html_tags~  s    (   R$   R%   R   R   R‚   Rƒ   (    (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyR{   k  s   				s$   Chad Miller <smartypantspy@chad.org>s(   1.5_1.6: Fri, 27 Jul 2007 07:06:40 -0400s"   http://wiki.chad.org/SmartyPantsPysN   Smart-quotes, smart-ellipses, and smart-dashes for weblog entries in pyblosxom("   R&   t   default_smartypants_attrRE   t   objectR   R1   R,   RM   RK   RL   RG   RH   RI   RJ   RN   RB   RD   R-   R$   t   localet	   setlocalet   LC_ALLt   docutils.coreRx   t   docstring_htmlt   unittestR~   t   TestCaseR{   t   maint
   __author__t   __version__t   __url__t   __description__(    (    (    s>   /usr/lib/python2.7/dist-packages/docutils/utils/smartquotes.pyt   <module>g  s@   Prc				 	*