User Tools

Site Tools


blog:integrate_mathjax_with_gitlab

Integrate Mathjax with Gitlab

A quick (not the best way, though) way to integrate Mathjax with Gitlab. Tested on Gitlab 7.9.4 and Gitlab shell 2.6.0.

Create the file /home/git/gitlab/app/views/layouts/_mathjax.html.haml, e.g.,

sudo -u git nano /home/git/gitlab/app/views/layouts/_mathjax.html.haml

with the following content

:javascript
  (function() {
    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = ('https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

Then edit the file _head.html.haml

sudo -u git nano /home/git/gitlab/app/views/layouts/_head.html.haml

and change to the following (the first line already existed and the second line was newly added:

= render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id')
= render 'layouts/mathjax'

Note one can control the use of mathjax just like the use of piwik.

Then restart gitlab using

sudo service gitlab restart
You could leave a comment if you were logged in.
blog/integrate_mathjax_with_gitlab.txt · Last modified: 2016/09/19 21:51 by johnny