summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Jie Lin <livibetter@gmail.com>2013-09-18 03:18:34 +0800
committerYu-Jie Lin <livibetter@gmail.com>2013-09-18 03:18:34 +0800
commit68e926a0dba69b96f908226bda12fa9d78f5aa1e (patch)
treea7fb9ae2e742f327365271d3f96d3ce728520a50
parentd47b1bcbdf62f832c8398efcc937f51a7e815a26 (diff)
downloadsmartypants-68e926a0dba69b96f908226bda12fa9d78f5aa1e.tar.gz
fix missing ampersand & in escape sequence table, add doctest to process_escapes()
-rwxr-xr-xsmartypants.py35
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 |
+ +========+===========+===========+
+ | ``\\`` | ``&#92;`` | ``\`` |
+ +--------+-----------+-----------+
+ | ``\"`` | ``&#34;`` | ``"`` |
+ +--------+-----------+-----------+
+ | ``\'`` | ``&#39;`` | ``'`` |
+ +--------+-----------+-----------+
+ | ``\.`` | ``&#46;`` | ``.`` |
+ +--------+-----------+-----------+
+ | ``\-`` | ``&#45;`` | ``-`` |
+ +--------+-----------+-----------+
+ | ``\``` | ``&#96;`` | ``\``` |
+ +--------+-----------+-----------+
+
+ >>> print(process_escapes(r'\\'))
+ &#92;
+ >>> print(smartypants(r'"smarty" \"pants\"'))
+ &#8220;smarty&#8221; &#34;pants&#34;
"""
text = re.sub(r'\\\\', '&#92;', text)