public function convert($html) {
    if (preg_match('/^\s*$/u', $html)) {
      return '';
    }
    $html = '<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head>' . $html . '</body></html>';
    $this->dom = new \DOMDocument();
    if (!$this->dom->loadHTML($html)) {
      return NULL;
    }
    $xp = new \DOMXPath($this->dom);
    return implode(self::BLOCK_DELIMITER, $this->getBlocks(
      $xp->query('/html/body')->item(0)->childNodes
    ));
  }
public function convert($html) {
    if (preg_match('/^\s*$/u', $html)) {
      return '';
    }
    $html = '<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head>' . $html . '</body></html>';
    $this->dom = new \DOMDocument();
    if (!$this->dom->loadHTML($html)) {
      return NULL;
    }
    $xp = new \DOMXPath($this->dom);
    return implode(self::BLOCK_DELIMITER, $this->getBlocks(
      $xp->query('/html/body')->item(0)->childNodes
    ));
  }
public function convert ( $ html ) { if ( preg_match ( '/^\s*$/u' , $ html ) ) { return '' ; } $ html = '<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head>' . $ html . '</body></html>' ; $ this -> dom = new \ DOMDocument ( ) ; if ( ! $ this -> dom -> loadHTML ( $ html ) ) { return NULL ; } $ xp = new \ DOMXPath ( $ this -> dom ) ; return implode ( self :: BLOCK_DELIMITER , $ this -> getBlocks ( $ xp -> query ( '/html/body' ) -> item ( 0 ) -> childNodes ) ) ; }
Convert HTML to Apple News Markdown.

@param string $html
HTML to convert. Value is not validated, it is caller's responsibility
to validate.

@return string|NULL
Markdown representation of the HTML, or NULL if failed.
Convert HTML to Apple News Markdown .