Skip to content

Commit 9c2da64

Browse files
committed
Version 0.2.1
1 parent d514dfc commit 9c2da64

File tree

4 files changed

+37
-24
lines changed

4 files changed

+37
-24
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# math-with-slack 0.2.1
2+
3+
* Minor fixes.
4+
5+
16
# math-with-slack 0.2
27

38
* Loads without delay.

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
11
# Rendered math (MathJax) with Slack's desktop client
22

3-
[Slack](https://slack.com) does not display rendered math. This script injects [MathJax](https://www.mathjax.org) into Slack's desktop client, which allows you to write nice-looking inline- and display-style math using familiar TeX/LaTeX syntax. You can also edit equations after you've posted them.
3+
[Slack](https://slack.com) does not display rendered math. The `math-with-slack` script allows you to write nice-looking math using familiar TeX syntax by injecting [MathJax](https://www.mathjax.org) into Slack's desktop client. This approach has several advantages over the plugin/bot solution:
4+
5+
* You can write both inline- and display-style equations.
6+
* You can edit equations after you've posted them.
7+
* Nothing is sent to external servers for rendering.
8+
9+
The downside is that equations are not rendered for team members without the MathJax injection.
410

511

612
![Math Slack Example](math-slack.gif "Amazing maths!")
713

814

915
## How do I install it?
1016

11-
Download and run your platform's script. Restart the Slack client. You're all done!
17+
Download and run your platform's script. Restart the Slack client. You're done!
1218

1319

1420
### Mac and Linux
1521

1622
Run the following in a terminal:
1723

1824
```shell
19-
curl -OL https://github.com/fsavje/math-with-slack/releases/download/v0.2/math_with_slack.sh
25+
curl -OL https://github.com/fsavje/math-with-slack/releases/download/v0.2.1/math_with_slack.sh
2026
sudo bash math_with_slack.sh
2127
```
2228

2329

2430
### Windows
2531

26-
[Download this script](https://github.com/fsavje/math-with-slack/releases/download/v0.2/math_with_slack.bat) and doubleclick to run. Alternatively, run it in the command prompt with:
32+
[Download the script](https://github.com/fsavje/math-with-slack/releases/download/v0.2.1/math_with_slack.bat) and double-click to run. Alternatively, run it in the command prompt with:
2733

2834
```shell
2935
math_with_slack.bat
3036
```
3137

32-
(You'll most likely get a security warning from Windows since the script was downloaded from Internet.)
38+
(Windows will probably give you a security warning when running the script since it's downloaded from Internet.)
3339

3440

3541
### Uninstall
@@ -47,12 +53,12 @@ math_with_slack.bat -u
4753

4854
### Updating Slack
4955

50-
When you update the Slack app, it might overwrite the code injected by the script. If the client stops rendering math after an update, re-run the script as above and it should work again.
56+
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.
5157

5258

5359
### If Slack cannot be found
5460

55-
If you've installed Slack in some exotic place, the script might not find the installation by itself and you need to specify the location of Slack's `app.asar.unpacked/src/static` folder as a parameter:
61+
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:
5662

5763
```shell
5864
sudo bash math_with_slack.sh /My_Apps/Slack.app/Contents/Resources/app.asar.unpacked/src/static

math_with_slack.bat

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
:: Constants
2020

21-
SET "MWS_VERSION=v0.2"
21+
SET "MWS_VERSION=v0.2.1"
2222

2323

2424
:: User input
@@ -44,16 +44,17 @@ IF "%SLACK_DIR%" == "" (
4444
FOR /F %%t IN ('DIR /B /OD %UserProfile%\AppData\Local\slack\app-?.*.*') DO (
4545
SET SLACK_DIR=%UserProfile%\AppData\Local\slack\%%t\resources\app.asar.unpacked\src\static
4646
)
47+
IF "%SLACK_DIR%" == "" (
48+
ECHO Cannot find Slack installation.
49+
PAUSE & EXIT /B 1
50+
) ELSE (
51+
ECHO Found Slack installation at: %SLACK_DIR%
52+
)
4753
)
4854

4955

5056
:: Check so installation exists
5157

52-
IF "%SLACK_DIR%" == "" (
53-
ECHO Cannot find Slack installation.
54-
PAUSE & EXIT /B 1
55-
)
56-
5758
IF NOT EXIST "%SLACK_DIR%" (
5859
ECHO Cannot find Slack installation at: %SLACK_DIR%
5960
PAUSE & EXIT /B 1

math_with_slack.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
## Constants
2020

21-
MWS_VERSION="v0.2"
21+
MWS_VERSION="v0.2.1"
2222

2323

2424
## Functions
@@ -66,14 +66,17 @@ if [ -z "$SLACK_DIR" ]; then
6666
break
6767
fi
6868
done
69+
if [ -z "$SLACK_DIR" ]; then
70+
error "Cannot find Slack installation."
71+
else
72+
echo "Found Slack installation at: $SLACK_DIR"
73+
fi
6974
fi
7075

7176

7277
## Check so installation exists and is writable
7378

74-
if [ -z "$SLACK_DIR" ]; then
75-
error "Cannot find Slack installation."
76-
elif [ ! -e "$SLACK_DIR" ]; then
79+
if [ ! -e "$SLACK_DIR" ]; then
7780
error "Cannot find Slack installation at: $SLACK_DIR"
7881
elif [ ! -e "$SLACK_DIR/ssb-interop.js" ]; then
7982
error "Cannot find Slack file: $SLACK_DIR/ssb-interop.js"
@@ -119,7 +122,7 @@ restore_file $SLACK_DIR/ssb-interop-lite.js
119122
## Are we uninstalling?
120123

121124
if [ -n "$UNINSTALL" ]; then
122-
echo "$(tput setaf 64)math-with-slack has been $(tput bold)un$(tput sgr0)$(tput setaf 64)installed. Please restart Slack client.$(tput sgr0)"
125+
echo "$(tput setaf 64)math-with-slack has been uninstalled. Please restart Slack client.$(tput sgr0)"
123126
exit 0
124127
fi
125128

@@ -181,12 +184,10 @@ inject_loader() {
181184
fi
182185

183186
# Inject loader code
184-
cat <<EOF >> $1
185-
186-
// ** math-with-slack $MWS_VERSION ** https://github.com/fsavje/math-with-slack
187-
var mwsp = path.join(__dirname, 'math-with-slack.js').replace('app.asar', 'app.asar.unpacked');
188-
require('fs').readFile(mwsp, 'utf8', (e, r) => { if (e) { throw e; } else { eval(r); } });
189-
EOF
187+
echo "" >> $1
188+
echo "// ** math-with-slack $MWS_VERSION ** https://github.com/fsavje/math-with-slack" >> $1
189+
echo "var mwsp = path.join(__dirname, 'math-with-slack.js').replace('app.asar', 'app.asar.unpacked');" >> $1
190+
echo "require('fs').readFile(mwsp, 'utf8', (e, r) => { if (e) { throw e; } else { eval(r); } });" >> $1
190191
}
191192

192193
inject_loader $SLACK_DIR/ssb-interop.js

0 commit comments

Comments
 (0)