/**
  * Apply Wikitext rewrites.
  *
  * @param AbstractRevision $revision Input we want to transfer into Markdown
  *
  * @return AbstractRevision
  */
 public function apply(AbstractRevision $revision)
 {
     if ($revision instanceof MediaWikiRevision) {
         try {
             $content = $this->getPageFromApi($revision->getTitle());
         } catch (Exception $e) {
             $title = $revision->getTitle();
             $url = $this->apiUrl . urlencode($title);
             $message = sprintf('Could not get data from API for %s with the following URI %s', $title, $url);
             throw new Exception($message, 0, $e);
         }
         $front_matter = [];
         $rev_matter = $revision->getFrontMatterData();
         $newRev = new MarkdownRevision($content, array_merge($rev_matter, $front_matter));
         return $newRev->setTitle($revision->getTitle());
     }
     return $revision;
 }
 /**
  * Apply Wikitext rewrites.
  *
  * @param AbstractRevision $revision Input we want to transfer into Markdown
  *
  * @return AbstractRevision
  */
 public function apply(AbstractRevision $revision)
 {
     throw new \Exception('This is a Stub class. Please adapt before using');
     if ($revision instanceof MediaWikiRevision) {
         $content = $this->filter($revision->getContent());
         // Should we make a loop for that?
         $content = preg_replace_callback('/\\[([^\\[\\]\\|\\n\': ]+)\\]/', 'self::helperExternlinks', $content);
         $content = preg_replace_callback('/\\[?\\[([^\\[\\]\\|\\n\' ]+)[\\| ]([^\\]\']+)\\]\\]?/', 'self::helperExternlinks', $content);
         $front_matter = array();
         if (empty(trim($content))) {
             $front_matter['is_stub'] = 'true';
             $content = PHP_EOL;
             // Let’s redefine at only one line instead of using a filter.
         }
         $rev_matter = $revision->getFrontMatterData();
         $newRev = new MarkdownRevision($content, array_merge($rev_matter, $front_matter));
         return $newRev->setTitle($revision->getTitle());
     }
     return $revision;
 }