Skip to content

Commit ca50a88

Browse files
committed
feat(mathjax): update MathJax integration and remove extension loading
Refactor MathJax integration to use a minimal build and streamline the loading process. Update paths in inject.js and manifest.json, and clean up mathjax.js and messages.js by removing unnecessary extension loading logic.
1 parent 6d516ee commit ca50a88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+7
-133
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ zip:
1010
-x "package-lock.json" \
1111
-x ".gitignore" \
1212
-x ".gitmodules" \
13-
-x "Makefile"
13+
-x "Makefile" \
14+
-x "debug-cli/*"
1415

1516
# Clean build artifacts
1617
clean:

background/inject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ md.inject = ({storage: {state}}) => (id) => {
4949
'/vendor/notebook.min.js',
5050
state.content.syntax && '/vendor/prism.min.js',
5151
state.content.emoji && '/content/emoji.js',
52-
state.content.mathjax && ['/vendor/mathjax/tex-mml-chtml.js', '/content/mathjax.js'],
52+
state.content.mathjax && ['/vendor/mathjax/tex-chtml.min.js', '/content/mathjax.js'],
5353
'/content/index.js',
5454
state.content.autoreload && '/content/autoreload.js',
5555
].filter(Boolean).flat(),

background/messages.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,9 @@ md.messages = ({storage, compilers, mathjax, xhr, webrequest}) => {
4242
sendResponse({message: 'html', nbjson: nbjson})
4343

4444
} else if (req.message === 'mathjax') {
45-
console.log('[Messages] Loading MathJax extension:', req.extension);
46-
chrome.scripting.executeScript({
47-
target: {tabId: sender.tab.id},
48-
files: [
49-
`/vendor/mathjax/extensions/${req.extension}.js`,
50-
],
51-
injectImmediately: true
52-
}, () => {
53-
if (chrome.runtime.lastError) {
54-
console.warn('[Messages] MathJax extension load failed:', chrome.runtime.lastError.message);
55-
} else {
56-
console.log('[Messages] MathJax extension loaded:', req.extension);
57-
}
58-
sendResponse();
59-
});
60-
return true; // async response
45+
// MathJax extension loading removed - using minimal build
46+
console.log('[Messages] MathJax extension request ignored (using minimal build)');
47+
sendResponse();
6148
} else if (req.message === 'autoreload') {
6249
xhr.get(req.location, (err, body) => {
6350
sendResponse({err, body})

content/mathjax.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
// Based on markdown-viewer's approach but adapted for notebooks
33

44
var MathJax = {
5-
loader: {
6-
pathFilters: [
7-
({name}) => name.startsWith('[tex]') ? false : true // keep the name
8-
],
9-
require: (path) => path.startsWith('[tex]') ?
10-
chrome.runtime.sendMessage({
11-
message: 'mathjax',
12-
extension: path.replace('[tex]/', '')
13-
}) : null
14-
},
155
tex: {
166
inlineMath: [
177
['$', '$'],
@@ -26,7 +16,6 @@ var MathJax = {
2616
packages: {'[+]': ['noerrors', 'noundefined', 'ams', 'newcommand']}
2717
},
2818
chtml: {
29-
fontURL: chrome.runtime.getURL('/vendor/mathjax/fonts'),
3019
scale: 1.0,
3120
mtextInheritFont: true
3221
},

manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
"/vendor/katex/fonts/*.woff2",
3535
"/vendor/katex/fonts/*.woff",
3636
"/vendor/katex/fonts/*.ttf",
37-
"/vendor/mathjax/fonts/*.woff",
38-
"/vendor/mathjax/extensions/*.js"
37+
"/vendor/mathjax/*.js"
3938
]
4039
}
4140
],

vendor/mathjax/extensions/action.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

vendor/mathjax/extensions/all-packages.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

vendor/mathjax/extensions/ams.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

vendor/mathjax/extensions/amscd.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

vendor/mathjax/extensions/autoload.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)