How do I serve MathJax from a local Happstack server?

一曲冷凌霜 提交于 2019-12-06 12:43:25

Ok I got MathJax working using portable Apache and the MathJax archive downloaded from docs.mathjax.org. The URL needs to be of the form (assuming you extracted the files into apache2/htdocs/MathJax):

http://localhost/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML

I wanted to keep this lightweight by reusing the same instance of Happstack as Gitit, but that seems beyond my skills/available time right now.

EDIT: Just found out that ghc will pack everything into one exe when building. So I doubt it is even possible to use the same Happstack instance, as the root directory of the server doesn't exist?

From the documentation, the static directory should work just fine:

On receiving a request, gitit always looks first in the static directory (or in whatever directory is specified for static-dir in the configuration file). If a file corresponding to the request is found there, it is served immediately. If the file is not found in static, gitit next looks in the static subdirectory of gitit's data file ($CABALDIR/share/gitit-x.y.z/data). This is where default css, images, and javascripts are stored. If the file is not found there either, gitit treats the request as a request for a wiki page or wiki command.

So, you can throw anything you want to be served statically (for example, a robots.txt file or favicon.ico) in the static directory. You can override any of gitit's default css, javascript, or image files by putting a file with the same relative path in static. Note that gitit has a default robots.txt file that excludes all URLs beginning with /_.

(source: https://github.com/jgm/gitit)

Download the MathJax.js file from e.g. cdn.mathjax.org and place it in data/static/js/MathJax.js. Then change the config you quote to:

mathjax-script: http://localhost:5001/js/MathJax.js
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!