• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/tidy-15.15/tidy/src/

Lines Matching +refs:xml +refs:node +refs:attributes

62 static Node* CleanNode( TidyDocImpl* doc, Node *node );
64 static void RenameElem( Node* node, TidyTagId tid )
67 MemFree( node->element );
68 node->element = TY_(tmbstrdup)( dict->name );
69 node->tag = dict;
322 Add class="foo" to node
324 static void AddClass( TidyDocImpl* doc, Node* node, ctmbstr classname )
326 AttVal *classattr = TY_(AttrGetById)(node, TidyAttr_CLASS);;
335 TY_(AddAttribute)( doc, node, "class", classname );
338 void TY_(AddStyleAsClass)( TidyDocImpl* doc, Node *node, ctmbstr stylevalue )
342 classname = FindStyle( doc, node->element, stylevalue );
343 AddClass( doc, node, classname);
347 Find style attribute in node, and replace it
352 Assumes that node doesn't have a class attribute
354 static void Style2Rule( TidyDocImpl* doc, Node *node)
359 styleattr = TY_(AttrGetById)(node, TidyAttr_STYLE);
366 TY_(RemoveAttribute)(doc, node, styleattr);
370 classname = FindStyle( doc, node->element, styleattr->value );
371 classattr = TY_(AttrGetById)(node, TidyAttr_CLASS);
380 TY_(RemoveAttribute)( doc, node, styleattr );
491 Node* node = TY_(FindBody)(doc);
492 if (node)
494 if (TY_(AttrGetById)(node, TidyAttr_BACKGROUND) ||
495 TY_(AttrGetById)(node, TidyAttr_BGCOLOR) ||
496 TY_(AttrGetById)(node, TidyAttr_TEXT) ||
497 TY_(AttrGetById)(node, TidyAttr_LINK) ||
498 TY_(AttrGetById)(node, TidyAttr_VLINK) ||
499 TY_(AttrGetById)(node, TidyAttr_ALINK))
513 Node *node, *head, *body;
520 node = TY_(NewNode)( lexer );
521 node->type = StartTag;
522 node->implicit = yes;
523 node->element = TY_(tmbstrdup)("style");
524 TY_(FindTag)( doc, node );
528 TY_(InsertAttributeAtStart)( node, av );
550 TY_(InsertNodeAtEnd)( node, TY_(TextToken)(lexer) );
555 doc is root node. search its children for html node
556 the head node should be first child of html node
559 TY_(InsertNodeAtEnd)( head, node );
564 void TY_(FixNodeLinks)(Node *node)
568 if (node->prev)
569 node->prev->next = node;
571 node->parent->content = node;
573 if (node->next)
574 node->next->prev = node;
576 node->parent->last = node;
578 for (child = node->content; child; child = child->next)
579 child->parent = node;
583 used to strip child of node when
584 the node has one and only one child
586 static void StripOnlyChild(TidyDocImpl* doc, Node *node)
590 child = node->content;
591 node->content = child->content;
592 node->last = child->last;
596 for (child = node->content; child; child = child->next)
597 child->parent = node;
608 Node *node, *parent = element->parent;
627 for (node = element->content; node; node = node->next)
628 node->parent = parent;
666 void TY_(AddStyleProperty)(TidyDocImpl* doc, Node *node, ctmbstr property )
668 AttVal *av = TY_(AttrGetById)(node, TidyAttr_STYLE);
688 TY_(InsertAttributeAtStart)( node, av );
692 static void MergeClasses(TidyDocImpl* doc, Node *node, Node *child)
697 for (s2 = NULL, av = child->attributes; av; av = av->next)
706 for (s1 = NULL, av = node->attributes; av; av = av->next)
733 TY_(InsertAttributeAtStart)( node, av );
737 static void MergeStyles(TidyDocImpl* doc, Node *node, Node *child)
745 needs to be copied to node's class
747 MergeClasses(doc, node, child);
749 for (s2 = NULL, av = child->attributes; av; av = av->next)
758 for (s1 = NULL, av = node->attributes; av; av = av->next)
779 TY_(InsertAttributeAtStart)( node, av );
833 static void AddFontFace( TidyDocImpl* doc, Node *node, ctmbstr face )
837 TY_(AddStyleProperty)( doc, node, buf );
840 static void AddFontSize( TidyDocImpl* doc, Node* node, ctmbstr size )
844 if (nodeIsP(node))
855 MemFree(node->element);
856 node->element = TY_(tmbstrdup)(value);
857 TY_(FindTag)(doc, node);
868 TY_(AddStyleProperty)( doc, node, buf );
872 static void AddFontColor( TidyDocImpl* doc, Node *node, ctmbstr color)
876 TY_(AddStyleProperty)( doc, node, buf );
880 static void AddAlign( TidyDocImpl* doc, Node *node, ctmbstr align )
892 TY_(AddStyleProperty)( doc, node, buf );
896 add style properties to node corresponding to
897 the font face, size and color attributes
899 static void AddFontStyles( TidyDocImpl* doc, Node *node, AttVal *av)
906 AddFontFace( doc, node, av->value );
908 AddFontSize( doc, node, av->value );
910 AddFontColor( doc, node, av->value );
920 static void TextAlign( TidyDocImpl* doc, Node* node )
926 for (av = node->attributes; av; av = av->next)
933 node->attributes = av->next;
936 AddAlign( doc, node, av->value );
948 next node when the original node has been deleted
956 static Bool Dir2Div( TidyDocImpl* doc, Node *node, Node **ARG_UNUSED(pnode))
960 if ( nodeIsDIR(node) || nodeIsUL(node) || nodeIsOL(node) )
962 child = node->content;
979 node->tag = TY_(LookupTagDef)( TidyTag_DIV );
980 MemFree( node->element );
981 node->element = TY_(tmbstrdup)("div");
982 TY_(AddStyleProperty)( doc, node, "margin-left: 2em" );
983 StripOnlyChild( doc, node );
995 static Bool Center2Div( TidyDocImpl* doc, Node *node, Node **pnode)
997 if ( nodeIsCENTER(node) )
1001 if (node->content)
1003 Node *last = node->last;
1004 DiscardContainer( doc, node, pnode );
1006 node = TY_(InferredTag)(doc, TidyTag_BR);
1007 TY_(InsertNodeAfterElement)(last, node);
1011 Node *prev = node->prev, *next = node->next,
1012 *parent = node->parent;
1013 DiscardContainer( doc, node, pnode );
1015 node = TY_(InferredTag)(doc, TidyTag_BR);
1017 TY_(InsertNodeBeforeElement)(next, node);
1019 TY_(InsertNodeAfterElement)(prev, node);
1021 TY_(InsertNodeAtStart)(parent, node);
1027 RenameElem( node, TidyTag_DIV );
1028 TY_(AddStyleProperty)( doc, node, "text-align: center" );
1035 /* Copy child attributes to node. Duplicate attributes are overwritten.
1036 Unique attributes (such as ID) disable the action.
1040 static Bool CopyAttrs( TidyDocImpl* doc, Node *node, Node *child)
1045 /* Detect attributes that cannot be merged or overwritten. */
1047 && TY_(AttrGetById)(node, TidyAttr_ID) != NULL)
1050 /* Move child attributes to node. Attributes in node
1052 for (av2 = child->attributes; av2; )
1060 /* Avoid duplicates in node */
1062 && (av1=TY_(AttrGetById)(node, id))!= NULL)
1063 TY_(RemoveAttribute)( doc, node, av1 );
1065 /* Move attribute from child to node */
1070 TY_(InsertAttributeAtEnd)( node, av1 );
1085 attributes are merged using MergeStyles().
1087 Style and Class attributes are merged using MergeStyles().
1090 TidyTagId Id, TidyTriState state, Node *node,
1096 || !TagIsId(node, Id) )
1099 child = node->content;
1107 && CopyAttrs(doc, node, child) == no )
1110 MergeStyles( doc, node, child );
1111 StripOnlyChild( doc, node );
1120 static Bool NestedList( TidyDocImpl* doc, Node *node, Node **pnode )
1124 if ( nodeIsUL(node) || nodeIsOL(node) )
1126 child = node->content;
1141 if (list->tag != node->tag)
1148 *pnode = list; /* Set node to resume iteration */
1150 /* move inner list node into position of outer node */
1151 list->prev = node->prev;
1152 list->next = node->next;
1153 list->parent = node->parent;
1160 node->content = NULL;
1161 node->next = NULL;
1162 TY_(FreeNode)( doc, node );
1163 node = NULL;
1166 If prev node was a list the chances are this node
1176 node = list;
1177 list = node->prev;
1181 list->next = node->next;
1184 node->parent = child;
1185 node->next = NULL;
1186 node->prev = child->last;
1187 TY_(FixNodeLinks)(node);
1188 CleanNode( doc, node );
1202 static Bool CanApplyBlockStyle( Node *node )
1204 if (node->tag->model & (CM_BLOCK | CM_LIST | CM_DEFLIST | CM_TABLE)
1205 && !nodeIsTABLE(node) && !nodeIsTR(node) && !nodeIsLI(node) )
1235 static Bool BlockStyle( TidyDocImpl* doc, Node *node, Node **ARG_UNUSED(pnode) )
1239 if (CanApplyBlockStyle(node))
1242 if ( !nodeIsCAPTION(node) )
1243 TextAlign( doc, node );
1245 child = node->content;
1255 MergeStyles( doc, node, child );
1256 TY_(AddStyleProperty)( doc, node, "font-weight: bold" );
1257 StripOnlyChild( doc, node );
1263 MergeStyles( doc, node, child );
1264 TY_(AddStyleProperty)( doc, node, "font-style: italic" );
1265 StripOnlyChild( doc, node );
1271 MergeStyles( doc, node, child );
1272 AddFontStyles( doc, node, child->attributes );
1273 StripOnlyChild( doc, node );
1282 static Bool InlineStyle( TidyDocImpl* doc, Node *node, Node **ARG_UNUSED(pnode) )
1286 if ( !nodeIsFONT(node) && TY_(nodeHasCM)(node, CM_INLINE|CM_ROW) )
1288 child = node->content;
1300 MergeStyles( doc, node, child );
1301 TY_(AddStyleProperty)( doc, node, "font-weight: bold" );
1302 StripOnlyChild( doc, node );
1308 MergeStyles( doc, node, child );
1309 TY_(AddStyleProperty)( doc, node, "font-style: italic" );
1310 StripOnlyChild( doc, node );
1316 MergeStyles( doc, node, child );
1317 AddFontStyles( doc, node, child->attributes );
1318 StripOnlyChild( doc, node );
1328 the font element's attributes and replacing them
1331 static Bool Font2Span( TidyDocImpl* doc, Node *node, Node **pnode )
1335 if ( nodeIsFONT(node) )
1339 DiscardContainer( doc, node, pnode );
1345 if ( node->parent->content == node && node->next == NULL &&
1346 CanApplyBlockStyle(node->parent) )
1349 AddFontStyles( doc, node, node->attributes );
1352 av = node->attributes;
1371 node->attributes = style;
1372 RenameElem( node, TidyTag_SPAN );
1380 Applies all matching rules to a node.
1382 Node* CleanNode( TidyDocImpl* doc, Node *node )
1387 for (next = node; TY_(nodeIsElement)(node); node = next)
1389 if ( Dir2Div(doc, node, &next) )
1393 ** that arg node and its parent no longer exist.
1395 ** call stack until we have a valid node reference.
1397 if ( NestedList(doc, node, &next) )
1400 if ( Center2Div(doc, node, &next) )
1403 if ( MergeNestedElements(doc, TidyTag_DIV, mergeDivs, node, &next) )
1406 if ( BlockStyle(doc, node, &next) )
1409 if ( InlineStyle(doc, node, &next) )
1412 if ( Font2Span(doc, node, &next) )
1421 /* Special case: if the current node is destroyed by
1422 ** CleanNode() lower in the tree, this node and its parent
1424 ** call stack until we have a valid node reference.
1427 static Node* CleanTree( TidyDocImpl* doc, Node *node )
1429 if (node->content)
1432 for (child = node->content; child != NULL; child = child->next)
1440 return CleanNode( doc, node );
1443 static void DefineStyleRules( TidyDocImpl* doc, Node *node )
1447 if (node->content)
1449 for (child = node->content;
1456 Style2Rule( doc, node );
1474 void TY_(NestedEmphasis)( TidyDocImpl* doc, Node* node )
1478 while (node)
1480 next = node->next;
1482 if ( (nodeIsB(node) || nodeIsI(node))
1483 && node->parent && node->parent->tag == node->tag)
1486 DiscardContainer( doc, node, &next );
1487 node = next;
1491 if ( node->content )
1492 TY_(NestedEmphasis)( doc, node->content );
1494 node = next;
1501 void TY_(EmFromI)( TidyDocImpl* doc, Node* node )
1503 while (node)
1505 if ( nodeIsI(node) )
1506 RenameElem( node, TidyTag_EM );
1507 else if ( nodeIsB(node) )
1508 RenameElem( node, TidyTag_STRONG );
1510 if ( node->content )
1511 TY_(EmFromI)( doc, node->content );
1513 node = node->next;
1517 static Bool HasOneChild(Node *node)
1519 return (node->content && node->content->next == NULL);
1529 void TY_(List2BQ)( TidyDocImpl* doc, Node* node )
1531 while (node)
1533 if (node->content)
1534 TY_(List2BQ)( doc, node->content );
1536 if ( node->tag && node->tag->parser == TY_(ParseList) &&
1537 HasOneChild(node) && node->content->implicit )
1539 StripOnlyChild( doc, node );
1540 RenameElem( node, TidyTag_BLOCKQUOTE );
1541 node->implicit = yes;
1544 node = node->next;
1554 void TY_(BQ2Div)( TidyDocImpl* doc, Node *node )
1559 while (node)
1561 if ( nodeIsBLOCKQUOTE(node) && node->implicit )
1565 while( HasOneChild(node) &&
1566 nodeIsBLOCKQUOTE(node->content) &&
1567 node->implicit)
1570 StripOnlyChild( doc, node );
1573 if (node->content)
1574 TY_(BQ2Div)( doc, node->content );
1579 RenameElem( node, TidyTag_DIV );
1580 TY_(AddStyleProperty)(doc, node, indent_buf );
1582 else if (node->content)
1583 TY_(BQ2Div)( doc, node->content );
1585 node = node->next;
1590 static Node* FindEnclosingCell( TidyDocImpl* ARG_UNUSED(doc), Node *node)
1594 for ( check=node; check; check = check->parent )
1602 /* node is <![if ...]> prune up to <![endif]> */
1603 static Node* PruneSection( TidyDocImpl* doc, Node *node )
1609 ctmbstr lexbuf = lexer->lexbuf + node->start;
1612 Node* cell = FindEnclosingCell( doc, node );
1619 TY_(InsertNodeBeforeElement)( node, nbsp );
1623 /* discard node and returns next */
1624 node = TY_(DiscardElement)( doc, node );
1626 if (node == NULL)
1629 if (node->type == SectionTag)
1631 if (TY_(tmbstrncmp)(lexer->lexbuf + node->start, "if", 2) == 0)
1633 node = PruneSection( doc, node );
1637 if (TY_(tmbstrncmp)(lexer->lexbuf + node->start, "endif", 5) == 0)
1639 node = TY_(DiscardElement)( doc, node );
1645 return node;
1648 void TY_(DropSections)( TidyDocImpl* doc, Node* node )
1651 while (node)
1653 if (node->type == SectionTag)
1656 if ((TY_(tmbstrncmp)(lexer->lexbuf + node->start, "if", 2) == 0) &&
1657 (TY_(tmbstrncmp)(lexer->lexbuf + node->start, "if !vml", 7) != 0)) /* #444394 - fix 13 Sep 01 */
1659 node = PruneSection( doc, node );
1664 node = TY_(DiscardElement)( doc, node );
1668 if (node->content)
1669 TY_(DropSections)( doc, node->content );
1671 node = node->next;
1675 static void PurgeWord2000Attributes( TidyDocImpl* ARG_UNUSED(doc), Node* node )
1679 for ( attr = node->attributes; attr; attr = next )
1699 (nodeIsTD(node) || nodeIsTR(node) || nodeIsTH(node)) ) ||
1705 node->attributes = next;
1717 Node *node, *prev = NULL, *content;
1732 node = content;
1734 TY_(RemoveNode)(node);
1735 TY_(InsertNodeBeforeElement)(span, node);
1736 prev = node;
1741 node = content;
1743 TY_(RemoveNode)(node);
1744 TY_(InsertNodeAfterElement)(prev, node);
1745 prev = node;
1751 node = span->next;
1754 return node;
1758 void TY_(NormalizeSpaces)(Lexer *lexer, Node *node)
1760 while ( node )
1762 if ( node->content )
1763 TY_(NormalizeSpaces)( lexer, node->content );
1765 if (TY_(nodeIsText)(node))
1768 tmbstr p = lexer->lexbuf + node->start;
1770 for (i = node->start; i < node->end; ++i)
1783 node->end = p - lexer->lexbuf;
1786 node = node->next;
1791 static Bool NoMargins(Node *node)
1793 AttVal *attval = TY_(AttrGetById)(node, TidyAttr_STYLE);
1810 static Bool SingleSpace( Lexer* lexer, Node* node )
1812 if ( node->content )
1814 node = node->content;
1816 if ( node->next != NULL )
1819 if ( node->type != TextNode )
1822 if ( (node->end - node->start) == 1 &&
1823 lexer->lexbuf[node->start] == ' ' )
1826 if ( (node->end - node->start) == 2 )
1829 TY_(GetUTF8)( lexer->lexbuf + node->start, &c );
1845 void TY_(CleanWord2000)( TidyDocImpl* doc, Node *node)
1851 while ( node )
1853 /* get rid of Word's xmlns attributes */
1854 if ( nodeIsHTML(node) )
1857 if ( !TY_(GetAttrByName)(node, "xmlns:o") &&
1861 TY_(FreeAttrs)( doc, node );
1867 if ( nodeIsP(node) )
1869 if (NoMargins(node))
1872 TY_(CoerceNode)(doc, node, TidyTag_PRE, no, yes);
1874 PurgeWord2000Attributes( doc, node );
1876 if (node->content)
1877 TY_(CleanWord2000)( doc, node->content );
1879 pre = node;
1880 node = node->next;
1884 while ( nodeIsP(node) && NoMargins(node) )
1886 next = node->next;
1887 TY_(RemoveNode)(node);
1889 TY_(InsertNodeAtEnd)(pre, node);
1890 StripSpan( doc, node );
1891 node = next;
1894 if (node == NULL)
1899 if (node->tag && (node->tag->model & CM_BLOCK)
1900 && SingleSpace(lexer, node))
1902 node = StripSpan( doc, node );
1906 if ( nodeIsSTYLE(node) || nodeIsMETA(node) ||
1907 node->type == CommentTag )
1909 node = TY_(DiscardElement)( doc, node );
1914 if ( nodeIsSPAN(node) || nodeIsFONT(node) )
1916 node = StripSpan( doc, node );
1920 if ( nodeIsLINK(node) )
1922 AttVal *attr = TY_(AttrGetById)(node, TidyAttr_REL);
1926 node = TY_(DiscardElement)( doc, node );
1932 if ( node->tag && TY_(tmbstrcmp)(node->tag->name,"o:p")==0)
1935 DiscardContainer( doc, node, &next );
1936 node = next;
1942 if ( node->content == NULL && nodeIsP(node) )
1945 Node *next = TY_(TrimEmptyElement)( doc, node );
1946 node = next;
1950 if ( nodeIsP(node) )
1954 attr = TY_(AttrGetById)(node, TidyAttr_CLASS);
1955 atrStyle = TY_(AttrGetById)(node, TidyAttr_STYLE);
1971 TY_(CoerceNode)(doc, node, TidyTag_LI, no, yes);
1977 TY_(InsertNodeBeforeElement)(node, list);
1980 PurgeWord2000Attributes( doc, node );
1982 if ( node->content )
1983 TY_(CleanWord2000)( doc, node->content );
1985 /* remove node and append to contents of list */
1986 TY_(RemoveNode)(node);
1987 TY_(InsertNodeAtEnd)(list, node);
1988 node = list;
1994 TY_(NormalizeSpaces)(lexer, node->content);
1999 TY_(InsertNodeBeforeElement)(node, list);
2002 /* remove node and append to contents of list */
2003 TY_(RemoveNode)(node);
2004 TY_(InsertNodeAtEnd)(list, node);
2005 StripSpan( doc, node );
2007 node = list->next;
2015 if (!node)
2018 /* strip out style and class attributes */
2019 if (TY_(nodeIsElement)(node))
2020 PurgeWord2000Attributes( doc, node );
2022 if (node->content)
2023 TY_(CleanWord2000)( doc, node->content );
2025 node = node->next;
2032 Node *node, *head;
2043 for (node = head->content; node; node = node->next)
2045 if ( !nodeIsMETA(node) )
2048 attval = TY_(AttrGetById)( node, TidyAttr_NAME );
2053 attval = TY_(AttrGetById)( node, TidyAttr_CONTENT );
2066 Node *node, *next, *head = NULL, *body = NULL;
2071 for ( node = html->content; node != NULL; node = node->next )
2073 if ( nodeIsHEAD(node) )
2074 head = node;
2076 if ( nodeIsBODY(node) )
2077 body = node;
2082 for (node = head->content; node != NULL; node = next)
2084 next = node->next;
2086 if ( nodeIsOBJECT(node) )
2091 for (child = node->content; child != NULL; child = child->next)
2094 if ( (TY_(nodeIsText)(child) && !TY_(IsBlank)(doc->lexer, node))
2104 TY_(RemoveNode)( node );
2105 TY_(InsertNodeAtStart)( body, node );
2126 /* The node may get trimmed, so save the next pointer, if any */
2140 if ( NULL == pNode->attributes && no == bBRDeleted )
2232 void TY_(DropComments)(TidyDocImpl* doc, Node* node)
2236 while (node)
2238 next = node->next;
2240 if (node->type == CommentTag)
2242 TY_(RemoveNode)(node);
2243 TY_(FreeNode)(doc, node);
2244 node = next;
2248 if (node->content)
2249 TY_(DropComments)(doc, node->content);
2251 node = next;
2255 void TY_(DropFontElements)(TidyDocImpl* doc, Node* node, Node **ARG_UNUSED(pnode))
2259 while (node)
2261 next = node->next;
2263 if (nodeIsFONT(node))
2265 DiscardContainer(doc, node, &next);
2266 node = next;
2270 if (node->content)
2271 TY_(DropFontElements)(doc, node->content, &next);
2273 node = next;
2277 void TY_(WbrToSpace)(TidyDocImpl* doc, Node* node)
2281 while (node)
2283 next = node->next;
2285 if (nodeIsWBR(node))
2289 TY_(InsertNodeAfterElement)(node, text);
2290 TY_(RemoveNode)(node);
2291 TY_(FreeNode)(doc, node);
2292 node = next;
2296 if (node->content)
2297 TY_(WbrToSpace)(doc, node->content);
2299 node = next;
2313 this to all node types and attribute values while
2338 void TY_(DowngradeTypography)(TidyDocImpl* doc, Node* node)
2343 while (node)
2345 next = node->next;
2347 if (TY_(nodeIsText)(node))
2350 tmbstr p = lexer->lexbuf + node->start;
2352 for (i = node->start; i < node->end; ++i)
2383 node->end = p - lexer->lexbuf;
2386 if (node->content)
2387 TY_(DowngradeTypography)(doc, node->content);
2389 node = next;
2393 void TY_(ReplacePreformattedSpaces)(TidyDocImpl* doc, Node* node)
2397 while (node)
2399 next = node->next;
2401 if (node->tag && node->tag->parser == TY_(ParsePre))
2403 TY_(NormalizeSpaces)(doc->lexer, node->content);
2404 node = next;
2408 if (node->content)
2409 TY_(ReplacePreformattedSpaces)(doc, node->content);
2411 node = next;
2415 void TY_(ConvertCDATANodes)(TidyDocImpl* doc, Node* node)
2419 while (node)
2421 next = node->next;
2423 if (node->type == CDATATag)
2424 node->type = TextNode;
2426 if (node->content)
2427 TY_(ConvertCDATANodes)(doc, node->content);
2429 node = next;
2435 the attributes for language information desired by the output
2437 'xml:lang' and 'lang' are desired, for XHTML 1.1 only 'xml:lang'
2440 void TY_(FixLanguageInformation)(TidyDocImpl* doc, Node* node, Bool wantXmlLang, Bool wantLang)
2444 while (node)
2446 next = node->next;
2450 if (TY_(nodeIsElement)(node))
2452 AttVal* lang = TY_(AttrGetById)(node, TidyAttr_LANG);
2453 AttVal* xmlLang = TY_(AttrGetById)(node, TidyAttr_XML_LANG);
2458 todo: check whether both attributes are in sync,
2466 if (TY_(NodeAttributeVersions)( node, TidyAttr_XML_LANG )
2468 TY_(RepairAttrValue)(doc, node, "xml:lang", lang->value);
2472 if (TY_(NodeAttributeVersions)( node, TidyAttr_LANG )
2474 TY_(RepairAttrValue)(doc, node, "lang", xmlLang->value);
2478 TY_(RemoveAttribute)(doc, node, lang);
2481 TY_(RemoveAttribute)(doc, node, xmlLang);
2484 if (node->content)
2485 TY_(FixLanguageInformation)(doc, node->content, wantXmlLang, wantLang);
2487 node = next;
2518 void TY_(FixAnchors)(TidyDocImpl* doc, Node *node, Bool wantName, Bool wantId)
2522 while (node)
2524 next = node->next;
2526 if (TY_(IsAnchorElement)(doc, node))
2528 AttVal *name = TY_(AttrGetById)(node, TidyAttr_NAME);
2529 AttVal *id = TY_(AttrGetById)(node, TidyAttr_ID);
2531 /* todo: how are empty name/id attributes handled? */
2540 TY_(ReportAttrError)( doc, node, name, ID_NAME_MISMATCH);
2544 if (TY_(NodeAttributeVersions)( node, TidyAttr_ID )
2549 TY_(RepairAttrValue)(doc, node, "id", name->value);
2553 TY_(ReportAttrError)(doc, node, name, INVALID_XML_ID);
2559 if (TY_(NodeAttributeVersions)( node, TidyAttr_NAME )
2562 TY_(RepairAttrValue)(doc, node, "name", id->value);
2566 TY_(RemoveAttribute)(doc, node, id);
2569 TY_(RemoveAttribute)(doc, node, name);
2571 if (TY_(AttrGetById)(node, TidyAttr_NAME) == NULL &&
2572 TY_(AttrGetById)(node, TidyAttr_ID) == NULL)
2573 TY_(RemoveAnchorByNode)(doc, node);
2576 if (node->content)
2577 TY_(FixAnchors)(doc, node->content, wantName, wantId);
2579 node = next;