[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Plugins\Preg; 9 10 use s9e\TextFormatter\Plugins\ParserBase; 11 12 class Parser extends ParserBase 13 { 14 /** 15 * {@inheritdoc} 16 */ 17 public function parse($text, array $matches) 18 { 19 foreach ($this->config['generics'] as list($tagName, $regexp, $passthroughIdx, $map)) 20 { 21 preg_match_all($regexp, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE); 22 23 foreach ($matches as $m) 24 { 25 $startTagPos = $m[0][1]; 26 $matchLen = strlen($m[0][0]); 27 28 if ($passthroughIdx && isset($m[$passthroughIdx]) && $m[$passthroughIdx][0] !== '') 29 { 30 // Compute the position and length of the start tag, end tag, and the content in 31 // between. PREG_OFFSET_CAPTURE gives us the position of the content, and we 32 // know its length. Everything before is considered part of the start tag, and 33 // everything after is considered part of the end tag 34 $contentPos = $m[$passthroughIdx][1]; 35 $contentLen = strlen($m[$passthroughIdx][0]); 36 $startTagLen = $contentPos - $startTagPos; 37 $endTagPos = $contentPos + $contentLen; 38 $endTagLen = $matchLen - ($startTagLen + $contentLen); 39 40 $tag = $this->parser->addTagPair($tagName, $startTagPos, $startTagLen, $endTagPos, $endTagLen, -100); 41 } 42 else 43 { 44 $tag = $this->parser->addSelfClosingTag($tagName, $startTagPos, $matchLen, -100); 45 } 46 47 foreach ($map as $i => $attrName) 48 { 49 if ($attrName && isset($m[$i]) && $m[$i][0] !== '') 50 { 51 $tag->setAttribute($attrName, $m[$i][0]); 52 } 53 } 54 } 55 } 56 } 57 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |