Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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: 01.05.2026, 11:28 - Dateigröße: 6.35 KiB


 001  var pos, table = null, tableTag, tables, _text = text;
 002   
 003  if (config.overwriteMarkdown)
 004  {
 005      overwriteMarkdown();
 006  }
 007  if (config.overwriteEscapes)
 008  {
 009      overwriteEscapes();
 010  }
 011   
 012  captureTables();
 013  processTables();
 014   
 015  /**
 016  * Add current line to a table
 017  *
 018  * @param {string} line Line of text
 019  */
 020  function addLine(line)
 021  {
 022      var ignoreLen = 0;
 023   
 024      if (!table)
 025      {
 026          table = { rows: [] };
 027   
 028          // Make the table start at the first non-space character
 029          ignoreLen = /^ */.exec(line)[0].length;
 030          line      = line.substring(ignoreLen);
 031      }
 032   
 033      // Overwrite the outermost pipes
 034      line = line.replace(/^( *)\|/, '$1 ').replace(/\|( *)$/, ' $1');
 035   
 036      table.rows.push({ line: line, pos: pos + ignoreLen });
 037  }
 038   
 039  /**
 040  * Process current table's body
 041  */
 042  function addTableBody()
 043  {
 044      var i   = 1,
 045          cnt = table.rows.length;
 046      while (++i < cnt)
 047      {
 048          addTableRow('TD', table.rows[i]);
 049      }
 050   
 051      createBodyTags(table.rows[2].pos, pos);
 052  }
 053   
 054  /**
 055  * Add a cell's tags for current table at current position
 056  *
 057  * @param {string} tagName Either TD or TH
 058  * @param {string} align   Either "left", "center", "right" or ""
 059  * @param {string} content Cell's text content
 060  */
 061  function addTableCell(tagName, align, content)
 062  {
 063      var startPos  = pos,
 064          endPos    = startPos + content.length,
 065          ignoreLen;
 066      pos = endPos;
 067   
 068      var m = /^( *).*?( *)$/.exec(content);
 069      if (m[1])
 070      {
 071          ignoreLen = m[1].length;
 072          createIgnoreTag(startPos, ignoreLen);
 073          startPos += ignoreLen;
 074      }
 075      if (m[2])
 076      {
 077          ignoreLen = m[2].length;
 078          createIgnoreTag(endPos - ignoreLen, ignoreLen);
 079          endPos -= ignoreLen;
 080      }
 081   
 082      createCellTags(tagName, startPos, endPos, align);
 083  }
 084   
 085  /**
 086  * Process current table's head
 087  */
 088  function addTableHead()
 089  {
 090      addTableRow('TH', table.rows[0]);
 091      createHeadTags(table.rows[0].pos, pos);
 092  }
 093   
 094  /**
 095  * Process given table row
 096  *
 097  * @param {string}  tagName Either TD or TH
 098  * @param {!Object} row
 099  */
 100  function addTableRow(tagName, row)
 101  {
 102      pos = row.pos;
 103      row.line.split('|').forEach(function(str, i)
 104      {
 105          if (i > 0)
 106          {
 107              createIgnoreTag(pos, 1);
 108              ++pos;
 109          }
 110   
 111          var align = (!table.cols[i]) ? '' : table.cols[i];
 112          addTableCell(tagName, align, str);
 113      });
 114   
 115      createRowTags(row.pos, pos);
 116  }
 117   
 118  /**
 119  * Capture all pipe tables in current text
 120  */
 121  function captureTables()
 122  {
 123      table  = null;
 124      tables = [];
 125   
 126      pos = 0;
 127      _text.split("\n").forEach(function(line)
 128      {
 129          if (line.indexOf('|') < 0)
 130          {
 131              endTable();
 132          }
 133          else
 134          {
 135              addLine(line);
 136          }
 137          pos += 1 + line.length;
 138      });
 139      endTable();
 140  }
 141   
 142  /**
 143  * Create a pair of TBODY tags for given text span
 144  *
 145  * @param {number} startPos
 146  * @param {number} endPos
 147  */
 148  function createBodyTags(startPos, endPos)
 149  {
 150      addTagPair('TBODY', startPos, 0, endPos, 0, -103);
 151  }
 152   
 153  /**
 154  * Create a pair of TD or TH tags for given text span
 155  *
 156  * @param {string} tagName  Either TD or TH
 157  * @param {number} startPos
 158  * @param {number} endPos
 159  * @param {string} align    Either "left", "center", "right" or ""
 160  */
 161  function createCellTags(tagName, startPos, endPos, align)
 162  {
 163      var tag;
 164      if (startPos === endPos)
 165      {
 166          tag = addSelfClosingTag(tagName, startPos, 0, -101);
 167      }
 168      else
 169      {
 170          tag = addTagPair(tagName, startPos, 0, endPos, 0, -101);
 171      }
 172      if (align)
 173      {
 174          tag.setAttribute('align', align);
 175      }
 176  }
 177   
 178  /**
 179  * Create a pair of THEAD tags for given text span
 180  *
 181  * @param {number} startPos
 182  * @param {number} endPos
 183  */
 184  function createHeadTags(startPos, endPos)
 185  {
 186      addTagPair('THEAD', startPos, 0, endPos, 0, -103);
 187  }
 188   
 189  /**
 190  * Create an ignore tag for given text span
 191  *
 192  * @param {number} pos
 193  * @param {number} len
 194  */
 195  function createIgnoreTag(pos, len)
 196  {
 197      tableTag.cascadeInvalidationTo(addIgnoreTag(pos, len, 1000));
 198  }
 199   
 200  /**
 201  * Create a pair of TR tags for given text span
 202  *
 203  * @param {number} startPos
 204  * @param {number} endPos
 205  */
 206  function createRowTags(startPos, endPos)
 207  {
 208      addTagPair('TR', startPos, 0, endPos, 0, -102);
 209  }
 210   
 211  /**
 212  * Create an ignore tag for given separator row
 213  *
 214  * @param {!Object} row
 215  */
 216  function createSeparatorTag(row)
 217  {
 218      createIgnoreTag(row.pos - 1, 1 + row.line.length);
 219  }
 220   
 221  /**
 222  * Create a pair of TABLE tags for given text span
 223  *
 224  * @param {number} startPos
 225  * @param {number} endPos
 226  */
 227  function createTableTags(startPos, endPos)
 228  {
 229      tableTag = addTagPair('TABLE', startPos, 0, endPos, 0, -104);
 230  }
 231   
 232  /**
 233  * End current buffered table
 234  */
 235  function endTable()
 236  {
 237      if (hasValidTable())
 238      {
 239          table.cols = parseColumnAlignments(table.rows[1].line);
 240          tables.push(table);
 241      }
 242      table = null;
 243  }
 244   
 245  /**
 246  * Test whether a valid table is currently buffered
 247  *
 248  * @return {boolean}
 249  */
 250  function hasValidTable()
 251  {
 252      return (table && table.rows.length > 2 && isValidSeparator(table.rows[1].line));
 253  }
 254   
 255  /**
 256  * Test whether given line is a valid separator
 257  *
 258  * @param  {string}  line
 259  * @return {boolean}
 260  */
 261  function isValidSeparator(line)
 262  {
 263      return /^ *:?-+:?(?:(?:\+| *\| *):?-+:?)+ */.test(line);
 264  }
 265   
 266  /**
 267  * Overwrite right angle brackets in given match
 268  *
 269  * @param  {string} str
 270  * @return {string}
 271  */
 272  function overwriteBlockquoteCallback(str)
 273  {
 274      return str.replace(/[!>]/g, ' ');
 275  }
 276   
 277  /**
 278  * Overwrite escape sequences in current text
 279  */
 280  function overwriteEscapes()
 281  {
 282      if (_text.indexOf('\\|') > -1)
 283      {
 284          _text = _text.replace(/\\[\\|]/g, '..');
 285      }
 286  }
 287   
 288  /**
 289  * Overwrite backticks in given match
 290  *
 291  * @param  {string} str
 292  * @return {string}
 293  */
 294  function overwriteInlineCodeCallback(str)
 295  {
 296      return str.replace(/\|/g, '.');
 297  }
 298   
 299  /**
 300  * Overwrite Markdown-style markup in current text
 301  */
 302  function overwriteMarkdown()
 303  {
 304      // Overwrite inline code spans
 305      if (_text.indexOf('`') > -1)
 306      {
 307          _text = _text.replace(/`[^`]*`/g, overwriteInlineCodeCallback);
 308      }
 309   
 310      // Overwrite blockquotes
 311      if (_text.indexOf('>') > -1)
 312      {
 313          _text = _text.replace(/^(?:>!? ?)+/gm, overwriteBlockquoteCallback);
 314      }
 315  }
 316   
 317  /**
 318  * Parse and return column alignments in given separator line
 319  *
 320  * @param  {string} line
 321  * @return {!Array<string>}
 322  */
 323  function parseColumnAlignments(line)
 324  {
 325      // Use a bitfield to represent the colons' presence and map it to the CSS value
 326      var align = [
 327              '',
 328              'right',
 329              'left',
 330              'center'
 331          ],
 332          cols = [],
 333          regexp = /(:?)-+(:?)/g,
 334          m;
 335   
 336      while (m = regexp.exec(line))
 337      {
 338          var key = (m[1] ? 2 : 0) + (m[2] ? 1 : 0);
 339          cols.push(align[key]);
 340      }
 341   
 342      return cols;
 343  }
 344   
 345  /**
 346  * Process current table declaration
 347  */
 348  function processCurrentTable()
 349  {
 350      var firstRow = table.rows[0],
 351          lastRow  = table.rows[table.rows.length - 1];
 352      createTableTags(firstRow.pos, lastRow.pos + lastRow.line.length);
 353   
 354      addTableHead();
 355      createSeparatorTag(table.rows[1]);
 356      addTableBody();
 357  }
 358   
 359  /**
 360  * Process all the captured tables
 361  */
 362  function processTables()
 363  {
 364      var i = -1, cnt = tables.length;
 365      while (++i < cnt)
 366      {
 367          table = tables[i];
 368          processCurrentTable();
 369      }
 370  }