[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Plugins/Preg/ -> Parser.php (source)

   1  <?php
   2  
   3  /*
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2019 The s9e Authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Plugins\Preg;
   9  use s9e\TextFormatter\Plugins\ParserBase;
  10  class Parser extends ParserBase
  11  {
  12  	public function parse($text, array $matches)
  13      {
  14          foreach ($this->config['generics'] as $_8d36e519)
  15          {
  16              list($tagName, $regexp, $passthroughIdx, $map) = $_8d36e519;
  17              \preg_match_all($regexp, $text, $matches, \PREG_SET_ORDER | \PREG_OFFSET_CAPTURE);
  18              foreach ($matches as $m)
  19              {
  20                  $startTagPos = $m[0][1];
  21                  $matchLen    = \strlen($m[0][0]);
  22                  if ($passthroughIdx && isset($m[$passthroughIdx]) && $m[$passthroughIdx][0] !== '')
  23                  {
  24                      $contentPos  = $m[$passthroughIdx][1];
  25                      $contentLen  = \strlen($m[$passthroughIdx][0]);
  26                      $startTagLen = $contentPos - $startTagPos;
  27                      $endTagPos   = $contentPos + $contentLen;
  28                      $endTagLen   = $matchLen - ($startTagLen + $contentLen);
  29                      $tag = $this->parser->addTagPair($tagName, $startTagPos, $startTagLen, $endTagPos, $endTagLen, -100);
  30                  }
  31                  else
  32                      $tag = $this->parser->addSelfClosingTag($tagName, $startTagPos, $matchLen, -100);
  33                  foreach ($map as $i => $attrName)
  34                      if ($attrName && isset($m[$i]) && $m[$i][0] !== '')
  35                          $tag->setAttribute($attrName, $m[$i][0]);
  36              }
  37          }
  38      }
  39  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1