diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-01-18 03:59:15 -0500 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-01-18 03:59:15 -0500 |
commit | 2b8f22bb9fa83bae9af8ad8cb5fb17a323248c8c (patch) | |
tree | 532f36098466625da478064bfbf1a16a38c9fddd | |
parent | 533ecde7c2f7a66ec7a5c938fc7b8bfc4ed8fed8 (diff) |
Worked on handling heading paragraphs.
-rw-r--r-- | source/docbook.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/source/docbook.py b/source/docbook.py index 2653dcb..7f5ecb2 100644 --- a/source/docbook.py +++ b/source/docbook.py @@ -128,7 +128,8 @@ class DocBookConverter: self.embeds = embeds self.root = node.Root() self.exthelps = {} # texts for extended helps. - self.headingParent = None + self.headingLevel = None + self.lastLevel = None self.__currentFileName = None def convert (self): @@ -183,7 +184,9 @@ class DocBookConverter: xhpbody = helpdoc.firstChildByName('body') # parent element for the xhp 'heading' paragraphs which should start a # new sub-section when converting to docbook. - self.headingParent = None + self.headingLevel = None + self.lastLevel = None + self.firstHeading = True encodedID = globals.encodeID(self.__currentFileName) if len(encodedID) > 0: dest.setAttr('id', encodedID) @@ -363,14 +366,20 @@ class DocBookConverter: if role == None: role = '' if role == 'heading': - # finish the current sub-section, adn start a new one. - if self.headingParent == None: - self.headingParent = dest - elem = DocBookConverter.startSubSection(self.headingParent) - self.__maybeAddElementID(src, elem) - title = elem.appendElement('title') - self.__walkAllChildNodes(src, title) - return elem + level = string.atoi(src.getAttr('level')) + if self.headingLevel == None: + self.headingLevel = level + else: + lv = level - self.headingLevel + delta = 0 + if self.lastLevel != None: + delta = self.lastLevel - level + if dest.name == 'formalpara': + dest = dest.parent + dest = dest.appendElement('formalpara') + dest.appendElement('title').appendContent("(Level %d) %s (lv = %d; d = %d)"%(level, src.getContent(), lv, delta)) + self.lastLevel = level + elif role == 'code': proglisting = dest.appendElement('programlisting') self.__walkAllChildNodes(src, proglisting) |