@@ -236,18 +236,12 @@ def rewrite_descriptor(doc, descriptor):
236236 pos = skip_leading_nodes (children )
237237 if pos < len (children ):
238238 child = children [pos ]
239- if child .get_nodeName () == "args" :
240- ## bwrite("found <args> in descriptor, moving to <signature>\n")
241- ## ewrite(descriptor.toxml() + "\n---\n")
242- # create an <args> in <signature>:
243- args = doc .createElement ("args" )
244- argchildren = []
245- map (argchildren .append , child .childNodes )
246- for n in argchildren :
247- child .removeChild (n )
248- args .appendChild (n )
249- signature .appendChild (doc .createTextNode ("\n " ))
250- signature .appendChild (args )
239+ if child .nodeName == "args" :
240+ # move <args> to <signature>, or remove if empty:
241+ child .parentNode .removeChild (child )
242+ if len (child .childNodes ):
243+ signature .appendChild (doc .createTextNode ("\n " ))
244+ signature .appendChild (child )
251245 signature .appendChild (doc .createTextNode ("\n " ))
252246 # 3, 4.
253247 pos = skip_leading_nodes (children , pos )
@@ -907,6 +901,32 @@ def fixup_bifuncindexes_chunk(container):
907901 container .removeChild (entry )
908902
909903
904+ def join_adjacent_elements (container , gi ):
905+ queue = [container ]
906+ while queue :
907+ parent = queue .pop ()
908+ i = 0
909+ children = parent .get_childNodes ()
910+ nchildren = len (children )
911+ while i < (nchildren - 1 ):
912+ child = children [i ]
913+ if child .nodeName == gi :
914+ if children [i + 1 ].nodeName == gi :
915+ ewrite ("--- merging two <%s/> elements\n " % gi )
916+ child = children [i ]
917+ nextchild = children [i + 1 ]
918+ nextchildren = nextchild .get_childNodes ()
919+ while len (nextchildren ):
920+ node = nextchildren [0 ]
921+ nextchild .removeChild (node )
922+ child .appendChild (node )
923+ parent .removeChild (nextchild )
924+ continue
925+ if child .nodeType == ELEMENT :
926+ queue .append (child )
927+ i = i + 1
928+
929+
910930_token_rx = re .compile (r"[a-zA-Z][a-zA-Z0-9.-]*$" )
911931
912932def write_esis (doc , ofp , knownempty ):
@@ -970,6 +990,9 @@ def convert(ifp, ofp):
970990 add_node_ids (fragment )
971991 fixup_refmodindexes (fragment )
972992 fixup_bifuncindexes (fragment )
993+ # Take care of ugly hacks in the LaTeX markup to avoid LaTeX and
994+ # LaTeX2HTML screwing with GNU-style long options (the '--' problem).
995+ join_adjacent_elements (fragment , "option" )
973996 #
974997 d = {}
975998 for gi in p .get_empties ():
0 commit comments