')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('\n')
-
- def description(self, doc, level, output):
- p=doc.getPreviousSibling()
- if p is None or p.getNodeName() is not doc.getNodeName():
- output('\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- n=doc.getNextSibling()
- if n is None or n.getNodeName() is not doc.getNodeName():
- output('\n')
-
- def descriptionTitle(self, doc, level, output):
- output('\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('\n')
-
- def descriptionBody(self, doc, level, output):
- output('\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('\n')
- output('\n')
+ except:
+ print "failed", c.getNodeName(), c
+ output('\n')
+
+ def description(self, doc, level, output):
+ p=doc.getPreviousSibling()
+ if p is None or p.getNodeName() is not doc.getNodeName():
+ output('\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ n=doc.getNextSibling()
+ if n is None or n.getNodeName() is not doc.getNodeName():
+ output('\n')
+
+ def descriptionTitle(self, doc, level, output):
+ output('\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('\n')
+
+ def descriptionBody(self, doc, level, output):
+ output('\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('\n')
+ output('\n')
+
+ def bullet(self, doc, level, output):
+ p=doc.getPreviousSibling()
+ if p is None or p.getNodeName() is not doc.getNodeName():
+ output('\n')
+ output('\n')
+
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ n=doc.getNextSibling()
+ output('\n')
+ if n is None or n.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')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ n=doc.getNextSibling()
+ output('\n')
+ if n is None or n.getNodeName() is not doc.getNodeName():
+ output('\n')
+
+ def example(self, doc, level, output):
+ i=0
+ for c in doc.getChildNodes():
+ if i==0:
+ output('\n' in your body will break this...
+ ##
+ output(prestrip(c.getNodeValue()))
+ output('\n]]>\n')
+ else:
+ getattr(self, self.element_types[c.getNodeName()])(
+ c, level, output)
+
+ def paragraph(self, doc, level, output):
+ output('\n\n')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(
+ c, level, output)
+ output('\n\n')
+
+ def link(self, doc, level, output):
+ output('' % doc.href)
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('')
- def bullet(self, doc, level, output):
- p=doc.getPreviousSibling()
- if p is None or p.getNodeName() is not doc.getNodeName():
- output('\n')
- output('\n')
+ def emphasis(self, doc, level, output):
+ output('')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output(' ')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- n=doc.getNextSibling()
- output('\n')
- if n is None or n.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')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- n=doc.getNextSibling()
- output('\n')
- if n is None or n.getNodeName() is not doc.getNodeName():
- output('\n')
-
- def example(self, doc, level, output):
- i=0
- for c in doc.getChildNodes():
- if i==0:
- output('\n' in your body will break this...
- ##
- output(prestrip(c.getNodeValue()))
- output('\n]]>\n')
- else:
- getattr(self, self.element_types[c.getNodeName()])(
- c, level, output)
-
- def paragraph(self, doc, level, output):
-
- output('\n\n')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(
- c, level, output)
- output('\n\n')
-
- def link(self, doc, level, output):
-# output('' % doc.href)
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
-# output('')
+ def literal(self, doc, level, output):
+ output('')
+ for c in doc.getChildNodes():
+ output(c.getNodeValue())
+ output('')
- def emphasis(self, doc, level, output):
- output('')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output(' ')
+ def strong(self, doc, level, output):
+ output('')
+ for c in doc.getChildNodes():
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('')
- def literal(self, doc, level, output):
- output('')
- for c in doc.getChildNodes():
- output(c.getNodeValue())
- output('')
+ def xref(self, doc, level, output):
+ output('' % doc.getNodeValue())
- def strong(self, doc, level, output):
- output('')
- for c in doc.getChildNodes():
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('')
+ def sgml(self, doc, level, output):
+ output(doc.getNodeValue())
- def xref(self, doc, level, output):
- output('' % doc.getNodeValue())
def prestrip(v):
- v=string.replace(v, '\r\n', '\n')
- v=string.replace(v, '\r', '\n')
- v=string.replace(v, '\t', ' ')
- lines=string.split(v, '\n')
- indent=len(lines[0])
- for line in lines:
- if not len(line): continue
- i=len(line)-len(string.lstrip(line))
- if i < indent:
- indent=i
- nlines=[]
- for line in lines:
- nlines.append(line[indent:])
- return string.join(nlines, '\r\n')
+ v=string.replace(v, '\r\n', '\n')
+ v=string.replace(v, '\r', '\n')
+ v=string.replace(v, '\t', ' ')
+ lines=string.split(v, '\n')
+ indent=len(lines[0])
+ for line in lines:
+ if not len(line): continue
+ i=len(line)-len(string.lstrip(line))
+ if i < indent:
+ indent=i
+ nlines=[]
+ for line in lines:
+ nlines.append(line[indent:])
+ return string.join(nlines, '\n')
class DocBookChapter(DocBookClass):
- def document(self, doc, level, output):
- output('\n')
- children=doc.getChildNodes()
- if (children and
- children[0].getNodeName() == 'StructuredTextSection'):
- output('%s' % children[0].getChildNodes()[0].getNodeValue())
- for c in children[0].getChildNodes()[1:]:
- getattr(self, self.element_types[c.getNodeName()])(c, level, output)
- output('\n')
+ def document(self, doc, level, output):
+ output('\n')
+ children=doc.getChildNodes()
+ if (children and
+ children[0].getNodeName() == 'StructuredTextSection'):
+ output('%s' % children[0].getChildNodes()[0].getNodeValue())
+ for c in children[0].getChildNodes()[1:]:
+ getattr(self, self.element_types[c.getNodeName()])(c, level, output)
+ output('\n')
ets = DocBookClass.element_types
-ets.update({'StructuredTextImage': 'image'})
+ets.update({'StructuredTextImage': 'image'})
class DocBookChapterWithFigures(DocBookChapter):
- element_types = ets
+ element_types = ets
- def image(self, doc, level, output):
- if hasattr(doc, 'key'):
- output('