. // }}} /** * Markdown note support for GNU social * * @package GNUsocial * @category Plugin * * @author Phablulo * @copyright 2018-2019, 2021 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace Plugin\MarkdownNotes; use App\Core\Event; use App\Core\Modules\Plugin; use EventResult; use Parsedown; class MarkdownNotes extends Plugin { public function onPostingAvailableContentTypes(array &$types): EventResult { $types['Markdown'] = 'text/markdown'; return Event::next; } public function onRenderNoteContent($content, $content_type, &$rendered): EventResult { if ($content_type !== 'text/markdown') { return Event::next; } // https://github.com/erusev/parsedown $Parsedown = new Parsedown(); $Parsedown->setSafeMode(true); $rendered = $Parsedown->text($content); return Event::stop; } }