Skip to content

abogatskiy/math-with-slack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rendered math (MathJax) with Slack's desktop client

Slack does not display rendered math. The math-with-slack script allows you to write nice-looking math using familiar TeX syntax by injecting MathJax into Slack's desktop client. This approach has several advantages over the plugin/bot solution:

  • You can write both inline- and display-style equations.
  • You can edit equations after you've posted them.
  • Nothing is sent to external servers for rendering.

The downside is that equations are not rendered for team members without the MathJax injection.

Math Slack Example

How do I install it?

Download and run your platform's script. Restart the Slack client. You're done!

Mac and Linux

Run the following in a terminal:

curl -OL https://github.com/fsavje/math-with-slack/releases/download/v0.2.2/math_with_slack.sh
sudo bash math_with_slack.sh

Windows

Download the script and double-click to run. Alternatively, run it in the command prompt with:

math_with_slack.bat

(Windows will probably give you a security warning when running the script since it's downloaded from Internet.)

Uninstall

To uninstall, run the script again with the -u flag:

sudo bash math_with_slack.sh -u
math_with_slack.bat -u

Updating Slack

The code injected by the script might be overwritten when you update the Slack app. If your client stops rendering math after an update, re-run the script as above and it should work again.

If Slack cannot be found

If you've installed Slack in some exotic place, the script might not find the installation by itself or it might find the wrong installation. In such cases, you need to specify the location of Slack's app.asar.unpacked/src/static folder as a parameter:

sudo bash math_with_slack.sh /My_Apps/Slack.app/Contents/Resources/app.asar.unpacked/src/static
math_with_slack.bat E:\My_Apps\slack\app-2.5.1\resources\app.asar.unpacked\src\static

How do I get my math rendered?

As you do in TeX, use $ ... $ for inline math and $$ ... $$ for display-style math. If you need to write a lot of dollar-signs in a message and want to prevent rendering, use backslash to escape them: \$.

Note that only users with MathJax injected in their client will see the rendered version of your math. Users with the standard client will see the equations just as you wrote them (i.e., unrendered including the dollar signs).

How does it work?

The script alters how Slack is loaded. Under the hood, the desktop client is based on ordinary web technology. The modified client loads the MathJax library after start-up and adds a listener for messages. As soon as it detects a new message, it looks for TeX-styled math and tries to render. Everything is done in the client; messages are never sent to any server for rendering.

Can I contribute?

Yes, please. Just add an issue or a pull request.

Thanks to past contributors:

Inspiration

This comment by jouni was extremely helpful. So was this snippet by etihwnad.

About

Rendered math (MathJax) with Slack's desktop client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Batchfile 51.2%
  • Shell 48.8%