X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c12bc4de5887421242de7f619b3c5e265bf631ac..77436c4cbac2269e564dc4fcf4494a58feca0af4:/wxPython/samples/stxview/StructuredText/HTMLClass.py diff --git a/wxPython/samples/stxview/StructuredText/HTMLClass.py b/wxPython/samples/stxview/StructuredText/HTMLClass.py index d5c03d8357..951aec4c97 100644 --- a/wxPython/samples/stxview/StructuredText/HTMLClass.py +++ b/wxPython/samples/stxview/StructuredText/HTMLClass.py @@ -84,6 +84,7 @@ ############################################################################## from string import join, split, find +from cgi import escape import re, sys, ST class HTMLClass: @@ -172,34 +173,34 @@ class HTMLClass: def bullet(self, doc, level, output): p=doc.getPreviousSibling() if p is None or p.getNodeName() is not doc.getNodeName(): - output('\n') def numbered(self, doc, level, output): p=doc.getPreviousSibling() if p is None or p.getNodeName() is not doc.getNodeName(): - output('
    \n') + output('\n
      \n') output('
    1. ') for c in doc.getChildNodes(): getattr(self, self.element_types[c.getNodeName()])(c, level, output) n=doc.getNextSibling() output('
    2. \n') if n is None or n.getNodeName() is not doc.getNodeName(): - output('
    \n') + output('\n
\n') def example(self, doc, level, output): i=0 for c in doc.getChildNodes(): if i==0: - output('
')
-                output(html_quote(c.getNodeValue()))
-                output('
\n') + output('\n
\n')
+                output(escape(c.getNodeValue()))
+                output('\n
\n') else: getattr(self, self.element_types[c.getNodeName()])( c, level, output) @@ -214,7 +215,7 @@ class HTMLClass: else: getattr(self, self.element_types[c.getNodeName()])( c, level, output) - output('

') + output('

\n') def link(self, doc, level, output): output('' % doc.href) @@ -231,7 +232,7 @@ class HTMLClass: def literal(self, doc, level, output): output('') for c in doc.getChildNodes(): - output(html_quote(c.getNodeValue())) + output(escape(c.getNodeValue())) output('') def strong(self, doc, level, output): @@ -267,6 +268,10 @@ class HTMLClass: def sgml(self,doc,level,output): for c in doc.getChildNodes(): getattr(self, self.element_types[c.getNodeName()])(c, level, output) + + def xref(self, doc, level, output): + val = doc.getNodeValue() + output('[%s]' % (val, val) ) def table(self,doc,level,output): """ @@ -279,29 +284,23 @@ class HTMLClass: for row in doc.getRows()[0]: output("\n") for column in row.getColumns()[0]: - str = "" % column.getSpan() + if hasattr(column,"getAlign"): + str = "<%s colspan=%s align=%s valign=%s>" % (column.getType(), + column.getSpan(), + column.getAlign(), + column.getValign()) + else: + str = "" % column.getSpan() output(str) - #for c in doc.getChildNodes(): - # getattr(self, self.element_types[c.getNodeName()])(c, level, output) for c in column.getChildNodes(): getattr(self, self.element_types[c.getNodeName()])(c, level, output) - output("\n") + if hasattr(column,"getType"): + output("\n") + else: + output("\n") output("\n") output("\n") -def html_quote(v, name='(Unknown name)', md={}, - character_entities=( - (('&'), '&'), - (('<'), '<' ), - (('>'), '>' ), - (('\213'), '<' ), - (('\233'), '>' ), - (('"'), '"'))): #" - text=str(v) - for re,name in character_entities: - if find(text, re) >= 0: text=join(split(text,re),name) - return text -