| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the league/commonmark-extras package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Colin O'Dell <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace League\CommonMark\Extras; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use League\CommonMark\Ext\Autolink\AutolinkExtension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use League\CommonMark\Ext\SmartPunct\SmartPunctExtension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use League\CommonMark\Extension\ExtensionInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | final class CommonMarkExtrasExtension implements ExtensionInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** @var ExtensionInterface[] */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private $extensions = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 | 3 |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 3 |  |         $this->extensions = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 3 |  |             new SmartPunctExtension(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 3 |  |             new AutolinkExtension(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 3 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 3 |  |     public function getBlockParsers() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 3 |  |         $ret = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 3 |  |         foreach ($this->extensions as $extension) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 3 |  |             foreach ($extension->getBlockParsers() as $parser) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 2 |  |                 $ret[] = $parser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 3 |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 49 | 3 |  |     public function getInlineParsers() | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 52 | 3 |  |         $ret = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 53 | 3 |  |         foreach ($this->extensions as $extension) { | 
            
                                                                        
                            
            
                                    
            
            
                | 54 | 3 |  |             foreach ($extension->getInlineParsers() as $parser) { | 
            
                                                                        
                            
            
                                    
            
            
                | 55 | 3 |  |                 $ret[] = $parser; | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 59 | 3 |  |         return $ret; | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 | 3 |  |     public function getInlineProcessors() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 3 |  |         $ret = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 3 |  |         foreach ($this->extensions as $extension) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 3 |  |             foreach ($extension->getInlineProcessors() as $processor) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 3 |  |                 $ret[] = $processor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 3 |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 3 |  |     public function getDocumentProcessors() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 3 |  |         $ret = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 3 |  |         foreach ($this->extensions as $extension) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 3 |  |             foreach ($extension->getDocumentProcessors() as $processor) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 3 |  |                 $ret[] = $processor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 3 |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 3 |  |     public function getBlockRenderers() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 3 |  |         $ret = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 3 |  |         foreach ($this->extensions as $extension) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 3 |  |             foreach ($extension->getBlockRenderers() as $class => $renderer) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 3 |  |                 $ret[$class] = $renderer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 3 |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 | 3 |  |     public function getInlineRenderers() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 3 |  |         $ret = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 3 |  |         foreach ($this->extensions as $extension) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 | 3 |  |             foreach ($extension->getInlineRenderers() as $class => $renderer) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 3 |  |                 $ret[$class] = $renderer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 3 |  |         return $ret; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 122 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 123 |  |  |  |