[cairo-commit] svgslides/src svgslides-4suite,1.11,1.12

Carl Worth commit at pdx.freedesktop.org
Wed Jul 20 12:06:51 PDT 2005


Committed by: cworth

Update of /cvs/cairo/svgslides/src
In directory gabe:/tmp/cvs-serv29906/src

Modified Files:
	svgslides-4suite 
Log Message:

        * src/svgslides-4suite: Fix so that slide titles and content may
        contain utf-8 characters without crashing python.
        Turn off the override of the transform attribute when copying a
        <g> element from input to output.

        * example/example-left-right.svg: Add missing file.


Index: svgslides-4suite
===================================================================
RCS file: /cvs/cairo/svgslides/src/svgslides-4suite,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- svgslides-4suite	12 Jul 2005 16:12:37 -0000	1.11
+++ svgslides-4suite	20 Jul 2005 19:06:41 -0000	1.12
@@ -7,6 +7,7 @@
 
 import sys
 import re
+import codecs
 
 from Ft.Xml.XPath.Context import Context
 from Ft.Xml import XPath
@@ -122,11 +123,12 @@
 file.close ()
 
 # Generate HTML output
-file = open ('index.html', 'w')
+presentation = u''
+file = codecs.open ('index.html', 'w', 'utf-8')
 try:
-	presentation = do_xpath (slides_doc, u'//ss:slides/@presentation')[0].nodeValue
+	presentation = u'' + do_xpath (slides_doc, u'//ss:slides/@presentation')[0].nodeValue
 except IndexError, exc:
-	presentation = ''
+	presentation = u''
 print >> file, '<html>\n  <head>\n    <title>', 
 print >> file, presentation,
 print >> file, '</title>\n  </head>\n  <body>'
@@ -137,16 +139,16 @@
 # unicode characters to utf-8?
 slide_num = 0
 for slide in slides:
-    print >> file, '    <p><a href="'+slide_file_name (slide_num, '.html')+'">'+get_attr (slide, 'title').encode('utf-8')+'</a>'
+    print >> file, '    <p><a href="'+slide_file_name (slide_num, '.html')+'">'+get_attr (slide, 'title')+'</a>'
     slide_num += 1
 print >> file, '  </body>\n</html>'
 file.close ()
     
 slide_num = 0
 for slide in slides:
-    file = open (slide_file_name (slide_num, '.html'), 'w')
+    file = codecs.open (slide_file_name (slide_num, '.html'), 'w', 'utf-8')
     print >> file, '<html>\n  <head>\n    <title>', 
-    print >> file, get_attr (slide, 'title').encode('utf-8')
+    print >> file, get_attr (slide, 'title')
     print >> file, '</title>\n  </head>\n  <body>'
     if slide_num > 0:
         print >> file, '    <a href="'+slide_file_name (slide_num-1, '.html')+'">prev</a>'
@@ -344,7 +346,10 @@
             elif y_align == 'center':
                 y_offset -= height / 2
 
-            group.setAttributeNS (None, u'transform', 'translate('+`x_offset`+','+`y_offset`+')')
+            # I think all this group stuff was misguided. What we really
+            # want is to just copy chunks of SVG into the output.
+            # So I'm turning this off for now.
+#            group.setAttributeNS (None, u'transform', 'translate('+`x_offset`+','+`y_offset`+')')
             root.appendChild (group)
 
             return root




More information about the cairo-commit mailing list