summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-01-17 18:41:11 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-01-17 18:41:11 -0500
commit533ecde7c2f7a66ec7a5c938fc7b8bfc4ed8fed8 (patch)
tree27b29bf21721d0ed9298fd5829097a61bafdf3a7 /source
parent2f869ddec7a47460494768e7729719c0e79beb60 (diff)
More work on getting the links working.
Diffstat (limited to 'source')
-rw-r--r--source/docbook.py29
-rw-r--r--source/globals.py2
2 files changed, 27 insertions, 4 deletions
diff --git a/source/docbook.py b/source/docbook.py
index 3c80618..2653dcb 100644
--- a/source/docbook.py
+++ b/source/docbook.py
@@ -203,7 +203,9 @@ class DocBookConverter:
dest = self.__walkXHP(child, dest)
def __walkTable (self, src, dest):
- tgrp = dest.appendElement('informaltable').appendElement('tgroup')
+ table = dest.appendElement('informaltable')
+ self.__maybeAddElementID(src, table)
+ tgrp = table.appendElement('tgroup')
# <tgroup> element needs 'cols' attribute to specify column size.
tbody = tgrp.appendElement('tbody')
totalColSize = 0
@@ -235,6 +237,22 @@ class DocBookConverter:
tgrp.setAttr('cols', totalColSize)
+ def __maybeAddElementID (self, src, dest):
+ if dest == None:
+ return
+
+ if self.__currentFileName == None:
+ return
+
+ id = src.getAttr('id')
+ if id == None:
+ return
+
+ idstr = globals.encodeID(self.__currentFileName + "_" + id)
+ if dest.hasAttr('id'):
+ dest.appendElement('anchor').setAttr('id', idstr)
+ else:
+ dest.setAttr('id', idstr)
def __walkXHP (self, src, dest):
@@ -243,11 +261,13 @@ class DocBookConverter:
content = src.content
if len(content.strip()) > 0:
dest.appendContent(content)
+ return dest
elif DocBookConverter.elemIgnored.has_key(src.name):
# we can ignore these elements.
- pass
- elif src.name == 'embed' or src.name == 'embedvar':
+ return dest
+
+ if src.name == 'embed' or src.name == 'embedvar':
# embed takes its content from another xhp file.
href = src.getAttr('href')
embed = self.__getEmbedNode(href)
@@ -347,6 +367,7 @@ class DocBookConverter:
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
@@ -371,8 +392,10 @@ class DocBookConverter:
if src.getAttr('id') == 'howtoget':
elem = dest.appendElement('tip')
elem.appendElement('title').appendContent('To access this command...')
+ self.__maybeAddElementID(src, elem)
self.__walkAllChildNodes(src, elem)
else:
+ self.__maybeAddElementID(src, dest)
self.__walkAllChildNodes(src, dest)
elif src.name == 'variable':
diff --git a/source/globals.py b/source/globals.py
index ec7168c..a4bdd3e 100644
--- a/source/globals.py
+++ b/source/globals.py
@@ -12,7 +12,7 @@ class Exception:
self.msg = msg
def encodeID (orig):
- return orig.replace('/', '_').replace('.', '_')
+ return orig.replace('/', '_').replace('.', '_').replace('#', '_')
# global parameters
productName = 'OpenOffice.org'