Commit 6b3c9211 authored by Andreas Jung's avatar Andreas Jung

document() function of HTMLWithImages now behaves like in HTMLClass

and recognizes the header attribute
parent f6a8b104
...@@ -56,7 +56,7 @@ class HTMLClass: ...@@ -56,7 +56,7 @@ class HTMLClass:
def document(self, doc, level, output): def document(self, doc, level, output):
children=doc.getChildNodes() children=doc.getChildNodes()
if self.header==1: if self.header:
output('<html>\n') output('<html>\n')
if (children and if (children and
children[0].getNodeName() == 'StructuredTextSection'): children[0].getNodeName() == 'StructuredTextSection'):
...@@ -67,7 +67,7 @@ class HTMLClass: ...@@ -67,7 +67,7 @@ class HTMLClass:
for c in children: for c in children:
getattr(self, self.element_types[c.getNodeName()])(c, level, output) getattr(self, self.element_types[c.getNodeName()])(c, level, output)
if self.header==1: if self.header:
output('</body>\n') output('</body>\n')
output('</html>\n') output('</html>\n')
......
...@@ -22,17 +22,22 @@ class HTMLWithImages(HTMLClass): ...@@ -22,17 +22,22 @@ class HTMLWithImages(HTMLClass):
element_types = ets element_types = ets
def document(self, doc, level, output): def document(self, doc, level, output):
output('<html>\n')
children=doc.getChildNodes() if self.header:
if (children and output('<html>\n')
children[0].getNodeName() == 'StructuredTextSection'): children=doc.getChildNodes()
output('<head>\n<title>%s</title>\n</head>\n' % if (children and
children[0].getChildNodes()[0].getNodeValue()) children[0].getNodeName() == 'StructuredTextSection'):
output('<body>\n') output('<head>\n<title>%s</title>\n</head>\n' %
children[0].getChildNodes()[0].getNodeValue())
output('<body>\n')
for c in children: for c in children:
getattr(self, self.element_types[c.getNodeName()])(c, level, output) getattr(self, self.element_types[c.getNodeName()])(c, level, output)
output('</body>\n')
output('</html>\n') if self.header:
output('</body>\n')
output('</html>\n')
def image(self, doc, level, output): def image(self, doc, level, output):
if hasattr(doc, 'key'): if hasattr(doc, 'key'):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment