Skip to content

Commit

Permalink
Version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fsavje committed Jun 9, 2017
1 parent d514dfc commit 9c2da64
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 24 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# math-with-slack 0.2.1

* Minor fixes.


# math-with-slack 0.2

* Loads without delay.
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
# Rendered math (MathJax) with Slack's desktop client

[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.
[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:

* 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](math-slack.gif "Amazing maths!")


## How do I install it?

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


### Mac and Linux

Run the following in a terminal:

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


### Windows

[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:
[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:

```shell
math_with_slack.bat
```

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


### Uninstall
Expand All @@ -47,12 +53,12 @@ math_with_slack.bat -u

### Updating Slack

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.
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 and you need to specify the location of Slack's `app.asar.unpacked/src/static` folder as a parameter:
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:

```shell
sudo bash math_with_slack.sh /My_Apps/Slack.app/Contents/Resources/app.asar.unpacked/src/static
Expand Down
13 changes: 7 additions & 6 deletions math_with_slack.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

:: Constants

SET "MWS_VERSION=v0.2"
SET "MWS_VERSION=v0.2.1"


:: User input
Expand All @@ -44,16 +44,17 @@ IF "%SLACK_DIR%" == "" (
FOR /F %%t IN ('DIR /B /OD %UserProfile%\AppData\Local\slack\app-?.*.*') DO (
SET SLACK_DIR=%UserProfile%\AppData\Local\slack\%%t\resources\app.asar.unpacked\src\static
)
IF "%SLACK_DIR%" == "" (
ECHO Cannot find Slack installation.
PAUSE & EXIT /B 1
) ELSE (
ECHO Found Slack installation at: %SLACK_DIR%
)
)


:: Check so installation exists

IF "%SLACK_DIR%" == "" (
ECHO Cannot find Slack installation.
PAUSE & EXIT /B 1
)

IF NOT EXIST "%SLACK_DIR%" (
ECHO Cannot find Slack installation at: %SLACK_DIR%
PAUSE & EXIT /B 1
Expand Down
23 changes: 12 additions & 11 deletions math_with_slack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

## Constants

MWS_VERSION="v0.2"
MWS_VERSION="v0.2.1"


## Functions
Expand Down Expand Up @@ -66,14 +66,17 @@ if [ -z "$SLACK_DIR" ]; then
break
fi
done
if [ -z "$SLACK_DIR" ]; then
error "Cannot find Slack installation."
else
echo "Found Slack installation at: $SLACK_DIR"
fi
fi


## Check so installation exists and is writable

if [ -z "$SLACK_DIR" ]; then
error "Cannot find Slack installation."
elif [ ! -e "$SLACK_DIR" ]; then
if [ ! -e "$SLACK_DIR" ]; then
error "Cannot find Slack installation at: $SLACK_DIR"
elif [ ! -e "$SLACK_DIR/ssb-interop.js" ]; then
error "Cannot find Slack file: $SLACK_DIR/ssb-interop.js"
Expand Down Expand Up @@ -119,7 +122,7 @@ restore_file $SLACK_DIR/ssb-interop-lite.js
## Are we uninstalling?

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

Expand Down Expand Up @@ -181,12 +184,10 @@ inject_loader() {
fi

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

inject_loader $SLACK_DIR/ssb-interop.js
Expand Down

0 comments on commit 9c2da64

Please sign in to comment.