Skip to content

Commit

Permalink
Merge pull request #374 from mathjax/develop
Browse files Browse the repository at this point in the history
1.3.0 release
  • Loading branch information
pkra authored Dec 29, 2017
2 parents b1618f8 + fd83f71 commit a30432f
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 266 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ node_js:
- '5'
- '6'
- '7'
- '8'
- '9'
- stable
sudo: false
script:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ The following are the default input options.
useGlobalCache: false, // use common <defs> for all equations?
linebreaks: false, // automatic linebreaking
equationNumbers: "none", // automatic equation numbering ("none", "AMS" or "all")
cjkCharWidth: 13, // width of CJK character

math: "", // the math string to typeset
format: "TeX", // the input format (TeX, inline-TeX, AsciiMath, or MathML)
Expand Down
8 changes: 7 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var fs = require('fs');
var path = require('path');
var url = require('url');
var jsdom = require('jsdom').jsdom;
var isFullwidthCodePoint = require('is-fullwidth-code-point');

require('./patch/jsdom.js').patch(jsdom); // Fix some bugs in jsdom

Expand All @@ -47,6 +48,7 @@ var defaults = {
useGlobalCache: false, // use common <defs> for all equations?
linebreaks: false, // do linebreaking?
equationNumbers: "none", // or "AMS" or "all"
cjkCharWidth: 13, // width of CJK character

math: "", // the math to typeset
format: "TeX", // the input format (TeX, inline-TeX, AsciiMath, or MathML)
Expand Down Expand Up @@ -309,7 +311,11 @@ function ConfigureMathJax() {
if (def["font-weight"] === "") delete def["font-weight"];
this.SUPER(arguments).Init.call(this,def);
SVG.addText(this.element,text);
var bbox = {width: text.length * 8.5, height: 18, y: -12};
// tweaking font fallback behavior: https://github.com/mathjax/MathJax-node/issues/299
var textWidth = text.split('')
.map(function(c) { return isFullwidthCodePoint(c.codePointAt()) ? data.cjkCharWidth : 8.5 })
.reduce(function(a, b) { return a + b }, 0);
var bbox = {width: textWidth, height: 18, y: -12};
scale *= 1000/SVG.em;
this.element.setAttribute("font-family","monospace");
this.element.setAttribute("transform","scale("+scale+") matrix(1 0 0 -1 0 0)");
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mathjax-node",
"version": "1.2.1",
"version": "1.3.0",
"description": "API's for calling MathJax from node.js",
"keywords": [
"MathJax",
Expand All @@ -23,8 +23,9 @@
"url": "git://github.com/mathjax/MathJax-node.git"
},
"dependencies": {
"is-fullwidth-code-point": "^2.0.0",
"jsdom": "7.0 - 9.12",
"mathjax": "*"
"mathjax": "^2.7.2"
},
"scripts": {
"test": "tape test/*.js"
Expand Down
116 changes: 0 additions & 116 deletions test-files/sample-mml.html

This file was deleted.

96 changes: 0 additions & 96 deletions test-files/sample-tex.html

This file was deleted.

12 changes: 0 additions & 12 deletions test-files/test-am.html

This file was deleted.

11 changes: 0 additions & 11 deletions test-files/test-mml.html

This file was deleted.

11 changes: 0 additions & 11 deletions test-files/test-mml2.html

This file was deleted.

11 changes: 0 additions & 11 deletions test-files/test-tex.html

This file was deleted.

6 changes: 0 additions & 6 deletions test-files/tex-filter.txt

This file was deleted.

17 changes: 17 additions & 0 deletions test/svg-full-width-chars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var tape = require('tape');
var mjAPI = require("../lib/main.js");

tape('the SVG output should renders full-width characters correctly', function(t) {
t.plan(1);

mjAPI.start();
var tex = '\\text{拾零}^i';

mjAPI.typeset({
math: tex,
format: "TeX",
svg: true
}, function(data) {
t.ok(data.width, '5.133ex', 'Width is correct');
});
});

0 comments on commit a30432f

Please sign in to comment.