diff --git a/plugins/MarkdownNotes/MarkdownNotes.php b/plugins/MarkdownNotes/MarkdownNotes.php new file mode 100644 index 0000000000..7b5bbe426c --- /dev/null +++ b/plugins/MarkdownNotes/MarkdownNotes.php @@ -0,0 +1,56 @@ +. +// }}} +/** + * 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 Parsedown; + +class MarkdownNotes extends Plugin +{ + public function onPostingAvailableContentTypes(array &$types): bool + { + $types['Markdown'] = 'text/markdown'; + return Event::next; + } + public function onRenderNoteContent($content, $content_type, &$rendered): bool + { + 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; + } +} diff --git a/plugins/MarkdownNotes/composer.json b/plugins/MarkdownNotes/composer.json new file mode 100644 index 0000000000..f7b79e5ccf --- /dev/null +++ b/plugins/MarkdownNotes/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "erusev/parsedown": "^1.7.4" + } +}