[ 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\Litedown\Parser\Passes; 9 10 abstract class AbstractInlineMarkup extends AbstractPass 11 { 12 /** 13 * Parse given inline markup in text 14 * 15 * The markup must start and end with exactly 2 characters 16 * 17 * @param string $str First markup string 18 * @param string $regexp Regexp used to match the markup's span 19 * @param string $tagName Name of the tag produced by this markup 20 * @return void 21 */ 22 protected function parseInlineMarkup(string $str, string $regexp, string $tagName): void 23 { 24 $pos = $this->text->indexOf($str); 25 if ($pos === false) 26 { 27 return; 28 } 29 30 preg_match_all($regexp, $this->text, $matches, PREG_OFFSET_CAPTURE, $pos); 31 foreach ($matches[0] as [$match, $matchPos]) 32 { 33 $matchLen = strlen($match); 34 $endPos = $matchPos + $matchLen - 2; 35 36 $this->parser->addTagPair($tagName, $matchPos, 2, $endPos, 2); 37 $this->text->overwrite($matchPos, 2); 38 $this->text->overwrite($endPos, 2); 39 } 40 } 41 }
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 |