diff options
author | Yu-Jie Lin <livibetter@gmail.com> | 2013-09-18 03:18:34 +0800 |
---|---|---|
committer | Yu-Jie Lin <livibetter@gmail.com> | 2013-09-18 03:18:34 +0800 |
commit | 68e926a0dba69b96f908226bda12fa9d78f5aa1e (patch) | |
tree | a7fb9ae2e742f327365271d3f96d3ce728520a50 | |
parent | d47b1bcbdf62f832c8398efcc937f51a7e815a26 (diff) | |
download | smartypants-68e926a0dba69b96f908226bda12fa9d78f5aa1e.tar.gz |
fix missing ampersand & in escape sequence table, add doctest to process_escapes()
-rwxr-xr-x | smartypants.py | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/smartypants.py b/smartypants.py index d4ff685..aec885b 100755 --- a/smartypants.py +++ b/smartypants.py @@ -662,21 +662,26 @@ def process_escapes(text): 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 | - +========+==========+=============+ - | ``\\`` | ``#92;`` | ``\`` | - +--------+----------+-------------+ - | ``\"`` | ``#34;`` | ``"`` | - +--------+----------+-------------+ - | ``\'`` | ``#39;`` | ``'`` | - +--------+----------+-------------+ - | ``\.`` | ``#46;`` | ``.`` | - +--------+----------+-------------+ - | ``\-`` | ``#45;`` | ``-`` | - +--------+----------+-------------+ - | ``\``` | ``#96;`` | ``\``` | - +--------+----------+-------------+ + +--------+-----------+-----------+ + | Escape | Value | Character | + +========+===========+===========+ + | ``\\`` | ``\`` | ``\`` | + +--------+-----------+-----------+ + | ``\"`` | ``"`` | ``"`` | + +--------+-----------+-----------+ + | ``\'`` | ``'`` | ``'`` | + +--------+-----------+-----------+ + | ``\.`` | ``.`` | ``.`` | + +--------+-----------+-----------+ + | ``\-`` | ``-`` | ``-`` | + +--------+-----------+-----------+ + | ``\``` | ````` | ``\``` | + +--------+-----------+-----------+ + + >>> print(process_escapes(r'\\')) + \ + >>> print(smartypants(r'"smarty" \"pants\"')) + “smarty” "pants" """ text = re.sub(r'\\\\', '\', text) |