Open yozachar opened 2 years ago
Hey @joe733 this is a good question! 💜
In technology the word format has many meanings, and sometimes it's used to mean both code formatting or to prettify (rustfmt, gofmt); and other times is used to mean different content types (JSON, YAML) also known as file format.
Tectonic
cli uses the later definition, such as in the TeX world there are different formats: TeX, LaTeX, ConTeXt, BibTeX...
Regarding formatting before compilation, I believe you can install both latexindent
and tectonic
separately with the package manager, and have a simple Makefile do a build process like:
$ latexindent src.tex > out.tex
$ tectonic out.tex
And have the two work together.
If you mean adding a built-in formatter I don't know how in-scope that'd be, since tectonic
is a compiler it makes me wonder about the benefit of reimplementing already existing tools...
@mnrvwl yes you're right!
If you mean adding a built-in formatter I don't know how in-scope that'd be, since tectonic is a compiler it makes me wonder about the benefit of reimplementing already existing tools...
No, I don't think it would.
Regarding formatting before compilation, I believe you can install both latexindent and tectonic separately with the package manager, and have a simple Makefile do a build process like:
I have a setup to run tectonic
automatically. Since tectonic
is capable of downloading packages on-demand from CTAN (correct me if I'm wrong), I was thinking of a possibility to download in-place code formatter like latexindent
and run it either as pre/post-compilation step.
But again, I'm not sure if this is in-scope either. If not, feel free to close this as not planned
.
I think it's an interesting line, and it goes along the discussion of what tectonic
should include.
I believe @pkgw already phrased it neatly, see: https://github.com/tectonic-typesetting/tectonic/issues/893#issuecomment-1287514236
TeX Live is a collection of a significant amount of things, generally: packages (macros stored in .sty
, .def
, etc.), fonts and binaries. Those binaries, or utilities, live on collection-binextra
(e.g. latexindent, latexmk); collection-binextra
(e.g. biber
) and collection-latexextra
(e.g. minted
). These tools are written in a variety of languages too, generally Perl, Python or C. Packaging a python script also involves packaging its dependencies and environment.
Tackling reproducibility is easier the less external dependencies you have, and as far as I know, the bundle doesn't include these cli utilities, because the challenges they pose, focusing instead on macros and fonts.
Tectonic
nowadays solves a particular problem: give reproducible builds without detriment to UX. We can see it as a subset of TeX Live that is not aiming at encapsulate its whole set of features. Currently, the best way to reproduce the full extent of TeX Live is, well, TeX Live.
Taking this further involves a good solution for a whole new exciting set of challenges called: package management. Even if this was solved, I can't tell you how much @pkgw would turn the knob, yet he recognises the value and importance of supporting more tools and workflows.
tectonic
bundle —green for included
, red for not included
, yellow for incomplete support
—I'll chime in here to say that I actually really want Tectonic to provide its own code formatting solution one day. In the world of "regular" programming languages like Go and Rust, I believe that we've learned that standardized code formatters are really important for helping teams collaborate over version control, and that's something that I want to see happen for TeX as well.
As for Tectonic providing its own solution instead of adopting another one, I also think that it is super important for Tectonic to provide a standard "superficial" TeX parsing library for source code analysis — here I call it "superficial" because TeX is like C in that you can't actually parse it without running the full compiler, due to the way its macros work; and I think a well-designed library has to be built with this fundamental limitation in mind. (Really, I think you have to approach it as specifying a new, different language that just happens to look like LaTeX.) But even with that limitation, having such a library opens up the path to all kinds of very useful tooling based on code analysis, and one of the top applications there is code formatting.
As for parsing there is a tree-sitter-latex plugin for https://tree-sitter.github.io/tree-sitter/
I know it's not really a solution, but if you use VSCode and the Latex Workshop extension you can work from a conda environment in which you do
mamba install -c conda-forge latexindent.pl perl-yaml-tiny
and from which you also launch VSCode with code .
.
Doing this ensures that VSCode uses latexindent
from the conda environment whatever you do with tectonic or any other TeX distribution.
I'd like to keep the document structure neat. Classically, I'd use
latexindent
[CTAN
] to do it. Is it possible to do so withtectonic
?The current
option changes the TeX engine. Maybe another option
--engine
is more apt for it, and then re-employ--format
to format documents?