jenkins-bot has submitted this change and it was merged.
Change subject: Return a texvcjs compatible json file
......................................................................
Return a texvcjs compatible json file
The special page mathdebug used to export
a php data format. Now, we switch to json
and make it compatible to texvcjs
Change-Id: I5328ef39c77cbc58b141d7c4246cd219dc7c87b6
---
M MathSearch.hooks.php
M SpecialMathDebug.php
2 files changed, 20 insertions(+), 11 deletions(-)
Approvals:
Physikerwelt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MathSearch.hooks.php b/MathSearch.hooks.php
index 5607bd6..6d67b91 100644
--- a/MathSearch.hooks.php
+++ b/MathSearch.hooks.php
@@ -351,15 +351,14 @@
return true;
}
$idGenerator = MathIdGenerator::newFromRevisionId( $revId );
- $mathTags= $idGenerator->getMathTags();
+ $mathTags = $idGenerator->getMathTags();
$harvest = "";
if ( $mathTags ) {
$dw = new MwsDumpWriter();
foreach ( $mathTags as $tag ) {
$id = null;
- $tagContent = $tag[1];
- $attributes = $tag[2];
- // $fullElement = $tag[3];
+ $tagContent = $tag[
MathIdGenerator::CONTENT_POS ];
+ $attributes = $tag[ MathIdGenerator::ATTRIB_POS
];
$renderer = MathRenderer::getRenderer(
$tagContent, $attributes, 'latexml' );
$renderer->render();
self::setMathId( $id, $renderer, $revId );
diff --git a/SpecialMathDebug.php b/SpecialMathDebug.php
index 825378c..40ad5d2 100644
--- a/SpecialMathDebug.php
+++ b/SpecialMathDebug.php
@@ -143,13 +143,21 @@
}
}
+ /**
+ * Generates test cases for texvcjs
+ *
+ * @param int $offset
+ * @param int $length
+ * @param string $page
+ * @param bool $purge
+ * @return bool
+ */
public function generateParserTests(
$offset = 0, $length = 10, $page = 'Testpage' , $purge = true
) {
$res = $this->getRequest()->response();
- $res->header( 'Content-Type: application/octet-stream' );
- $res->header( 'charset=utf-8' );
- $res->header( 'Content-Disposition:
attachment;filename=ParserTest.data' );
+ $res->header( 'Content-Type: application/json' );
+ $res->header( 'Content-Disposition:
attachment;filename=ParserTest.json' );
$out = $this->getOutput();
$out->setArticleBodyOnly( true );
@@ -157,10 +165,12 @@
foreach (
array_slice( self::getMathTagsFromPage( $page ),
$offset, $length, true ) as $key => $input
) {
- $output = MathRenderer::renderMath( $input, [], 'png' );
- $parserTests[]= [ (string) $input , $output ];
+ $m = new MathMathML( $input );
+ $m->checkTeX();
+ $parserTests[] = [ 'id' => $key, 'input' => (string)
$input, 'texvcjs' => $m->getTex() ];
}
- $out->addHTML( serialize( $parserTests ) );
+ $out->addHTML( json_encode( $parserTests ) );
+ return true;
}
function generateLaTeXMLOutput( $offset = 0, $length = 10, $page =
'Testpage' ) {
@@ -216,7 +226,7 @@
private function getTexvcTex( $tex ) {
$renderer = MathRenderer::getRenderer( $tex, [], 'source' );
- $renderer->checkTex();
+ $renderer->checkTeX();
return $renderer->getTex();
}
--
To view, visit https://gerrit.wikimedia.org/r/286384
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5328ef39c77cbc58b141d7c4246cd219dc7c87b6
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: Dyiop <[email protected]>
Gerrit-Reviewer: Hcohl <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: Whyameri <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits