[Python-checkins] r62632 - in doctools/trunk: CHANGES sphinx/htmlhelp.py

georg.brandl python-checkins at python.org
Fri May 2 11:52:35 CEST 2008


Author: georg.brandl
Date: Fri May  2 11:52:34 2008
New Revision: 62632

Log:
Encode non-ASCII as HTML entities in HTML help files.


Modified:
   doctools/trunk/CHANGES
   doctools/trunk/sphinx/htmlhelp.py

Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES	(original)
+++ doctools/trunk/CHANGES	Fri May  2 11:52:34 2008
@@ -14,7 +14,8 @@
 ----------
 
 * sphinx.htmlwriter: Correctly write the TOC file for any structure of the
-  master document.
+  master document.  Also encode non-ASCII characters as entities in TOC
+  and index file.
 
 
 Release 0.2 (Apr 27, 2008)

Modified: doctools/trunk/sphinx/htmlhelp.py
==============================================================================
--- doctools/trunk/sphinx/htmlhelp.py	(original)
+++ doctools/trunk/sphinx/htmlhelp.py	Fri May  2 11:52:34 2008
@@ -158,8 +158,8 @@
                 for subnode in node:
                     write_toc(subnode, ullevel)
             elif isinstance(node, nodes.reference):
-                f.write(object_sitemap % (cgi.escape(node.astext()),
-                                          node['refuri']))
+                item = object_sitemap % (cgi.escape(node.astext()), node['refuri'])
+                f.write(item.encode('ascii', 'xmlcharrefreplace'))
             elif isinstance(node, nodes.bullet_list):
                 if ullevel != 0:
                     f.write('<UL>\n')
@@ -185,7 +185,8 @@
         def write_index(title, refs, subitems):
             if refs:
                 f.write('<LI> ')
-                f.write(object_sitemap % (cgi.escape(title), refs[0]))
+                item = object_sitemap % (cgi.escape(title), refs[0])
+                f.write(item.encode('ascii', 'xmlcharrefreplace'))
                 for ref in refs[1:]:
                     f.write(object_sitemap % ('[Link]', ref))
             if subitems:


More information about the Python-checkins mailing list