Skip to content

Commit 14947d8

Browse files
committed
Update to include v4.1 options, accessibility changes, and other fixes
1 parent 678bf1d commit 14947d8

File tree

9 files changed

+153
-44
lines changed

9 files changed

+153
-44
lines changed

advanced/model.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ processors are called `jax`, and are described in more detail
2020
below.
2121

2222
When MathJax runs, it looks through the page for special markers that
23-
delimit/indicate mathematics; for each such marker, it locates an
24-
appropriate input jax, which it uses to convert the mathematics into
25-
an internal form (a MathML tree as javascript objects), and then calls
26-
an output jax to transform the internal format into HTML content that
27-
displays the mathematics within the page. The page author configures
28-
MathJax by indicating which input and output jax are to be used, and
29-
which extensions should be included.
23+
indicate mathematics; for each such marker, it locates an appropriate
24+
input jax, which it uses to convert the mathematics into an internal
25+
form (a MathML tree as javascript objects), and then calls an output
26+
jax to transform the internal format into HTML content that displays
27+
the mathematics within the page. The page author configures MathJax
28+
by indicating which input and output jax are to be used, and which
29+
extensions should be included.
3030

3131
While MathML notation is an XML format that consists of tags like
3232
those that make up the HTML language, it is not a format that is easy

basic/accessibility.rst

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,24 @@ browser/os/screen-reader combinations to ensure that the user
6868
experience is an seamless as possible.
6969

