From 87775a4fa9778d1e7371d4f447fd7d588f3f3c22 Mon Sep 17 00:00:00 2001 From: Lincoln Russell Date: Sun, 7 Jan 2024 17:03:57 -0500 Subject: [PATCH] Fix TextFormatter attribute order for Flarum post mentions Per @JoshyPHP's comment https://github.com/linc/nitro-porter/discussions/42 --- src/Parser/Flarum/QuoteEmbed.php | 2 +- src/Postscript/Flarum.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Parser/Flarum/QuoteEmbed.php b/src/Parser/Flarum/QuoteEmbed.php index 8fc98619..9a55aadc 100644 --- a/src/Parser/Flarum/QuoteEmbed.php +++ b/src/Parser/Flarum/QuoteEmbed.php @@ -84,7 +84,7 @@ public function render(Lexer $lexer) // Omits 'p' tags that wrap thru {body} normally because we don't know if the body has 'p' tags. $this->wrapElement('> ' . // Postscript will fill in blank attributes BUT THEY MUST BE IN THIS ORDER. - '' . + '' . '@"{author}"#p{postid} {body}', ['author', 'postid', 'body', 'discussionid']); } } diff --git a/src/Postscript/Flarum.php b/src/Postscript/Flarum.php index 99549c68..7ed39e44 100644 --- a/src/Postscript/Flarum.php +++ b/src/Postscript/Flarum.php @@ -130,7 +130,7 @@ protected function numberPosts(ExportModel $ex) /** * Find mentions in posts and record to database table. * - * @see QuoteEmbed — '' + * @see QuoteEmbed — '' */ protected function buildPostMentions(ExportModel $ex) { @@ -163,7 +163,7 @@ protected function buildPostMentions(ExportModel $ex) // Find converted mentions and connect to userID. $mentions = []; preg_match_all( - '//U', + '//U', $post->content, $mentions ); @@ -222,7 +222,7 @@ protected function buildPostMentions(ExportModel $ex) * @param int $quoteID The post referenced in the content. * @param string $quoteType One of 'post' or 'discussion'. * @return bool Whether the post mention was repaired. - *@see QuoteEmbed — '' + *@see QuoteEmbed — '' */ protected function repairPostMention(ExportModel $ex, int $postid, string $content, int $quoteID, string $quoteType) { @@ -253,16 +253,16 @@ protected function repairPostMention(ExportModel $ex, int $postid, string $conte // Swap it into the mention markup. // Only one of these will match and it's easier than a logic gate. $body = str_replace( - '