Sysmagine / SemanticDiff

Community support for SemanticDiff, the programming language aware diff for Visual Studio Code and GitHub.
https://semanticdiff.com
40 stars 0 forks source link

Support for Latex files #9

Open tobiasdiez opened 1 year ago

tobiasdiez commented 1 year ago

Latex is commonly used in a scientific context to write papers and notes. In this regard, it is primarily a text-based format similar to markdown.

There is not really a good parser for latex, so it's probably not easy to integrate a full semantic representation. However, already ignoring formatting changes would be a helpful addition. In the future, this could be enhanced to e.g. recognize renames of equation labels and their references.

Reference: https://www.latex-project.org

mmueller2012 commented 1 year ago

We have experimented with Latex support in the past. The way macros and environments work in Tex makes it very difficult to write a parser. You have to parse and interpret the file at the same time to get a proper semantic representation. We decided against this approach because it would require access to all the Tex packages used and would add a lot of complexity. Instead, we went with a parser that follows a best effort principle by hardcoding the grammar for many popular packages. However, we weren't very happy with the result.

The outcome of the experiment was that we decided to drop the idea of full Latex support for now and instead implement a more generic text file parser that offers fewer features but could be tweaked for a variety of text-based file formats such as Markdown or reStructuredText. It is currently a work in progress and not yet included in the beta. I will post an update when it is available.