Physikerwelt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/331906 )

Change subject: Maintain whitespaces in chem tags
......................................................................

Maintain whitespaces in chem tags

texvcjs changed the whitespaces in \ce
commands, which caused rendering issues.
See

http://ctan.mirrors.hoobly.com/macros/latex/contrib/mhchem/mhchem.pdf

for the mhchem syntax.

This change uses the unchanged input for rendering
of chem tags.

Bug: T140217
Change-Id: I4a685c5c4a969d1228271b50ccd64671061297a9
---
M routes/mathoid.js
M test/features/math/simple.js
2 files changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mathoid 
refs/changes/06/331906/1

diff --git a/routes/mathoid.js b/routes/mathoid.js
index 433c9ce..0e36e7b 100644
--- a/routes/mathoid.js
+++ b/routes/mathoid.js
@@ -94,6 +94,10 @@
         feedback = texvcInfo.feedback(q, {usemhchem: chem});
         // XXX properly handle errors here!
         if (feedback.success) {
+            if (chem) {
+                // keep the spacing for chemical formulae
+                feedback.checked = q;
+            }
             sanitizedTex = feedback.checked || '';
             q = sanitizedTex;
         } else {
@@ -102,12 +106,11 @@
         if (info) {
             if (outFormat === "graph") {
                 res.json(texvcInfo.texvcinfo(q, {"format": "json", "compact": 
true}));
-                return;
-            }
-            if (info && outFormat === "texvcinfo") {
+            } else {
+                // outFormat === "texvcinfo"
                 res.json(feedback).end();
-                return;
             }
+            return;
         }
     }
 
diff --git a/test/features/math/simple.js b/test/features/math/simple.js
index c18acc0..1b321fe 100644
--- a/test/features/math/simple.js
+++ b/test/features/math/simple.js
@@ -161,7 +161,7 @@
             response: {
                 status: 200,
                 body: {
-                    "mml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"; 
alttext=\"upper H Subscript 2 Superscript Baseline upper O\">\n  <semantics>\n  
  <mrow class=\"MJX-TeXAtom-ORD\">\n      <msubsup>\n        <mtext>H</mtext>\n 
       <mrow class=\"MJX-TeXAtom-ORD\">\n          <mn>2</mn>\n        
</mrow>\n        <mrow class=\"MJX-TeXAtom-ORD\">\n          <mspace 
width=\"0pt\" height=\"0pt\" depth=\".2em\" />\n        </mrow>\n      
</msubsup>\n      <mtext>O</mtext>\n    </mrow>\n    <annotation 
encoding=\"application/x-tex\">{\\ce {H2O}}</annotation>\n  
</semantics>\n</math>",
+                    "mml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"; 
alttext=\"upper H Subscript 2 Superscript Baseline upper O\">\n  <semantics>\n  
  <mrow>\n      <msubsup>\n        <mtext>H</mtext>\n        <mrow 
class=\"MJX-TeXAtom-ORD\">\n          <mn>2</mn>\n        </mrow>\n        
<mrow class=\"MJX-TeXAtom-ORD\">\n          <mspace width=\"0pt\" 
height=\"0pt\" depth=\".2em\" />\n        </mrow>\n      </msubsup>\n      
<mtext>O</mtext>\n    </mrow>\n    <annotation 
encoding=\"application/x-tex\">\\ce{H2O}</annotation>\n  </semantics>\n</math>",
                     "speakText": "upper H Subscript 2 Superscript Baseline 
upper O",
                     "svg": "<?xml version=\"1.0\" 
standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" 
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\";>\n<svg 
xmlns:xlink=\"http://www.w3.org/1999/xlink\"; width=\"4.634ex\" 
height=\"2.843ex\" style=\"vertical-align: -1.005ex;\" viewBox=\"0 -791.3 
1995.1 1223.9\" xmlns=\"http://www.w3.org/2000/svg\"; role=\"math\" 
aria-labelledby=\"MathJax-SVG-1-Title MathJax-SVG-1-Desc\">\n<title 
id=\"MathJax-SVG-1-Title\">Equation</title>\n<desc 
id=\"MathJax-SVG-1-Desc\">upper H Subscript 2 Superscript Baseline upper 
O</desc>\n<defs aria-hidden=\"true\">\n<path stroke-width=\"10\" 
id=\"E1-MJMAIN-48\" d=\"M128 622Q121 629 117 631T101 634T58 637H25V683H36Q57 
680 180 680Q315 680 324 683H335V637H302Q262 636 251 634T233 622L232 
500V378H517V622Q510 629 506 631T490 634T447 637H414V683H425Q446 680 569 680Q704 
680 713 683H724V637H691Q651 636 640 634T622 622V61Q628 51 639 49T691 
46H724V0H713Q692 3 569 3Q434 3 425 0H414V46H447Q489 47 498 49T517 
61V332H232V197L233 61Q239 51 250 49T302 46H335V0H324Q303 3 180 3Q45 3 36 
0H25V46H58Q100 47 109 49T128 61V622Z\"></path>\n<path stroke-width=\"10\" 
id=\"E1-MJMAIN-32\" d=\"M109 429Q82 429 66 447T50 491Q50 562 103 614T235 
666Q326 666 387 610T449 465Q449 422 429 383T381 315T301 241Q265 210 201 149L142 
93L218 92Q375 92 385 97Q392 99 409 186V189H449V186Q448 183 436 95T421 
3V0H50V19V31Q50 38 56 46T86 81Q115 113 136 137Q145 147 170 174T204 211T233 
244T261 278T284 308T305 340T320 369T333 401T340 431T343 464Q343 527 309 573T212 
619Q179 619 154 602T119 569T109 550Q109 549 114 549Q132 549 151 535T170 489Q170 
464 154 447T109 429Z\"></path>\n<path stroke-width=\"10\" id=\"E1-MJMAIN-4F\" 
d=\"M56 340Q56 423 86 494T164 610T270 680T388 705Q521 705 621 601T722 341Q722 
260 693 191T617 75T510 4T388 -22T267 3T160 74T85 189T56 340ZM467 647Q426 665 
388 665Q360 665 331 654T269 620T213 549T179 439Q174 411 174 354Q174 144 277 
61Q327 20 385 20H389H391Q474 20 537 99Q603 188 603 354Q603 411 598 439Q577 592 
467 647Z\"></path>\n</defs>\n<g stroke=\"currentColor\" fill=\"currentColor\" 
stroke-width=\"0\" transform=\"matrix(1 0 0 -1 0 0)\" aria-hidden=\"true\">\n 
<use xlink:href=\"#E1-MJMAIN-48\" x=\"0\" y=\"0\"></use>\n <use 
transform=\"scale(0.707)\" xlink:href=\"#E1-MJMAIN-32\" x=\"1067\" 
y=\"-444\"></use>\n <use xlink:href=\"#E1-MJMAIN-4F\" x=\"1212\" 
y=\"0\"></use>\n</g>\n</svg>",
                     "mathoidStyle": "vertical-align: -1.005ex; width:4.634ex; 
height:2.843ex;",

-- 
To view, visit https://gerrit.wikimedia.org/r/331906
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a685c5c4a969d1228271b50ccd64671061297a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mathoid
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <w...@physikerwelt.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to