From 0511982426e319e90b6bd03c9eae775ddfaad622 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 8 Jun 2015 15:04:22 +0930 Subject: [PATCH] Update for new formatting API. --- .../mentions/src/PostMentionsFormatter.php | 24 ++++++++----------- .../mentions/src/UserMentionsFormatter.php | 15 ++++++++---- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/extensions/mentions/src/PostMentionsFormatter.php b/extensions/mentions/src/PostMentionsFormatter.php index f2c7e1bee..7d9c1ea30 100644 --- a/extensions/mentions/src/PostMentionsFormatter.php +++ b/extensions/mentions/src/PostMentionsFormatter.php @@ -1,6 +1,9 @@ parser = $parser; } - public function format($text, $post = null) + public function afterPurification($text, Post $post = null) { if ($post) { - $text = $this->parser->replace($text, function ($match) use ($post) { - return ''.$match['username'].''; - }, $text); + $text = $this->ignoreTags($text, ['a', 'code', 'pre'], function ($text) use ($post) { + return $this->parser->replace($text, function ($match) use ($post) { + return ''.$match['username'].''; + }, $text); + }); } return $text; } - - public function strip($text) - { - $text = $this->parser->replace($text, function () { - return ' '; - }); - - return $text; - } } diff --git a/extensions/mentions/src/UserMentionsFormatter.php b/extensions/mentions/src/UserMentionsFormatter.php index 9e2598373..9a9c6d275 100644 --- a/extensions/mentions/src/UserMentionsFormatter.php +++ b/extensions/mentions/src/UserMentionsFormatter.php @@ -1,6 +1,9 @@ parser = $parser; } - public function format($text, $post = null) + public function afterPurification($text, Post $post = null) { - $text = $this->parser->replace($text, function ($match) { - return ''.$match['username'].''; - }, $text); + $text = $this->ignoreTags($text, ['a', 'code', 'pre'], function ($text) { + return $this->parser->replace($text, function ($match) { + return ''.$match['username'].''; + }, $text); + }); return $text; }