1

I would like to use KATEX to convert a Latex expression into a HTML element. I just want the HTML element and no window. I have found that the pywebview library is a lightweight webviewer that is capable of evaluating javascript expressions.

From the documentation, instantiating a webview always results in a window. Is it possible to run the webview in windowless mode so that a javascript funtion from the KATEX library can be called?

The javascript function would be something like:

var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", {
    throwOnError: false
});

The files main.py and demo1.html are below:

#main.py
import webview
window = webview.create_window('Hello world', 'demo1.html')
webview.start()
<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="katex/katex.css" >
    <script defer src="katex/katex.min.js" ></script>
</head>
<body>
</body>
</html>
mr_js
  • 949
  • 12
  • 29
  • first you should check documentation. See options in [create_window](https://pywebview.flowrl.com/guide/api.html#webview-create-window) - maybe option `hidden` will work. OR you will have to digg in source code to see if it can be hidden. – furas Aug 06 '21 at 16:02
  • I'm wondering if you could do it without browser - see [Executing Javascript from Python](https://stackoverflow.com/questions/10136319/executing-javascript-from-python) – furas Aug 06 '21 at 18:12

0 Answers0