Browse Source

Don't leave hanging katexserver.

pull/28/head
Jan Černohorský 2 years ago
parent
commit
e07141fe10
  1. 10
      formatitko.py
  2. 6
      katex.py

10
formatitko.py

@ -48,14 +48,14 @@ doc = doc.walk(transform, context)
# setting out to TeX
doc.content = [Group(*doc.content, metadata={"language":language})]
# Initialize KaTeX client (this runs the node app and connects to a unix socket)
katexClient = KatexClient()
# Initialize the image processor (this just keeps some basic state)
imageProcessor = ImageProcessor(args.img_public_dir, args.img_web_path, *args.img_lookup_dirs)
# Generate HTML and TeX out of the transformed document
open(args.output_html, "w").write(html(doc, katexClient, imageProcessor))
open(args.output_tex, "w").write(tex(doc, imageProcessor))
# Initialize KaTeX client (this runs the node app and connects to a unix socket)
with KatexClient() as katexClient:
# Generate HTML and TeX out of the transformed document
open(args.output_html, "w").write(html(doc, katexClient, imageProcessor))
open(args.output_tex, "w").write(tex(doc, imageProcessor))
if args.debug:
print(show(doc))

6
katex.py

@ -56,3 +56,9 @@ class KatexClient:
def endgroup(self):
self._client.sendall("endgroup\n".encode("utf-8"))
def __enter__(self):
return self
def __exit__(self, type, value, tb):
self._server_process.terminate()

Loading…
Cancel
Save