kzykhys / Ciconia

A New Markdown parser for PHP5.4
http://ciconia.kzykhys.com/
MIT License
356 stars 31 forks source link

URL in [ ] breaks output HTML #51

Open kenjis opened 9 years ago

kenjis commented 9 years ago
<?php
require 'vendor/autoload.php';

use Ciconia\Ciconia;
use Ciconia\Extension\Gfm;

$ciconia = new Ciconia();
$ciconia->addExtension(new Gfm\FencedCodeBlockExtension());
$ciconia->addExtension(new Gfm\TaskListExtension());
$ciconia->addExtension(new Gfm\InlineStyleExtension());
$ciconia->addExtension(new Gfm\WhiteSpaceExtension());
$ciconia->addExtension(new Gfm\TableExtension());
$ciconia->addExtension(new Gfm\UrlAutoLinkExtension());

$html = $ciconia->render(
    '[phalcon-php.spec - See http://blog.ohgaki.net/phalcon-php-rpm-package](https://gist.github.com/yohgaki/ee26b252d85ac6655c16)'
);

echo $html, PHP_EOL;

Actual result: <p><a href="https://gist.github.com/yohgaki/ee26b252d85ac6655c16">phalcon-php.spec - See <a href="http://blog.ohgaki.net/phalcon-php-rpm-package</a">http://blog.ohgaki.net/phalcon-php-rpm-package</a</a>></p>

Expected result: <p><a href="https://gist.github.com/yohgaki/ee26b252d85ac6655c16">phalcon-php.spec - See http://blog.ohgaki.net/phalcon-php-rpm-package</a></p>

willvincent commented 9 years ago

This probably isn't a bug considering you've included the UrlAutoLinkExtension class. If you're going to use normal markdown style named links, inclusion of the autolink extension probably isn't the best idea.

Though the regex pattern might be able to be updated to ignore any url wrapped inside square brackets or parens, since those matches would be picked up by the core link parser