I understand that headers shouldn't be a part of paragraph, but still it should be more explicit in context of code bellow.
If Element is replaced with div or null everything is perfect
Sorry for Kotlin, hope it still readable.
val bareFragment = "<h2> text </h2>"
Document("").parser().parseFragmentInput(bareFragment, Element("p"), "")
output:
java.lang.NullPointerException
at org.jsoup.parser.HtmlTreeBuilderState$7.inBodyStartTag(HtmlTreeBuilderState.java:545)
at org.jsoup.parser.HtmlTreeBuilderState$7.process(HtmlTreeBuilderState.java:286)
at org.jsoup.parser.HtmlTreeBuilder.process(HtmlTreeBuilder.java:149)
at org.jsoup.parser.TreeBuilder.runParser(TreeBuilder.java:76)
at org.jsoup.parser.HtmlTreeBuilder.parseFragment(HtmlTreeBuilder.java:133)
at org.jsoup.parser.Parser.parseFragmentInput(Parser.java:53)
I understand that headers shouldn't be a part of paragraph, but still it should be more explicit in context of code bellow.
If Element is replaced with
divornulleverything is perfectSorry for Kotlin, hope it still readable.
output: