| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | * @package   s9e\TextFormatter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | * @copyright Copyright (c) 2010-2017 The s9e Authors | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | * @license   http://www.opensource.org/licenses/mit-license.php The MIT License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | namespace s9e\TextFormatter\Plugins\Litedown; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use s9e\TextFormatter\Parser\Tag; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\ParsedText; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\Blocks; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\Emphasis; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\ForcedLineBreaks; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\Images; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\InlineCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\LinkReferences; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\Links; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\Strikethrough; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use s9e\TextFormatter\Plugins\Litedown\Parser\Passes\Superscript; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use s9e\TextFormatter\Plugins\ParserBase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class Parser extends ParserBase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	* {@inheritdoc} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 |  |  | 	*/ | 
            
                                                        
            
                                    
            
            
                | 28 | 263 |  | 	public function parse($text, array $matches) | 
            
                                                        
            
                                    
            
            
                | 29 |  |  | 	{ | 
            
                                                        
            
                                    
            
            
                | 30 | 263 |  | 		$text = new ParsedText($text); | 
            
                                                        
            
                                    
            
            
                | 31 | 263 |  | 		$text->decodeHtmlEntities = $this->config['decodeHtmlEntities']; | 
            
                                                        
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 33 |  |  | 		// Match block-level markup as well as forced line breaks | 
            
                                                        
            
                                    
            
            
                | 34 | 263 |  | 		(new Blocks($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 36 |  |  | 		// Capture link references after block markup as been overwritten | 
            
                                                        
            
                                    
            
            
                | 37 | 263 |  | 		(new LinkReferences($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 39 |  |  | 		// Inline code must be done first to avoid false positives in other inline markup | 
            
                                                        
            
                                    
            
            
                | 40 | 263 |  | 		(new InlineCode($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 42 |  |  | 		// Do the rest of inline markup. Images must be matched before links | 
            
                                                        
            
                                    
            
            
                | 43 | 263 |  | 		(new Images($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 44 | 263 |  | 		(new Links($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 45 | 263 |  | 		(new Strikethrough($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 46 | 263 |  | 		(new Superscript($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 47 | 263 |  | 		(new Emphasis($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 48 | 263 |  | 		(new ForcedLineBreaks($this->parser, $text))->parse(); | 
            
                                                        
            
                                    
            
            
                | 49 |  |  | 	} | 
            
                                                        
            
                                    
            
            
                | 50 |  |  | } |