o $ar> @sdZddlZddlZddlmZmZmZddlmZddl m Z ddl m Z ede idd d d d d dddd dd dddddd dd dddddddd dddd ddid d d!d d"dd#dd$d%d&d'd(d)d*d+d,dd-d.d/dd0d1d2d d3d4d5dd6d d7did8d9d:d d;ddd?d@d dAd dBd dCd dDd dEdFdGdFdHdIdJdFdKdIdLd9idMdNdOddPd dQd9dRdSdTd dUddVd dWddXd dYddZdd[d\d]d^d_dd`d%dad'd ddSd d d?dbZdmdceddedeefdfdgZejdfdheeeefdieddedeeeddffdjdkZe dlkrBee_ee_eej_dSdS)nuP 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. N) GeneratorIterableTuple) smartquotes)RemovedInSphinx60Warning)__version_info__z&sphinx.util.smartypants is deprecated.afu “”‘’z af-x-altquotu „”‚’bgu „“‚‘cau «»“”z ca-x-altquotcsz cs-x-altquotu »«›‹daz da-x-altquotdez de-x-altquotzde-chu «»‹›elenzen-uk-x-altquotu ‘’“”eoesz es-x-altquotetz et-x-altquoteufiu ””’’z fi-x-altquotu »»››fr)u« u »“”z fr-x-altquot)«  »rrzfr-chzfr-ch-x-altquot)rru‹ u ›glheu ”“»«z he-x-altquothru „”‘’z hr-x-altquothsbz hsb-x-altquothuu „”«»isitzit-chz it-x-altquotjau 「」『』ltlvmknlz nl-x-altquotnbu «»’’nnz nn-x-altquotu «»‘’noz no-x-altquotplz pl-x-altquotu «»‚’ptzpt-brroruu «»„“shz sh-x-altquotskz sk-x-altquotslz sl-x-altquotsqz sq-x-altquotu “„‘‚sru „”’’z sr-x-altquotsvz sv-x-altquot)trz tr-x-altquotukz uk-x-altquotzzh-cnzzh-twtextlanguagereturnc Cst|}z|j}Wn tyd}Ynwd}td|f|j|}td|f|j|}td|j|j |}td|j |j|}| drStjd||tj d }d }d }t d |ftj tj B}|d |j |}|j|krt dtj }|||}t d|ftj tj B} | d |j|}t d|ftj tj B} | d|j|}td|j |}t d|ftj } | d |j|}t d|ftj } | |j|}t d|ftj } | d |j|}td|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’z)[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]z ^'(?=%s\\B)z ^"(?=%s\\B)z"'(?=\w)z'"(?=\w)rz '(?=\d{2}s))flagsz[^\ \t\r\n\[\{\(\-]z–|—a< ( \s | # a whitespace char, or   | # 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 z\1z(?<=(\w|\d))'(?=\w)z (%s) ' (?!\s | # whitespace s\b | \d # digits ('80s) ) zc (%s) ' (\s | s\b) z\1%s\2'a< ( \s | # a whitespace char, or   | # 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 z #(%s)? # character that indicates the quote should be closing " (?=\s) z} (%s) # character that indicates the quote should be closing " ")r smartchars apostrophe Exceptionresubcsquotecpquoteopquoteosquote startswithUNICODEcompileVERBOSE) r5r6smartr< punct_class close_class dec_dashesopening_single_quotes_regexapostrophe_regexclosing_single_quotes_regexopening_double_quotes_regexclosing_double_quotes_regexrQ9/usr/lib/python3/dist-packages/sphinx/util/smartypants.py educateQuotessr             rS text_tokensattrccsd}d}d}d}d}d}|dkrd}d}d}nO|dkr#d}d}d}nD|dkr0d}d}d }d}n7|d kr7d}n0d |vr=d}d |vrCd}d |vrId}d|vrOd}d|vrUd}d|vr[d }d|vrad}d|vrgd}d} |D]\} } | dksu| sy| Vqk| dkr| dd} | Vqk| dd} t| } |rtdd| } |dkrt| } n|dkrt| } n |d krt| } |rt| } |rt| |} |dkrt | |} |r| dd dd} t | | |dd} |rt | |} | } tj| dd} | VqkdS)a5Return 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/ Fr1T23z-1qbBdDiew tagliteralNz"r:;r9)restore) rprocessEscapesr>r? educateDasheseducateDashesOldSchooleducateDashesOldSchoolInvertededucateEllipseseducateBacktickseducateSingleBackticksreplacerSstupefyEntities)rTrUr6 convert_quot do_dashes do_backticks do_quotes do_ellipses do_stupefyprev_token_last_charttyper5 last_charcontextrQrQrReducate_tokenss!            r})r rY)r)__doc__r>warningstypingrrrdocutils.utilsrsphinx.deprecationrsphinx.util.docutilsrdocutils_versionwarn langquotesstrrSdefault_smartypants_attrr}r;quotesrQrQrQrRsP       !"#$%&'()+,-.0134589<=@ABCDEFGHIJKLMNOPZs