From bcc16a332985b6a4b68876169cdb5fdf8f48ca5e Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 31 Aug 2015 13:36:54 +0930 Subject: [PATCH] Add target="_blank" and rel="nofollow" to all formatted links closes #247 --- src/Core/Formatter/Formatter.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Core/Formatter/Formatter.php b/src/Core/Formatter/Formatter.php index 6ad6798fd..ba0b5e2c7 100644 --- a/src/Core/Formatter/Formatter.php +++ b/src/Core/Formatter/Formatter.php @@ -42,6 +42,15 @@ class Formatter event(new FormatterConfigurator($configurator)); + $dom = $configurator->tags['URL']->template->asDOM(); + + foreach ($dom->getElementsByTagName('a') as $a) { + $a->setAttribute('target', '_blank'); + $a->setAttribute('rel', 'nofollow'); + } + + $dom->saveChanges(); + return $configurator; }