cebe / markdown

A super fast, highly extensible markdown parser for PHP

Home Page:http://markdown.cebe.cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

identifyUl override not working

soullivaneuh opened this issue · comments

I am implementing on option for Slack support on my own parser.

Slack does not support lists and tables, so I override related identify*( methods to just return false for ol, ul, and table:

class MarkdownParser extends GithubMarkdown implements MarkdownParserInterface
{
    protected $slack = true;

    protected function identifyOl($line)
    {
        if (true === $this->slack) {
            return false;
        }

        return parent::identifyOl($line);
    }

    protected function identifyUl($line)
    {
        if (true === $this->slack) {
            return false;
        }

        return parent::identifyUl($line);
    }

    protected function identifyTable($line, $lines, $current)
    {
        if (true === $this->slack) {
            return false;
        }

        return parent::identifyTable($line, $lines, $current);
    }
}

This works great for ol and table which are not converted, but ul is still identified and converted.

this is because the function name is changed when importing the trait:

identifyUl as protected identifyBUl;

You have to override identifyBUl instead.

Actually, you have to override both of them:

/**
 * {@inheritdoc}
 */
protected function identifyUl($line)
{
    if (true === $this->slack) {
        return false;
    }

    return parent::identifyUl($line);
}

/**
 * {@inheritdoc}
 */
protected function identifyBUl($line)
{
    if (true === $this->slack) {
        return false;
    }

    return parent::identifyBUl($line);
}

Thanks for your help.