pygobject r1013 - in branches/pygobject-2-16: . codegen



Author: gianmt
Date: Fri Feb 20 21:21:12 2009
New Revision: 1013
URL: http://svn.gnome.org/viewvc/pygobject?rev=1013&view=rev

Log:
Do not escape the ampersand 

Modified:
   branches/pygobject-2-16/ChangeLog
   branches/pygobject-2-16/codegen/docextract_to_xml.py

Modified: branches/pygobject-2-16/codegen/docextract_to_xml.py
==============================================================================
--- branches/pygobject-2-16/codegen/docextract_to_xml.py	(original)
+++ branches/pygobject-2-16/codegen/docextract_to_xml.py	Fri Feb 20 21:21:12 2009
@@ -7,21 +7,26 @@
 # # ./docextract_to_xml.py -s /gnome/head/cvs/gtk+/gtk/ -s /gnome/head/cvs/gtk+/docs/reference/gtk/tmpl/ > gtk_docs.xml
 
 import getopt
+import re
 import string
 import sys
 
 import docextract
 
 def escape_text(unescaped_text):
-    escaped_text = unescaped_text
+    # Escape every "&" not part of an entity reference
+    escaped_text = re.sub(r'&(?![A-Za-z]+;)', '&', unescaped_text)
+
+    # These weird entities turn up in the output...
+    escaped_text = string.replace(escaped_text, '—', '—')
+    escaped_text = string.replace(escaped_text, '*', '*')
+    escaped_text = string.replace(escaped_text, '%', '%')
+    escaped_text = string.replace(escaped_text, '@', '@')
+
+    # Escape for both tag contents and attribute values
     escaped_text = string.replace(escaped_text, '<', '&lt;')
     escaped_text = string.replace(escaped_text, '>', '&gt;')
-    escaped_text = string.replace(escaped_text, '&', '&amp;')
-    escaped_text = string.replace(escaped_text, '\'', '&apos;')
-    escaped_text = string.replace(escaped_text, '\"', '&quot;')
-
-    #Apparently this is an undefined symbol:
-    escaped_text = string.replace(escaped_text, '&mdash;', ' mdash ')
+    escaped_text = string.replace(escaped_text, '"', '&quot;')
 
     return escaped_text
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]