Using mathjax to render a mirrored site

269 views
Skip to first unread message

Eric Auld

unread,
Aug 6, 2013, 9:45:42 AM8/6/13
to mathja...@googlegroups.com
I've mirrored a website using HTTrack. (The page I'm mirroring is a wiki started by my school to help prepare for the written examinations. I'd like to read it while I'm on vacation, away from the internet.)

Try as I might, it continues to look like this when I open it using Chrome or Firefox.

Following the advice here, I tried downloading the STIX fonts and installing them. I tried putting the fonts in the local directory of the mirrored website, in order to please Firefox. No success.

I noticed when I opened it in Chrome I was getting errors like "File failed to load: C:\My Web Sites\Courant Wiki\math.nyu.edu\student_resources\MathJax". So I copied all the mathjax files to the directory where it seemed to be looking for it. Now I don't get those error messages, but the jax still won't render.

Any ideas? 

Apologies if this is off-topic; this is my first time posting here.

Peter Krautzberger

unread,
Aug 6, 2013, 11:59:23 AM8/6/13
to mathja...@googlegroups.com
Hi,

What kind of Wiki software is your school using? If it's MediaWiki with their Math Extension, then it's probably trickier and mirroring won't have copied enough.

It might be easier to use a greasemonkey userscript to run MathJax on every page.

Peter.


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Eric Auld

unread,
Aug 6, 2013, 12:24:46 PM8/6/13
to mathja...@googlegroups.com
Hi Peter, yes, it is MediaWiki. Is such a userscript easy to set up? 

Peter Krautzberger

unread,
Aug 6, 2013, 12:50:47 PM8/6/13
to mathja...@googlegroups.com
Hi Eric,

Depends on your browser. Both Firefox and Chrome have plugins (greasemonkey, tampermonkey) that simplify things. You can modify our example from the docs, something like below should work (changing the source to your local file). 

Keep in mind that MediaWiki's math extension has custom macros which won't be covered by that. If you need it, you'll have to grab. it from their source code.


Peter.

// ==UserScript==
// @name           MathJax MathML
// @namespace      http://www.mathjax.org/
// @description    Insert MathJax into pages containing MathML
// @include        *
// ==/UserScript==

    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full";
    document.getElementsByTagName("head")[0].appendChild(script);

Eric Auld

unread,
Aug 6, 2013, 2:00:09 PM8/6/13
to mathja...@googlegroups.com
Thanks! When you say "my local file", do you mean the biggest file folder, containing everything in Mathjax, or just the folder immediately containing a particular .js file?

Peter Krautzberger

unread,
Aug 6, 2013, 2:05:37 PM8/6/13
to mathja...@googlegroups.com
Wherever you keep a copy of MathJax.js.

Replace 


file://YOURPATHTO/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full 

I think that should work (but there might be security constraints for userscripts that I'm not aware of)

Peter.

Eric Auld

unread,
Aug 6, 2013, 2:18:19 PM8/6/13
to mathja...@googlegroups.com
OK, below is what I tried. I changed the @match line to the first part of where the mirrored page is loading from. Is that right? Can you spot any mistakes?  (Still not working.)

Thanks for your help!


// ==UserScript==
// @name       My Fancy New Userscript
// @version    0.1
// @description  enter something useful
// @match      file:///C:/My%20Web%20Sites/Courant%20Wiki/math.nyu.edu
// @copyright  2012+, You
// ==/UserScript==

var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "C:\Users\Dell User\Desktop\mathjax-MathJax-v2.2-8-g727332c\mathjax-MathJax-727332c\MathJax.js?config=TeX-AMS-MML_HTMLorMML-full";
    document.getElementsByTagName("head")[0].appendChild(script);


Peter Krautzberger

unread,
Aug 6, 2013, 2:24:17 PM8/6/13
to mathja...@googlegroups.com
Did you enable userscripts for local files? That's hidden in the settings of greasemonkey/tampermonkey. BTW, which browser are you using?

Peter.

Eric Auld

unread,
Aug 6, 2013, 2:36:58 PM8/6/13
to mathja...@googlegroups.com
It was previously unenabled, but I just enabled it and restarted the browser. Still no dice. I'm using Chrome version Version 28.0.1500.95 m

Peter Krautzberger

unread,
Aug 6, 2013, 5:52:56 PM8/6/13
to mathja...@googlegroups.com
Hm, using it with tampermonkey on Chrome 29beta works for me. Make sure you use the Tampermonkey beta (with Blink/Chrome28+ support). You can also try adding file://*/* to the user includes of the specific script.

Peter.

Eric Auld

unread,
Aug 6, 2013, 8:23:44 PM8/6/13
to mathja...@googlegroups.com
Shoot, I wonder what the problem is. Thank you very much for your help, though. It's probably something simple that's just hard to catch. 

Peter Krautzberger

unread,
Aug 6, 2013, 10:34:55 PM8/6/13
to mathja...@googlegroups.com
Hm, does MathJax load? Do you see any errors in the javascript console? Oh, and what are your delimiters?

Peter.


Reply all
Reply to author
Forward
0 new messages