KnpMarkdownBundle/Helper/MarkdownHelper.php

57 lines
1.1 KiB
PHP
Raw Normal View History

2010-05-06 15:17:59 +02:00
<?php
namespace Knplabs\Bundle\MarkdownBundle\Helper;
2010-05-06 15:17:59 +02:00
use Symfony\Component\Templating\Helper\HelperInterface;
use Knplabs\Bundle\MarkdownBundle\Parser\MarkdownParser;
2010-05-06 15:17:59 +02:00
class MarkdownHelper implements HelperInterface
{
/**
* @var MarkdownParser
*/
protected $parser;
protected $charset = 'UTF-8';
public function __construct(MarkdownParser $parser)
{
$this->parser = $parser;
}
/**
* Sets the default charset.
*
* @param string $charset The charset
*/
public function setCharset($charset)
{
$this->charset = $charset;
}
/**
* Gets the default charset.
*
* @return string The default charset
*/
public function getCharset()
{
return $this->charset;
}
public function getName()
{
return 'markdown';
}
/**
* Transforms markdown syntax to HTML
* @param string $markdownText The markdown syntax text
* @return string The HTML code
*/
public function transform($markdownText)
{
return $this->parser->transform($markdownText);
}
}