[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/translation. If the source
contains a DOCTYPE declaration, output it in the rendering.
Chris McDonough
chrism at plope.com
Wed Aug 6 00:51:44 EDT 2008
Log message for revision 89421:
If the source contains a DOCTYPE declaration, output it in the rendering.
Changed:
U z3c.pt/trunk/src/z3c/pt/translation.py
U z3c.pt/trunk/src/z3c/pt/translation.txt
-=-
Modified: z3c.pt/trunk/src/z3c/pt/translation.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.py 2008-08-05 21:17:22 UTC (rev 89420)
+++ z3c.pt/trunk/src/z3c/pt/translation.py 2008-08-06 04:51:41 UTC (rev 89421)
@@ -427,6 +427,17 @@
# visit root
root.interpolate(stream)
+
+ # output doctype if any
+ tree = root.getroottree()
+ if tree.docinfo.doctype:
+ dt = (tree.docinfo.doctype +'\n').encode('utf-8')
+ doctype = clauses.Out(dt)
+ stream.scope.append(set())
+ stream.begin([doctype])
+ stream.end([doctype])
+ stream.scope.pop()
+
root.visit(stream)
return generator
Modified: z3c.pt/trunk/src/z3c/pt/translation.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.txt 2008-08-05 21:17:22 UTC (rev 89420)
+++ z3c.pt/trunk/src/z3c/pt/translation.txt 2008-08-06 04:51:41 UTC (rev 89421)
@@ -30,6 +30,20 @@
<div>
<img alt="'Hello World!'" />
</div>
+
+With DOCTYPE:
+
+ >>> print render("""\
+ ... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ ... "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ ... <html xmlns="http://www.w3.org/1999/xhtml"
+ ... xmlns:tal="http://xml.zope.org/namespaces/tal">
+ ... <img alt="'Hello World!'" />
+ ... </html>""", translate_xml)
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html>
+ <img alt="'Hello World!'" />
+ </html>
Attributes and contents:
More information about the Checkins
mailing list