Skip to content

kentora/slacktex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slacktex

An API server for integrating LaTeX formulas into Slack. (What is Slack?)

About

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.

Prerequisites

  • Linux
  • Apache or nginx
  • node
  • dvipng
  • latex

Setup

First things first, run the following:

$ ./configure
$ npm install

Configuration

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

Configuration File

Server

{
  "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

{
  "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

{
  "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

{
  "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

About

An API for integrating LaTeX equations into Slack.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.4%
  • TeX 2.6%