mathjax / MathJax-node

MathJax for Node
Apache License 2.0
615 stars 97 forks source link

[CommonHTML] displayAlign:"left" not working #220

Closed pkra closed 8 years ago

pkra commented 8 years ago

Here's a test.

var tape = require('tape');
var mjAPI = require("..//lib/mj-single.js");
var jsdom = require('jsdom').jsdom;

tape('displayAlign:left', function(t) {
  t.plan(1);
  mjAPI.config({"displayAlign": "left"});
  mjAPI.start();
  var tex = 'x';
  var expected = "text-align: left;";

  mjAPI.typeset({
    math: tex,
    format: "TeX",
    html: true
  }, function(data) {
    var document = jsdom(data.html);
    console.log(data.html);
    var window = document.defaultView;
    var element = window.document.getElementsByClassName("MJXc-display")[0];
    var result = element.getAttribute('style');
    t.equal(result, expected);
  });
});
dpvc commented 8 years ago

There are two problems. The first is that the configuration is wrong. You need

  mjAPI.config({MathJax: {"displayAlign": "left"}});

in order to get add configuration for MathJax itself (rather than mathjax-node). But even if you do that, it won't work properly because of a bug in jsdom (actually the underlying CSSStyleDeclaration library). I have a patch and will submit that shortly.

dpvc commented 8 years ago

The issue220 branch should problem with width: auto that was preventing the displayAlign from working properly.