···201201 while len(entries) > 1:
202202 entries[-2][1].children.append(entries.pop()[1])
203203 return (entries[0][1], examples, figures)
204204+205205+_xml_id_translate_table = {
206206+ ord('*'): ord('_'),
207207+ ord('<'): ord('_'),
208208+ ord(' '): ord('_'),
209209+ ord('>'): ord('_'),
210210+ ord('['): ord('_'),
211211+ ord(']'): ord('_'),
212212+ ord(':'): ord('_'),
213213+ ord('"'): ord('_'),
214214+}
215215+# this function is needed to generate option id attributes in the same format as
216216+# the docbook toolchain did to not break existing links. we don't actually use
217217+# xml any more, that's just the legacy we're dealing with and part of our structure
218218+# now.
219219+def make_xml_id(s: str) -> str:
220220+ return s.translate(_xml_id_translate_table)