|
19 | 19 | use SMF\ActionTrait; |
20 | 20 | use SMF\Attachment; |
21 | 21 | use SMF\Autolinker; |
22 | | -use SMF\BBCodeParser; |
23 | 22 | use SMF\Board; |
24 | 23 | use SMF\BrowserDetector; |
25 | 24 | use SMF\Cache\CacheApi; |
|
29 | 28 | use SMF\IntegrationHook; |
30 | 29 | use SMF\IP; |
31 | 30 | use SMF\Lang; |
32 | | -use SMF\MarkdownParser; |
| 31 | +use SMF\Parser; |
33 | 32 | use SMF\Sapi; |
34 | 33 | use SMF\Theme; |
35 | 34 | use SMF\Time; |
@@ -779,11 +778,11 @@ public function getXmlNews(): array |
779 | 778 | $row['body'] = strtr(Utils::entitySubstr(str_replace('<br>', "\n", $row['body']), 0, Config::$modSettings['xmlnews_maxlen'] - 3), ["\n" => '<br>']) . '...'; |
780 | 779 | } |
781 | 780 |
|
782 | | - $row['body'] = BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], (int) $row['id_msg']); |
783 | | - |
784 | | - if (!empty(Config::$modSettings['enableMarkdown'])) { |
785 | | - $row['body'] = MarkdownParser::load()->parse($row['body'], true); |
786 | | - } |
| 781 | + $row['body'] = Parser::transform( |
| 782 | + string: $row['body'], |
| 783 | + input_types: Parser::INPUT_BBC | Parser::INPUT_MARKDOWN | ((bool) $row['smileys_enabled'] ? Parser::INPUT_SMILEYS : 0), |
| 784 | + options: ['cache_id' => (int) $row['id_msg']], |
| 785 | + ); |
787 | 786 |
|
788 | 787 | Lang::censorText($row['body']); |
789 | 788 | Lang::censorText($row['subject']); |
@@ -1223,11 +1222,11 @@ public function getXmlRecent(): array |
1223 | 1222 | $row['body'] = strtr(Utils::entitySubstr(str_replace('<br>', "\n", $row['body']), 0, Config::$modSettings['xmlnews_maxlen'] - 3), ["\n" => '<br>']) . '...'; |
1224 | 1223 | } |
1225 | 1224 |
|
1226 | | - $row['body'] = BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], (int) $row['id_msg']); |
1227 | | - |
1228 | | - if (!empty(Config::$modSettings['enableMarkdown'])) { |
1229 | | - $row['body'] = MarkdownParser::load()->parse($row['body'], true); |
1230 | | - } |
| 1225 | + $row['body'] = Parser::transform( |
| 1226 | + string: $row['body'], |
| 1227 | + input_types: Parser::INPUT_BBC | Parser::INPUT_MARKDOWN | ((bool) $row['smileys_enabled'] ? Parser::INPUT_SMILEYS : 0), |
| 1228 | + options: ['cache_id' => (int) $row['id_msg']], |
| 1229 | + ); |
1231 | 1230 |
|
1232 | 1231 | Lang::censorText($row['body']); |
1233 | 1232 | Lang::censorText($row['subject']); |
@@ -1991,11 +1990,11 @@ public function getXmlPosts(): array |
1991 | 1990 | } |
1992 | 1991 |
|
1993 | 1992 | // If using our own format, we want both the raw and the parsed content. |
1994 | | - $row[$this->format === 'smf' ? 'body_html' : 'body'] = BBCodeParser::load()->parse($row['body'], (bool) $row['smileys_enabled'], (int) $row['id_msg']); |
1995 | | - |
1996 | | - if (!empty(Config::$modSettings['enableMarkdown'])) { |
1997 | | - $row[$this->format === 'smf' ? 'body_html' : 'body'] = MarkdownParser::load()->parse($row[$this->format === 'smf' ? 'body_html' : 'body'], true); |
1998 | | - } |
| 1993 | + $row[$this->format === 'smf' ? 'body_html' : 'body'] = Parser::transform( |
| 1994 | + string: $row['body'], |
| 1995 | + input_types: Parser::INPUT_BBC | Parser::INPUT_MARKDOWN | ((bool) $row['smileys_enabled'] ? Parser::INPUT_SMILEYS : 0), |
| 1996 | + options: ['cache_id' => (int) $row['id_msg']], |
| 1997 | + ); |
1999 | 1998 |
|
2000 | 1999 | // Do we want to include any attachments? |
2001 | 2000 | if (!empty(Config::$modSettings['attachmentEnable']) && !empty(Config::$modSettings['xmlnews_attachments'])) { |
@@ -2446,11 +2445,7 @@ public function getXmlPMs(): array |
2446 | 2445 | } |
2447 | 2446 |
|
2448 | 2447 | // If using our own format, we want both the raw and the parsed content. |
2449 | | - $row[$this->format === 'smf' ? 'body_html' : 'body'] = BBCodeParser::load()->parse($row['body']); |
2450 | | - |
2451 | | - if (!empty(Config::$modSettings['enableMarkdown'])) { |
2452 | | - $row[$this->format === 'smf' ? 'body_html' : 'body'] = MarkdownParser::load()->parse($row[$this->format === 'smf' ? 'body_html' : 'body'], true); |
2453 | | - } |
| 2448 | + $row[$this->format === 'smf' ? 'body_html' : 'body'] = Parser::transform($row['body']); |
2454 | 2449 |
|
2455 | 2450 | $recipients = array_combine(explode(',', $row['id_members_to']), explode($separator, $row['to_names'])); |
2456 | 2451 |
|
|
0 commit comments