使用 markdown 编辑器在 gitlab wiki 中显示乳胶方程

Displaying latex equation in gitlab wiki using the markdown editor

我有兴趣在 gitlab 上为我的科学计算代码构建一个 wiki,这需要我编写方程式并将它们呈现在 gitlab 的 wiki 中。

如何操作。
我试图粘贴 mathjax 渲染脚本,但它不起作用。

KaTeX还能用吗?

$$
  \partial_t \int_{\Omega} \mathbf{q} d \Omega =
  \int_{\partial \Omega} \mathbf{f} (
  \mathbf{q}) \cdot \mathbf{n}d \partial
  \Omega - \int_{\Omega} hg \nabla z_b
$$

2017 年 2 月更新:如 sfarzy's , this is now integrated (merge request 8003)

中所述

原始答案,2016 年 2 月:关于 Mathjax,有一个 ticket requesting its integration in 2014 (also PR 5280)

如果你可以访问你自己的 gitlab 服务器,你 could integrate Mathjax yourself (source Zhiyong Johnny Zhang)

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 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'

但如果您想在 gitlab.com 上发布它,此集成尚未激活。

GitLab 使用代码反引号从 GitLab CE 8.15 支持 KaTex。

文档是 here 并且 相关讨论在merge request 8003.

这是在 GitLab 中使用方程式的当前方式