Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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: 02.04.2025, 15:04 - Dateigröße: 5.70 KiB


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