You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, please see below a test program that tries to extract the text node range positions from the malformed fragment foo<p/>far. Notice the malformed tag <p/>.
import org.jsoup.nodes.*;
import org.jsoup.parser.*;
import org.jsoup.select.*;
public class Test {
public static void main(String[] args) {
HtmlTreeBuilder treeBuilder = new HtmlTreeBuilder();
Parser parser = new Parser(treeBuilder);
parser.setTrackPosition(true);
Document document = parser.parseInput("foo<p/>bar", "");
NodeTraversor.traverse((Node node, int depth) -> {
if (node instanceof TextNode textNode) {
Range sourceRange = textNode.sourceRange();
System.out.printf("text=%s start=%d end=%d%n",
textNode.text(),
sourceRange.start().pos(),
sourceRange.end().pos());
}
}, document);
}
}
Hello, please see below a test program that tries to extract the text node range positions from the malformed fragment
foo<p/>far
. Notice the malformed tag<p/>
.With release 1.16.1, all positions are negative:
With release 1.18.1, it's a little better, except for the
-1
start position for thebar
text immediately following the malformed tag.The text was updated successfully, but these errors were encountered: