def expand(self, node, format, node_map): return ''.join(['<para>'] + [expand(child, format, node_map) for child in node.children] + ['</para>'])
def testExpandFromTree(self): p = ParagraphNode() tn = TextNode() tn.content = 'content' p.children.append(tn) self.assertEquals(expand(p, 'docbook5', node_map), '<para>content</para>')
def testExpandFromTreeWithEntitiesEnabled(self): p = ParagraphNode() tn = TextNode() tn.content = '<b>not bold</b>' p.children.append(tn) self.assertEquals(expand(p, 'docbook5', node_map), '<para><b>not bold</b></para>')
def expand_with_content(self, node, format, node_map, prefix=u'', suffix=u''): return u''.join([prefix] + [expand(child, format, node_map) for child in node.children] + [suffix])