Add KaTeX rendering for Org-mode files #9751

Open
opened 2025-11-02 08:48:33 -06:00 by GiteaMirror · 10 comments
Owner

Originally created by @tecosaur on GitHub (Oct 30, 2022).

Feature Description

Now that KaTeX rendering for Markdown has been merged, it would be nice to extend that to Org documents too.

I've made a quick test/about document on try.gitea: https://try.gitea.io/tecosaur/testing/src/branch/main/gitea-maths-test.org

The short version is that it seems like go-org (which gitea currently uses) already identifies maths, but nothing is done with it. I would recommend targeting the following constructs:

  • \( inline maths \)
  • \[ display maths \]
  • \begin{env} latex env \env{env}

Screenshots

No response

Originally created by @tecosaur on GitHub (Oct 30, 2022). ### Feature Description Now that [KaTeX rendering for Markdown](https://github.com/go-gitea/gitea/pull/20571) has been merged, it would be nice to extend that to Org documents too. I've made a quick test/about document on try.gitea: https://try.gitea.io/tecosaur/testing/src/branch/main/gitea-maths-test.org The short version is that it seems like go-org (which gitea currently uses) already identifies maths, but nothing is done with it. I would recommend targeting the following constructs: - `\( inline maths \)` - `\[ display maths \]` - `\begin{env} latex env \env{env}` ### Screenshots _No response_
GiteaMirror added the type/proposaltype/feature labels 2025-11-02 08:48:33 -06:00
Author
Owner

@eeyrjmr commented on GitHub (Oct 30, 2022):

I guess the proposal should be more for Katex to work in md files not just comments.

@eeyrjmr commented on GitHub (Oct 30, 2022): I guess the proposal should be more for Katex to work in md files not just comments.
Author
Owner

@delvh commented on GitHub (Oct 30, 2022):

I think that is exactly what this issue is trying to say, but you need the knowledge what go-org is…

@delvh commented on GitHub (Oct 30, 2022): I think that is exactly what this issue is trying to say, but you need the knowledge what go-org is…
Author
Owner

@tecosaur commented on GitHub (Oct 30, 2022):

I'm not sure about the support for LaTeX constructs in other plaintext markup formats Gitea supports, I just know that go-org (https://github.com/niklasfasching/go-org) is used for Org (.org files), and it recognises them.

@tecosaur commented on GitHub (Oct 30, 2022): I'm not sure about the support for LaTeX constructs in other plaintext markup formats Gitea supports, I just know that go-org (https://github.com/niklasfasching/go-org) is used for Org (`.org` files), and it recognises them.
Author
Owner

@holocronweaver commented on GitHub (Mar 23, 2023):

FWIW for org-mode latex I typically use dollar signs for inline ($) and display ($$), though the single-dollar has some slightly wonky rules for recognition.

Would be happy to see any support though, especially for \( and \[.

@holocronweaver commented on GitHub (Mar 23, 2023): FWIW for org-mode latex I typically use dollar signs for inline (`$`) and display (`$$`), though [the single-dollar has some slightly wonky rules for recognition](https://orgmode.org/manual/LaTeX-fragments.html). Would be happy to see any support though, especially for `\(` and `\[`.
Author
Owner

@tecosaur commented on GitHub (Mar 25, 2023):

Yea, $ are soon to be recommended against in the official manual, there's even been talk of removing them from the syntax on the mailing list (not going to happen due to backwards compatibility concerns). So, I'd consider supporting \( and \[ much more important than $/$$.

@tecosaur commented on GitHub (Mar 25, 2023): Yea, `$` are soon to be recommended against in the official manual, there's even been talk of removing them from the syntax on the mailing list (not going to happen due to backwards compatibility concerns). So, I'd consider supporting `\(` and `\[` much more important than `$`/`$$`.
Author
Owner

@holocronweaver commented on GitHub (Mar 25, 2023):

$ are soon to be recommended against in the official manual

That's unfortunate, though I can understand why, parsing would be wonky. Still, in my limited experience $ is fairly common in the wild, and as you said it isn't going away anytime soon, so would be nice to have it for compatibility. But I agree \( and \[ should have higher priority, though wide compatibility is pretty important too so having $ support would still be great.

@holocronweaver commented on GitHub (Mar 25, 2023): > `$` are soon to be recommended against in the official manual That's unfortunate, though I can understand why, parsing would be wonky. Still, in my limited experience `$` is fairly common in the wild, and as you said it isn't going away anytime soon, so would be nice to have it for compatibility. But I agree `\(` and `\[` should have higher priority, though wide compatibility is pretty important too so having `$` support would still be great.
Author
Owner

@JirR02 commented on GitHub (Mar 29, 2025):

Is it possible to solve this issue by adding MathJax as a script or do you intend to implement this using go?

Edit: Adding MathJax with a custom template to the header solved the issue for me but I would consider this more of a temporary solution. What I did is the following (I am running docker instance):

  1. create the directory $GITEA_CUSTOM/templates/custom/header.tmpl
  2. Add <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.1/es5/tex-mml-chtml.js"></script> to the file
  3. Restart your Gitea instance.
@JirR02 commented on GitHub (Mar 29, 2025): Is it possible to solve this issue by adding [MathJax](https://www.mathjax.org/#gettingstarted) as a script or do you intend to implement this using go? Edit: Adding MathJax with a custom template to the header solved the issue for me but I would consider this more of a temporary solution. What I did is the following (I am running docker instance): 1. create the directory `$GITEA_CUSTOM/templates/custom/header.tmpl` 1. Add `<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.1/es5/tex-mml-chtml.js"></script>` to the file 1. Restart your Gitea instance.
Author
Owner

@wxiaoguang commented on GitHub (Apr 5, 2025):

It works, you only need to render a "math" language code block:

Image

Image

However, the orgmode https://orgmode.org/manual/LaTeX-fragments.html isn't supported yet

@wxiaoguang commented on GitHub (Apr 5, 2025): It works, you only need to render a "math" language code block: <details> ![Image](https://github.com/user-attachments/assets/91adcbb1-044f-49ee-9fea-84b43f3a0bf6) ![Image](https://github.com/user-attachments/assets/4a54d576-1344-4d9e-89f9-b54f0d7d0825) </details> However, the orgmode https://orgmode.org/manual/LaTeX-fragments.html isn't supported yet
Author
Owner

@JirR02 commented on GitHub (Apr 5, 2025):

It works, you only need to render a "math" language code block:
However, the orgmode https://orgmode.org/manual/LaTeX-fragments.html isn't supported yet

So I am guessing that they want to implement it using go?

@JirR02 commented on GitHub (Apr 5, 2025): > It works, you only need to render a "math" language code block: > However, the orgmode https://orgmode.org/manual/LaTeX-fragments.html isn't supported yet So I am guessing that they want to implement it using go?
Author
Owner

@wxiaoguang commented on GitHub (Apr 5, 2025):

So I am guessing that they want to implement it using go?

Yes, only need to make the orgmode render module output HTML like <code class="language-math"></code>, then frontend KaTeX module will render it correctly.

@wxiaoguang commented on GitHub (Apr 5, 2025): > So I am guessing that they want to implement it using go? Yes, only need to make the orgmode render module output HTML like `<code class="language-math"></code>`, then frontend KaTeX module will render it correctly.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9751