Created
March 10, 2016 16:29
-
-
Save colinodell/cef401b8a8cb1268a991 to your computer and use it in GitHub Desktop.
Adding 'dir' attribute to all paragraphs (UNTESTED)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// TODO: Set your "namespace" and "use" statements here | |
// Also see this documentation: http://commonmark.thephpleague.com/customization/abstract-syntax-tree/#document-processor | |
class ParagraphDirProcessor implements DocumentProcessorInterface | |
{ | |
public function processDocument(Document $document) | |
{ | |
$walker = $document->walker(); | |
while ($event = $walker->next()) { | |
$node = $event->getNode(); | |
// Only stop at Paragraph nodes when we first encounter them | |
if (!($node instanceof Paragraph) || !$event->isEntering()) { | |
continue; | |
} | |
$node->data['attributes']['dir'] = 'rtl'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment