Expand description
Main .tex discovery for directory inputs.
Equivalent to the binary’s --whatsin=directory mode: given a
source directory, return the path of the file the converter should
treat as the top-level entrypoint. Lifted from
bin/latexml_oxide.rs so embedders (e.g. ar5iv-editor,
cortex_worker) can run the same heuristic without shelling out.
Detection order:
00README.json“sources” entry withusage == "toplevel"(modern arXiv format).00README.XXXline taggedtoplevelfile(legacy arXiv). Lines taggedignoreexclude the named file from later heuristic scanning (PerlPack.pm::detect_sourceunlinks them; we filter the candidate list instead — safer if the directory isn’t a sandbox).- Pack.pm-derived likelihood scoring across every
.tex/.txt/.ltx(and, as a fallback, every long-extensioned or extension-less file). Files vetoed by\input/\includereferences are excluded;\documentclass/\documentstyleand Mac-classic markers boost the score; bibtex / metafont / %auto-ignore / withdrawal sentinels disqualify.
Returns the absolute path of the chosen entry as a PathBuf. The
Err arm carries a Perl-canonical Fatal:invalid:not_tex_source
style message (matching what the binary printed before this lift).
Functions§
- find_
main_ tex - Discover the main
.texfile insidedir, mirroring the binary’s--whatsin=directoryheuristic. The returned path is rooted atdir. Errors carry a human-readable diagnostic onFatal:failure modes (PDF mis-named as TeX, only%auto-ignorefiles, no TeX at all). - is_
pdf_ magic