import socket import subprocess import tempfile class KatexClient: def __init__(self): self._client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self._temp_dir = tempfile.TemporaryDirectory(prefix='formatitko') socket_file = self._temp_dir.name + "/katex-socket" self._client.bind(socket_file) self._server = subprocess.Popen(["node", "./katex-server/index.mjs", socket_file])