Skip to content

Commit 21ef765

Browse files
committed
[main] enable css output without html output
Resolves #292
1 parent 9b4ef93 commit 21ef765

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

lib/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ function GetSpeech(result) {
563563
// Create HTML and CSS output, if requested
564564
//
565565
function GetHTML(result) {
566+
if (data.css) result.css = CHTMLSTYLES;
566567
if (!data.html && !data.htmlNode) return;
567568
var jax = MathJax.Hub.getAllJax()[0]; if (!jax) return;
568569
var script = jax.SourceElement(), html = script.previousSibling;
@@ -591,7 +592,6 @@ function GetHTML(result) {
591592
}
592593
if (data.html) result.html = html.outerHTML;
593594
if (data.htmlNode) result.htmlNode = html;
594-
if (data.css) result.css = CHTMLSTYLES;
595595
}
596596

597597
//
@@ -684,7 +684,7 @@ function StartQueue() {
684684
//
685685
GetState(data.state);
686686

687-
var renderer = ( (data.html || data.htmlNode) ? "CommonHTML" : "SVG");
687+
var renderer = ( (data.html || data.htmlNode || data.css) ? "CommonHTML" : "SVG");
688688

689689
//
690690
// Set up a timeout timer to restart MathJax if it runs too long,
@@ -784,7 +784,7 @@ function SetRenderer(renderer) {
784784
}
785785

786786
function RerenderSVG(result) {
787-
if ((data.html || data.htmlNode ) && (data.svg || data.svgNode)) {
787+
if ((data.html || data.htmlNode || data.css) && (data.svg || data.svgNode)) {
788788
timer = setTimeout(RestartMathJax,data.timeout);
789789
var queue = MathJax.Callback.Queue(), $$ = window.Array;
790790
return queue.Push(

test/css.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var tape = require('tape');
2+
var mjAPI = require("../lib/main.js");
3+
4+
tape('CSS output', function(t) {
5+
t.plan(2);
6+
mjAPI.start();
7+
var tex = 'x';
8+
mjAPI.typeset({
9+
math: tex,
10+
format: "TeX",
11+
css: true
12+
}, function(data) {
13+
t.ok(data.css, 'css output while no other output');
14+
});
15+
mjAPI.typeset({
16+
math: tex,
17+
format: "TeX",
18+
css: true,
19+
svg: true
20+
}, function(data) {
21+
t.ok(data.css, 'css output with SVG output');
22+
});
23+
});

0 commit comments

Comments
 (0)