Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class TargetBlankLinkProcessor implements DocumentProcessorInterface
* @param Document $document
* @return void
public function processDocument(Document $document)
$walker = $document->walker();
while ($event = $walker->next()) {
$node = $event->getNode();
// Only stop at Link nodes when we first encounter them
if (!($node instanceof Link) || !$event->isEntering()) {
$node->data['attributes']['target'] = '_blank';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.