@@ -25,6 +25,15 @@ md.messages = ({storage: {defaults, state, set}, compilers, mathjax, xhr, webreq
sendResponse({err, body})
})
}
+ else if (req.message === 'mathjax') {
+ chrome.scripting.executeScript({
+ target: {tabId: sender.tab.id},
+ files: [
+ `/vendor/mathjax/extensions/${req.extension}.js`,
+ ],
+ injectImmediately: true
+ }, sendResponse)
+ }
// popup
else if (req.message === 'popup') {
@@ -8,7 +8,11 @@ git clone --depth 1 --branch 3.2.2 https://github.com/mathjax/MathJax.git tmp
# https://github.com/mathjax/MathJax#reducing-the-size-of-the-components-directory
mkdir -p ../../vendor/mathjax
cp tmp/es5/tex-mml-chtml.js ../../vendor/mathjax
+
mkdir -p ../../vendor/mathjax/fonts
cp tmp/es5/output/chtml/fonts/woff-v2/*.woff ../../vendor/mathjax/fonts
+mkdir -p ../../vendor/mathjax/extensions
+cp tmp/es5/input/tex/extensions/*.js ../../vendor/mathjax/extensions/
rm -rf tmp/
@@ -1,5 +1,15 @@
var MathJax = {
+ loader: {
+ pathFilters: [
+ ({name}) => name.startsWith('[tex]') ? false : true // keep the name
+ require: (path) => path.startsWith('[tex]') ?
+ chrome.runtime.sendMessage({
+ message: 'mathjax',
+ extension: path.replace('[tex]/', '')
+ }) : null
+ },
tex: {
inlineMath: [
['$', '$'],