-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added extensible converter #105
Conversation
I do like this better than #103. Before I accept it, let me run a possible alternative by you: What if we move class CommonMarkConverter
{
public function __construct(DocParser $docParser, HtmlRendererInterface $htmlRenderer)
{
$this->docParser = $docParser;
$this->htmlRenderer = $htmlRenderer;
}
public function convertToHtml($commonMark)
{
$documentAST = $this->docParser->parse($commonMark);
return $this->htmlRenderer->renderBlock($documentAST);
}
public static function create(array $config = array())
{
$environment = Environment::createCommonMarkEnvironment();
$environment->mergeConfig($config);
$docParser = new DocParser($environment);
$htmlRenderer = new HtmlRenderer($environment);
return new static($docParser, $htmlRenderer);
}
} The downside is that it'll break BC. Technically that's okay with The upside is that I'm not sure how I feel about the static method though. Any thoughts on this? (If you like this approach, should the /cc @philsturgeon and @GrahamCampbell - I'd greatly appreciate any guidance you might have on this. |
I think I've decided on the direction I'd like to go (for now anyway):
This ensures backwards-compatibility and adds the functionality you're looking for in a logical manner. It's similar to your proposed change, but with the inheritance hierarchy reversed. @hason if you're up to making that change I will gladly accept it :) Otherwise I'll work on it sometime this week. |
@colinodell Accepted and updated. |
Awesome, thanks @hason! |
Alternative to #103