code: protected function wrapChildrenWithP(\DOMElement $parentEl, $lineNumbered)
      {
          $childNodes = [];
          while ($parentEl->childNodes->length > 0) {
              $el = $parentEl->firstChild;
              $parentEl->removeChild($el);
              $childNodes[] = $el;
          }
  
          $appendNode = null;
          foreach ($childNodes as $childNode) {
              if (in_array(strtolower($childNode->nodeName), ['p', 'list'])) {
                  if ($appendNode) {
                      $parentEl->appendChild($appendNode);
                      $appendNode = null;
                  }
                  $parentEl->appendChild($childNode);
              } else {
                  if (!$appendNode) {
                      $appendNode = $this->getNextNodeTemplate($lineNumbered);
                  }
                  $appendNode->appendChild($childNode);
              }
          }
          if ($appendNode) {
              $parentEl->appendChild($appendNode);
          }
  
          return $parentEl;
      }
docs: Wraps all child nodes with text:p nodes, if necessary
  (it's not necessary for child nodes that are p's themselves or lists)
  
  @param \DOMElement $parentEl
  @param boolean $lineNumbered
  
  @return \DOMElement