summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-01-19 21:46:48 (GMT)
committerFred Drake <fdrake@acm.org>1999-01-19 21:46:48 (GMT)
commit2664db9f763568dee0f53426ab9885ea3c624395 (patch)
tree471855320231855519965edc280895b8050d55cd /Doc
parenta7998f650a0c674b475be7bba71a5bdb0aa95b77 (diff)
downloadcpython-2664db9f763568dee0f53426ab9885ea3c624395.zip
cpython-2664db9f763568dee0f53426ab9885ea3c624395.tar.gz
cpython-2664db9f763568dee0f53426ab9885ea3c624395.tar.bz2
handle_labels(): Fix problem for document fragments containing more
than one "root" that prevented all the <label id=...> items from being promoted to id attributes on the enclosing chapter/ section/... properly.
Diffstat (limited to 'Doc')
-rwxr-xr-xDoc/tools/sgmlconv/docfixer.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/Doc/tools/sgmlconv/docfixer.py b/Doc/tools/sgmlconv/docfixer.py
index 2aa7284..985195f 100755
--- a/Doc/tools/sgmlconv/docfixer.py
+++ b/Doc/tools/sgmlconv/docfixer.py
@@ -165,18 +165,20 @@ def handle_appendix(doc):
def handle_labels(doc):
- labels = doc.getElementsByTagName("label")
- for label in labels:
- id = label.getAttribute("id")
- if not id:
- continue
- parent = label.parentNode
- if parent.tagName == "title":
- parent.parentNode.setAttribute("id", id)
- else:
- parent.setAttribute("id", id)
- # now, remove <label id="..."/> from parent:
- parent.removeChild(label)
+ for node in doc.childNodes:
+ if node.nodeType == xml.dom.core.ELEMENT:
+ labels = node.getElementsByTagName("label")
+ for label in labels:
+ id = label.getAttribute("id")
+ if not id:
+ continue
+ parent = label.parentNode
+ if parent.tagName == "title":
+ parent.parentNode.setAttribute("id", id)
+ else:
+ parent.setAttribute("id", id)
+ # now, remove <label id="..."/> from parent:
+ parent.removeChild(label)
def fixup_trailing_whitespace(doc, wsmap):