openlab-at-city-tech / webworkqa

WeBWorK integration for WordPress and BuddyPress
GNU General Public License v2.0
4 stars 2 forks source link

Allow MathJax font location to be filtered #189

Closed boonebgorges closed 3 years ago

boonebgorges commented 3 years ago

wordpress.org doesn't want us to load remote fonts, which means we're stuck packaging them. But the default TeX font used by MathJax is png-based, and it's enormous (~150MB). So I think we cannot ship it with the plugin. Instead, we'll have to use STIX or some smaller font. Then perhaps I can add some additional filters or whatever to allow for the specification of better fonts, which we'd ideally use on the OpenLab to mimic the current experience.

boonebgorges commented 3 years ago

This has now been built. The MathJax that ships with webworkqa is pared down so that only STIX is available out of the box. The MathJax file loader and config can be filtered. Here's how to make it work nicely with the CDN version:

add_filter(
    'webwork_mathjax_url',
    function( $url ) {
        return 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_HTMLorMML-full';
    }
);

add_filter(
    'webwork_mathjax_config',
    function( $config ) {
        $config['HTML-CSS']['webFont'] = 'TeX';
        return $config;
    }
);