Menu

Any ETA on table support

2002-04-12
2012-10-11
  • Patrick Kellum

    Patrick Kellum - 2002-04-12

    Just curious on how support for tables in the new markup language is going?  The define list thing is nice, but I prefer my 'headers' at the top of the table, not the side.  Also, it's more limited then the old system (no alignment for example).

     
    • Patrick Kellum

      Patrick Kellum - 2002-04-12

      I was bored, so I wrote my own old-skool table markup as a plugin :)  It's not perfect (I just learned to write plug-in's a couple hours ago) and it ignores any additional markup (I can't figure out the parsing system yet) but here it is incase anyone wants it...

      class WikiPlugin_Table extends WikiPlugin
      {
          function getName()
          {
              return _('Table');
          }

          function getDescription()
          {
              return _('Generate an old-skool table');
          }

          function run($dbi, $argstr, $request)
          {
              $html = '<table border="1" cellpadding="1" cellspacing="1">';
              $row = '';
              $lines = explode("\n", $argstr);
              foreach ($lines as $line)
              {
                  $row .= '<tr>';
                  while (preg_match('/^(|+)(v*)([<>^]?)([^|]*)/', $line, $m))
                  {
                      $line = substr($line, strlen($m[0]));

                      if (strlen($m[1]) > 1)
                      {
                          $colspan = ' colspan="'.strlen($m[1]).'"';
                      } else {
                          $colspan = '';
                      }
                      if (strlen($m[2]) > 0)
                      {
                          $rowspan = ' rowspan="'.(strlen($m[2]) + 1).'"';
                      } else {
                          $rowspan = '';
                      }
                      if (strlen(trim($m[4])) < 1)
                      {
                          $m[4] = '&nbsp;';
                      }

                      switch ($m[3])
                      {
                          case '^':
                          {
                              $align = 'center';
                              break;
                          }
                          case '>':
                          {
                              $align = 'right';
                              break;
                          }
                          default:
                          case '<':
                          {
                              $align = 'left';
                              break;
                          }
                      }
                      $row .= '<td align="'.$align.'"'.$colspan.$rowspan.'>'
                          .trim($m[4])
                          .'</td>'
                      ;
                  }
                  $row .= '</tr>';
              }
              $html .= $row.'</table>';
              return HTML::raw($html);
          }
      }

       
    • Patrick Kellum

      Patrick Kellum - 2002-04-12

      BTW, just write your tables as before, but surrond them with the <?plugin Table ?> tag.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.