fsavje / math-with-slack

Rendered math (MathJax) with Slack's desktop client
MIT License
433 stars 63 forks source link

duplication and loss of dollar signs when editing #12

Closed ghennequin closed 7 years ago

ghennequin commented 7 years ago

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).

fsavje commented 7 years ago

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

ghennequin commented 7 years ago

Thanks! Any update on that? :smiley:

fsavje commented 7 years ago

@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.

gauss256 commented 7 years ago

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?

fsavje commented 7 years ago

@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.

gauss256 commented 7 years ago

I added the line

ignoreClass: "ql-editor",

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

fsavje commented 7 years ago

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

ghennequin commented 7 years ago

Thank you both!