erusev / parsedown-extra

Markdown Extra Extension for Parsedown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Abbreviation UTF8

crossrw opened this issue · comments

Abbreviation does not work for multi-byte encoding.

Example:
*[АБВГ]: This Cyrillic alphabet

For solve need add "u" modifier to pattern at unmarkedText($text) function :

protected function unmarkedText($text)
    {
        $text = parent::unmarkedText($text);
        if (isset($this->DefinitionData['Abbreviation']))
        {
            foreach ($this->DefinitionData['Abbreviation'] as $abbreviation => $meaning)
            {
                $pattern = '/\b'.preg_quote($abbreviation, '/').'\b/u';     // add "u"
                $text = preg_replace($pattern, '<abbr title="'.$meaning.'">'.$abbreviation.'</abbr>', $text);
            }
        }
        return $text;
    }