-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LaTeX syntax support in wiki #3445
Comments
Thank you for your answer. |
I have a feeling perhaps this issue is low priority, especially when it should be possible to implement a solution with the external markup api. You should at least give it a try! (and ask question here if you have trouble) |
Hello folks! About LaTeX support, its possible to allow https://github.com/mathjax/MathJax to be inserted as render? MediaWiki does have https://www.mediawiki.org/wiki/Extension:SimpleMathJax and AFAIK is not that bad to add a option to enable MathJax loading in Wiki section and use it to parse the $$ flags. Thanks! |
P.s: I made a tiny Dockerfile to install asciidoc - if someone needs it:
|
P.s 2: Can be used some engine like https://upmath.me/ ? |
upmath itself requries some PHP for the backend. Using upmath as an external service is not an option (we're aiming for self-hosting). But eventually implementing MathJax definitely sounds great, although something that does not depend on JS sounds even better, although it might be less feasible :) |
Hello @thehowl ! But math w/o JS can be only made with backend software and images - like Wikipedia does - but its not convinient for cientific applications - for example, as I intent to use. Can this be a choose? Also, I'm not a skilled developer, but if I can help with something to support MathJax, for me its a great pleasure. Thanks! |
Hmm. Keep in mind that Gitea Wikis are really meant for documentation and not really for math, while I understand your use case. If anything, I would suggest using .tex files in a repository with a custom render that plugs in MathJax, but I'm not quite sure if adding a markdown extension for maths is worth it when it comes to gitea. |
Hello @thehowl ! I know, but for some simple scientific projects, MathJax will be enough. Maybe the support can come as a generic support, fitting the example in http://docs.mathjax.org/en/latest/start.html of the following:
So if Gitea allows to use custom html before the markdown parser page, it may help with the issue - not only allowing MathJax, but another JS parsers/features. This also allow the user to fit the interface in a easier way than editing the source of Gitea for simple operations. Thanks! |
You could include this in custom template (see docs - customizing Gitea) |
(keep in mind though that @lafriks solution only works on 1.4, so you'll have to use the rc release for now) |
@sapk that implementation will only affect files but not wikis. We needs some work based that for wiki support. |
I think a good solution could be to put in contrib a Dockerfile example of gitea with external rendering and put it under contrib folder (I could try something). Even more do a article or docs that explain how to do it. |
|
Support for LaTeX in markdown files inside Git helps me, since I can use the markdown + mathjax support inside wiki. I'm using this to create the documentation of a project, so a Wiki or a -doc repository does not differ for me. But Wiki support is a beautiful way to go. I vote for mathjax support since its a easier and beauty way to parse math, add support for screen readers - as mathjax supports formats for blind readers and etc. |
same here, it will be great if gitea supports mathjax (or even katex), very useful feature |
Using pandoc as an replacement external renderer for markdown you can support TeX math with KaTeX/MathJax/... in markdown with gitea. Just install pandoc and add this to your app.ini (see here):
And in your
This is the standard KaTeX inclusion code from https://github.com/Khan/KaTeX (You can of course put the KaTeX files in your This works for markdown-files in repos and in wikis. The latter currently gives an error message due to a bug which I just fixed in PR #4863. mathjax should work just the same, Pandoc supports it as well, but I didn't try that out. Check out their manual. Pandoc has a few other html math options described there that might be worth looking at. On another note, adding math syntax support is not part of gitea, but rather of blackfriday, the markdown processor gitea uses. See this PR. There is a ongoing discussion about that over there. |
I am inspired by Mr.Eisfunke's comment.
<!-- MathJax -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
}
});
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> I think it works well. --> A wIki page for MathJax test in Gitea |
I got it working with KaTeX without server side rendering by simply adding <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"></script>
<!--The following is needed to render inline math delimited by single "$"-->
<script>
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "$", right: "$", display: false}
]
});
});
</script> to I tested the following code: # This is a test
**Definition 1.1.** Given the human set $H$, we call "fun" the function
$$\begin{array}{rccl}\mathscr{S} \colon & H & \to & \{0, 1\} \times \{0, 1\} \times \{0, \frac{1}{2}, 1\} \\\ & h & \mapsto & (e(h), x(h), g(h))\end{array}$$
where $e(h)$ value is 0 if $h$ started as A and 1 if $h$ started as B.
**Definition 1.2.** Let $h \in X$ be an element of the set $U$ [...]
$${\mu}_{t} = {\rho} {C} _ {\mu} {\frac{k^2}{\epsilon}}$$
$$T^1_{0} = \begin{bmatrix} C_1 & 0 & -S_1 & a_1 C_1 \\\ S_1 & 0 & C_1 & a_1 S_1 \\\ 0 & -1 & 0 & d_1 \\\ 0 & 0 & 0 & 1 \end{bmatrix}$$ |
yes this works :) I put the script portion to footer.tmpl instead of header.tmpl though to be safer |
I use the following code in <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha256-tn6hZ2YGDv0w1/DaFL4MiUoXuAVclrtFZs13ch3TB9M=" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha256-1qhJwAgsSPVSSjlQVTewHS49eaoAbOz651dveUANVBI=" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha256-oEuQVLwO5Ii6subChtLbrY5gx7NDRU+UJJ9jvvau+FI=" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll(".markdown").forEach(function(elem) {
renderMathInElement(elem, {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "$", right: "$", display: false}
]
});
})
});
</script> By set |
Since gitea now uses goldmark, I think https://github.com/litao91/goldmark-mathjax could be used for rendering latex. |
That unfortunately would reguire recompilation or for MathJax to be included & distributed with gitea |
For everybody comming to this issue and searching for a solution. So a short tutorial how it works:
So in my example the container data is in
If you use Nginx with Content Security Policies you need to add |
It's not only about wiki, but all Markdown content, right? GitHub has recently added MathJax. |
exactly. all markdown content. |
Is there a verdict of whether MathJax or Katex is the "better" renderer? Any pro/cons? GitLab uses Katex, GitHub MathJax. |
https://www.intmath.com/cg5/katex-mathjax-comparison.php Also there are several unsupported escapes in Katex Also I just added katex to my test gitea and there is an odd quirk if you edit a markdown cell... the auto-render bracers are replaced when you proceed to edit (this might just be due to it being a 3rd class citizen in gitea ) --edit-- |
Correction... it wasn't gitea, it was some configuration... once guards are used \$ e^{ix} = cos x + i sin x \$ both katex and mathjax works well Katex is fast and it is only missing some esoteric dialect |
If this is actually wanted I can dust off a branch that adds katex support to goldmark. |
This PR adds mathematical rendering with KaTeX. The first step is to add a Goldmark extension that detects the latex (and tex) mathematics delimiters. The second step to make this extension only run if math support is enabled. The second step is to then add KaTeX CSS and JS to the head which will load after the dom is rendered. Fix go-gitea#3445 Signed-off-by: Andrew Thornton <art27@cantab.net>
This PR adds mathematical rendering with KaTeX. The first step is to add a Goldmark extension that detects the latex (and tex) mathematics delimiters. The second step to make this extension only run if math support is enabled. The second step is to then add KaTeX CSS and JS to the head which will load after the dom is rendered. Fix #3445 Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
[x]
):Description
It seems that gitea does NOT support LaTeX syntax in wiki.
Are there any suggestions for solving this problem?
The text was updated successfully, but these errors were encountered: