diff --git a/misuzu.php b/misuzu.php index dae0df08..c8a6ed7e 100644 --- a/misuzu.php +++ b/misuzu.php @@ -40,6 +40,7 @@ require_once __DIR__ . '/src/Forum/perms.php'; require_once __DIR__ . '/src/Forum/post.php'; require_once __DIR__ . '/src/Forum/topic.php'; require_once __DIR__ . '/src/Forum/validate.php'; +require_once __DIR__ . '/src/Parsers/parse.php'; require_once __DIR__ . '/src/Users/login_attempt.php'; require_once __DIR__ . '/src/Users/profile.php'; require_once __DIR__ . '/src/Users/relations.php'; diff --git a/public/forum/posting.php b/public/forum/posting.php index 0899b9b7..dcc1e6d3 100644 --- a/public/forum/posting.php +++ b/public/forum/posting.php @@ -126,7 +126,7 @@ if ($postRequest) { $app->getUserId(), IPAddress::remote()->getString(), $postText, - MSZ_FORUM_POST_PARSER_BBCODE + MSZ_PARSER_BBCODE ); forum_topic_mark_read($app->getUserId(), $topicId, $forum['forum_id']); diff --git a/public/settings.php b/public/settings.php index ed195a73..261721a3 100644 --- a/public/settings.php +++ b/public/settings.php @@ -114,13 +114,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!$perms['edit_about']) { $settingsErrors[] = "You're not allowed to edit your about page."; } else { - $aboutParser = (int)($_POST['about']['parser'] ?? MSZ_FORUM_POST_PARSER_PLAIN); + $aboutParser = (int)($_POST['about']['parser'] ?? MSZ_PARSER_PLAIN); $aboutText = $_POST['about']['text'] ?? ''; // TODO: this is disgusting (move this into a user_set_about function or some shit) while (true) { // TODO: take parser shit out of forum_post - if (!forum_post_is_valid_parser($aboutParser)) { + if (!parser_is_valid($aboutParser)) { $settingsErrors[] = 'Invalid parser specified.'; break; } diff --git a/src/Forum/post.php b/src/Forum/post.php index b20459ea..4cde54a0 100644 --- a/src/Forum/post.php +++ b/src/Forum/post.php @@ -1,27 +1,13 @@ parseText($text); + + case MSZ_PARSER_BBCODE: + return BBCodeParser::instance()->parseText($text); + + case MSZ_PARSER_PLAIN: + return $text; + } +} + +function parse_line(string $line, int $parser): string +{ + if (!parser_is_valid($parser)) { + return ''; + } + + switch ($parser) { + case MSZ_PARSER_MARKDOWN: + return MarkdownParser::instance()->parseLine($line); + + case MSZ_PARSER_BBCODE: + return BBCodeParser::instance()->parseLine($line); + + case MSZ_PARSER_PLAIN: + return $line; + } +} diff --git a/templates/changelog/change.twig b/templates/changelog/change.twig index 602f4717..37e3406b 100644 --- a/templates/changelog/change.twig +++ b/templates/changelog/change.twig @@ -62,7 +62,7 @@
This change has no additional notes.
{% endif %} diff --git a/templates/forum/macros.twig b/templates/forum/macros.twig index 069419cf..ac3a14e6 100644 --- a/templates/forum/macros.twig +++ b/templates/forum/macros.twig @@ -292,13 +292,7 @@