if lang and '[' not in w:
w += "[%s]" % lang
entry.append(E.indexterm(E.primary(w)))
+ ids = {}
glossary = E.glossary()
for e in sorted(words, key=lambda x: langsort(lang, x)):
ldesc = 'desc-%s' % lang
if 'topic' in e and lang in topicmap:
e['topic'] = topicmap[lang][e['topic']]
if lang in e:
+ w = e[lang].split(',')
+ id = w[0] \
+ .replace('[', '_') \
+ .replace(']', '_') \
+ .replace('(', '_') \
+ .replace(')', '_') \
+ .replace('/', '_') \
+ .replace(' ', '_')
+ while id in ids:
+ id = id + 'x'
+ ids[id] = True
if ldesc not in e:
print("warning: %s missing %s description" % (e[lang], lang))
continue
- entry = E.glossentry()
+ entry = E.glossentry(id=id)
if list_topic and 'topic' in e:
entry.append(E.glossterm('%s [%s]' % (e[lang], e['topic'])))
else:
e[codestr]))))
glossary.append(entry)
- if False: # failed to set docbook glossary like xmlto and lint want it...
- glossary =\
- E.glossary(E.title("x"),
- E.glossdiv(E.title("y"),
- glossary))
-
+ # Add See also entries pointing to main entry
+ if 1 < len(w):
+ for t in w[1:]:
+ t = t.strip().lstrip()
+ entry = E.glossentry()
+ entry.append(E.glossterm(t))
+ # FIXME
+ entry.append(E.glosssee(otherterm=id))
+ glossary.append(entry)
+
+ def glosstermlocale(x):
+ # Look up glossterm (FIXME figure out more robust way)
+ t = x.getchildren()[0].text
+ if t:
+ return locale.strxfrm(t)
+ else:
+ return ""
+ # Sort list to mix seealso entries into their correct location.
+ glossary[:] = sorted(glossary, key=glosstermlocale)
+
content = lxml.etree.tostring(glossary,
pretty_print=True,
xml_declaration=True,