private boolean isAllowedInLastOpenTag(BaseToken token, CleanTimeValues cleanTimeValues) { TagPos last = getOpenTags(cleanTimeValues).getLastTagPos(); if (last != null) { if (last.info != null) { return last.info.allowsItem(token); } } return true; }
/** * Checks if open fatal tag is missing if there is a fatal tag for * the specified tag. * @param tag */ private boolean isFatalTagSatisfied(TagInfo tag, CleanTimeValues cleanTimeValues) { if (tag != null) { String fatalTagName = tag.getFatalTag(); return fatalTagName == null ? true : getOpenTags(cleanTimeValues).tagExists(fatalTagName); } return true; }
private boolean isAllowedInLastOpenTag(BaseToken token, CleanTimeValues cleanTimeValues) { TagPos last = getOpenTags(cleanTimeValues).getLastTagPos(); if (last != null) { if (last.info != null) { return last.info.allowsItem(token); } } return true; }
private void saveToLastOpenTag(List nodeList, Object tokenToAdd, CleanTimeValues cleanTimeValues) { TagPos last = getOpenTags(cleanTimeValues).getLastTagPos(); if ( last != null && last.info != null && last.info.isIgnorePermitted() ) { return; } TagPos rubbishPos = getOpenTags(cleanTimeValues).findTagToPlaceRubbish(); if (rubbishPos != null) { TagNode startTagToken = (TagNode) nodeList.get(rubbishPos.position); startTagToken.addItemForMoving(tokenToAdd); } }
/** * Close all unclosed tags if there are any. */ private void closeAll(List nodeList, CleanTimeValues cleanTimeValues) { TagPos firstTagPos = getOpenTags(cleanTimeValues).findFirstTagPos(); for (TagPos pos : getOpenTags(cleanTimeValues).list) { properties.fireHtmlError(true, (TagNode)nodeList.get(pos.position), ErrorType.UnclosedTag); } if (firstTagPos != null) { closeSnippet(nodeList, firstTagPos, null, cleanTimeValues); } }
private void saveToLastOpenTag(List nodeList, Object tokenToAdd, CleanTimeValues cleanTimeValues) { TagPos last = getOpenTags(cleanTimeValues).getLastTagPos(); // // If we can simply ignore this token, then we remove it. // if (last != null && last.info != null && last.info.isIgnorePermitted()) { return; } // // Find an open tag where the token can live // TagPos rubbishPos = getOpenTags(cleanTimeValues).findTagToPlaceRubbish(); if (rubbishPos != null) { TagNode startTagToken = (TagNode) nodeList.get(rubbishPos.position); if (startTagToken != null) { startTagToken.addItemForMoving(tokenToAdd); return; } } }
/** * Close all unclosed tags if there are any. */ private void closeAll(List nodeList, CleanTimeValues cleanTimeValues) { TagPos firstTagPos = getOpenTags(cleanTimeValues).findFirstTagPos(); for (TagPos pos : getOpenTags(cleanTimeValues).list) { if (Thread.currentThread().isInterrupted()) { handleInterruption(); return; } properties.fireHtmlError(true, (TagNode) nodeList.get(pos.position), ErrorType.UnclosedTag); } if (firstTagPos != null) { closeSnippet(nodeList, firstTagPos, null, cleanTimeValues); } }
/** * Check if specified tag requires parent tag, but that parent * tag is missing in the appropriate context. * @param tag */ private boolean mustAddRequiredParent(TagInfo tag, CleanTimeValues cleanTimeValues) { if (tag != null) { String requiredParent = tag.getRequiredParent(); if (requiredParent != null) { String fatalTag = tag.getFatalTag(); int fatalTagPositon = -1; if (fatalTag != null) { TagPos tagPos = getOpenTags(cleanTimeValues).findTag(fatalTag); if (tagPos != null) { fatalTagPositon = tagPos.position; } } // iterates through the list of open tags from the end and check if there is some higher ListIterator it = getOpenTags(cleanTimeValues).list.listIterator( getOpenTags(cleanTimeValues).list.size() ); while ( it.hasPrevious() ) { TagPos currTagPos = (TagPos) it.previous(); if (tag.isHigher(currTagPos.name)) { return currTagPos.position <= fatalTagPositon; } } return true; } } return false; }
/** * Checks if open fatal tag is missing if there is a fatal tag for * the specified tag. * * @param tag */ private boolean isFatalTagSatisfied(TagInfo tag, CleanTimeValues cleanTimeValues) { boolean fatal = true; if (tag != null) { if (tag.getFatalTags().isEmpty()) return true; fatal = false; for (String fatalTagName : tag.getFatalTags()) { if (getOpenTags(cleanTimeValues).tagExists(fatalTagName)) { fatal = true; } } } return fatal; }
private void reopenBrokenNode(ListIterator<BaseToken> nodeIterator, TagNode toReopen, CleanTimeValues cleanTimeValues) { TagNode closedByPresidence = toReopen; TagNode copy = closedByPresidence.makeCopy(); copy.setAutoGenerated(true); copy.removeAttribute("id"); nodeIterator.add(copy); getOpenTags(cleanTimeValues).addTag(closedByPresidence.getName(), nodeIterator.previousIndex()); }
private void reopenBrokenNode(ListIterator<BaseToken> nodeIterator, TagNode toReopen, CleanTimeValues cleanTimeValues) { TagNode closedByPresidence = toReopen; TagNode copy = closedByPresidence.makeCopy(); copy.setAutoGenerated(true); copy.removeAttribute("id"); nodeIterator.add(copy); getOpenTags(cleanTimeValues).addTag(closedByPresidence.getName(), nodeIterator.previousIndex()); }
for (String fatalTag : tag.getFatalTags()) { if (fatalTag != null) { TagPos tagPos = getOpenTags(cleanTimeValues).findTag(fatalTag); if (tagPos != null) { fatalTagPosition = tagPos.position; for (String requiredTag : tag.getRequiredParentTags()) { if (requiredTag != null) { TagPos currTagPos = getOpenTags(cleanTimeValues).findTag(requiredTag); if (currTagPos != null) { requiredTagMissing = currTagPos.position <= fatalTagPosition; ListIterator it = getOpenTags(cleanTimeValues).list.listIterator(getOpenTags(cleanTimeValues).list.size()); while (it.hasPrevious()) { TagPos currTagPos = (TagPos) it.previous();
getOpenTags(cleanTimeValues).removeTag(newTagNode.getName()); tagNode = newTagNode; } else {
getOpenTags(cleanTimeValues).removeTag( newTagNode.getName() ); tagNode = newTagNode; } else {
TagPos matchingPosition = getOpenTags(cleanTimeValues).findTag(tagName); TagInfo tag = getTagInfo(tagName, cleanTimeValues); TagPos lastTagPos = getOpenTags(cleanTimeValues).isEmpty() ? null : getOpenTags(cleanTimeValues).getLastTagPos(); TagInfo lastTagInfo = lastTagPos == null ? null : getTagInfo(lastTagPos.name, cleanTimeValues); closeSnippet(nodeList, lastTagPos, startTagToken, cleanTimeValues); nodeIterator.previous(); } else if (tag != null && tag.hasPermittedTags() && getOpenTags(cleanTimeValues).someAlreadyOpen(tag.getPermittedTags())) { nodeIterator.set(null); } else if (tag != null && tag.isUnique() && getOpenTags(cleanTimeValues).tagEncountered(tagName)) { nodeIterator.set(null); properties.fireHtmlError(true, startTagToken, ErrorType.UniqueTagDuplicated); getOpenTags(cleanTimeValues).addTag(tagName, nodeIterator.previousIndex()); if (getOpenTags(cleanTimeValues).getLastTagPos() == null) { cleanTimeValues._headTags.add(new ProxyTagNode((CommentNode) token, cleanTimeValues.bodyNode));
} else { TagPos matchingPosition = getOpenTags(cleanTimeValues).findTag(tagName); TagInfo tag = getTagInfoProvider().getTagInfo(tagName); TagPos lastTagPos = getOpenTags(cleanTimeValues).isEmpty() ? null : getOpenTags(cleanTimeValues).getLastTagPos(); TagInfo lastTagInfo = lastTagPos == null ? null : getTagInfoProvider().getTagInfo(lastTagPos.name); closeSnippet(nodeList, lastTagPos, startTagToken, cleanTimeValues); nodeIterator.previous(); } else if ( tag != null && tag.hasPermittedTags() && getOpenTags(cleanTimeValues).someAlreadyOpen(tag.getPermittedTags()) ) { nodeIterator.set(null); } else if ( tag != null && tag.isUnique() && getOpenTags(cleanTimeValues).tagEncountered(tagName) ) { nodeIterator.set(null); properties.fireHtmlError(true, startTagToken, ErrorType.UniqueTagDuplicated); getOpenTags(cleanTimeValues).addTag( tagName, nodeIterator.previousIndex() ); if (getOpenTags(cleanTimeValues).getLastTagPos()==null) { cleanTimeValues._headTags.add(new ProxyTagNode((CommentNode)token, cleanTimeValues.bodyNode));