Example #1
0
 /**
  * Converts page content:
  * - Yaml frontmatter to PHP array
  * - Markdown body to HTML.
  *
  * @param Page   $page
  * @param string $format
  *
  * @return Page
  */
 public function convertPage(Page $page, $format = 'yaml')
 {
     // converts frontmatter
     try {
         $variables = Converter::convertFrontmatter($page->getFrontmatter(), $format);
     } catch (Exception $e) {
         $message = sprintf("> Unable to convert frontmatter of '%s': %s", $page->getId(), $e->getMessage());
         call_user_func_array($this->phpoole->getMessageCb(), ['CONVERT_PROGRESS', $message]);
         return false;
     }
     $page->setVariables($variables);
     // converts body
     $html = Converter::convertBody($page->getBody());
     $page->setHtml($html);
     return $page;
 }