diff options
Diffstat (limited to 'source/docbook.py')
-rw-r--r-- | source/docbook.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/source/docbook.py b/source/docbook.py index 2d61390..e19767b 100644 --- a/source/docbook.py +++ b/source/docbook.py @@ -109,9 +109,10 @@ class DocBookConverter: else: return None - def __init__ (self, treeroot, xhproots): + def __init__ (self, treeroot, xhproots, embeds): self.treeroot = treeroot self.xhproots = xhproots + self.embeds = embeds self.root = node.Root() self.headingParent = None @@ -152,11 +153,20 @@ class DocBookConverter: for xhpelem in xhpbody.getChildNodes(): dest = self.__walkXHP(xhpelem, dest) + def __getEmbedNode (self, href): + filename, id = href.split('#') + if filename.startswith('/'): + filename = filename[1:] + if self.embeds.has_key(filename) and self.embeds[filename].has_key(id): + return self.embeds[filename][id] + return None + def __walkXHP (self, src, dest): if src.nodeType == node.NodeType.Content: # content node. - if len(src.content.strip()) > 0: + content = src.content.strip() + if len(content) > 0: dest.appendElement('warning').appendContent("unhandled content : '%s'"%src.content.strip()) elif src.name == 'comment': @@ -165,7 +175,13 @@ class DocBookConverter: elif src.name == 'embed': # embed takes its content from another xhp file. href = src.getAttr('href') - dest.appendElement('warning').appendContent('take embedded content from ' + href) + embed = self.__getEmbedNode(href) + if embed == None: + dest.appendElement('warning').appendContent('take embedded content from ' + href) + else: + dest = self.__walkXHP(embed, dest) + elif src.name == 'link': + dest.appendElement('para').appendContent(src.getContent()) elif src.name == 'paragraph': # normal paragraph content. @@ -182,9 +198,10 @@ class DocBookConverter: para = dest.appendElement('para') para.appendContent(src.getContent()) - elif src.name == 'section': + elif src.name == 'section' or src.name == 'variable': # we can probably just ignore this element for now. Section elements - # are used only to group multiple elements together. + # are used only to group multiple elements together. Same with + # the variable elements. for child in src.getChildNodes(): dest = self.__walkXHP(child, dest) |