Discourse Math Plugin

official
(Sam Saffron) #103

Open to a PR that adds some level of support to it!

1 Like
(Stephen Hill) #104

I would gladly do that except that I don’t know the first thing about the discourse codebase. Do you have any pointers as to how to approach this particular problem? For instance, is there an existing mechanism/feature that I could use as a template for how to inject html code from a plugin into a .erb?

(Markus) #105

Can someone explain me, how to increase the font / overall size of KaTeX formula? I found this on the KaTeX docs, but don’t know how to work with that… solved by using \cfrac \displaystyle

My example:

**for** $t = 1$ to $t_{max}$ **do**

$$
\vec{x}_{min+} = \text{arg min } s_i \vec{w}^T \vec{x}_i , \text{wobei }  (X^+= \{\vec{x_i | s_i = 1}\}\\ 
\vec{x}_{min-} = \text{arg min } s_i \vec{w}^T \vec{x}_i, \text{wobei } (X^-= \{\vec{x_i | s_i = -1}\}\\
\vec{w} = \vec{w} + \vec{x}^{\text{min + }} -  \vec{x}^{\text{min - }}
$$

**end for**

$\theta = \frac{\vec{w} = \vec{w} + \vec{x}^{\text{min + }} -  \vec{x}^{\text{min - }}}{2}$ 

08

Thanks in advance!

PS: How can I align multiple lines with the “=” as anker point? … solved

3 Likes
(Don Turrentine) #106

Thanks so much for this plugin!

We just moved to Discourse from phpBB, where we used the [latex] and [/latex] codes … I was wondering if there would be any interest in expanding the plugin’s markers to include such things …

Otherwise I’m looking at search-and-replace across all our forum posts… :sweat_smile:

1 Like
(Daniel Hollas) #107

It seems it might not be too difficult to add a generic setting for a math block marker, by modifying this function:

Additional complexity here is that the end marker is different from the beginning marker.
I can take a crack at it if folks are open to a PR here, but citing from the OP:

Not sure whether this was intentinal or not. It would be a bit more difficult to have a generic setting for inline math due to the special heuristic that was implemented for this.

1 Like
(Don Turrentine) #108

Right, it doesn’t look too hard but maybe the plugin is supposed to be more lightweight. Thanks for chiming in!

(Daniel Hollas) #109

Ha, good reminder. Forgot to write here that the support for KaTeX was added some time ago. :tada:

If you have a math-heavy forum, this should give you rather large speed boost. Editing a post is also a much nicer experience since equations do not flicker as you type. :sun_with_face: MathJax has generally better overall support for more obscure LaTeX and it remains a default for this plugin.

I’ve updated the OP accordingly, and also added a mention about support for asciimath that was added a while back.

3 Likes
(Markus) #110

It would be amazing if someone could integrate something like Detexify LaTeX handwritten symbol recognition as reference for that plugin. Any good reference for everyday use would be so great :slight_smile:

What do you think?

It seems, there are multiple feature detection APIs / libs:

2 Likes
Context menu (right-click) for the composer
(Daniel Hollas) #111

@sam are you open for a PR to allow custom block math delimiters?

(Sam Saffron) #112

You are the major consumer here, if it makes sense to you, then I guess it sounds ok. That said I would urge to stay as close as possible to what folks at mathoverflow and stack exchange maths are using.

6 Likes
(Markus) #113

Just a small but very usefull side note for all math enthusiasts: https://mathpix.com

2 Likes
(Daniel Hollas) #114

Thinking about this a bit more…could you clarify, whether you’d like to use the [latex] for math going forward even on the new forum or just for the old posts? i.e. would you like to support both $$ and [latex] as delimiters or just one of them? Also, do your post look like this?

[latex]
math here
[/latex]

or is it also inline?

(Jay Pfaffman) #115

Right. If the problem is imported data, the solution is to replace the delimiters in those posts. That said, when I tried recently, I failed and the site had only a dozen or so such posts and we didn’t find the problem until it was to late to run the import again.

1 Like
(Darix) #116

Is it supposed to render formulas within quoted text?

(Daniel Hollas) #117

Could you post an example string? I am not sure what you mean.

(Darix) #118

The formula actually shows another render bug but that is independent

1 Like