Skip to main content

Module paper_tex_source

Module paper_tex_source 

Source
Expand description

Fetch the raw LaTeX source of an arXiv paper from the arXiv source API (https://export.arxiv.org/src/<id>).

This is the complement to crate::paper_text (ar5iv HTML extraction): ar5iv renders only papers that have been through the LaTeXML pipeline; the source API is always available for arXiv submissions that have a TeX source (PDF-only submissions return NO_OA_AVAILABLE).

§Why TeX source instead of ar5iv HTML?

ar5iv HTML extraction (paper_text) is best-effort and unavailable for papers that were never processed by LaTeXML. The raw TeX source — when the submission has one — is the authoritative structured text. LLMs handle LaTeX well: \section{}, \begin{equation}…\end{equation}, etc. provide explicit structure that is often more reliable than ar5iv’s HTML rendering.

§Source (arXiv E-print API)

arXiv serves submission sources at https://export.arxiv.org/src/<arxiv_id>. The response is:

  • Gzip’d tar for multi-file submissions.
  • Gzip’d single file for single-file submissions.
  • Raw PDF bytes (%PDF- magic) for PDF-only submissions — no TeX source available; yields TextUnavailable.

Detection is by magic bytes on the response body.

§Source key

Uses the existing "arxiv" HTTP source key (registered in crate::http::tier_1_allowlist), which covers export.arxiv.org. The provenance source field is labelled "arxiv-src" to distinguish TeX-source fetches from PDF fetches in the audit trail.

§Capability tier

Tier 1 OA metadata, always-on: no env gate, no Cargo feature gate. Read-only, open-access, same posture class as crate::paper_text (ADR-0032 D2). TeX source is a structured text artifact, never a PDF reinterpretation (ADR-0032 D1 carve).

§Caching

Results are cached at <cache_root>/tex-src/<safekey>.json. Best-effort: cache failures degrade to a re-fetch, never an error.

Structs§

PaperTexSource
The raw LaTeX source of an arXiv paper.
SourceFile
One file extracted from an arXiv source tarball.

Enums§

BundleFilter
Which subset of the source tarball to materialise.

Constants§

ARXIV_SRC_DEFAULT_BASE
Production arXiv source API base. Overridable via DOIGET_ARXIV_SRC_BASE for tests.

Functions§

paper_source_bundle
Fetch the arXiv source bundle (or figures only) for id.
paper_tex_source
Fetch the LaTeX source of an arXiv paper.
resolve_arxiv_src_base
Resolve the arXiv source base URL.