[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

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

   1  config.generics.forEach(function(entry)
   2  {
   3      var tagName        = entry[0],
   4          regexp         = entry[1],
   5          passthroughIdx = entry[2],
   6          map            = entry[3],
   7          m;
   8  
   9      // Reset the regexp
  10      regexp.lastIndex = 0;
  11  
  12      while (m = regexp.exec(text))
  13      {
  14          var startTagPos = m.index,
  15              matchLen    = m[0].length,
  16              tag;
  17  
  18          if (HINT.PREG_HAS_PASSTHROUGH && passthroughIdx && m[passthroughIdx] !== '')
  19          {
  20              // Compute the position and length of the start tag, end tag, and the content in
  21              // between. m.index gives us the position of the start tag but we don't know its length.
  22              // We use indexOf() to locate the content part so that we know how long the start tag
  23              // is. It is an imperfect solution but it should work well enough in most cases.
  24              var contentPos  = text.indexOf(m[passthroughIdx], startTagPos),
  25                  contentLen  = m[passthroughIdx].length,
  26                  startTagLen = contentPos - startTagPos,
  27                  endTagPos   = contentPos + contentLen,
  28                  endTagLen   = matchLen - (startTagLen + contentLen);
  29  
  30              tag = addTagPair(tagName, startTagPos, startTagLen, endTagPos, endTagLen, -100);
  31          }
  32          else
  33          {
  34              tag = addSelfClosingTag(tagName, startTagPos, matchLen, -100);
  35          }
  36  
  37          map.forEach(function(attrName, i)
  38          {
  39              // NOTE: subpatterns with no name have an empty entry to preserve the array indices
  40              if (attrName && typeof m[i] !== 'undefined')
  41              {
  42                  tag.setAttribute(attrName, m[i]);
  43              }
  44          });
  45      }
  46  });


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1