", $data ); $data = preg_replace( "/\\\\n/", "
", $data ); $data = preg_replace( "/\s\s/", "  ", $data ); } $output .= $data; } } } function inTag( $tagName ) { global $inTag; if ( array_key_exists( $tagName, $inTag ) ) { return $inTag[$tagName ]; }else{ return 0; } } // Returns the name of the current HTML tag function currentTag() { global $tagStack; $stackSize = sizeof( $tagStack ); if ( $stackSize >= 1 ) { return $tagStack[ $stackSize - 1 ]; }else{ return ""; } } // Tells the script that we are entering a new tag // $tagName - the HTML tag to open // $tagAttributes - The attributes to give the tag, defaults to none // $write - If this tag should be written - 1 yes - 0 no - defaults to yes function openTag( $tagName, $tagAttributes = "", $write = 1 ) { global $inTag; global $attributes; global $output; global $tagStack; global $tagWritten; array_push( $tagStack, $tagName ); array_push( $tagWritten, $write ); $inTag[ $tagName ] = 1; $attributes[ $tagName ] = $tagAttributes; if ( $write == 1) { $output .= ""; } return $tagName; } //Closes the passed tag function closeSpecificTag( $tagName ) { if ( inTag( $tagName ) ) { do { $closed = closeTag(); }while( $closed != $tagName && $closed != NULL ); return $closed; }else{ // If we weren't in the tag to begin with, its not possible to close it return 0; } } function printElement( $name, $attrs ) { echo "

$name\n"; print_r ($attrs); echo "

\n"; } function setStyles( $attrs ) { global $inlineOutput; if ( array_key_exists('ALIGNMENT', $attrs ) ) { if ( $attrs['ALIGNMENT'] == "centred" && $inlineOutput == 0 ) { openTag( 'center' ); } } if ( array_key_exists('STYLE', $attrs ) ) { $style = $attrs['STYLE']; if ( $style == "Title" ) { if ( inTag('center') == 0 ) { openTag( 'center'); } openTag( 'h1' ); }elseif ( $style == "Heading 1" ) { openTag( 'h1' ); }elseif ( $style == "Heading 2" ) { openTag( 'h2' ); }elseif ( $style == "Heading 3" ) { openTag( 'h3' ); }elseif ( $style == "Heading 4" ) { openTag( 'h4' ); }elseif ( $style == "Author" ) { if ( inTag('center') == 0 ) { openTag( 'center'); } }elseif ( $style == "Warning" ) { openTag( 'font', "color=\"#0000ff\" face=\"Monospaced\"" ); }elseif ( $style == "Error" ) { openTag( 'font', "color=\"#ff00ff\" face=\"monospace\"" ); }elseif ( $style == "Maple Input" ) { openTag( 'strong' ); openTag( 'font', "color=\"#ff0000\" face=\"Monospaced\""); }elseif ( $style == "Maple Plot" ) { openTag( 'center' ); }elseif ( $style == "2D Output" ) { openTag( 'center' ); }elseif( $style == "Bullet Item" ) { openTag( 'li' ); }elseif( $style == "Line Printed Output" ) { openTag( 'font', "color=\"#0000ff\" face=\"monospace\"" ); }else{ } } } function startElement($parser, $name, $attrs) { global $plotWidth; global $plotHeight; global $plotType; global $output; global $inTag; global $attributes; global $hideInput; global $hideOutput; global $inlineOutput; global $hidden; global $gotDisplayEqn; global $maxWidth; global $maxHeight; if ( $name == "STYLES" ) { openTag( 'styles', "", 0 ); } elseif ( $name == "TEXT-FIELD" && inTag('styles') == 0 ) { //echo "

io $inlineOutput intag ". inTag('output'). "

"; openTag('text-field', "", 0 ); if( inTag('group' ) == 0 ) { if ( inTag('p') != 0 ) { closeSpecificTag('p'); } openTag('p'); } if ( $inlineOutput != 1 && $hidden==0 ) { setStyles($attrs); } if ( array_key_exists('PROMPT', $attrs ) && ( $attributes['group'] == "code" || inTag('presblock') == 0 ) ) { $output .= $attrs['PROMPT']; } }elseif( $name == "FONT" && inTag('styles') == 0 ) { if ( $inlineOutput != 1 || inTag('output') == 0 ) { setStyles($attrs); } if ( array_key_exists('BOLD', $attrs ) && $attrs['BOLD'] == "true" ) { openTag( 'strong' ); } if ( array_key_exists('ITALIC', $attrs ) && $attrs['ITALIC'] == "true" ) { openTag( 'i' ); } }elseif( $name == "PLOT" ) { // printElement($name, $attrs ); openTag('plot', "", 0 ); $plotWidth = $attrs['WIDTH']; if ( $plotWidth > $maxWidth ) { $plotWidth = $maxWidth; } $plotHeight = $attrs['HEIGHT']; if ( $plotHeight > $maxHeight ) { $plotHeight = $maxHeight; } if ( $attrs['TYPE'] == "two-dimensional" ) { $plotType = 2; }else{ $plotType = 3; } }elseif( $name == "EC-PLOT" ) { //

Please Wait...