Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jhy committed Jul 9, 2021
1 parent 0a5a7ef commit f034561
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main/java/org/jsoup/parser/HtmlTreeBuilderState.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;

import javax.annotation.Nullable;
import java.util.ArrayList;

import static org.jsoup.internal.StringUtil.inSorted;
Expand Down Expand Up @@ -123,7 +124,7 @@ boolean process(Token t, HtmlTreeBuilder tb) {
if (name.equals("base") && el.hasAttr("href"))
tb.maybeSetBaseUri(el);
} else if (name.equals("meta")) {
Element meta = tb.insertEmpty(start);
tb.insertEmpty(start);
// todo: charset switches
} else if (name.equals("title")) {
handleRcData(start, tb);
Expand Down Expand Up @@ -842,7 +843,6 @@ else if (!tb.onStack(formatEl)) {
tb.replaceOnStack(node, replacement);
node = replacement;

//noinspection StatementWithEmptyBody
if (lastNode == furthestBlock) {
// move the aforementioned bookmark to be immediately after the new node in the list of active formatting elements.
// not getting how this bookmark both straddles the element above, but is inbetween here...
Expand All @@ -855,14 +855,16 @@ else if (!tb.onStack(formatEl)) {
lastNode = node;
}

if (inSorted(commonAncestor.normalName(), Constants.InBodyEndTableFosters)) {
if (lastNode.parent() != null)
lastNode.remove();
tb.insertInFosterParent(lastNode);
} else {
if (lastNode.parent() != null)
lastNode.remove();
commonAncestor.appendChild(lastNode);
if (commonAncestor != null) { // safety check, but would be an error if null
if (inSorted(commonAncestor.normalName(), Constants.InBodyEndTableFosters)) {
if (lastNode.parent() != null)
lastNode.remove();
tb.insertInFosterParent(lastNode);
} else {
if (lastNode.parent() != null)
lastNode.remove();
commonAncestor.appendChild(lastNode);
}
}

Element adopter = new Element(formatEl.tag(), tb.getBaseUri());
Expand Down

0 comments on commit f034561

Please sign in to comment.