SVGorHTML output processors?

133 visualizzazioni
Passa al primo messaggio da leggere

Jason Grout

da leggere,
3 apr 2012, 09:27:5003/04/12
a MathJax Users
I like the new SVG renderer in 2.0. However, in the docs, it says that
the SVG processor doesn't work for IE versions < 9. Could there be an
TeX-AMS-MML_SVGorHTML config to prefer SVG when it is applicable, then
prefer HTML for IE < 9?

On the other hand, I could just prefer HTML for IE via the 'prefer'
parameter, but the docs only mention HTML and MML as possible options,
not SVG:
http://www.mathjax.org/docs/2.0/options/MMLorHTML.html#configure-mmlorhtml

Can I use SVG in the 'prefer' option?

Thanks,

Jason

Jason Grout

da leggere,
3 apr 2012, 10:05:1403/04/12
a mathja...@googlegroups.com

I just realized that the prefer config option is for the MMLorHTML
block, so of course it shouldn't support SVG.

So the first question still stands: can we have a TeX-AMS-MML_SVGorHTML
config that prefers SVG, but falls back to HTML when needed?

Thanks,

Jason


Davide P. Cervone

da leggere,
3 apr 2012, 20:00:4803/04/12
a mathja...@googlegroups.com
You are right, the prefer setting is just for the MMLorHTML
configuration. There isn't a corresponding one that chooses between
SVG and another output jax at the moment.

Before version 2.0 when there were just two input and two output jax,
the number of reasonable configurations were fairly small. But now
that there are three input and three output jax, the number of
possible combinations is much larger. We had tried to keep the number
of predefined configurations as small as possible by picking what we
thought were the most likely combinations and arranging for the
ability to modify that by in-line configuration. With the addition of
the AsciiMath input jax and the SVG output jax, it was no longer quite
so clear what the most important combinations should be. We still
didn't want to have too many predefined configurations, so I only
added a few using the new jax. I suppose the TeX-AMS-MML_SVG
configuration could be _SVGorHTML.

In any case, here is some configuration that will do the switch for you:

<script type="text/x-mathjax-config">
if (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 9) {
MathJax.Hub.Register.StartupHook("End Config",function () {
var settings = MathJax.Hub.config.menuSettings;
if (!settings.renderer) {settings.renderer = "HTML-CSS"}
});
}
</script>

This will select HTML-CSS for IE when not in IE9 standards mode (or
above), and when the user hasn't selected some other renderer by
hand. I think that is what you are after.

Davide

Jason Grout

da leggere,
3 apr 2012, 22:34:1903/04/12
a mathja...@googlegroups.com

Thanks! That seems to work well.

And I agree that an SVGorHTML config would be perfect, as it addresses
one of the main concerns with choosing the SVG renderer (which seems
superior in most respects to the HTML renderer).

Thanks,

Jason

Jason Grout

da leggere,
3 apr 2012, 22:56:5503/04/12
a mathja...@googlegroups.com
On 4/3/12 7:00 PM, Davide P. Cervone wrote:


Is there an easy way to detect if the browser is Android pre-SVG (I
think Android 2.x?)? MathJax.Hub.Browser.is* doesn't seem to cover
Android, at least not by the name Android, anyway.

Thanks,

Jason

Davide P. Cervone

da leggere,
4 apr 2012, 12:15:4904/04/12
a mathja...@googlegroups.com
> Is there an easy way to detect if the browser is Android pre-SVG (I
> think Android 2.x?)? MathJax.Hub.Browser.is* doesn't seem to cover
> Android, at least not by the name Android, anyway.

Javascript doesn't have direct access to the OS version number, but it
is often encoded in the navigator values somewhere. But note that
testing for Android 2.x isn't quite the right thing, since Firefox on
Android 2.x does handle SVG. It is really the renderer that needs to
be tested. One could do a feature test, except that the point when
you need to know that is before the document body is ready, and so you
can't use DOM inserts to figure out of SVG is supported.

Here is a navigator.appVersion test that probably will work for you:

<script type="text/x-mathjax-config">
(function () {
var HUB = MathJax.Hub, noSVG = false;
if (HUB.Browser.isMSIE && (document.documentMode||0) < 9) {noSVG =
true}
if (HUB.Browser.isSafari) {
var match = navigator.appVersion.match(/ Android ((\d+\.)+)/);
if (match && match[1].split(/\./)[0] < "3") {noSVG = true}
}
if (noSVG) {
HUB.Register.StartupHook("End Config",function () {
var settings = HUB.config.menuSettings;


if (!settings.renderer) {settings.renderer = "HTML-CSS"}
});
}

})();
</script>

I don't have an Android 3.0 device to test this on, but it does cause
my Android 2.3 browser to switch to HTML-CSS output, but Firefox still
uses SVG.

Davide

Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi