From ed64504c35fbcf7e9037ffdc2cfb20f0202b6781 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Mon, 8 Sep 2003 07:52:03 +0000 Subject: [PATCH] table markup --- includes/OutputPage.php | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 3021fa6c59..849fb84d6f 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -622,6 +622,65 @@ class OutputPage { } +function doTableStuff ( $t ) +{ + $t = explode ( "\n" , $t ) ; + $td = array () ; # Is currently a td tag open? + $tr = array () ; # Is currently a tr tag open? + foreach ( $t AS $k => $x ) + { + $x = rtrim ( $x ) ; + if ( "{|" == substr ( $x , 0 , 2 ) ) + { + $t[$k] = "" ; + array_push ( $td , false ) ; + array_push ( $tr , false ) ; + } + else if ( count ( $td ) == 0 ) { } # Don't do any of the following + else if ( "|}" == substr ( $x , 0 , 2 ) ) + { + $z = "
\n" ; + if ( array_pop ( $tr ) ) $z = "" . $z ; + if ( array_pop ( $td ) ) $z = "" . $z ; + $t[$k] = $z ; + } + else if ( "|_" == substr ( $x , 0 , 2 ) ) # Caption +{ +$z = trim ( substr ( $x , 2 ) ) ; +$t[$k] = "{$z}{$y[1]}" ; + $t[$k] .= $y ; + array_push ( $td , true ) ; + } + } + } + $t = implode ( "\n" , $t ) ; + return $t ; +} + # Well, OK, it's actually about 14 passes. But since all the # hard lifting is done inside PHP's regex code, it probably # wouldn't speed things up much to add a real parser. @@ -647,6 +706,7 @@ class OutputPage { $text = $this->replaceExternalLinks( $text ); $text = $this->replaceInternalLinks ( $text ); + $text = $this->doTableStuff ( $text ) ; $text = $this->magicISBN( $text ); $text = $this->magicRFC( $text ); -- 2.20.1