nix-archive-1(type directoryentry(namebinnode(type directoryentry(name.smartypants-realnode(typeregular executablecontents #!/gnu/store/iq3f64nydx9vbki6r0iwaqyc6pw92p59-python-wrapper-3.10.7/bin/python # Copyright (c) 2017 Leo Hemsted # Licensed under the BSD License, for detailed license information, see COPYING """ ============ Command-line ============ smartypants =========== ``smartypants`` provides a command-line interface for :py:mod:`smartypants` module, which is named as same as the module. It takes input from either standard input or files and output the result to standard output. Usage ===== Syntax:: smartypants [-h] [-v] [-a ATTR] [-s SKIP] [FILE [FILE ...]] Some examples:: $ smartypants inputfile $ command-foo inputfile | command-bar | smartypants Options ======= ``-a``, ``--attr``: processe attrbutes tells smartypants how to translate, The attributes is a string of characters, which are taken from the names of attributes of :py:class:`smartypants.Attr `. For example, the default attribute is :py:attr:`smartypants.Attr.set1 `:: smartypants -a 1 If you want :py:attr:`smartypants.Attr.q ` and :py:attr:`smartypants.Attr.w ` then it would be invoked as:: smartypants -a qw ``-s``, ``--skip``: skip specified HTML elements. It is a comma-separated string. For example:: smartypants -s tag1,tag2,tag3 ``FILE``: files to be processed. If no ``FILE`` is specified, the input is taken from standard input. """ from __future__ import print_function import argparse import sys import warnings import smartypants def _str_attr_to_int(str_attr): """ Convert str-type attr into int >>> f = _str_attr_to_int >>> f('q') == Attr.q True >>> f('1') == Attr.set1 True >>> with warnings.catch_warnings(record=True) as w: ... f('bz') ... len(w) ... print(w[-1].message) 2 1 Unknown attribute: z """ attr = 0 for c in str_attr: if '0' <= c <= '3': c = 'set' + c if not hasattr(smartypants.Attr, c): warnings.warn('Unknown attribute: %s' % c, Warning) continue attr |= getattr(smartypants.Attr, c) return attr def main(): parser = argparse.ArgumentParser(description=smartypants.__description__) parser.add_argument('-v', '--version', action='version', version=smartypants.__version__) parser.add_argument('-a', '--attr', default='1', help='processing attributes (Default: %(default)s)') parser.add_argument('-s', '--skip', default=','.join(smartypants.tags_to_skip), help='skip HTML elements (Default: %(default)s)') parser.add_argument('files', metavar='FILE', type=argparse.FileType('r'), nargs='*', help='files to be processed ') args = parser.parse_args() with warnings.catch_warnings(record=True) as w: attr = _str_attr_to_int(args.attr) if len(w): print(w[-1].message) sys.exit(1) smartypants.tags_to_skip = args.skip.split(',') if args.files: for f in args.files: print(smartypants.smartypants(f.read(), attr), end='') else: print(smartypants.smartypants(sys.stdin.read(), attr), end='') if __name__ == '__main__': main() ))entry(name smartypantsnode(typeregular executablecontentsÊ#!/gnu/store/d7q6yazfa1bxf4x7p9n3b99hn97q6bvw-bash-minimal-5.1.16/bin/bash export GUIX_PYTHONPATH="/gnu/store/8hxwgl9q1v5fa5awilx04kqvm79vvas1-python-smartypants-2.0.1/lib/python3.10/site-packages:/gnu/store/pbcc4vzsh76r6x58pq5s204ladvbf435-python-docutils-0.19/lib/python3.10/site-packages:/gnu/store/fys3lcf06rrrgfa827650a8jsfakzlwl-python-nose-1.3.7/lib/python3.10/site-packages:/gnu/store/hj8ijq03pfd2h4dihlv5m02lzvyx5dhb-python-pygments-2.12.0/lib/python3.10/site-packages:/gnu/store/yxq8wfig9rq7rv71d7z769ryl1cg7q3z-python-3.10.7/lib/python3.10/site-packages${GUIX_PYTHONPATH:+:}$GUIX_PYTHONPATH" exec -a "$0" "/gnu/store/8hxwgl9q1v5fa5awilx04kqvm79vvas1-python-smartypants-2.0.1/bin/.smartypants-real" "$@" ))))entry(namelibnode(type directoryentry(name python3.10node(type directoryentry(name site-packagesnode(type directoryentry(name __pycache__node(type directoryentry(namesmartypants.cpython-310.pycnode(typeregularcontents¼-o ¿¯‹a ¹|ã@s´dZdZdZdZdZdZdZddlZGd d „d eƒZ e ƒZ e j a gd ¢Z d$d d „Zd$dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„ZdS)%z_ smartypants module ================== :func:`smartypants` is the core of smartypants module. z Leo Hemstedzleohemsted@gmail.comz2.0.1z BSD Licensez,https://github.com/leohemsted/smartypants.pyzPython with the SmartyPantséNc@sÔeZdZdZdZ dZ deBZ eeBZdZ deBZ deBZ ee Be BZ dZ d Z d Z d Z d Z eeBeBZd Z eeBeBe BZ eeBe Be BZ eeBe Be BZ edd„ƒZejdd„ƒZdS)Ú_AttrzC class for instantiation of module attribute :attr:`Attr`. éééééé é@é€éiircCstS)z7Default value of attributes, same value as :attr:`set1`©Údefault_smartypants_attr)Úself©rúp/gnu/store/8hxwgl9q1v5fa5awilx04kqvm79vvas1-python-smartypants-2.0.1/lib/python3.10/site-packages/smartypants.pyÚdefault‡sz _Attr.defaultcCs|adS©Nr )rÚattrrrrrsN)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚqÚbÚBÚmask_bÚdÚDÚiÚmask_dÚeÚwÚuÚhÚsÚmask_oÚset0Úset1Úset2Úset3ÚpropertyrÚsetterrrrrrsN   r)ÚpreÚsampÚcodeÚttÚkbdÚscriptÚstyleÚmathcCs6|durt}t|ttfƒrd |¡}t d|tj¡S)zÕ Convert a list of skipped tags into regular expression The default *tags* are :attr:`tags_to_skip`. >>> f = _tags_to_skip_regex >>> print(f(['foo', 'bar']).pattern) <(/)?(foo|bar)[^>]*> Nú|z<(/)?(%s)[^>]*>)Ú tags_to_skipÚ isinstanceÚlistÚtupleÚjoinÚreÚcompileÚI)ÚtagsrrrÚ_tags_to_skip_regex¥s   r>cCsLg}|dur tj}|tj@}|tj@}|tj@}|tj@}|tj@}|tj@}t|ƒ} g} d} d} t ƒ} | D]ê}|ddkr‚|   |d¡|   |d¡}|r|  d¡s`|  |  d¡  ¡¡d} q6t|ƒdkry|d }|  d¡  ¡|krx| ¡n t|ƒdkrd} q6|d}|d d…}| st|ƒ}|rœt d d |¡}|r¹|tjkr§t|ƒ}|tjkr°t|ƒ}|tjkr¹t|ƒ}|r¿t|ƒ}|tjkrÈt|ƒ}|tjkrÑt|ƒ}|r÷|d krãt  d | ¡ràd}nd}n|d krót  d | ¡rðd}nd}nt|ƒ}|r|tjkrdn|tj kr dn |tj!krdnd}t"||ƒ}|} |   |¡q6d #| ¡S)zµ SmartyPants function >>> print(smartypants('"foo" -- bar')) “foo” — bar >>> print(smartypants('"foo" -- bar', Attr.d)) "foo" — bar NFÚrÚtagrrTéÿÿÿÿz"ú"ú'z\Sú’ú‘ú”ú“é)$ÚAttrrrrrr r%r!Ú _tokenizer>ÚappendÚmatchÚgroupÚlowerÚlenÚpopÚprocess_escapesr:ÚsubrÚconvert_dashesrÚconvert_dashes_oldschoolrÚ!convert_dashes_oldschool_invertedÚconvert_ellipsesrÚconvert_backticksrÚconvert_single_backticksÚconvert_quotesr"r#r$Úconvert_entitiesr9)ÚtextrÚskipped_tag_stackÚ do_quotesÚ do_backticksÚ do_dashesÚ do_ellipsesÚ do_entitiesÚ convert_quotÚtokensÚresultÚin_preÚprev_token_last_charÚtags_to_skip_regexÚ cur_tokenÚ skip_matchÚ_tagÚtÚ last_charÚmoderrrÚ smartypants¸sŠ            €        ý   rncCs>d}t d|fd|¡}t d|fd|¡}t dd|¡}t dd |¡}t d d|¡}d }d }t d |ftj¡}| d|¡}t d|ftj¡}| d|¡}t d|ftj¡}| d|¡}t dd|¡}t d|ftj¡}| d|¡}t d|ftj¡}| d|¡}t d|ftj¡}| d|¡}t dd|¡}|S)zŸ Convert quotes in *text* into HTML curly quote entities. >>> print(convert_quotes('"Isn\'t this fun?"')) “Isn’t this fun?” z)[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]z ^'(?=%s\\B)rDz ^"(?=%s\\B)rFz"'(?=\w)z“‘z'"(?=\w)z‘“z \b'(?=\d{2}s)z[^\ \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 \1‘zJ (%s) ' (?!\s | s\b | \d) z \1’zC (%s) ' (\s | s\b) z \1’\2rCrEaÌ ( \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 \1“zz #(%s)? # character that indicates the quote should be closing " (?=\s) ze (%s) # character that indicates the quote should be closing " z \1”rBrG)r:rRr;ÚVERBOSE)r[Ú punct_classÚ close_classÚ dec_dashesÚopening_single_quotes_regexÚclosing_single_quotes_regexÚopening_double_quotes_regexÚclosing_double_quotes_regexrrrrY+s^ õ õ üü üü  õ õ üü ýý rYcCó t dd|¡}t dd|¡}|S)zÀ Convert ````backticks''``-style double quotes in *text* into HTML curly quote entities. >>> print(convert_backticks("``Isn't this fun?''")) “Isn't this fun?” z``rGz''rF©r:rR©r[rrrrW‰ó rWcCrw)zÉ Convert ```backticks'``-style single quotes in *text* into HTML curly quote entities. >>> print(convert_single_backticks("`Isn't this fun?'")) ‘Isn’t this fun?’ ú`rErCrDrxryrrrrX—rzrXcCst dd|¡}|S)zÓ Convert ``--`` in *text* into em-dash HTML entities. >>> quote = 'Nothing endures but change. -- Heraclitus' >>> print(convert_dashes(quote)) Nothing endures but change. — Heraclitus ú--ú—rxryrrrrS¥s rScCrw)a3 Convert ``--`` and ``---`` in *text* into en-dash and em-dash HTML entities, respectively. >>> quote = 'Life itself is the proper binge. --- Julia Child (1912--2004)' >>> print(convert_dashes_oldschool(quote)) Life itself is the proper binge. — Julia Child (1912–2004) ú---r}r|ú–rxryrrrrT²s rTcCrw)uß Convert ``--`` and ``---`` in *text* into em-dash and en-dash HTML entities, respectively. Two reasons why: * First, unlike the en- and em-dash syntax supported by :func:`convert_dashes_oldschool`, 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.) >>> quote = 'Dare to be naïve. -- Buckminster Fuller (1895---1983)' >>> print(convert_dashes_oldschool_inverted(quote)) Dare to be naïve. — Buckminster Fuller (1895–1983) r~rr|r}rxryrrrrUÁsrUcCs t dd|¡}t dd|¡}|S)z{ Convert ``...`` in *text* into ellipsis HTML entities >>> print(convert_ellipses('Huh...?')) Huh…? z\.\.\.ú…z\. \. \.rxryrrrrVÚsrVcCs:ddddddddœ}| ¡D] \}}| |||¡}q|S) uŽ Convert numeric character references to, if *mode* is - *0*: Unicode characters - *1*: HTML named entities - *2*: ASCII equivalents >>> print(convert_entities('‘', 0)) ‘ >>> print(convert_entities('‘SmartyPants’', 1)) ‘SmartyPants’ >>> print(convert_entities('“Hello — world.”', 2)) "Hello -- world." )u–z–ú-)u—z—r|)u‘z‘rC)u’z’rC)u“z“rB)uâ€z”rB)u…z…z...)rr}rErDrGrFr€)ÚitemsÚreplace)r[rmÚCTBLÚkÚvrrrrZçsù rZcCsXt dd|¡}t dd|¡}t dd|¡}t dd|¡}t d d |¡}t d d |¡}|S) aq Processe the following backslash escape sequences in *text*. This is useful if you want to force a "dumb" quote or other character to appear. +--------+-----------+-----------+ | Escape | Value | Character | +========+===========+===========+ | ``\\`` | ``\`` | ``\`` | +--------+-----------+-----------+ | ``\"`` | ``"`` | ``"`` | +--------+-----------+-----------+ | ``\'`` | ``'`` | ``'`` | +--------+-----------+-----------+ | ``\.`` | ``.`` | ``.`` | +--------+-----------+-----------+ | ``\-`` | ``-`` | ``-`` | +--------+-----------+-----------+ | ``\``` | ````` | ``\``` | +--------+-----------+-----------+ >>> print(process_escapes(r'\\')) \ >>> print(smartypants(r'"smarty" \"pants\"')) “smarty” "pants" z\\\\z\z\\"z"z\\'z'z\\\.z.z\\-z-z\\`z`rxryrrrrQsrQcCsÎg}t dtj¡}| |¡}d}|rT| d¡r!| d| d¡g¡| d¡}d}| d¡r?d|d d … d ¡ ¡ d ¡vr?d}| ||g¡| ¡}| || ¡¡}|s|t |ƒkre| d||d …g¡|S) aÝ Reference to an array of the tokens comprising the input string. Each token is either a tag (possibly with nested, tags contained therein, such as ````, or a run of text between tags. Each element of the array is a two-element array; 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 z([^<]*)(