2022-12-23 13:33:57 +00:00
|
|
|
<?php
|
|
|
|
|
2023-11-24 09:30:05 +00:00
|
|
|
namespace MediaWiki\Extension\Math\WikiTexVC\MMLmappings\Util;
|
2022-12-23 13:33:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This class contains functions to generate a
|
|
|
|
* HTML File which shows the formula converted to MathML
|
2023-11-24 09:30:05 +00:00
|
|
|
* by WikiTexVC
|
2022-12-23 13:33:57 +00:00
|
|
|
* @author Johannes Stegmüller
|
|
|
|
*/
|
|
|
|
class MMLTestUtilHTML {
|
|
|
|
|
|
|
|
public static function generateHTMLtableItem( $input, $bold = false ) {
|
|
|
|
if ( !$bold ) {
|
2022-12-29 10:03:29 +00:00
|
|
|
return "<td class=\"tg-0lax\">" . $input . "</td>";
|
2022-12-23 13:33:57 +00:00
|
|
|
} else {
|
2022-12-29 10:03:29 +00:00
|
|
|
return "<td class=\"tg-0lax\">" . "<b>" . $input . "</b>" . "</td>";
|
2022-12-23 13:33:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function generateHTMLEnd( $filePath, $active = true ) {
|
|
|
|
if ( !$active ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$file = fopen( $filePath, 'a' );
|
2022-12-29 10:03:29 +00:00
|
|
|
fwrite( $file, "</tbody></table>" );
|
2022-12-23 13:33:57 +00:00
|
|
|
fclose( $file );
|
|
|
|
}
|
|
|
|
|
2023-01-20 14:48:41 +00:00
|
|
|
public static function generateHTMLtableRow( $filePath, $rows, $bold = false, $active = true ) {
|
2022-12-23 13:33:57 +00:00
|
|
|
if ( !$active ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$file = fopen( $filePath, 'a' );
|
|
|
|
|
2023-01-20 14:48:41 +00:00
|
|
|
$stringData = "<tr>";
|
|
|
|
foreach ( $rows as $row ) {
|
|
|
|
$stringData .= self::generateHTMLtableItem( $row, $bold );
|
|
|
|
}
|
|
|
|
$stringData .= "</tr>";
|
2022-12-23 13:33:57 +00:00
|
|
|
|
|
|
|
fwrite( $file, $stringData );
|
|
|
|
|
|
|
|
fclose( $file ); // tbd only open close once for all tests
|
|
|
|
}
|
|
|
|
|
2023-01-20 14:48:41 +00:00
|
|
|
public static function generateHTMLstart( $filePath, $headrows = [ "name","Tex-Input",
|
2023-11-24 09:30:05 +00:00
|
|
|
"MathML(MathJax3)","MathML(WikiTexVC)" ], $active = true ) {
|
2022-12-23 13:33:57 +00:00
|
|
|
if ( !$active ) {
|
|
|
|
return;
|
|
|
|
}
|
2023-01-20 14:48:41 +00:00
|
|
|
|
|
|
|
$htmlRows = "";
|
|
|
|
foreach ( $headrows as $header ) {
|
|
|
|
$htmlRows .= "<th class=\"tg-0lax\"><b>" . $header . "</b></th>";
|
|
|
|
}
|
|
|
|
|
2022-12-23 13:33:57 +00:00
|
|
|
$file = fopen( $filePath, 'w' ); // or die("error");
|
2022-12-29 10:03:29 +00:00
|
|
|
$stringData = /** @lang HTML */
|
|
|
|
<<<HTML
|
2023-01-20 14:48:41 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
</head>
|
|
|
|
<style>
|
|
|
|
.tg {
|
|
|
|
border-collapse: collapse;
|
|
|
|
border-spacing: 0;
|
|
|
|
}
|
|
|
|
.tg td {
|
|
|
|
border-color: black;
|
|
|
|
border-style: solid;
|
|
|
|
border-width: 1px;
|
|
|
|
font-family: Arial, sans-serif;
|
|
|
|
font-size: 14px;
|
|
|
|
overflow: hidden;
|
|
|
|
padding: 10px 5px;
|
|
|
|
word-break: normal;
|
|
|
|
}
|
|
|
|
.tg th {
|
|
|
|
border-color: black;
|
|
|
|
border-style: solid;
|
|
|
|
border-width: 1px;
|
|
|
|
font-family: Arial,
|
|
|
|
sans-serif;
|
|
|
|
font-size: 14px;
|
|
|
|
font-weight: normal;
|
|
|
|
overflow: hidden;
|
|
|
|
padding: 10px 5px;
|
|
|
|
word-break: normal;
|
|
|
|
}
|
|
|
|
.tg .tg-0lax {
|
|
|
|
text-align: left;
|
|
|
|
vertical-align: top
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<table class="tg">
|
|
|
|
<thead>
|
|
|
|
<tr>{$htmlRows}</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
HTML;
|
2022-12-23 13:33:57 +00:00
|
|
|
fwrite( $file, $stringData );
|
|
|
|
fclose( $file );
|
|
|
|
}
|
|
|
|
}
|