An API server for integrating LaTeX formulas into Slack. (What is Slack?)
This API accepts requests originating from a Slack slash command. The slash command input is expected to be properly formatted LaTeX formula code. From the code, it generates images and places them in a user specified directory. It then generates a URL for the image and POSTs back to Slack with the link.
- Linux
- Apache or nginx
- node
- dvipng
- latex
First things first, run the following:
$ ./configure
$ npm install
You'll need to add two things to slack:
- A slash command
- An incoming webhook
While setting those up, you'll need to determine certain configuration values that are also needed for slacktex. The default configuration is located in config/default.json
. To customize this simply
make a copy of the file and customize it.
$ cd config
$ cp default.json local.json
{
"server": {
"host": "example.com",
"port": 8000,
"request_path": "/command",
"output_path": "",
"output_dir": "",
"temp_dir": "/tmp",
"output_tex": ""
}
}
property | description |
---|---|
host | The hostname of the server that will accept the API requests |
port | The port to bind to |
request_path | The HTTP path that will accept requests, all other paths will 404 |
output_path | The HTTP path that will be used to generate image links, in addition to the host |
output_dir | The filesystem location where the images will be put |
temp_dir | The temporary directory where the API will work; this must exist |
output_tex | If set to 'true', outputs the tex file also. (filename: file.png.tex) |
{
"slack": {
"token": "",
"command": "/command",
"webhook_url": "",
"link_text": ""
}
}
property | description |
---|---|
token | The token string coming from Slack along with the request |
command | The slash command set up in Slack sent with the request |
webhook_url | The Slack incoming webhook url to POST back to after generating the image |
link_text | The text to display on Slack as the link description. If empty, the given latex input will be used |
{
"png": {
"bin": "/usr/bin/dvipng"
}
}
property | description |
---|---|
bin | The file system path of the dvipng binary that converts and trims the DVI file generated by LaTeX |
{
"tex": {
"bin": "/usr/bin/latex",
"template": "./resource/template.tex"
}
}
property | description |
---|---|
bin | The file system path of the LaTeX binary |
template | The file system path of the LaTeX template used for generating the images |