<?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-2015 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.

History

August 17th, 2015: update by Jean-Pierre Chrétien
to make the file PHP >= 5.5 compatible (remove the "e" modifier
in substitution strings)
    
*/
SDV($RecipeInfo['RowspanInSimpleTables']['Version'], '2015-08-17');

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

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

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