From b0a13b7217c69bac34bd0568f9518842a957daaa Mon Sep 17 00:00:00 2001 From: physikerwelt Date: Mon, 15 Feb 2016 22:13:37 +0100 Subject: [PATCH] Add svg dimensions to the mml endpoing * This informatino is not strictly required, but used by the math extension. Change-Id: If6bfbe7611f2292f7df56185f6bb6ea7fa86a559 --- package.json | 2 +- routes/mathoid.js | 6 +++++- test/features/math/no-check.js | 9 +++++++++ test/features/math/simple.js | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 44c9b3542..09dfafbca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mathoid", - "version": "0.4.1", + "version": "0.4.2", "description": "Render TeX to SVG and MathML using MathJax. Based on svgtex.", "main": "./app.js", "scripts": { diff --git a/routes/mathoid.js b/routes/mathoid.js index b4141a139..9082237ac 100644 --- a/routes/mathoid.js +++ b/routes/mathoid.js @@ -55,8 +55,8 @@ function handleRequest(res, q, type, outFormat, features) { var svg = app.conf.svg && /^svg|json|complete$/.test(outFormat); var mml = (type !== "MathML") && /^mml|json|complete$/.test(outFormat); var png = app.conf.png && /^png|json|complete$/.test(outFormat); - var img = app.conf.img && /^json|complete$/.test(outFormat); var info = app.conf.texvcinfo && /^graph|texvcinfo$/.test(outFormat); + var img = app.conf.img && /^mml|json|complete$/.test(outFormat); var speech = (outFormat !== "png") && features.speech || outFormat === "speech"; var chem = type === "chem"; @@ -125,6 +125,10 @@ function handleRequest(res, q, type, outFormat, features) { }); res.json(data).end(); break; + case 'mml': + res.set(Object.assign({}, outHeaders.mml, {'x-mathoid-style': data.mathoidStyle})); + res.send(data.mml).end(); + break; default: res.set(outHeaders[outFormat]); res.send(data[outFormat]).end(); diff --git a/test/features/math/no-check.js b/test/features/math/no-check.js index 38e9bfa59..7f75250e4 100644 --- a/test/features/math/no-check.js +++ b/test/features/math/no-check.js @@ -258,6 +258,15 @@ describe('Mathoid API tests with no_check option', function () { assert.deepEqual(res.body, "upper E equals m c squared"); }); }); + it("get svg dimensions in mathml headers", function () { + return preq.post({ + uri: baseURL + "mml", + body: {q: "E=mc^2"} + }).then(function (res) { + assert.status(res, 200); + assert.deepEqual(res.headers['x-mathoid-style'], 'vertical-align: -0.338ex; width:9.025ex; height:2.676ex;'); + }); + }); }); }); diff --git a/test/features/math/simple.js b/test/features/math/simple.js index a49ef33ae..c18acc012 100644 --- a/test/features/math/simple.js +++ b/test/features/math/simple.js @@ -304,6 +304,15 @@ describe('Simple Mathoid API tests', function () { assert.deepEqual(res.body, "upper E equals m c squared"); }); }); + it("get svg dimensions in mathml headers", function () { + return preq.post({ + uri: baseURL + "mml", + body: {q: "E=mc^2"} + }).then(function (res) { + assert.status(res, 200); + assert.deepEqual(res.headers['x-mathoid-style'], 'vertical-align: -0.338ex; width:9.025ex; height:2.676ex;'); + }); + }); }); });