7070
In version 4, the extensions for generating speech and exploring
71-
expressions are included an enabled in all the :ref:`combined
71+
expressions are included and enabled in all the :ref:`combined
7272
components <combined-components>` so that your pages should be
7373
accessible to users with screen or Braille readers automatically in
7474
that case. (In version 3, the user had to activate the accessibility
7575
features to turn them on.)
7676

77+
.. note::
78+
79+
Support for tactile Braille output devices varies across screen
80+
readers, operative systems, and browsers. Users of Braille output
81+
devices may need to select the "Combine with Speech" option in the
82+
MathJax contextual menu's Braille submenu in order to obtain Nemeth
83+
or Euro Braille output rather than the speech text on their Braille
84+
device (this can also be accomplished by pressing the |bkey| b
85+
|ekey| key while exploring an expression interactively). NVDA
86+
users in Windows will want to do this, though JAWS users should be
87+
fine with the default settings.
88+
7789
If you are making a custom configuration, you can include ``ui/menu``
7890
to enable the contextual menu, or you can include any of the
7991
:ref:`a11y extensions <accessibility-components>` explicitly. In
@@ -90,8 +102,8 @@ configure the extensions.
90102
in the combined components. That is no longer the case in v4,
91103
which now uses the speech and explorer components instead. Users
92104
can still use the MathJax contextual menu to turn on the hidden
93-
MathML and turn off the semantic enrichment that underlies the
94-
speech and explorer components if they want to have a similar
105+
MathML, which will turn off the speech and Braille generation that
106+
underlies the explorer component, if they want to have a similar
95107
experience to the one from v3.
96108

97109

@@ -104,16 +116,19 @@ Screen reader support in Mathjax v3 was based on the
104116
:ref:`assistive-mml-component` component, which embedded a MathML
105117
representation of each expression that was visually hidden, but
106118
available to screen readers, in addition to its typeset version that
107-
was visible for sighted users, but hidden from screen readers.
108-
The quality of MathML support in screenreaders varies greatly, with
119+
was visible for sighted users, but hidden from screen readers. The
120+
quality of MathML support in screenreaders varies greatly, with
109121
different levels of MathML feature support, different speech rule
110122
sets, and different voicing technologies.
111123

112-
This approach only worked with those screen readers that understand
113-
MathML, and even then, the experience was different depending on the
114-
screen reader and browser that was being used. As screen-reader and
115-
browser versions changed, they sometimes failed to work properly with
116-
the hidden MathML, and it was difficult to maintain this feature.
124+
Using hidden MAthML only worked with those screen readers that
125+
understand MathML, and even then, the experience was different
126+
depending on the screen reader and browser that was being used. As
127+
screen-reader and browser versions changed, they sometimes failed to
128+
work properly with the hidden MathML; for example, some screen readers
129+
skip the math entirely when reading the page as a whole, even when
130+
they voice the math while stepping through the page in smaller units.
131+
This makes it difficult to maintain this feature.
117132

118133
In version 4, screen reader support is now being handled through the
119134
:ref:`explorer-component` and :ref:`speech-component` components of

basic/explorer-commands.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ Advanced Keys
106106
without a screen reader. This mode remains in effect until turned
107107
off. It can also be controlled via the MathJax contextual menu.
108108

109+
|bkey| B |ekey|
110+
Toggle the "Combine with Speech" menu item, which tells MathJax
111+
whether to include the Braille rendering within the
112+
:attr:`aria-label` attribute along with the speech text or whether
113+
to put it in the :attr:`aria-braillelabel` attribute. See the
114+
notes below.
115+
109116
|bkey| D |ekey|
110117
Get positional information; i.e., the current level in the
111118
sub-expression tree as well as collapsibility/expandability of the
@@ -179,4 +186,17 @@ manually when you are done exploring the expression. How that is done
179186
depends on the screen reader, so consult the reader's documentation
180187
for details on how to accomplish that.
181188

189+
For users of tactile Braille devices, MathJax handles the Braille
190+
notation using the :attr:`aria-braillelabel` attribute (part of the
191+
ARIA specification), but not all screen readers process this attribute
192+
properly. To help accommodate this limitation, MathJax provides an
193+
option that will put the Braille into the :attr:`aria-label` attribute
194+
instead, along with the generated speech, as some screen readers will
195+
pass the Braille on to the Braille device that way. NVDA users will
196+
want to enable this feature, for example.
197+
198+
This feature can be enabled by selecting the "Combine with Speech"
199+
item in the Braille submenu of the MathJax contextual menu, or by
200+
pressing the |bkey| b |ekey| key while exploring an expression.
201+
182202
|-----|

options/accessibility.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ The Configuration Block
341341
MathJax = {
342342
options: {
343343
enableExplorer: true, // set to false to disable the explorer
344+
enableExplorerHelp: true, // set to false to disable the help icon and dialog
344345
a11y: {
345346
speech: true, // switch on speech output
346347
braille: true, // switch on Braille output
@@ -388,6 +389,20 @@ Option Descriptions
388389
`explorer` component has been loaded automatically and you don't
389390
need it.
390391

392+
.. _explorer-enableExplorerHelp:
393+
.. describe:: enableExplorerHelp: true
394+
395+
This controls whether the small "info" icon is displayed at the
396+
upper right-hand corner of an expression when it is focused.
397+
Setting it to ``false`` will prevent the icon from appearing, will
398+
disable the "press H for help" message from being spoken when an
399+
expression is first focused, and disables the help dialog when the
400+
"h" key is pressed during expression exploration. This means that
401+
users of assistive technology will be unable to obtain help on how
402+
to use MathJax's assistive features, so you should not set this to
403+
``false`` if your pages may be viewed by users with accessibility
404+
needs.
405+
391406
The :data:`a11y` options are all controlled by the MathJax contextual
392407
menu, when the menu component is present, so you should use the
393408
corresponding menu options to set these values in that case. If the

options/output/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ The options are given here with their default values.
5555
},
5656
font: '', // the font component to load
5757
fontPath: FONTPATH, // The path to the font definitions
58+
fontExtensions: [], // The font extensions to load
5859
htmlHDW: 'auto', // 'use', 'force', or 'ignore' data-mjx-hdw attributes
5960
preFilters: [], // A list of pre-filters to add to the output jax
6061
postFilters: [], // A list of post-filters to add to the output jax
@@ -284,6 +285,13 @@ Option Descriptions
284285
in node applications. Any occurrences of ``%%FONT%%`` in the path
285286
will be replaced by the font name when the font is accessed.
286287

288+
.. _output-fontExtensions:
289+
.. describe:: fontExtensions: []
290+
291+
This gives a list of font extensions to load when the output jax is
292+
loaded. For example, setting this to ``['mathjax-euler']`` would
293+
load the euler font extension.
294+
287295
.. _output-htmlHDW:
288296
.. describe:: htmlHDW: 'auto'
289297

options/startup/loader.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ In the example below, :data:`Loader` represents the
2727
failed: function (error) { // function to call if a component fails to load
2828
console.log(`MathJax(${error.package || '?'}): ${error.message}`);
2929
},
30-
paths: {mathjax: Loader.getRoot()}, // the path prefixes for use in specifying components
30+
paths: { // the path prefixes for use in specifying components
31+
mathjax: Loader.getRoot(),
32+
fonts: (typeof window === 'undefined'
33+
? '@mathjax'
34+
: 'https:cdn.jsdelivr.net/npm/@mathjax')
35+
},
3136
source: {}, // the URLs for components, when defaults aren't right
3237
dependencies: {}, // arrays of dependencies for each component
3338
provides: {}, // components provided by each component
@@ -75,7 +80,7 @@ Option Descriptions
7580
section below for how to trap individual component errors.
7681

7782
.. _loader-paths:
78-
.. describe:: paths: {mathjax: Loader.getRoot()}
83+
.. describe:: paths: {mathjax: Loader.getRoot(), fonts: ...}
7984

8085
This object links path prefixes to their actual locations. By
8186
default, the ``mathjax`` prefix is predefined to be the location
@@ -85,11 +90,22 @@ Option Descriptions
8590
prefix. For example, ``input/tex`` will become
8691
``[mathjax]/input/jax`` automatically.
8792

93+
The ``fonts`` path is predefined to point to the location where
94+
MathJax will load fonts. For node applications, it is set to
95+
``@mathjax`` so that fonts are taken from the
96+
``node_modules/@mathjax`` directory. For web applications, it is
97+
set to ``https://cdn.jsdelivr.net/npm/@mathjax`` so that fonts are
98+
loaded from that CDN.
99+
88100
When the TeX :ref:`tex-require` extension is loaded, an additional
89101
``tex`` path is created in order to be able to load the various TeX
90-
extensions.
102+
extensions. Other paths that may be predefined include ``sre`` and
103+
``mathmaps`` for the locations of the speech-rule-engine files,
104+
``mml`` for MathML extensions, and font-specific paths like
105+
``mathjax-newcm`` for the locations of the files needed by the
106+
fonts.
91107

92-
You can define your own prefixes, for example,
108+
You can define your own prefixes; for example,
93109

94110
.. code-block:: javascript
95111
@@ -100,10 +116,10 @@ Option Descriptions
100116
}
101117
};
102118
103-
which defines a ``custom`` prefix that you can used to access
104-
custom extensions. The URL can even be to a different server than
105-
where you loaded the main MathJax code, so you can host your own
106-
custom extensions and still use a CDN for the main MathJax code.
119+
defines a ``custom`` prefix that you can used to access custom
120+
extensions. The URL can even be to a different server than where
121+
you loaded the main MathJax code, so you can host your own custom
122+
extensions and still use a CDN for the main MathJax code.
107123

108124
You can define as many different paths as you need. Note that
109125
paths can refer to other paths, so you could do

options/startup/startup.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ In the example below, :data:`Startup` represents the
3232
input: [], // The names of the input jax to use from among those loaded
3333
output: null, // The name for the output jax to use from among those loaded
3434
handler: null, // The name of the handler to register from among those loaded
35-
adaptor: null // The name for the DOM adaptor to use from among those loaded
35+
adaptor: null, // The name for the DOM adaptor to use from among those loaded
36+
polyfillHasOwn: true, // True if a polyfill for Object.hasOwn should be used when
37+
// it is not available natively
3638
}
3739
};
3840
@@ -149,4 +151,14 @@ Option Descriptions
149151
do, it will set this value so that it will be used automatically.
150152
There are several other DOM adaptors for use in `node`, as well.
151153

154+
.. _startup-polyfillHasOwn:
155+
.. describe:: polyfillHasOwn: true
156+
157+
This indicates whether MathJax should provide a polyfill for the
158+
:meth:`Object.hasOwn()` method when it is not available natively in
159+
the browser. It is defined in all modern browsers, but some
160+
browsers that are several years old may not have an implementation
161+
for it, so MathJax will provide one when needed unless this option
162+
is set to ``false``.
163+
152164
|-----|

output/fonts.rst

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,50 @@ font via
6464
6565
npm install @mathjax/mathjax-stix2-font
6666
67-
(add ``-font`` to the name of whichever font you want, and obtain it
68-
from the ``@mathjax`` scope); MathJax should find the font in your
69-
:file:`node_modules/@mathjax` folder. It is also possible to
70-
configure the path to the fonts using the :data:`fontPath` option of
71-
the :data:`output` block. This should be set to a string that
72-
indicates where the font can be found; that string should include
73-
``%%FONT%%`` in any part of the path where the font name needs to
74-
appear. For example,
67+
(add ``-font`` to the name of whichever font you want, or
68+
``-font-extension`` for a font extension, and obtain it from the
69+
``@mathjax`` scope); MathJax should find the font in your
70+
:file:`node_modules/@mathjax` folder.
71+
72+
By default, MathJax components use the predefined ``fonts`` path to
73+
locate the fonts. That is, when the font is specified as
74+
``mathjax-stix2``, for example, MathJax will use
75+
``[fonts]/mathjax-stix2-font`` as the path to the font. This path is
76+
set to ``https://cdn.jsdelivr.net/npm/@mathjax`` for web applications
77+
and ``@mathjax`` for node applications. If you host your own copy of
78+
MathJax and its fonts, you can set this path to the location where the
79+
fonts are stored. For example,
80+
81+
.. code-block:: javascript
82+
83+
MathJax = {
84+
loader: {
85+
paths: {
86+
font: '/mathjax-fonts',
87+
}
88+
};
89+
90+
would tell MathJax to obtain fonts from the top-level
91+
``mathjax-fonts`` directory on the server where web page came from.
92+
93+
It is also possible to configure the path to the fonts using the
94+
:data:`fontPath` option of the :data:`output` block. This should be
95+
set to a string that indicates where the font can be found; that
96+
string should include ``%%FONT%%`` in any part of the path where the
97+
font name needs to appear. For example,
7598
7699
.. code-block:: javascript
77100
78101
MathJax = {
79102
output: {
80-
fontPath: '@mathjax/%%FONT%%-font'
103+
fontPath: '[fonts]/%%FONT%%-font'
81104
}
82105
};
83106
84-
is the default path in node applications.
107+
is the default path for MathJax components.
85108
86-
It is also possible to specify an explicit URL as the font name in the
87-
configuration:
109+
Finally, you can specify an explicit URL to a font as the font name in
110+
the configuration:
88111
89112
.. code-block:: javascript
90113
@@ -144,15 +167,15 @@ a separate *pseudo-variant* used internally by MathJax, so are
144167
available only through the macros provided by the corresponding TeX
145168
extension.
146169
147-
For ``mathjax-euler``, configure MathJax to load the given extension.
148-
For example,
170+
For ``mathjax-euler``, configure MathJax to load the given extension
171+
using the :data:`fontExtensions` array of the :data:`output` block of
172+
your configuration. For example,
149173
150174
.. code-block:: javascript
151175
152176
MathJax = {
153-
loader: {
154-
paths: {font: 'https://cdn.jsdelivr.net/npm/@mathjax'},
155-
load: ['[font]/mathjax-euler-font']
177+
output: {
178+
fontExtensions: ['mathjax-euler']
156179
}
157180
};
158181

upgrading/earlier/whats-new-2.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ recommended).
2626

2727

2828
Reduced flickering during typesetting
29-
====================================
29+
=====================================
3030

3131
In the past, each expression was displayed as soon as it was typeset,
3232
which caused a lot of visual flickering as MathJax processed the page.

0 commit comments

Comments
 (0)