summaryrefslogtreecommitdiff
path: root/sphinx/util/json.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-09-24 11:51:02 +0000
committerGeorg Brandl <georg@python.org>2008-09-24 11:51:02 +0000
commit0830a04bbf83f3da75c3ab95cee27bba0e721c46 (patch)
treef534ce20a7241ba7619b94473802f596e65fadaf /sphinx/util/json.py
parent3d3bcb00dfbd8f7cc973371e075d0f931af6649c (diff)
downloadsphinx-git-0830a04bbf83f3da75c3ab95cee27bba0e721c46.tar.gz
A fix in the JS dumper and further compression by omitting redundant braces.
Diffstat (limited to 'sphinx/util/json.py')
-rw-r--r--sphinx/util/json.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/sphinx/util/json.py b/sphinx/util/json.py
index 5bf1ace4b..a2fda2b8d 100644
--- a/sphinx/util/json.py
+++ b/sphinx/util/json.py
@@ -20,6 +20,7 @@ import re
_str_re = re.compile(r'"(\\\\|\\"|[^"])*"')
_int_re = re.compile(r'\d+')
_name_re = re.compile(r'[a-zA-Z]\w*')
+_nameonly_re = re.compile(r'[a-zA-Z]\w*$')
# escape \, ", control characters and everything outside ASCII
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
@@ -78,7 +79,7 @@ def dumps(obj, key=False):
if key:
if not isinstance(obj, basestring):
obj = str(obj)
- if _name_re.match(obj) and obj not in reswords:
+ if _nameonly_re.match(obj) and obj not in reswords:
return obj # return it as a bare word
else:
return encode_string(obj)