Zabalíčkování KaTeX serveru
This commit is contained in:
parent
ef18947916
commit
27ff4b7d58
4 changed files with 14 additions and 6 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -2,5 +2,5 @@
|
|||
path = ucwmac
|
||||
url = git://git.ucw.cz/ucwmac.git
|
||||
[submodule "src/formatitko/katex-server"]
|
||||
path = src/formatitko/katex-server
|
||||
path = src/formatitko/katex_server
|
||||
url = https://gitea.ks.matfyz.cz:/KSP/formatitko-katex-server
|
||||
|
|
|
@ -33,11 +33,19 @@ dependencies = [
|
|||
[project.scripts]
|
||||
formatitko = "formatitko.formatitko:main"
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"formatitko.katex_server" = [
|
||||
"*",
|
||||
"node_modules/*",
|
||||
"node_modules/katex/*",
|
||||
"node_modules/katex/src/*",
|
||||
"node_modules/katex/dist/*",
|
||||
]
|
||||
|
||||
[tool.setuptools_scm]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
exclude = ["src/formatitko/katex-server/node_modules"]
|
||||
|
||||
[tool.pyright]
|
||||
strictParameterNoneValue = false
|
||||
|
|
|
@ -46,20 +46,20 @@ class KatexClient:
|
|||
srcdir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
# Test if `node_modules` directory exists and if not, run `npm install`
|
||||
if not os.path.isdir(srcdir + "/katex-server/node_modules"):
|
||||
if not os.path.isdir(srcdir + "/katex_server/node_modules"):
|
||||
print("Installing node dependencies for the first time...")
|
||||
npm = shutil.which("npm") or shutil.which("yarnpkg")
|
||||
if npm is None:
|
||||
raise NPMNotFoundError("npm not found. Node.js is required to use KaTeX.")
|
||||
subprocess.run([npm, "install"], cwd=srcdir+"/katex-server", check=True)
|
||||
subprocess.run([npm, "install"], cwd=srcdir+"/katex_server", check=True)
|
||||
|
||||
self._katex_server_path = srcdir + "/katex-server/index.mjs"
|
||||
self._katex_server_path = srcdir + "/katex_server/index.mjs"
|
||||
|
||||
self._server_process = subprocess.Popen(["node", self._katex_server_path, self._socket_file], stdout=subprocess.PIPE)
|
||||
|
||||
ok = self._server_process.stdout.readline()
|
||||
if ok != b"OK\n":
|
||||
raise KatexServerError("Failed to connect to katex-server")
|
||||
raise KatexServerError("Failed to connect to katex_server")
|
||||
|
||||
def connect(self):
|
||||
self._client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
|
|
Loading…
Reference in a new issue