- $this->isTopLevel = $isTopLevel;
- $this->contents = $isTopLevel ? [$section] : [...$section->childNodes];
+ $contents = $isTopLevel ? [$section] : [...$section->childNodes];
+ return new self($contents, !$isTopLevel);
+ }
+
+ public static function fromInlineHtml(string $html): self
+ {
+ if (empty($html)) {
+ return new self([], true);
+ }
+
+ $doc = new HtmlDocument($html);
+
+ return new self([...$doc->getBodyChildren()], true);