Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Parser.js

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 4.68 KiB


 001  var attrName       = config.attrName,
 002      hasSingleQuote = (text.indexOf("'") >= 0),
 003      hasDoubleQuote = (text.indexOf('"') >= 0),
 004      tagName        = config.tagName;
 005   
 006  parseSingleQuotes();
 007  parseSymbolsAfterDigits();
 008  parseSingleQuotePairs();
 009  parseDoubleQuotePairs();
 010  parseDashesAndEllipses();
 011  parseSymbolsInParentheses();
 012  parseNotEqualSign();
 013  parseGuillemets();
 014   
 015  /**
 016  * Add a fancy replacement tag
 017  *
 018  * @param  {!number} tagPos Position of the tag in the text
 019  * @param  {!number} tagLen Length of text consumed by the tag
 020  * @param  {!string} chr    Replacement character
 021  * @param  {number}  prio   Tag's priority
 022  * @return {!Tag}
 023  */
 024  function addTag(tagPos, tagLen, chr, prio)
 025  {
 026      var tag = addSelfClosingTag(tagName, tagPos, tagLen, prio || 0);
 027      tag.setAttribute(attrName, chr);
 028   
 029      return tag;
 030  }
 031   
 032  /**
 033  * Parse dashes and ellipses
 034  *
 035  * Does en dash –, em dash — and ellipsis …
 036  */
 037  function parseDashesAndEllipses()
 038  {
 039      if (text.indexOf('...') < 0 && text.indexOf('--') < 0)
 040      {
 041          return;
 042      }
 043   
 044      var chrs = {
 045              '--'  : "\u2013",
 046              '---' : "\u2014",
 047              '...' : "\u2026"
 048          },
 049          regexp = /---?|\.\.\./g,
 050          m;
 051      while (m = regexp.exec(text))
 052      {
 053          addTag(+m['index'], m[0].length, chrs[m[0]]);
 054      }
 055  }
 056   
 057  /**
 058  * Parse pairs of double quotes
 059  *
 060  * Does quote pairs “” -- must be done separately to handle nesting
 061  */
 062  function parseDoubleQuotePairs()
 063  {
 064      if (hasDoubleQuote)
 065      {
 066          parseQuotePairs('"', /(?:^|\W)".+?"(?!\w)/g, "\u201c", "\u201d");
 067      }
 068  }
 069   
 070  /**
 071  * Parse guillemets-style quotation marks
 072  */
 073  function parseGuillemets()
 074  {
 075      if (text.indexOf('<<') < 0)
 076      {
 077          return;
 078      }
 079   
 080      var m, regexp = /<<( ?)(?! )[^\n<>]*?[^\n <>]\1>>(?!>)/g;
 081      while (m = regexp.exec(text))
 082      {
 083          var left  = addTag(+m['index'],                   2, "\u00AB"),
 084              right = addTag(+m['index'] + m[0].length - 2, 2, "\u00BB");
 085   
 086          left.cascadeInvalidationTo(right);
 087      }
 088  }
 089   
 090  /**
 091  * Parse the not equal sign
 092  */
 093  function parseNotEqualSign()
 094  {
 095      if (text.indexOf('!=') < 0)
 096      {
 097          return;
 098      }
 099   
 100      var m, regexp = /\b !=(?= \b)/g;
 101      while (m = regexp.exec(text))
 102      {
 103          addTag(+m['index'] + 1, 2, "\u2260");
 104      }
 105  }
 106   
 107  /**
 108  * Parse pairs of quotes
 109  *
 110  * @param {!string} q          ASCII quote character 
 111  * @param {!RegExp} regexp     Regexp used to identify quote pairs
 112  * @param {!string} leftQuote  Fancy replacement for left quote
 113  * @param {!string} rightQuote Fancy replacement for right quote
 114  */
 115  function parseQuotePairs(q, regexp, leftQuote, rightQuote)
 116  {
 117      var m;
 118      while (m = regexp.exec(text))
 119      {
 120          var left  = addTag(+m['index'] + m[0].indexOf(q), 1, leftQuote),
 121              right = addTag(+m['index'] + m[0].length - 1, 1, rightQuote);
 122   
 123          // Cascade left tag's invalidation to the right so that if we skip the left quote,
 124          // the right quote remains untouched
 125          left.cascadeInvalidationTo(right);
 126      }
 127  }
 128   
 129  /**
 130  * Parse pairs of single quotes
 131  *
 132  * Does quote pairs ‘’ must be done separately to handle nesting
 133  */
 134  function parseSingleQuotePairs()
 135  {
 136      if (hasSingleQuote)
 137      {
 138          parseQuotePairs("'", /(?:^|\W)'.+?'(?!\w)/g, "\u2018", "\u2019");
 139      }
 140  }
 141   
 142  /**
 143  * Parse single quotes in general
 144  *
 145  * Does apostrophes ’ after a letter or at the beginning of a word or a couple of digits
 146  */
 147  function parseSingleQuotes()
 148  {
 149      if (!hasSingleQuote)
 150      {
 151          return;
 152      }
 153   
 154      var m, regexp = /[a-z]'|(?:^|\s)'(?=[a-z]|[0-9]{2})/gi;
 155      while (m = regexp.exec(text))
 156      {
 157          // Give this tag a worse priority than default so that quote pairs take precedence
 158          addTag(+m['index'] + m[0].indexOf("'"), 1, "\u2019", 10);
 159      }
 160  }
 161   
 162  /**
 163  * Parse symbols found after digits
 164  *
 165  * Does symbols found after a digit:
 166  *  - apostrophe ’ if it's followed by an "s" as in 80's
 167  *  - prime ′ and double prime ″
 168  *  - multiply sign × if it's followed by an optional space and another digit
 169  */
 170  function parseSymbolsAfterDigits()
 171  {
 172      if (!hasSingleQuote && !hasDoubleQuote && text.indexOf('x') < 0)
 173      {
 174          return;
 175      }
 176   
 177      /** @const */
 178      var map = {
 179          // 80's -- use an apostrophe
 180          "'s" : "\u2019",
 181          // 12' or 12" -- use a prime
 182          "'"  : "\u2032",
 183          "' " : "\u2032",
 184          "'x" : "\u2032",
 185          '"'  : "\u2033",
 186          '" ' : "\u2033",
 187          '"x' : "\u2033"
 188      };
 189   
 190      var m, regexp = /[0-9](?:'s|["']? ?x(?= ?[0-9])|["'])/g;
 191      while (m = regexp.exec(text))
 192      {
 193          // Test for a multiply sign at the end
 194          if (m[0].charAt(m[0].length - 1) === 'x')
 195          {
 196              addTag(+m['index'] + m[0].length - 1, 1, "\u00d7");
 197          }
 198   
 199          // Test for an apostrophe/prime right after the digit
 200          var str = m[0].substr(1, 2);
 201          if (map[str])
 202          {
 203              addTag(+m['index'] + 1, 1, map[str]);
 204          }
 205      }
 206  }
 207   
 208  /**
 209  * Parse symbols found in parentheses such as (c)
 210  *
 211  * Does symbols ©, ® and ™
 212  */
 213  function parseSymbolsInParentheses()
 214  {
 215      if (text.indexOf('(') < 0)
 216      {
 217          return;
 218      }
 219   
 220      var chrs = {
 221              '(c)'  : "\u00A9",
 222              '(r)'  : "\u00AE",
 223              '(tm)' : "\u2122"
 224          },
 225          regexp = /\((?:c|r|tm)\)/gi,
 226          m;
 227      while (m = regexp.exec(text))
 228      {
 229          addTag(+m['index'], m[0].length, chrs[m[0].toLowerCase()]);
 230      }
 231  }