original_string: public function init()
      {
          if (!isset($this->dom->documentElement)) {
              return false;
          }
  
          // Assume successful outcome
          $this->success = true;
          $bodyElems = $this->dom->getElementsByTagName('body');
  
          // WTF multiple body nodes?
          if (null === $this->bodyCache) {
              $this->bodyCache = '';
              foreach ($bodyElems as $bodyNode) {
                  $this->bodyCache .= trim($bodyNode->getInnerHTML());
              }
          }
  
          if ($bodyElems->length > 0 && null === $this->body) {
              $this->body = $bodyElems->item(0);
          }
  
          $this->prepDocument();
  
          // Build readability's DOM tree.
          $overlay = $this->dom->createElement('div');
          $innerDiv = $this->dom->createElement('div');
          $articleTitle = $this->getArticleTitle();
          $articleContent = $this->grabArticle();
  
          if (!$articleContent) {
              $this->success = false;
              $articleContent = $this->dom->createElement('div');
              $articleContent->setAttribute('class', 'readability-content');
              $articleContent->setInnerHtml('<p>Sorry, Readability was unable to parse this page for content.</p>');
          }
  
          $overlay->setAttribute('class', 'readOverlay');
          $innerDiv->setAttribute('class', 'readInner');
  
          // Glue the structure of our document together.
          $innerDiv->appendChild($articleTitle);
          $innerDiv->appendChild($articleContent);
          $overlay->appendChild($innerDiv);
  
          // Clear the old HTML, insert the new content.
          $this->body->setInnerHtml('');
          $this->body->appendChild($overlay);
          $this->body->removeAttribute('style');
          $this->postProcessContent($articleContent);
  
          // Set title and content instance variables.
          $this->articleTitle = $articleTitle;
          $this->articleContent = $articleContent;
  
          return $this->success;
      }
code: public function init()
      {
          if (!isset($this->dom->documentElement)) {
              return false;
          }
  
          // Assume successful outcome
          $this->success = true;
          $bodyElems = $this->dom->getElementsByTagName('body');
  
          // WTF multiple body nodes?
          if (null === $this->bodyCache) {
              $this->bodyCache = '';
              foreach ($bodyElems as $bodyNode) {
                  $this->bodyCache .= trim($bodyNode->getInnerHTML());
              }
          }
  
          if ($bodyElems->length > 0 && null === $this->body) {
              $this->body = $bodyElems->item(0);
          }
  
          $this->prepDocument();
  
          // Build readability's DOM tree.
          $overlay = $this->dom->createElement('div');
          $innerDiv = $this->dom->createElement('div');
          $articleTitle = $this->getArticleTitle();
          $articleContent = $this->grabArticle();
  
          if (!$articleContent) {
              $this->success = false;
              $articleContent = $this->dom->createElement('div');
              $articleContent->setAttribute('class', 'readability-content');
              $articleContent->setInnerHtml('<p>Sorry, Readability was unable to parse this page for content.</p>');
          }
  
          $overlay->setAttribute('class', 'readOverlay');
          $innerDiv->setAttribute('class', 'readInner');
  
          // Glue the structure of our document together.
          $innerDiv->appendChild($articleTitle);
          $innerDiv->appendChild($articleContent);
          $overlay->appendChild($innerDiv);
  
          // Clear the old HTML, insert the new content.
          $this->body->setInnerHtml('');
          $this->body->appendChild($overlay);
          $this->body->removeAttribute('style');
          $this->postProcessContent($articleContent);
  
          // Set title and content instance variables.
          $this->articleTitle = $articleTitle;
          $this->articleContent = $articleContent;
  
          return $this->success;
      }
code_tokens: public function init ( ) { if ( ! isset ( $ this -> dom -> documentElement ) ) { return false ; } // Assume successful outcome $ this -> success = true ; $ bodyElems = $ this -> dom -> getElementsByTagName ( 'body' ) ; // WTF multiple body nodes? if ( null === $ this -> bodyCache ) { $ this -> bodyCache = '' ; foreach ( $ bodyElems as $ bodyNode ) { $ this -> bodyCache .= trim ( $ bodyNode -> getInnerHTML ( ) ) ; } } if ( $ bodyElems -> length > 0 && null === $ this -> body ) { $ this -> body = $ bodyElems -> item ( 0 ) ; } $ this -> prepDocument ( ) ; // Build readability's DOM tree. $ overlay = $ this -> dom -> createElement ( 'div' ) ; $ innerDiv = $ this -> dom -> createElement ( 'div' ) ; $ articleTitle = $ this -> getArticleTitle ( ) ; $ articleContent = $ this -> grabArticle ( ) ; if ( ! $ articleContent ) { $ this -> success = false ; $ articleContent = $ this -> dom -> createElement ( 'div' ) ; $ articleContent -> setAttribute ( 'class' , 'readability-content' ) ; $ articleContent -> setInnerHtml ( '<p>Sorry, Readability was unable to parse this page for content.</p>' ) ; } $ overlay -> setAttribute ( 'class' , 'readOverlay' ) ; $ innerDiv -> setAttribute ( 'class' , 'readInner' ) ; // Glue the structure of our document together. $ innerDiv -> appendChild ( $ articleTitle ) ; $ innerDiv -> appendChild ( $ articleContent ) ; $ overlay -> appendChild ( $ innerDiv ) ; // Clear the old HTML, insert the new content. $ this -> body -> setInnerHtml ( '' ) ; $ this -> body -> appendChild ( $ overlay ) ; $ this -> body -> removeAttribute ( 'style' ) ; $ this -> postProcessContent ( $ articleContent ) ; // Set title and content instance variables. $ this -> articleTitle = $ articleTitle ; $ this -> articleContent = $ articleContent ; return $ this -> success ; }
docstring: Runs readability.
  
  Workflow:
  1. Prep the document by removing script tags, css, etc.
  2. Build readability's DOM tree.
  3. Grab the article content from the current dom tree.
  4. Replace the current DOM tree with the new one.
  5. Read peacefully.
  
  @return bool true if we found content, false otherwise
docstring_tokens: Runs readability .