Cover report and geometry documents in the compatibility corpus
This commit is contained in:
1 parent
90cf2236ee
commit
3d01fbe589
3 files changed
+131
-9
No files matched your search
@@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
|
||||
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
|
||||
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
|
||||
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
|
||||
PDF opt-in with `?engine=route-d`). 898 workspace tests are green and no oracle
|
||||
PDF opt-in with `?engine=route-d`). 900 workspace tests are green and no oracle
|
||||
fixture is ignored. Preview JSON also carries a `warnings` array naming
|
||||
environments route-D cannot lay out and control words that survived layout, so
|
||||
unsupported source is reported instead of being silently typeset.
|
||||
|
||||
+3
-3
@@ -367,7 +367,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal
|
||||
|
||||
Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph.
|
||||
|
||||
The crate currently has 427 unit tests plus ten route-D integration tests and thirty-eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 898 tests (427 route-D unit, 287 engine binary unit, 10 route-D integration, 38 oracle, 71 v1 integration, 60 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path.
|
||||
The crate currently has 427 unit tests plus ten route-D integration tests and thirty-eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 900 tests (427 route-D unit, 289 engine binary unit, 10 route-D integration, 38 oracle, 71 v1 integration, 60 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
@@ -421,9 +421,9 @@ workspace suite is at 839 tests.
|
||||
| --- | --- |
|
||||
| M3 `\halign` | shared column widths, `l`/`c`/`r`/`p{width}` with wrapped cells, `\tabskip`, `@{}`/`@{\hspace{...}}`, booktabs rule weights and partial spans, `\cline`, `\noalign{\vskip}`, `\multicolumn`, longtable heads/feet, `*{n}{cols}`, vertical `|` rules, optional position/bracket arguments, row `\\[dim]` gaps, LaTeX `tabular`/`longtable` capture, `tabularx` targets whose `X` columns share the leftover width, `\multirow{n}{width}{text}` cells expanding to their text on the first row of the span, and page splitting that keeps column geometry. |
|
||||
| M4 math | `cases`, `matrix`/`pmatrix`/`bmatrix`/`Bmatrix`/`vmatrix`/`Vmatrix` and `array` environments laid out as two-dimensional grids with sized delimiters; Computer Modern math metrics (cmmi/cmsy/cmex/msbm/eufm) embedded as Type1 outlines, TeX's 3/4/5mu class table, `\mid`/`\colon`, `\mskip`-family dimension scans, `\frac` and infix fraction forms, `\left`/`\right`/`\middle` and `\big` CMEX sizing, `align`/`gather`/`alignat` row layout with per-row tags, `split` blocks numbered once and `multline` edge alignment, equation numbering with `\eqref`/`\ref`/`\tag`/`\notag`, `cases` with `&`-separated cells, matrix delimiters and `array` column specs (matrix rows advance 12pt and cases 14.4pt, matching amsmath's `\arraystretch`, and pmatrix/cases word positions are checked against pdfLaTeX within 1pt), math alphabets (`\mathbf`/`\mathit`/`\mathsf`/`\mathtt`/`\mathcal`/`\mathbb`/`\mathfrak`) wide-display line splitting, `\operatorname`/`\operatorname*` upright operator names with optional stacked limits, and `\DeclareMathOperator` definitions. |
|
||||
| M5 fonts | twelve Computer Modern text programs (roman/bold/italic/bold-italic/mono/sans/sans-bold/sans-italic/small-caps/slanted/bold-slanted/mono-italic) plus four math programs, all embedded as Type1 with TFM widths; NFSS declarations, legacy switches, paragraph/inline runs with relative composition, per-run base sizes, superscripts/subscripts, accent composition, case commands, per-glyph Liberation fallback and Type1 ToUnicode CMaps. |
|
||||
| M5 fonts | twelve Computer Modern text programs (roman/bold/italic/bold-italic/mono/sans/sans-bold/sans-italic/small-caps/slanted/bold-slanted/mono-italic) plus four math programs, all embedded as Type1 with TFM widths; NFSS declarations, legacy switches, paragraph/inline runs with relative composition, per-run base sizes, superscripts/subscripts, accent composition, case commands, per-glyph Liberation fallback and Type1 ToUnicode CMaps; colour, link and explicit-size runs are split in 10pt paragraphs, while larger class sizes keep those commands on the plain-text path. |
|
||||
| M6 class execution | article size options and `\linespread`, title/author/date and `\maketitle`, five-level sectioning with counters, TOC and float lists with page numbers and dot leaders, floats and in-text graphics with `\includegraphics` sizing/`\graphicspath`, footnote insertions, `thebibliography`/`\cite`, theorem environments and `\newtheorem`, nested lists with article skips and hanging indents, `quotation`/`quote`/`verse`, `minipage`, `\today`, page numbering, label/counter renaming, and preamble macro execution (`\newcommand`/`\def`/`\let`/`\newenvironment`/`\newif`/`\newlength`/`\newcounter`). Project `.cls`/`.sty` files are inlined with `\DeclareOption`/`\ProcessOptions`/`\ExecuteOptions`, `\LoadClass` inheritance, recursive `\RequirePackage`, local `\input`, `\AtBeginDocument` hooks and `\PassOptionsToClass`/`\PassOptionsToPackage`. |
|
||||
| M7 service | route-D preview/PDF/edit endpoints and the `?engine=route-d` project switch, `TEXRRA_ENGINE` default, memoised project previews/PDFs (source and image bytes in the key), flat endpoint caches with FIFO eviction and concurrency coverage, JSON 422 errors, PDF `/Link` annotations from `\href`, per-glyph Unicode extraction, and a `warnings` array in preview JSON that reports unsupported environments and control words that survived layout instead of failing silently. |
|
||||
| M7 service | route-D preview/PDF/edit endpoints and the `?engine=route-d` project switch, `TEXRRA_ENGINE` default, memoised project previews/PDFs (source and image bytes in the key), flat endpoint caches with FIFO eviction and concurrency coverage, JSON 422 errors, PDF `/Link` annotations from `\href`, per-glyph Unicode extraction, and a `warnings` array in preview JSON that reports unsupported environments and control words that survived layout instead of failing silently (custom `\newtheorem`/`\newenvironment` names count as supported, and three compatibility corpus documents render with an empty array). |
|
||||
|
||||
Residuals are deliberate and documented rather than template special cases:
|
||||
|
||||
|
||||
+127
-5
@@ -120,7 +120,7 @@ pub fn project_preview_json_with_images(
|
||||
(engine, changed, recomputed)
|
||||
}
|
||||
};
|
||||
let mut warnings = source_warnings(source);
|
||||
let mut warnings = source_warnings(source, &geometry);
|
||||
warnings.extend(document_warnings(&document));
|
||||
let json = render_json(
|
||||
&document,
|
||||
@@ -4285,7 +4285,7 @@ pub fn preview_json(source: &str) -> Result<String, String> {
|
||||
let mut document = build_document(¶graphs, &geometry);
|
||||
apply_geometry(&mut document, &geometry);
|
||||
let engine = layout_document(&document);
|
||||
let mut warnings = source_warnings(source);
|
||||
let mut warnings = source_warnings(source, &geometry);
|
||||
warnings.extend(document_warnings(&document));
|
||||
let json = render_json(&document, &engine, None, &geometry, &warnings);
|
||||
// Keep the layout so a following `/edit` request can diff against it and
|
||||
@@ -4433,7 +4433,7 @@ pub fn edit_json(source: &str, unit: usize) -> Result<String, String> {
|
||||
}
|
||||
let changed = engine.changed_pages().to_vec();
|
||||
let recomputed = engine.recomputed_pages();
|
||||
let mut warnings = source_warnings(source);
|
||||
let mut warnings = source_warnings(source, &geometry);
|
||||
warnings.extend(document_warnings(&next));
|
||||
let json = render_json(
|
||||
&next,
|
||||
@@ -9247,7 +9247,7 @@ const SUPPORTED_ENVIRONMENTS: &[&str] = &[
|
||||
];
|
||||
|
||||
/// Report environments that route-D would otherwise leave as literal text.
|
||||
fn source_warnings(source: &str) -> Vec<String> {
|
||||
fn source_warnings(source: &str, geometry: &PageGeometry) -> Vec<String> {
|
||||
let mut warnings = Vec::new();
|
||||
let mut rest = source;
|
||||
while let Some(index) = rest.find("\\begin{") {
|
||||
@@ -9257,7 +9257,15 @@ fn source_warnings(source: &str) -> Vec<String> {
|
||||
};
|
||||
let name = after[..close].trim();
|
||||
let normalized = name.trim_end_matches('*');
|
||||
if !SUPPORTED_ENVIRONMENTS.contains(&normalized) {
|
||||
let declared = geometry
|
||||
.theorem_definitions
|
||||
.iter()
|
||||
.any(|definition| definition.name == normalized)
|
||||
|| geometry
|
||||
.environments
|
||||
.iter()
|
||||
.any(|definition| definition.name == normalized);
|
||||
if !SUPPORTED_ENVIRONMENTS.contains(&normalized) && !declared {
|
||||
let message = format!("unsupported environment `{name}`");
|
||||
if !warnings.contains(&message) {
|
||||
warnings.push(message);
|
||||
@@ -10382,6 +10390,120 @@ a & b
|
||||
assert_eq!(geometry.macros.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compatibility_report_document_is_warning_free() {
|
||||
let source = r#"\documentclass{article}
|
||||
\newcommand{\vect}[1]{\mathbf{#1}}
|
||||
\newtheorem{claim}{Claim}
|
||||
\newenvironment{note}{\begin{quote}}{\end{quote}}
|
||||
\definecolor{accent}{HTML}{336699}
|
||||
\begin{document}
|
||||
\tableofcontents
|
||||
\listoffigures
|
||||
|
||||
\section{Intro}\label{sec:intro}
|
||||
|
||||
Text with $\vect{x}$, \textcolor{accent}{accent} and \fcolorbox{red}{yellow}{box}.
|
||||
|
||||
\begin{claim}\label{cl:one}
|
||||
A claim.
|
||||
\end{claim}
|
||||
|
||||
\begin{note}
|
||||
Quoted note.
|
||||
\end{note}
|
||||
|
||||
\begin{itemize}
|
||||
\item First
|
||||
\begin{enumerate}
|
||||
\item Nested
|
||||
\end{enumerate}
|
||||
\end{itemize}
|
||||
|
||||
\begin{center}
|
||||
Centred.
|
||||
\end{center}
|
||||
|
||||
\begin{figure}[t]
|
||||
\rule{80pt}{30pt}
|
||||
\caption{A figure}\label{fig:one}
|
||||
\end{figure}
|
||||
|
||||
\begin{table}[h]
|
||||
\begin{tabularx}{250pt}{lX}
|
||||
A & wide cell text \\
|
||||
\end{tabularx}
|
||||
\caption{A table}\label{tab:one}
|
||||
\end{table}
|
||||
|
||||
See \ref{sec:intro}, \ref{fig:one}, \pageref{tab:one}.
|
||||
|
||||
\appendix
|
||||
|
||||
\section{Extra}\label{sec:extra}
|
||||
|
||||
Appendix text.
|
||||
|
||||
\begin{thebibliography}{1}
|
||||
\bibitem{k} Entry.
|
||||
\end{thebibliography}
|
||||
\end{document}
|
||||
"#;
|
||||
let json = preview_json(source).expect("preview");
|
||||
assert!(json.contains("\"warnings\":[]"), "warnings: {}", json);
|
||||
assert!(json.contains(">Q</text>"));
|
||||
assert!(
|
||||
json.contains("stroke=") && json.contains("#ff0000"),
|
||||
"frame missing"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compatibility_geometry_document_is_warning_free() {
|
||||
let source = r#"\documentclass{article}
|
||||
\usepackage[margin=1in]{geometry}
|
||||
\linespread{1.15}
|
||||
\hypersetup{pdftitle={Doc},urlcolor=blue,linkbordercolor=red}
|
||||
\begin{document}
|
||||
\setcounter{page}{3}
|
||||
|
||||
\section{One}\label{sec:one}
|
||||
|
||||
A footnote\footnote{Note.} and a link \href{https://example.com}{Example} plus \url{https://example.com/a_b}.
|
||||
|
||||
\begin{quotation}
|
||||
Quoted paragraph with $a^2+b^2=c^2$ math.
|
||||
\end{quotation}
|
||||
|
||||
\begin{tabular}{lc}
|
||||
\hline
|
||||
A & B \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
\begin{figure}[b]
|
||||
\rule{60pt}{20pt}
|
||||
\caption{Bottom figure}
|
||||
\end{figure}
|
||||
|
||||
\newpage
|
||||
|
||||
Second page.
|
||||
\end{document}
|
||||
"#;
|
||||
let json = preview_json(source).expect("preview");
|
||||
assert!(json.contains("\"warnings\":[]"), "warnings: {}", json);
|
||||
assert!(json.contains(">E</text>"));
|
||||
assert!(
|
||||
json.contains("fill=") && json.contains("#0000ff"),
|
||||
"link colour missing"
|
||||
);
|
||||
assert!(
|
||||
json.contains("stroke=") && json.contains("#ff0000"),
|
||||
"link border missing"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compatibility_sample_document_is_warning_free() {
|
||||
let source = concat!(
|
||||
|
||||
Reference in new issue
Block a user