From 40d9911ee1f57306d6ff4eeca776443f67b0ced0 Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Wed, 4 Aug 2004 16:37:48 +0000 Subject: [PATCH] Allow indentation of tables using :{| Bug #989788. --- includes/Parser.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 6ae7903a7e..745228c4a1 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -713,13 +713,17 @@ class Parser $ltd = array () ; # Was it TD or TH? $tr = array () ; # Is currently a tr tag open? $ltr = array () ; # tr attributes + $indent_level = 0; # indent level of the table foreach ( $t AS $k => $x ) { $x = trim ( $x ) ; $fc = substr ( $x , 0 , 1 ) ; - if ( '{|' == substr ( $x , 0 , 2 ) ) + if ( preg_match( '/^(:*)\{\|(.*)$/', $x, $matches ) ) { - $t[$k] = "\nfixTagAttributes ( substr ( $x , 2 ) ) . '>' ; + $indent_level = strlen( $matches[1] ); + $t[$k] = "\n" . + str_repeat( "
", $indent_level ) . + "
fixTagAttributes ( $matches[2] ) . '>' ; array_push ( $td , false ) ; array_push ( $ltd , '' ) ; array_push ( $tr , false ) ; @@ -733,7 +737,7 @@ class Parser if ( array_pop ( $tr ) ) $z = '' . $z ; if ( array_pop ( $td ) ) $z = "" . $z ; array_pop ( $ltr ) ; - $t[$k] = $z ; + $t[$k] = $z . str_repeat( "", $indent_level ); } else if ( '|-' == substr ( $x , 0 , 2 ) ) # Allows for |--------------- { -- 2.20.1