diff --git a/demo/sub/math.md b/demo/sub/math.md new file mode 100644 index 0000000..f8b1ca3 --- /dev/null +++ b/demo/sub/math.md @@ -0,0 +1,7 @@ +# MathJax Browser Check + +Inline equation: $ \sin^2x + \cos^2x = 1 $. + +Display equation: + +$$ \int_{-\infty}^\infty f(x) dx = 1 $$ diff --git a/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/ZOXg7QkiGzwIXBtR899wx7Qg9CQd.xml b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/ZOXg7QkiGzwIXBtR899wx7Qg9CQd.xml new file mode 100644 index 0000000..4356a6a --- /dev/null +++ b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/ZOXg7QkiGzwIXBtR899wx7Qg9CQd.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/ZOXg7QkiGzwIXBtR899wx7Qg9CQp.xml b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/ZOXg7QkiGzwIXBtR899wx7Qg9CQp.xml new file mode 100644 index 0000000..01cb34e --- /dev/null +++ b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/ZOXg7QkiGzwIXBtR899wx7Qg9CQp.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/mliwxxW4DJFMNwIku7VL4CQRIIYd.xml b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/mliwxxW4DJFMNwIku7VL4CQRIIYd.xml new file mode 100644 index 0000000..4356a6a --- /dev/null +++ b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/mliwxxW4DJFMNwIku7VL4CQRIIYd.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/mliwxxW4DJFMNwIku7VL4CQRIIYp.xml b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/mliwxxW4DJFMNwIku7VL4CQRIIYp.xml new file mode 100644 index 0000000..82572dd --- /dev/null +++ b/resources/project/6w5DYSNhgTDUpgeU0d-vjdTyxYY/mliwxxW4DJFMNwIku7VL4CQRIIYp.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/aM_fJ0UXVwZfzE_yzKDyj7pVqZg/6w5DYSNhgTDUpgeU0d-vjdTyxYYd.xml b/resources/project/aM_fJ0UXVwZfzE_yzKDyj7pVqZg/6w5DYSNhgTDUpgeU0d-vjdTyxYYd.xml new file mode 100644 index 0000000..4356a6a --- /dev/null +++ b/resources/project/aM_fJ0UXVwZfzE_yzKDyj7pVqZg/6w5DYSNhgTDUpgeU0d-vjdTyxYYd.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/aM_fJ0UXVwZfzE_yzKDyj7pVqZg/6w5DYSNhgTDUpgeU0d-vjdTyxYYp.xml b/resources/project/aM_fJ0UXVwZfzE_yzKDyj7pVqZg/6w5DYSNhgTDUpgeU0d-vjdTyxYYp.xml new file mode 100644 index 0000000..00cea33 --- /dev/null +++ b/resources/project/aM_fJ0UXVwZfzE_yzKDyj7pVqZg/6w5DYSNhgTDUpgeU0d-vjdTyxYYp.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/tbx/docmaker/resources/mathjax-config.js b/tbx/docmaker/resources/mathjax-config.js index bab4657..33df857 100644 --- a/tbx/docmaker/resources/mathjax-config.js +++ b/tbx/docmaker/resources/mathjax-config.js @@ -5,13 +5,14 @@ window.MathJax = { tex: { inlineMath: [['$', '$']], displayMath: [['$$', '$$']] + }, + // Disable semantic enrichment and its dependent speech and braille + // features; DocMaker does not bundle the required SRE worker assets. + options: { + menuOptions: { + settings: { + enrich: false + } + } } }; - -// Dynamically load MathJax -(function () { - const script = document.createElement('script'); - script.src = "tex-mml-chtml.js"; - script.async = true; - document.head.appendChild(script); -})(); diff --git a/tests/tdocconvert.m b/tests/tdocconvert.m index d6b8519..93415ec 100644 --- a/tests/tdocconvert.m +++ b/tests/tdocconvert.m @@ -48,6 +48,37 @@ function tLaTeXConversionProducesCorrectHTMLFile( testCase ) "docconvert did not preserve non-math content." ) end % tLaTeXConversionProducesCorrectHTMLFile + + function tMathJaxScriptsLoadOnceForNestedPages( testCase ) + + nestedFolder = fullfile( testCase.Folder, "guide" ); + mkdir( nestedFolder ) + markdownFile = fullfile( nestedFolder, "chapter.md" ); + copyfile( testCase.ExampleLaTeXFile, markdownFile ) + + output = docconvert( markdownFile, ... + "Root", testCase.Folder, "Interpreter", "latex" ); + html = fileread( output ); + + configFile = fullfile( testCase.Folder, ... + "resources", "mathjax-config.js" ); + config = fileread( configFile ); + testCase.verifyFalse( contains( config, "tex-mml-chtml.js" ), ... + "The MathJax configuration should not load the bundle." ) + + configPath = "../resources/mathjax-config.js"; + bundlePath = "../resources/tex-mml-chtml.js"; + testCase.verifyEqual( count( html, configPath ), 1, ... + "The MathJax configuration should be included once." ) + testCase.verifyEqual( count( html, bundlePath ), 1, ... + "The MathJax bundle should be included once." ) + + configIndex = strfind( html, configPath ); + bundleIndex = strfind( html, bundlePath ); + testCase.verifyLessThan( configIndex, bundleIndex, ... + "The MathJax configuration must precede the bundle." ) + + end % tMathJaxScriptsLoadOnceForNestedPages end % methods ( Test )