fsavje/math-with-slack

duplication and loss of dollar signs when editing

Closed this issue · 8 comments

Thanks for this very useful piece of code! I (and a friend) have an issue with editing messages that have LaTeX in them; when editing a message, the LaTeX formula gets duplicated and dollar signs disappear (e.g. $\pi$ becomes \pi\pi). This also seems to happen upon first composition of a message, if we take too long to compose it (e.g. $\pi$ will become \pi\pi after 30sec or so).

Thank you @ghennequin for the bug report! I can replicate the issue and will start looking into it.

Thanks! Any update on that? 😃

@ghennequin Sorry for the slow progress. I've had a quick look, and a fix requires more than trivial work. I'm just about to change job and move, so I unfortunately have limited time to spare at the moment. I'm afraid it might be a while before I get around to this. Feel free to push a fix if you find one.

I love this code but am also experiencing the dollar sign problem.

I'm prepared to look into it but does anyone have any idea why it is happening? Where to start looking?

@gauss256 It's would be lovely if you have time to look into this. I suspect the problem is that with the latest Slack update so that MathJax becomes confused and renders math not only in the chat log but also in the text input element. Two things need to go wrong for this to happen. (1) the code confuses the text box for a chat message. (2) the MathJax rendering event must be triggered even when no message has been sent. To do this properly, one would need figure out how to differentiate been a chat message in the making and one that's been sent, and ensure that MathJax is only triggered when a new message is sent or received.

I added the line

ignoreClass: "ql-editor",

to the tex2jax arguments and it seems to work now. I've submitted a pull request.

New version solves this. Thanks @gauss256 for the fix!

Thank you both!