Discourse Math

In the preview plane whilst drafting a post, when the SVG gets rendered the preview plane scrolls up. Is there a setting that can be changed so the scrolling returns to lowest position?

Having to scroll down every time i edit math annoys my lecturers, but i have been coping

I’ve notice a couple of ā€œdeprecateā€ in the activity.

If someone could please explain what this means for an instance with a large databases of math that renders ok

after a full update/rebuild, the math seems to be rendering fine

For those that haven’t heard, this plugin is now bundled with core. Please see rebuild/revision 2 of 3 of this post to show this.

In the deed! :+1: Sorry for causing concern. You should be good to go now.

:partying_face: This plugin is now bundled with Discourse core as part of Bundling more popular plugins with Discourse core. If you are self-hosting and use the plugin, you need to remove it from your app.yml before your next upgrade.

3 Likes

I have a math character problem in the AI answers. It gives me answers in latex format even though I have typed the required prompt. This creates an image as if there are broken characters. Can you solve this problem. Example;

\( A = \begin{pmatrix} x & -1 \\ z & 2y \end{pmatrix} \)

\[
\boxed{
x = 0, \quad y = 4, \quad z = 4
}
\]

\[
\begin{cases}
A_{11} = B^T_{11} \Rightarrow x = y - z \\
A_{12} = B^T_{12} \Rightarrow -1 = -1 \quad (\text{benar otomatis}) \\
A_{21} = B^T_{21} \Rightarrow z = y \\
A_{22} = B^T_{22} \Rightarrow 2y = 8 \\
\end{cases}
\]

I have previously shared solutions from the openai community

Hi @ozkn

I too have this problem. My recommendation would be

  • sign up for an account with the AI provider
  • tell the AI account to

remember for future answers that Discourse is compatible with MathJax/Katex $…$ $$…$$ inline or multi-line centric formatting.

  • you should find your output more copy-paste’able when logged into your AI account
you may need to keep pushing for the best memory
3 Likes

Just to add to the last point — if you’re mixing math and currency, remember:

  • $...$ = math
  • \$ = literal dollar sign

So:
$x+1$ costs \$5. → renders math for x+1 and shows the price as $5.

That’s really all you need: math with $, money with \$.

2 Likes

another good one to encourage chatGPT to remember is that you can’t render math in details pane titles

@sam and all interested in typing math in Discourse. I’ve updated the discourse-math plugin so that it uses MathJax V3, rather than the much slower and very outdated V2. As expected, the result is a much snappier user experience, while still maintaining the feature rich environment as compared to KaTeX.

I’d love to issue a pull request, if you think the results look good.


You can see it in action on my class Discourse site:

Most of the content on that site is private or unlisted. There should be several topics at the top in the MathJax V3 category that illustrate the ideas, though

You can examine the code for the plugin in this standalone discourse-mathjax plugin repo. The file that has the most modifications by far is the initializer.

You can also use that repo to install it on a standalone site right now. Just be sure to remove the old repo during installation. Thus, you’d modify the standard plugin install technique to look like this:

hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - rm -r discourse-math
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/mcmcclur/discourse-math.git

Comments

The most recent version of MathJax is actually 4.0.0. I chose to go with V3.2.2 for several reasons

  • While V4 is certainly much faster than V2, it’s not quite as fast as V3.
  • The user experience is a bit different in V4, particularly if the user clicks on the output.
  • The 4.0.0 status makes me wonder how many bugs there might be.

Having said that, the API for V4 is identical to that of V3. It should be possible to upgrade later, by simply dropping the latest MathJax Repo in.

I had to make one small change in the locales/server.en.yml file. Of course, there are a ton more such files for various languages. My understanding is that those other files would be automatically translated later?

I really don’t use chat at all and haven’t tested it in that context.

4 Likes

Pull request to upgrade MathJax to V3 made with all tests passed!

2 Likes

Regarding:

This is fantastic :hugs: , but I wonder if we can use this an an opportunity to trim down our repo a bit.

Now that we moved mathjax to core, we can lean on pnpm to pull the package and avoid bundling all the source like we do for FullCalendar for example.

Particularly have the goal of only having ā€œlinksā€ in our repo and then we can use the build process to pull the correct dependencies.

Give us a few days I want to consult with with the dev xp team here. Thanks so much for your efforts here!

4 Likes

Yes, I think that’s certainly the right thing to do. I always kinda wondered why you packaged the whole thing!

So, I guess you’ll build a loadMathJax function for your library that’s used to load MathJax?

I will say that rolling all the plugins into core has made it a bit trickier to to play with them. Tying the dependencies to the build process would only make it harder still, though I’m sure I could pull MathJax or FullCalendar from a CDN.

I’m mostly just talking about when I tinker with plugins for use in my own forums, though, and I absolutely think you oughtta pull MathJax in during the build.

Absolutely! I’ve been using Discourse for years and am super happy you think this is fantastic! :rocket:

3 Likes

Yes, exactly. A good one to copy is morphlex:

1 Like