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).confinedis whether the conversion will read confined (OXIDIZED_DESIGN_DIVERGENCES #1183: an archive input,--paranoid-input, the cortex worker): then only a file that opens insidediris a candidate or a.bbl, and a link leading out of it counts for nothing; unconfined, a link is followed, as Perl’s detection does. - find_
top_ level_ texs - Ordered list of top-level
.texfiles: the main document first, then any Supplementary-Material documents that ship alongside it.find_main_texreturns element 0 of this list; embedders that want to convert the whole submission (main + supplements, appended in order — arXiv’s multi-top-level model,submit_legacy_differences) drive off the full list. - is_
pdf_ magic - main_
tex_ in find_main_tex;reportwarns of a00READMEentry outsidedir(readme_entry) — the language server’s detection passes false, as its warnings would only pile up unreported.- readme_
entry - The file
namea00READMEmarks top-level, insidedir;Nonewhen it is not a file (., a folder), or, with aWarning:archive:path, whennameis absolute, has a..or resolves outsidedir(PerlUtil/Pack.pmdetect_sourceL78, L93; OXIDIZED_DESIGN_DIVERGENCES #1166). - readme_
text - The text of the
00READMEfilenameindir;confined, only when it opens inside it (ascollect_tex_fileskeeps a file).