[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Plugins/Litedown/Parser/Passes/ -> AbstractScript.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\Litedown\Parser\Passes;
   9  abstract class AbstractScript extends AbstractPass
  10  {
  11      protected $longRegexp;
  12      protected $shortRegexp;
  13      protected $syntaxChar;
  14      
  15      protected $tagName;
  16  	protected function parseAbstractScript($tagName, $syntaxChar, $shortRegexp, $longRegexp)
  17      {
  18          $this->tagName     = $tagName;
  19          $this->syntaxChar  = $syntaxChar;
  20          $this->shortRegexp = $shortRegexp;
  21          $this->longRegexp  = $longRegexp;
  22          $pos = $this->text->indexOf($this->syntaxChar);
  23          if ($pos === \false)
  24              return;
  25          $this->parseShortForm($pos);
  26          $this->parseLongForm($pos);
  27      }
  28  	protected function parseLongForm($pos)
  29      {
  30          $pos = $this->text->indexOf($this->syntaxChar . '(', $pos);
  31          if ($pos === \false)
  32              return;
  33          \preg_match_all($this->longRegexp, $this->text, $matches, \PREG_OFFSET_CAPTURE, $pos);
  34          foreach ($matches[0] as $_4b034d25)
  35          {
  36              list($match, $matchPos) = $_4b034d25;
  37              $matchLen = \strlen($match);
  38              $this->parser->addTagPair($this->tagName, $matchPos, 2, $matchPos + $matchLen - 1, 1);
  39              $this->text->overwrite($matchPos, $matchLen);
  40          }
  41          if (!empty($matches[0]))
  42              $this->parseLongForm($pos);
  43      }
  44  	protected function parseShortForm($pos)
  45      {
  46          \preg_match_all($this->shortRegexp, $this->text, $matches, \PREG_OFFSET_CAPTURE, $pos);
  47          foreach ($matches[0] as $_4b034d25)
  48          {
  49              list($match, $matchPos) = $_4b034d25;
  50              $matchLen = \strlen($match);
  51              $startPos = $matchPos;
  52              $endLen   = (\substr($match, -1) === $this->syntaxChar) ? 1 : 0;
  53              $endPos   = $matchPos + $matchLen - $endLen;
  54              $this->parser->addTagPair($this->tagName, $startPos, 1, $endPos, $endLen);
  55          }
  56      }
  57  }


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