Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ wfLoadExtension( 'SimpleMathJax' );
| `$wgSmjCdnVersion` | `'4'` | MathJax version to load from the CDN | `'4.1.3'` |
| `$wgSmjScale` | `1` | `MathJax.chtml.scale` | `1.5` |
| `$wgSmjEnableMenu` | `true` | `MathJax.options.enableMenu` | `false` |
| `$wgSmjExplorerEnabled` | `false` | Whether to enable MathJax's accessibility explorer (click/keyboard exploration, speech, Braille) | `true` |
| `$wgSmjDelimitersEnabled` | `false` | Whether to also scan for bare delimiters (e.g. `$...$`) outside `<math>`/`<chem>` | `true` |
| `$wgSmjDelimitersInlineMath` | `[]` | Inline math delimiter pairs | `[['$','$']]` |
| `$wgSmjDelimitersDisplayMath` | `[]` | Display math delimiter pairs | `[['$$','$$']]` |
Expand Down
17 changes: 17 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and examples. Upgrading from before 1.0.0? See the
| `$wgSmjCdnVersion` | `'4'` | MathJax version to load from the CDN |
| `$wgSmjScale` | `1` | `MathJax.chtml.scale` |
| `$wgSmjEnableMenu` | `true` | `MathJax.options.enableMenu` |
| `$wgSmjExplorerEnabled` | `false` | Whether to enable MathJax's accessibility explorer (click/keyboard exploration, speech, Braille) |
| `$wgSmjDelimitersEnabled` | `false` | Whether to also scan for bare delimiters (e.g. `$...$`) outside `<math>`/`<chem>` |
| `$wgSmjDelimitersInlineMath` | `[]` | Inline math delimiter pairs, e.g. `[['$','$']]` |
| `$wgSmjDelimitersDisplayMath` | `[]` | Display math delimiter pairs, e.g. `[['$$','$$']]` |
Expand Down Expand Up @@ -80,6 +81,22 @@ wfLoadExtension( 'SimpleMathJax' );
$wgSmjEnableMenu = false;
```

### `$wgSmjExplorerEnabled`

MathJax 4 enriches each formula with semantic information for its
accessibility explorer. With it on, clicking a formula selects and
highlights a symbol, arrow keys move through the expression, and screen
readers get spoken and Braille output. SimpleMathJax turns this off by
default so a click does not select part of a formula. Readers can still
enable it per browser from the MathJax menu (right-click, Accessibility).

To enable it for everyone:

```php
wfLoadExtension( 'SimpleMathJax' );
$wgSmjExplorerEnabled = true;
```

### `$wgSmjDelimitersEnabled`

By default, `$wgSmjDelimitersEnabled` is `false`, so only TeX wrapped in
Expand Down
4 changes: 4 additions & 0 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
"value": true,
"description": "Whether to enable MathJax context menu"
},
"SmjExplorerEnabled": {
"value": false,
"description": "Whether to enable MathJax's accessibility explorer (semantic enrichment: click/keyboard exploration with highlighting, speech and Braille)"
},
"SmjAllowedAttributes": {
"value": [],
"description": "Generic HTML attributes to carry over from <math>/<chem> to the output <span>"
Expand Down
5 changes: 3 additions & 2 deletions includes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Hooks {
private static string $ignoreHtmlClass = '';

public static function onParserFirstCallInit( Parser $parser ) {
global $wgOut, $wgSmjCdnEnabled, $wgSmjCdnVersion, $wgSmjEnableMenu,
global $wgOut, $wgSmjCdnEnabled, $wgSmjCdnVersion, $wgSmjEnableMenu, $wgSmjExplorerEnabled,
$wgSmjDelimitersEnabled, $wgSmjDelimitersInlineMath, $wgSmjDelimitersDisplayMath,
$wgSmjIgnoreHtmlClass, $wgSmjScale,
$wgSmjAllowedAttributes, $wgSmjRevisionOverrides;
Expand All @@ -30,6 +30,7 @@ public static function onParserFirstCallInit( Parser $parser ) {
"wgSmjIgnoreHtmlClass" => $wgSmjIgnoreHtmlClass,
"wgSmjScale" => $wgSmjScale,
"wgSmjEnableMenu" => $wgSmjEnableMenu,
"wgSmjExplorerEnabled" => $wgSmjExplorerEnabled,
"wgSmjAllowedAttributes" => $wgSmjAllowedAttributes,
];

Expand All @@ -38,7 +39,7 @@ public static function onParserFirstCallInit( Parser $parser ) {

$clientConfigVars = [ "wgSmjCdnEnabled", "wgSmjCdnVersion",
"wgSmjDelimitersEnabled", "wgSmjDelimitersInlineMath", "wgSmjDelimitersDisplayMath",
"wgSmjIgnoreHtmlClass", "wgSmjScale", "wgSmjEnableMenu" ];
"wgSmjIgnoreHtmlClass", "wgSmjScale", "wgSmjEnableMenu", "wgSmjExplorerEnabled" ];
foreach ( $clientConfigVars as $varname ) {
$wgOut->addJsConfigVars( $varname, $config[$varname] );
}
Expand Down
12 changes: 10 additions & 2 deletions resources/ext.SimpleMathJax.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ var defaults = {
wgSmjDelimitersInlineMath: [],
wgSmjDelimitersDisplayMath: [],
wgSmjIgnoreHtmlClass: 'mathjax_ignore|comment|diff-(context|addedline|deletedline)',
wgSmjScale: 1
wgSmjScale: 1,
wgSmjExplorerEnabled: false
};

function config(name) {
Expand Down Expand Up @@ -144,7 +145,14 @@ function ensureLoaded() {
},
options: {
ignoreHtmlClass: config('wgSmjIgnoreHtmlClass'),
processHtmlClass: "mathjax_process|smj-container"
processHtmlClass: "mathjax_process|smj-container",
// Semantic enrichment drives MathJax 4's explorer: a click selects and
// highlights a symbol. Readers can still turn it on from the menu.
menuOptions: {
settings: {
enrich: config('wgSmjExplorerEnabled')
}
}
},
chtml: {
scale: config('wgSmjScale'),
Expand Down
Loading