Example #1
0
 public function getArticle($uri)
 {
     $environment = Environment::createCommonMarkEnvironment();
     $environment->addExtension(new TableExtension());
     $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment));
     $contents = \Storage::get($uri . '.md');
     preg_match('/^.*$/m', $contents, $matches);
     return view('portal', array('body' => $converter->convertToHtml($contents), 'title' => substr($matches[0], 2)));
 }
 /**
  * Creates a new Drupal\CommonMark\CommonMark instance.
  *
  * @param DocParser $parser
  *   The document parser instance.
  * @param ElementRendererInterface $renderer
  *   The html renderer instance.
  */
 public function __construct(DocParser $parser = NULL, ElementRendererInterface $renderer = NULL, $filter = NULL)
 {
     if (!isset($parser)) {
         $parser = new DocParser($this->getEnvironment($filter));
     }
     if (!isset($renderer)) {
         $renderer = new HtmlRenderer($this->getEnvironment($filter));
     }
     parent::__construct($parser, $renderer);
 }
 /**
  * Compile the view at the given path.
  *
  * @param string $path
  *
  * @return void
  */
 public function compile($path)
 {
     $contents = $this->markdown->convertToHtml($this->files->get($path));
     $this->files->put($this->getCompiledPath($path), $contents);
 }
 /**
  * Get the evaluated contents of the view.
  *
  * @param string $path
  * @param array  $data
  *
  * @return string
  */
 public function get($path, array $data = [])
 {
     $contents = parent::get($path, $data);
     return $this->markdown->convertToHtml($contents);
 }
 /**
  * {@inheritdoc}
  */
 public function convert(ConverterContextInterface $converterContext)
 {
     $converterContext->setContent($this->converter->convertToHtml($converterContext->content()));
 }
 /**
  * Compile the view at the given path.
  *
  * @param string $path
  *
  * @return void
  */
 public function compile($path)
 {
     $contents = $this->reStructuredText->convertToHtml($this->files->get($path));
     $this->files->put($this->getCompiledPath($path), $contents);
 }
Example #7
0
 /**
  * Converts CommonMark to HTML.
  *
  * @param string $commonMark
  * @return string 
  * @api 
  * @static 
  */
 public static function convertToHtml($commonMark)
 {
     return \League\CommonMark\Converter::convertToHtml($commonMark);
 }