summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2009-12-24 23:31:51 -0500
committerKohei Yoshida <kyoshida@novell.com>2009-12-24 23:31:51 -0500
commit40309880fb1004b9b5786c1f02c5a1efb2805864 (patch)
tree4d350e53da348bdecad9da62a23f739d2825ca83 /source
parentb332db0cae43eaf3b8b7c0a2d78597f909732e8d (diff)
Hanldle <ahelp>, <bookmark> and <section id="howtoget">.
Diffstat (limited to 'source')
-rw-r--r--source/docbook.py64
-rw-r--r--source/node.py3
2 files changed, 56 insertions, 11 deletions
diff --git a/source/docbook.py b/source/docbook.py
index 7da564d..cf910ad 100644
--- a/source/docbook.py
+++ b/source/docbook.py
@@ -127,6 +127,7 @@ class DocBookConverter:
self.xhproots = xhproots
self.embeds = embeds
self.root = node.Root()
+ self.exthelps = {} # texts for extended helps.
self.headingParent = None
def convert (self):
@@ -242,6 +243,19 @@ class DocBookConverter:
else:
self.__walkAllChildNodes(src, dest)
+ elif src.name == 'ahelp':
+ # this tag is used for extended tips from the application. Let's
+ # store the content of this element for later use.
+ if src.hasAttr('hid'):
+ hid = src.getAttr('hid')
+ self.exthelps[hid] = src.getContent()
+
+ visible = True
+ if src.hasAttr('visibility'):
+ visible = src.getAttr('visibility') == 'visible'
+ if visible:
+ self.__walkAllChildNodes(src, dest)
+
elif src.name == 'paragraph':
# normal paragraph content.
role = src.getAttr('role')
@@ -260,23 +274,27 @@ class DocBookConverter:
self.__walkAllChildNodes(src, proglisting)
else:
paraName = 'para'
- if role != None:
- if role == 'note':
- paraName = 'note'
- elif role == 'warning':
- paraName = 'caution'
- elif role == 'tip':
- paraName = 'tip'
+ if role == 'note':
+ paraName = 'note'
+ elif role == 'warning':
+ paraName = 'caution'
+ elif role == 'tip':
+ paraName = 'tip'
para = dest.appendElement(paraName)
self.__walkAllChildNodes(src, para)
elif src.name == 'emph':
dest.appendElement('emphasis').appendContent(src.getContent())
- 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. Same with
- # the variable elements.
+ elif src.name == 'section':
+ if src.getAttr('id') == 'howtoget':
+ elem = dest.appendElement('tip')
+ elem.appendElement('title').appendContent('To access this command...')
+ self.__walkAllChildNodes(src, elem)
+ else:
+ self.__walkAllChildNodes(src, dest)
+
+ elif src.name == 'variable':
self.__walkAllChildNodes(src, dest)
elif src.name == 'table':
@@ -296,6 +314,30 @@ class DocBookConverter:
# and start a new one at the same level.
if dest.name == 'para':
dest = dest.parent.appendElement('para')
+
+ elif src.name == 'bookmark':
+ # For now, I ignore the 'contents' branch.
+ branch = src.getAttr('branch')
+ if branch == None:
+ branch = ''
+
+ if branch == 'index':
+ values = src.getChildByName('bookmark_value')
+ for value in values:
+ indexterm = dest.appendElement('indexterm')
+ strlist = value.getContent().split(';')
+ for i in xrange(0, len(strlist)):
+ s = strlist[i].strip()
+ if i == 0:
+ indexterm.appendElement('primary').appendContent(s)
+ elif i == 1:
+ indexterm.appendElement('secondary').appendContent(s)
+ elif i == 2:
+ indexterm.appendElement('tertiary').appendContent(s)
+ elif branch.startswith('hid/'):
+ hid = branch[4:]
+ dest.appendElement('anchor').setAttr('id', hid)
+
else:
# unhandled element. My work is done when these elements go away.
dest.appendElement('warning').appendContent("unhandled element '%s'"%src.name)
diff --git a/source/node.py b/source/node.py
index 2feb0a3..e14f894 100644
--- a/source/node.py
+++ b/source/node.py
@@ -87,6 +87,9 @@ class Element(NodeBase):
def setAttr (self, name, val):
self.attrs[name] = val
+ def hasAttr (self, name):
+ return self.attrs.has_key(name)
+
encodeTable = {
'>': 'gt',
'<': 'lt',