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
7 changes: 7 additions & 0 deletions demo/sub/math.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# MathJax Browser Check

Inline equation: $ \sin^2x + \cos^2x = 1 $.

Display equation:

$$ \int_{-\infty}^\infty f(x) dx = 1 $$
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="1" type="DIR_SIGNIFIER"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="math.md" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="sub" type="File"/>
17 changes: 9 additions & 8 deletions tbx/docmaker/resources/mathjax-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})();
31 changes: 31 additions & 0 deletions tests/tdocconvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

Expand Down
Loading