TeX Syntax Checker

so I am currently working on a small application that mainly consists of an editor and a preview. One writes LaTeX in an editor, and the idea is that you get a live preview as you type. Like here on stackoverflow. To do this, I have to compile the TeX input at some point (because I need an image / pdf to display the preview), and since it's not just plain text, I'd rather do this until there is a compilation error.

So my question is, using PyQT5, can I somehow continue to check the syntax and somehow know when the current Tex input can be compiled successfully?

+3


source to share


2 answers


Perhaps you could compile the LaTeX code in the background whenever an edit is done and only show the result based on no compilation errors. You can even keep the previous successful compilation in preview until the next point to be compiled is reached. This way, you won't need to check that the syntax is correct and ready for display, but your viewer will only show helpful previews.

I suppose this can be done by analyzing the output files or even checking their modification times. While writing LaTeX code, there are many points in which it cannot compile, as well as a large number of packages that can be used, so the ambitious project seems to be using a full parser. Plus, you can even display compiler messages in real time in the previewer while still keeping a useful compiled view to work with. I could see that both are very useful for any LaTeX user.



I apologize if some of them seem to be better suited for commenting, but I cannot yet on this site, despite the possibility of TeX.SX , where this might also make a difference. Hopefully, however, this is a helpful idea.

+1


source


TeX syntax is very complex and it is very difficult to predict if it will compile successfully. I am not aware of any previews that have tried it.

Instead, they try to compile the source. If that fails, they quit and save the previously generated PDF file. After some input they will try again. Or they allow the user to trigger the render using a key shortcut.



Some things you may or may not want to know about: QTeXEngine ; KLFBackend ; and PyLaTeX .

+1


source







All Articles