mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-16 04:42:51 -05:00
LaTeX syntax support in wiki #1493
Closed
opened 2025-11-02 04:02:22 -06:00 by GiteaMirror
·
31 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v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1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#1493
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @guyansrg on GitHub (Feb 2, 2018).
[x]):Description
It seems that gitea does NOT support LaTeX syntax in wiki.
Are there any suggestions for solving this problem?
@sapk commented on GitHub (Feb 2, 2018):
Hi,
You can use external rendering implemented in #2570 and documented here. With that you can setup your LaTex environnement and make gitea call it.
@guyansrg commented on GitHub (Feb 4, 2018):
Thank you for your answer.
I'm not sure I can solve it by myself.
I hope there has an offical solution for this problem.
@kellpossible commented on GitHub (Feb 8, 2018):
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)
@leleobhz commented on GitHub (Mar 2, 2018):
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!
@leleobhz commented on GitHub (Mar 2, 2018):
P.s: I made a tiny Dockerfile to install asciidoc - if someone needs it:
@leleobhz commented on GitHub (Mar 2, 2018):
P.s 2: Can be used some engine like https://upmath.me/ ?
@thehowl commented on GitHub (Mar 2, 2018):
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 :)
@leleobhz commented on GitHub (Mar 5, 2018):
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!
@thehowl commented on GitHub (Mar 5, 2018):
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.
@leleobhz commented on GitHub (Mar 6, 2018):
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!
@lafriks commented on GitHub (Mar 6, 2018):
You could include this in custom template (see docs - customizing Gitea)
@thehowl commented on GitHub (Mar 6, 2018):
(keep in mind though that @lafriks solution only works on 1.4, so you'll have to use the rc release for now)
@lunny commented on GitHub (Mar 7, 2018):
@sapk that implementation will only affect files but not wikis. We needs some work based that for wiki support.
@sapk commented on GitHub (Mar 7, 2018):
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.
@sapk commented on GitHub (Mar 7, 2018):
@leleobhz commented on GitHub (Mar 9, 2018):
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.
@laoshaw commented on GitHub (May 15, 2018):
same here, it will be great if gitea supports mathjax (or even katex), very useful feature
@Eisfunke commented on GitHub (Sep 3, 2018):
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
custom/templates/custom/header.tmpl(see here):This is the standard KaTeX inclusion code from https://github.com/Khan/KaTeX (You can of course put the KaTeX files in your
custom/publicdirectory (or anywhere else where they get served) and reference those instead of using the cdn).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.
@dymaxionkim commented on GitHub (Nov 18, 2018):
I am inspired by Mr.Eisfunke's comment.
so I tried to enable MathJax like that ;
.../templates/custom/header.tmplThis is my header.tmpl file.
I think it works well. --> A wIki page for MathJax test in Gitea
Thank you!
@AlphaJack commented on GitHub (May 16, 2020):
I got it working with KaTeX without server side rendering by simply adding
to
/var/lib/gitea/custom/templates/custom/header.tmpl.I tested the following code:
@laoshaw commented on GitHub (May 16, 2020):
yes this works :) I put the script portion to footer.tmpl instead of header.tmpl though to be safer
@joyqat commented on GitHub (Jan 3, 2021):
I use the following code in
footer.tmpl:By set
ENABLE_HARD_LINE_BREAK_IN_COMMENTStofalse, latex in issues and prs can also be rendered. ref: https://docs.gitea.io/en-us/config-cheat-sheet/#markdown-markdown@joyqat commented on GitHub (Jan 3, 2021):
Since gitea now uses goldmark, I think https://github.com/litao91/goldmark-mathjax could be used for rendering latex.
@zeripath commented on GitHub (Jan 3, 2021):
That unfortunately would reguire recompilation or for MathJax to be included & distributed with gitea
@Y0ngg4n commented on GitHub (Jun 1, 2021):
For everybody comming to this issue and searching for a solution.
I have used @joyqat code and got it working.
So a short tutorial how it works:
Go to your data directory of gitea.
So for example if you use the docker container check in what directory you mount the
/datadirectory of the docker container.So as example if you are using docker-compose you will have something like this:
So in my example the container data is in
/opt/docker/volumes/gitea.cd /opt/docker/volumes/giteacd giteals -layou will see some file structure like this:app.ini:nano conf/app.inimkdir -p templates/customnano templates/custom/footer.tmplIf you use Nginx with Content Security Policies you need to add
https://cdn.jsdelivr.nettoscript-src,font-srcandstyle-src.@silverwind commented on GitHub (May 19, 2022):
It's not only about wiki, but all Markdown content, right?
GitHub has recently added MathJax.
@Y0ngg4n commented on GitHub (May 19, 2022):
exactly. all markdown content.
@silverwind commented on GitHub (May 20, 2022):
Is there a verdict of whether MathJax or Katex is the "better" renderer? Any pro/cons? GitLab uses Katex, GitHub MathJax.
@eeyrjmr commented on GitHub (May 20, 2022):
https://www.intmath.com/cg5/katex-mathjax-comparison.php
MathJax might be more complete w.r.t Latex syntax which might be of importance for Jupyter and co but for a problem report?
Also there are several unsupported escapes in Katex
https://katex.org/docs/support_table.html
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--
just tried mathjax, it also suffers from the auto-render bracers being changed when you edit in gitea (something up with gitea...) but it does render and it is visibly slower so a large set of latex could be a visual distraction
@eeyrjmr commented on GitHub (Jul 30, 2022):
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 wellKatex is fast and it is only missing some esoteric dialect
@zeripath commented on GitHub (Jul 30, 2022):
If this is actually wanted I can dust off a branch that adds katex support to goldmark.