finally, a working version (needs flexbisonparse, cli mode)
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Mon, 20 Dec 2004 13:50:33 +0000 (13:50 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Mon, 20 Dec 2004 13:50:33 +0000 (13:50 +0000)
includes/ParserXML.php

index a4c30b1..130b4e5 100644 (file)
@@ -4,6 +4,11 @@ require_once ( "Parser.php" ) ;
 /**
  * This should one day become the XML->(X)HTML parser
  * Based on work by Jan Hidders and Magnus Manske
+ * To use, set
+ *    $wgUseXMLparser = true ;
+ *    $wgEnableParserCache = false ;
+ *    $wgWiki2xml to the path and executable of the command line version (cli)
+ * in LocalSettings.php
  * @package MediaWiki
  * @subpackage Experimental
  */
@@ -127,6 +132,14 @@ class element {
                {
                $ret .= $this->sub_makeXHTML ( $parser , "td" ) ;
                }
+       else if ( $n == "TABLEHEAD" )
+               {
+               $ret .= $this->sub_makeXHTML ( $parser , "th" ) ;
+               }
+       else if ( $n == "CAPTION" )
+               {
+               $ret .= $this->sub_makeXHTML ( $parser , "caption" ) ;
+               }
 
 
        else if ( $n == "LISTITEM" )
@@ -315,9 +328,18 @@ class ParserXML EXTENDS Parser
        }
        
        function parse( $text, &$title, $options, $linestart = true, $clearState = true ) {
-               global $dummytext ;
-               $text = $dummytext ;
-               
+                global $wgWiki2xml ;
+               $tmpfname = tempnam("/tmp", "FOO");
+
+               $handle = fopen($tmpfname, "w");
+               fwrite($handle, $text);
+               fclose($handle);
+
+                exec ( $wgWiki2xml . " < " . $tmpfname , $a ) ;
+                $text = implode ( "\n" , $a ) ;
+
+               unlink($tmpfname);
+
                $w = new xml2php;
                $result = $w->scanString( $text );
                $text .= "<hr>" . $result->makeXHTML ( $this );