Skip to content

Commit

Permalink
Merge pull request #22 from cidilabs/scottcooper/UDOIT3-880-SSML-erro…
Browse files Browse the repository at this point in the history
…r-on-creation

remove getting errors from DomDocument and restructure formatting of DomDocument
  • Loading branch information
cidilabs authored Feb 27, 2023
2 parents ca715b9 + 338e5a4 commit 622a9ca
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/SsmlCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ class SsmlCreator

public function buildSsmlText($text)
{
$preCleanedHtml = $this->cleanUpBeforeDomDoc($text);
$strippedHtml = $this->stripHTML($preCleanedHtml);
$strippedHtml = $this->stripHTML($text);
$html = new DOMDocument();
libxml_use_internal_errors(true);
$html->loadHTML($strippedHtml);
$data['errors'] = libxml_get_errors();

// remove doctype
$html->removeChild($html->doctype);
$html = $this->cleanUpDomDoc($html);
// $data['errors'] = libxml_get_errors();

$html = $this->setupBaseSSML($html);

Expand Down Expand Up @@ -262,11 +259,7 @@ private function changeTagName( $node, $name ) {

}

private function cleanUpBeforeDomDoc($html) {

$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($html);
private function cleanUpDomDoc($dom) {

// remove doctype
$dom->removeChild($dom->doctype);
Expand All @@ -278,7 +271,7 @@ private function cleanUpBeforeDomDoc($html) {
$head->parentNode->removeChild($head);
}

return $dom->saveHTML();
return $dom;
}

}

0 comments on commit 622a9ca

Please sign in to comment.