/** * Performs some pre-processing on the input text * and pass it through the document gamut. * * @param \MarkdownExtended\Content $content * * @return \MarkdownExtended\Content */ public function parse(Content $content) { $this->_setup(); $text = $content->getSource(); // first run transform gamut methods $text = $this->runGamuts('transform_gamut', $text); // then run document gamut methods $text = $this->runGamuts('document_gamut', $text); $content->setBody($text . "\n"); $this->_teardown(); return $content; }
/** * Transforms a source file * * @param string $path * @param bool $primary * @return \MarkdownExtended\API\ContentInterface|string * * @throws \MarkdownExtended\Exception\FileSystemException if the file can not be found or read */ public function transformSource($path, $primary = true) { if (!file_exists($path)) { throw new FileSystemException(sprintf('Source file "%s" not found', $path)); } if (!is_readable($path)) { throw new FileSystemException(sprintf('Source file "%s" is not readable', $path)); } $source = Helper::readFile($path); $content = new Content($source, $this->getKernel()->get('config')->getAll()); $content->addMetadata('last_update', new DateTime('@' . filemtime($path)))->addMetadata('file_name', $path); $this->getKernel()->addConfig('base_path', realpath(dirname($path))); $filename = $this->getKernel()->applyConfig('filepath_to_title', array($path)); return $this->transform($content, $filename, $primary); }