chobie / php-sundown

php-sundown is just simple wrapper of sundown
Other
137 stars 16 forks source link

segfault error when using last version #12

Closed ikwattro closed 12 years ago

ikwattro commented 12 years ago

Hi chobie,

If I use the last version of the PECL Sundown, I get always segfault error in my logs and an empty_response from the app

[Sun Mar 04 13:47:37 2012] [notice] child pid 30341 exit signal Segmentation fault (11) [Sun Mar 04 13:48:43 2012] [notice] child pid 11304 exit signal Segmentation fault (11) [Sun Mar 04 13:48:56 2012] [notice] child pid 30343 exit signal Segmentation fault (11) [Sun Mar 04 13:48:57 2012] [notice] child pid 11302 exit signal Segmentation fault (11)

I've downgraded to the sundown-0.2.0 for the moment.

I have to say when I show my page the first time it works, then get the error if I refresh or use a page that use the extension. Looks like he do not accept to use another instance.

chobie commented 12 years ago

oops, sorry. let me look into it.

ikwattro commented 12 years ago

no problem, btw do you intend to add some extra renderers. like the possibilty to have markdown into html like the following :

<div style="text-align:center;"> # Level 1 title </div>

Or with your own syntax

center# Level 1 title
chobie commented 12 years ago

Sorry for rain response. Probably I've fixed the issue. could you check with latest master branch? chobie/php-sundown@683b1d32ccd66e5e71ad4d01653187153dd6b531

No I don't. But you can define custom render like this.

<?php

class YourRender extends \Sundown\Render\HTML
{
        public function paragraph($text)
        {
                return sprintf('<div class="text-align:center">%s</div>',$text);
        }
}

$md = new Sundown\Markdown(new YourRender());
echo $md->render("
lorem ipsum
");
// this will output
// <div class="text-align:center">lorem ipsum</div>

or use preprocess

<?php

class YourRender extends \Sundown\Render\HTML
{
        public function preProcess($text)
        {
                return preg_replace("/^center# (.+)/m","<div style=\"text-align:center;\">$1</div>",$text);
        }
}

$md = new Sundown\Markdown(new YourRender());
echo $md->render("
echo $md->render("
center# Level 1 Hello
# header text");

// this will output
// <div style="text-align:center;">Level 1 Hello</div>
// <h1>header text</h1>

Sundown does not provide any custom parser AFAIK. In this case, you should use preProcess or some custom render method.

ikwattro commented 12 years ago

I will try it.

Yes sundown does not provide such renderers. But I would prefer to avoid php parsing with regex's.

ikwattro commented 12 years ago

closed for a time but forgot to do it.