MCPcopy Create free account
hub / github.com/Kitware/VTK / htmlAutoCloseOnClose

Function htmlAutoCloseOnClose

ThirdParty/libxml2/vtklibxml2/HTMLparser.c:1409–1444  ·  view source on GitHub ↗

* htmlAutoCloseOnClose: * @ctxt: an HTML parser context * @newtag: The new tag name * @force: force the tag closure * * The HTML DTD allows an ending tag to implicitly close other tags. */

Source from the content-addressed store, hash-verified

1407 * The HTML DTD allows an ending tag to implicitly close other tags.
1408 */
1409static void
1410htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag)
1411{
1412 const htmlElemDesc *info;
1413 int i, priority;
1414
1415 priority = htmlGetEndPriority(newtag);
1416
1417 for (i = (ctxt->nameNr - 1); i >= 0; i--) {
1418
1419 if (xmlStrEqual(newtag, ctxt->nameTab[i]))
1420 break;
1421 /*
1422 * A misplaced endtag can only close elements with lower
1423 * or equal priority, so if we find an element with higher
1424 * priority before we find an element with
1425 * matching name, we just ignore this endtag
1426 */
1427 if (htmlGetEndPriority(ctxt->nameTab[i]) > priority)
1428 return;
1429 }
1430 if (i < 0)
1431 return;
1432
1433 while (!xmlStrEqual(newtag, ctxt->name)) {
1434 info = htmlTagLookup(ctxt->name);
1435 if ((info != NULL) && (info->endTag == 3)) {
1436 htmlParseErr(ctxt, XML_ERR_TAG_NAME_MISMATCH,
1437 "Opening and ending tag mismatch: %s and %s\n",
1438 newtag, ctxt->name);
1439 }
1440 if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
1441 ctxt->sax->endElement(ctxt->userData, ctxt->name);
1442 htmlnamePop(ctxt);
1443 }
1444}
1445
1446/**
1447 * htmlAutoCloseOnEnd:

Callers 1

htmlParseEndTagFunction · 0.85

Calls 4

htmlGetEndPriorityFunction · 0.85
xmlStrEqualFunction · 0.85
htmlTagLookupFunction · 0.85
htmlnamePopFunction · 0.85

Tested by

no test coverage detected