Kaydet (Commit) 645af9fe authored tarafından Fred Drake's avatar Fred Drake

rewrite_descriptor(): Fixup conversion of arguments (simpler).

join_adjacent_elements():  Hack to merge adjacent instances of
        <option>; the source \programopt with GNU-style long options
        created problems with LaTeX2HTML; this removes the evil
        workaround, which should never be necessary from structured
        documents(!).
üst 8a3b4495
...@@ -236,18 +236,12 @@ def rewrite_descriptor(doc, descriptor): ...@@ -236,18 +236,12 @@ def rewrite_descriptor(doc, descriptor):
pos = skip_leading_nodes(children) pos = skip_leading_nodes(children)
if pos < len(children): if pos < len(children):
child = children[pos] child = children[pos]
if child.get_nodeName() == "args": if child.nodeName == "args":
## bwrite("found <args> in descriptor, moving to <signature>\n") # move <args> to <signature>, or remove if empty:
## ewrite(descriptor.toxml() + "\n---\n") child.parentNode.removeChild(child)
# create an <args> in <signature>: if len(child.childNodes):
args = doc.createElement("args") signature.appendChild(doc.createTextNode("\n "))
argchildren = [] signature.appendChild(child)
map(argchildren.append, child.childNodes)
for n in argchildren:
child.removeChild(n)
args.appendChild(n)
signature.appendChild(doc.createTextNode("\n "))
signature.appendChild(args)
signature.appendChild(doc.createTextNode("\n ")) signature.appendChild(doc.createTextNode("\n "))
# 3, 4. # 3, 4.
pos = skip_leading_nodes(children, pos) pos = skip_leading_nodes(children, pos)
...@@ -907,6 +901,32 @@ def fixup_bifuncindexes_chunk(container): ...@@ -907,6 +901,32 @@ def fixup_bifuncindexes_chunk(container):
container.removeChild(entry) container.removeChild(entry)
def join_adjacent_elements(container, gi):
queue = [container]
while queue:
parent = queue.pop()
i = 0
children = parent.get_childNodes()
nchildren = len(children)
while i < (nchildren - 1):
child = children[i]
if child.nodeName == gi:
if children[i+1].nodeName == gi:
ewrite("--- merging two <%s/> elements\n" % gi)
child = children[i]
nextchild = children[i+1]
nextchildren = nextchild.get_childNodes()
while len(nextchildren):
node = nextchildren[0]
nextchild.removeChild(node)
child.appendChild(node)
parent.removeChild(nextchild)
continue
if child.nodeType == ELEMENT:
queue.append(child)
i = i + 1
_token_rx = re.compile(r"[a-zA-Z][a-zA-Z0-9.-]*$") _token_rx = re.compile(r"[a-zA-Z][a-zA-Z0-9.-]*$")
def write_esis(doc, ofp, knownempty): def write_esis(doc, ofp, knownempty):
...@@ -970,6 +990,9 @@ def convert(ifp, ofp): ...@@ -970,6 +990,9 @@ def convert(ifp, ofp):
add_node_ids(fragment) add_node_ids(fragment)
fixup_refmodindexes(fragment) fixup_refmodindexes(fragment)
fixup_bifuncindexes(fragment) fixup_bifuncindexes(fragment)
# Take care of ugly hacks in the LaTeX markup to avoid LaTeX and
# LaTeX2HTML screwing with GNU-style long options (the '--' problem).
join_adjacent_elements(fragment, "option")
# #
d = {} d = {}
for gi in p.get_empties(): for gi in p.get_empties():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment