Frédéric Wang has submitted this change and it was merged.
Change subject: Add SVG generation for LaTeXML
......................................................................
Add SVG generation for LaTeXML
Currently SVGs are generated only in
MathML mode but not in LaTeXML mode.
Since LaTeXML can benefit from the
SVGs as well this change introduces
the functionality to generate SVG
images from LaTeXML MathML input.
Generating SVG images for LaTeXML is an essential
part of Math 2.0. It enables to include LaTeXMLs Content
MathML and provides fallback
images for visitors with MathML disabled browsers.
Change-Id: If13a8b0825bf12dbfe4920ddb7ad552df9bc095f
---
M MathLaTeXML.php
1 file changed, 32 insertions(+), 1 deletion(-)
Approvals:
Frédéric Wang: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MathLaTeXML.php b/MathLaTeXML.php
index a93417f..b30a820 100644
--- a/MathLaTeXML.php
+++ b/MathLaTeXML.php
@@ -145,7 +145,6 @@
}
}
-
/**
* Internal version of @link self::embedMathML
* @return string
@@ -174,6 +173,38 @@
return Xml::tags( 'span', $attribs, $mml );
}
+ /**
+ * Calculates the SVG image based on the MathML input
+ * No cache is used.
+ * @return boolean
+ */
+ public function calulateSvg() {
+ $renderer = new MathMathML( $this->getTex() );
+ $renderer->setMathml( $this->getMathml() );
+ $renderer->setMode( MW_MATH_LATEXML );
+ $renderer->setPurge( true );
+ $res = $renderer->render();
+ if ( $res == true ) {
+ $this->svg = $renderer->getSvg();
+ } else {
+ $lastError = $renderer->getLastError();
+ wfDebugLog( 'Math', 'failed to convert LaTeXML-MathML
to SVG:' . $lastError );
+ }
+ return $res;
+ }
+
+ /**
+ * Gets the SVG image
+ * Lazy evaluation: If no SVG image exists it's generated on the fly
+ * @return string XML-Document of the rendered SVG
+ */
+ public function getSvg() {
+ if ( $this->isPurge() || $this->svg == '' ) {
+ $this->calulateSvg();
+ }
+ return $this->svg;
+ }
+
protected function getMathTableName() {
return 'mathlatexml';
}
--
To view, visit https://gerrit.wikimedia.org/r/149916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If13a8b0825bf12dbfe4920ddb7ad552df9bc095f
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: All1 <[email protected]>
Gerrit-Reviewer: Cjucovschi <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Dginev <[email protected]>
Gerrit-Reviewer: Frédéric Wang <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits