<?php if (!defined('PmWiki')) exit();
/*
#
#   This recipe adds rowspan markup to simple tables with ||text++++||
#   The number of + signs determines the number of rows spanned
#
#   It also adds 2 "filler" markups to improve table editing layout:
#
#   ||^^^^^^^^^|| is a filler to put in the row(s) below a rowspan
#
#   ||_________|| is a filler to use instead of |||| to denote colspan
#
#   These are cosmetic, optional and have no effect on output
#  
    Copyright 2008 John Rankin (john.rankin@affinity.co.nz)
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    
*/
SDV($RecipeInfo['RowspanInSimpleTables']['Version'], '2008-08-29');

## rowspan in simple tables
Markup('||++', '>^||', '/(<t[dh][^>]*>.*?)(\+\++)/e',
  "CellRowspan(PSS('$1'),strlen('$2'))");
function CellRowspan($string,$r) {
  return preg_replace('/^(.*<\/t[dh]>)?(<t[dh][^>]*)(>.*?)$/',
      '$1$2 rowspan="'.$r.'"$3',$string);
}

## rowspan filler
Markup('||^^', '<^||||', '/\|\|\^\^+(?=\|\|)/','');

## colspan filler
Markup('||__', '<^||||', '/\|\|__+(?=\|\|)/','||');