[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

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

   1  var tagName  = config.tagName,
   2      attrName = config.attrName;
   3  
   4  matches.forEach(function(m)
   5  {
   6      if (isAllowed(m[0][0]))
   7      {
   8          return;
   9      }
  10  
  11      // NOTE: unlike the PCRE regexp, the JavaScript regexp can consume an extra character at the
  12      //       start of the match, so we have to adjust the position and length accordingly
  13      var offset = /^\W/.test(m[0][0]) ? 1 : 0,
  14          word   = m[0][0].substr(offset),
  15          tag    = addSelfClosingTag(tagName, m[0][1] + offset, word.length);
  16  
  17      if (HINT.CENSOR_HAS_REPLACEMENTS && config.replacements)
  18      {
  19          for (var i = 0; i < config.replacements.length; ++i)
  20          {
  21              var regexp      = config.replacements[i][0],
  22                  replacement = config.replacements[i][1];
  23  
  24              if (regexp.test(word))
  25              {
  26                  tag.setAttribute(attrName, replacement);
  27                  break;
  28              }
  29          }
  30      }
  31  });
  32  
  33  /**
  34  * Test whether given word is allowed
  35  *
  36  * @param  {!string}  word
  37  * @return {!boolean}
  38  */
  39  function isAllowed(word)
  40  {
  41      return (HINT.CENSOR_HAS_ALLOWED && config.allowed && config.allowed.test(word));
  42  }


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