Add some MathJax checks and AMSmath support

Former-commit-id: 0aa283e8a81ccef805a5291ce542fadcd046cf5b [formerly 8035fadee8e63ab5cc921bbdc36305b0f10bffd8]
Former-commit-id: a9c67045928e431a5b849de4c68ce589c8069564
This commit is contained in:
Jaifroid 2017-08-07 13:43:16 +01:00
parent 3a2b534399
commit f8917dec6d
6 changed files with 35 additions and 39 deletions

View File

@ -21,6 +21,6 @@
<WindowsPhoneEmulatorID>F0AB49D8-754C-4531-A635-E6B4395FD39A;Mobile Emulator 10.0.15063.0 QHD 5.2 inch 3GB</WindowsPhoneEmulatorID>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebuggerFlavor>AppHostDeviceDebugger</DebuggerFlavor>
<DebuggerFlavor>AppHostLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@ -32,7 +32,7 @@
<AppXManifest Include="C:\Users\geoff\Source\Repos\kiwix-js-windows\bin\Release\AppxManifest.xml">
<PackagePath>AppxManifest.xml</PackagePath>
<ReRegisterAppIfChanged>true</ReRegisterAppIfChanged>
<Modified>2017-08-07T05:59:43.248</Modified>
<Modified>2017-08-07T07:17:46.496</Modified>
</AppXManifest>
</ItemGroup>
<ItemGroup>
@ -531,7 +531,7 @@
</AppxPackagedFile>
<AppxPackagedFile Include="C:\Users\geoff\Source\Repos\kiwix-js-windows\www\js\app.js">
<PackagePath>www\js\app.js</PackagePath>
<Modified>2017-08-07T05:50:10.176</Modified>
<Modified>2017-08-07T06:45:19.435</Modified>
</AppxPackagedFile>
<AppxPackagedFile Include="C:\Users\geoff\Source\Repos\kiwix-js-windows\www\js\init.js">
<PackagePath>www\js\init.js</PackagePath>
@ -603,7 +603,7 @@
</AppxPackagedFile>
<AppxPackagedFile Include="C:\Users\geoff\Source\Repos\kiwix-js-windows\www\js\MathJax\config\config.js">
<PackagePath>www\js\MathJax\config\config.js</PackagePath>
<Modified>2017-08-05T18:18:34.635</Modified>
<Modified>2017-08-07T07:17:27.329</Modified>
</AppxPackagedFile>
<AppxPackagedFile Include="C:\Users\geoff\Source\Repos\kiwix-js-windows\www\js\MathJax\extensions\a11y\accessibility-menu.js">
<PackagePath>www\js\MathJax\extensions\a11y\accessibility-menu.js</PackagePath>
@ -1456,7 +1456,7 @@
<AppxPackagedFile Include="C:\Users\geoff\Source\Repos\kiwix-js-windows\bin\Release\ReverseMap\resources.pri">
<PackagePath>resources.pri</PackagePath>
<ReRegisterAppIfChanged>true</ReRegisterAppIfChanged>
<Modified>2017-08-07T05:58:16.299</Modified>
<Modified>2017-08-07T06:40:52.194</Modified>
</AppxPackagedFile>
</ItemGroup>
<ItemGroup>

View File

@ -1,6 +1,9 @@
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
TeX: {
extensions: ["AMSmath.js", "AMSsymbols.js"]
},
"HTML-CSS": {
availableFonts: ["TeX"],
imageFont: null
@ -10,10 +13,4 @@ MathJax.Hub.Config({
showFontMenu: false,
showLocale: false
}
});
function Typeset(element) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, element]);
}
function Configured() {
MathJax.Hub.Configured();
}
});

View File

@ -1320,25 +1320,27 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
//TESTING
if (countImages <= maxVisibleSliceSize + prefetchSliceSize) { console.timeEnd("Time to Document Ready"); }
//Use the MathJax method of typesetting formulae if user has requested this
if (params['useMathJax']) {
var counter = 0;
$(svgSlice).each(function () {
var node = this;
if (/mwe-math-fallback-image/i.test(node.className) && node.alt) {
var text = node.alt;
var script = document.createElement("script");
script.type = "math/tex";
script.text = text;
$(this).replaceWith(script);
console.log("Typesetting image #" + countImages + "...");
countImages++;
svgSlice.splice(counter, 1);
} else {
counter++;
}
});
window.frames[0].MathJax.Hub.Queue(["Typeset", window.frames[0].MathJax.Hub]);
if (svgSlice.length) {
//Use the MathJax method of typesetting formulae if user has requested this
if (params['useMathJax'] && window.frames[0].MathJax) {
var counter = 0;
$(svgSlice).each(function () {
var node = this;
if (/mwe-math-fallback-image/i.test(node.className) && node.alt) {
var text = node.alt;
var script = document.createElement("script");
script.type = "math/tex";
script.text = text;
$(this).replaceWith(script);
console.log("Typesetting image #" + countImages + "...");
countImages++;
svgSlice.splice(counter, 1);
} else {
counter++;
}
});
window.frames[0].MathJax.Hub.Queue(["Typeset", window.frames[0].MathJax.Hub]);
}
}
//If there are any SVGs left which were not dealt with by MathJax, process fallback images
if (svgSlice.length) {

View File

@ -1,6 +1,9 @@
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX", "output/HTML-CSS"],
TeX: {
extensions: ["AMSmath.js", "AMSsymbols.js"]
},
"HTML-CSS": {
availableFonts: ["TeX"],
imageFont: null
@ -10,10 +13,4 @@ MathJax.Hub.Config({
showFontMenu: false,
showLocale: false
}
});
function Typeset(element) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, element]);
}
function Configured() {
MathJax.Hub.Configured();
}
});

View File

@ -1322,7 +1322,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
if (svgSlice.length) {
//Use the MathJax method of typesetting formulae if user has requested this
if (params['useMathJax']) {
if (params['useMathJax'] && window.frames[0].MathJax) {
var counter = 0;
$(svgSlice).each(function () {
var node = this;