SasView / sasview

Code for the SasView application.
BSD 3-Clause "New" or "Revised" License
51 stars 41 forks source link

Math not rendered without network connection (Windows) (Trac #639) #771

Open ajj opened 5 years ago

ajj commented 5 years ago

Testing on Windows 7, a lack of network connection means that the math in the documentation does not get rendered.

On the Mac, it is still being rendered even without a network connection.

I thought that mathjax was being bundled, so this should be working.

Migrated from http://trac.sasview.org/ticket/639

{
    "status": "assigned",
    "changetime": "2017-10-26T12:37:01",
    "_ts": "2017-10-26 12:37:01.721958+00:00",
    "description": "Testing on Windows 7, a lack of network connection means that the math in the documentation does not get rendered.\n\nOn the Mac, it is still being rendered even without a network connection.\n\nI thought that mathjax was being bundled, so this should be working.",
    "reporter": "ajj",
    "cc": "",
    "resolution": "",
    "workpackage": "SasView Bug Fixing",
    "time": "2016-08-30T15:07:39",
    "component": "SasView",
    "summary": "Math not rendered without network connection (Windows)",
    "priority": "critical",
    "keywords": "",
    "milestone": "SasView 4.3.0",
    "owner": "ajj",
    "type": "defect"
}
butlerpd commented 5 years ago

Trac update at 2016/09/05 14:43:22: butler changed priority from "major" to "critical"

butlerpd commented 5 years ago

Trac update at 2016/09/05 14:43:55:

pkienzle commented 5 years ago

Trac update at 2016/09/07 12:53:51:

!MathJax can be shipped with !SasView.

We need to add _static/MathJax to the doc tree, with the following files from the !MathJax distribution (776 kB):

{{{ MathJax.js config/TeX-AMS-MML_HTMLorMML-full.js fonts/HTML-CSS/TeX/woff/ jax/output/HTML-CSS/fonts/TeX/ }}}

The html header needs the following: {{{

</script>
<script type="text/javascript" src="../../_static/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"></script>

}}}

to:

1473255409788826

!MathJax can be shipped with !SasView.

We need to add _static/MathJax to the doc tree, with the following files from the !MathJax distribution (776 kB):

{{{ MathJax.js config/TeX-AMS-MML_HTMLorMML-full.js fonts/HTML-CSS/TeX/woff/ jax/output/HTML-CSS/fonts/TeX/ }}}

The html header needs the following: {{{

</script>
<script type="text/javascript" src="../../_static/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"></script>

}}}

We might be able to accomplish this by updating sphinx conf.py with:

{{{ mathjax_path="MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full&delayStartupUntil=configured" }}}

and adding _templates/layout.html with: {{{ {% extends "!layout.html" %}

{%- block extrahead %}

{% endblock %} }}}

to:

1473255885801011

!MathJax can be shipped with !SasView.

We need to add _static/MathJax to the doc tree, with the following files from the !MathJax distribution (776 kB):

    MathJax.js
    config/TeX-AMS-MML_HTMLorMML-full.js
    fonts/HTML-CSS/TeX/woff/*
    jax/output/HTML-CSS/fonts/TeX/*

The html header needs the following:

    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      "HTML-CSS": {
        //undefinedFamily: ["STIXGeneral, 'Arial Unicode MS', serif"],
        preferredFont: "TeX",
        availableFonts: ["TeX"],
        webFont: "TeX",
        imageFont: null
      }
    });
    </script>
    </script>
    <script type="text/javascript" src="../../_static/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"></script>

We might be able to accomplish this by updating sphinx conf.py with:

    mathjax_path="MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full&delayStartupUntil=configured"

and adding _templates/layout.html with:

{% extends "!layout.html" %}

{%- block extrahead %}
       <script type="text/javascript">
       MathJax.Hub.Config({
           // displayAlign: "left",
           // displayIndent: "2.5em",
           "HTML-CSS": {
             //undefinedFamily: ["STIXGeneral, 'Arial Unicode MS', serif"],
             preferredFont: "TeX",
             availableFonts: ["TeX"],
             webFont: "TeX",
             imageFont: null
           }
       });
       MathJax.Hub.Configured()
       </script>
{% endblock %}

There are a few options for including !MathJax with !SasView:

butlerpd commented 5 years ago

Trac update at 2016/09/13 14:26:06:

maybe best to move to 4.1? We could provide a PDF downladable somewhere?

rozyczko commented 5 years ago

Trac update at 2016/09/20 13:44:10:

This is slightly more convoluted. On my windows box I need to also add fonts/HTML-CSS/TeX/eot/*

Also, extensions/ is required if we want to enable right-click context menu, as in the online version. It is possible than on other machines/systems/OSes we need to add more subdirectories in fonts/*

Obviously adding everything is not an option, as uncompressed MathJax is 172MB.

to:

1474379141909554

This is slightly more convoluted. On my windows box I need to also add

fonts/HTML-CSS/TeX/eot/*

Also,

extensions/

is required if we want to enable right-click context menu, as in the online version. It is possible than on other machines/systems/OSes we need to add more subdirectories in fonts/*

Obviously adding everything is not an option, as uncompressed MathJax is 172MB.

ajj commented 5 years ago

Trac update at 2016/09/23 14:18:40: ajj commented:

https://github.com/mathjax/MathJax-grunt-cleaner/blob/master/Gruntfile.js

seems to be the "official" way to do this - clone the repo and run grunt. However, this is yet another lot of infrastructure.

If it is all local, we should probably just have a script to pull in the right bits and update occasionally as mathjax changes.

butlerpd commented 5 years ago

Trac update at 2016/09/27 14:35:20:

a bit annoying when no network is available but not a show stopper and needs a bit more care than 2 days before a release -- moving to 4.1

butlerpd commented 5 years ago

Trac update at 2016/10/11 17:36:22:

Didn't get addressed at code camp so moving to 4.2

RichardHeenan commented 5 years ago

Trac update at 2016/10/19 10:06:31: richardh commented:

19th Oct 2016, on my windows 7 desktop, the equations in the docu are rendering only slowly if at all. Before they do render a message pops up briefly at bottom on docu screen which says:

File failed to load: https://cdn.mathjax.org/mathjax/contrib/a11y/accessibility-menu.js

Is this a different issue to the above, or is it just flaky web access here?

Richard

ajj commented 5 years ago

Trac update at 2017/05/17 12:12:54: ajj commented:

From #1025 ...

Longer term, need to replace mathjax with katex, which is faster and smaller and easier to bundle with the application. This is closer to working on Qt than it is in wx.

butlerpd commented 5 years ago

Trac update at 2017/10/26 12:37:01: butler changed milestone from "SasView 4.2.0" to "SasView 4.3.0"

butlerpd commented 4 years ago

This issue remains but have not had much of a problem of late nor heard a lot of complaints. Is bundling Katex still something we want to do? I note that @ajj says it is easier in Qt so definitely a 5.x if we want to deal with it? will move it to 5.1 (and drop importance to minor) for now so we can decide what to do.

pkienzle commented 3 years ago

There is a katex package for sphinx, so this may be easy to do now.

You can bundle katex with the docs with fonts, min.css, and min.js for offline use (~2 MB). This may lead to longer load times (CDNs cache packages close to the user), but user privacy may improve (depending on how much tracking is done by CDNs).

The sphinx package has a pre-rendering option, but it doesn't buy us much: we still need the 1.5 MB of fonts and the 1/4 MB of javascript to render help for user defined models in exchange for slightly faster pages.