diff --git a/README.md b/README.md index cd698e8..1524546 100644 --- a/README.md +++ b/README.md @@ -518,6 +518,10 @@ document: spacing macros, symbols and letters, NFSS declarations, small caps, advisory breaks, starred `\vspace`/`\hspace`, `center`, `\hrule`, `\fbox`, `\mbox`, and `\parbox`. +## New-template compatibility + +The SIVP class (`sn-jnl.cls`) loads completely and `sn-article.tex` exports a 12-page PDF; the Huawei E fragment (`projects/e/问题一.tex`) compiles to 16 A4 pages. This required generic TeX conditionals (`\if`, `\ifx`), `\newcount`/`\newdimen`, `\char`, 64-bit dimension scanning, `tabular*`/`tabularx` environments, and the math accent/operator/arrow vocabulary used by both documents. Both are covered by integration tests. + ## Capability matrix (current) | Area | Implemented | Remaining | diff --git a/crates/texrra-core/src/document_parser.rs b/crates/texrra-core/src/document_parser.rs index 093cfdf..3d5e049 100644 --- a/crates/texrra-core/src/document_parser.rs +++ b/crates/texrra-core/src/document_parser.rs @@ -2044,7 +2044,7 @@ impl Parser { self.flush_paragraph(); self.finish_list(); } - (true, "tabular") | (true, "tabular*") | (true, "longtable") => { + (true, "tabular") | (true, "tabular*") | (true, "tabularx") | (true, "longtable") => { self.flush_paragraph(); self.finish_list(); self.table = Some(TableBuilder { @@ -2056,7 +2056,10 @@ impl Parser { self.current_reference = self.table_number.to_string(); } } - (false, "tabular") | (false, "tabular*") | (false, "longtable") => self.finish_table(), + (false, "tabular") + | (false, "tabular*") + | (false, "tabularx") + | (false, "longtable") => self.finish_table(), (true, "figure") => { self.flush_paragraph(); self.float_placement = String::new(); diff --git a/docs/STATUS.md b/docs/STATUS.md index f9013c0..9a717c3 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -126,7 +126,7 @@ See `docs/ROADMAP.md` for concrete implementation plans. 0.29 MB and `pdffonts` reports only embedded CID TrueType faces); this avoids viewer-dependent glyph substitution. Tables use natural column widths and centered rules; preview and PDF share the same table line coordinates. -- `cargo fmt --check` passes; `cargo test --offline` (58 tests: 54 compiler +- `cargo fmt --check` passes; `cargo test --offline` (70 tests: 66 compiler integration tests + 4 server tests) covers the three examples, the arXiv fixture, figure/table floats (top and bottom), newpage, page styles and `\thispagestyle`, SVG/PDF output, project API, static frontend assets, path traversal, the legacy @@ -135,7 +135,7 @@ See `docs/ROADMAP.md` for concrete implementation plans. ## Verification snapshot -- Compiler integration tests: 53; server tests: 4; total 57. +- Compiler integration tests: 66; server tests: 4; total 70. - `cargo fmt --check` passes. - arXiv fixture: 3 Letter pages, ~0.29 MB; four serif faces and one monospace face embedded (bold/italic monospace falls back to the regular face). The bundled SubsetTTF faces are pyftsubset outputs with retained glyph ids and a filtered legacy kern table; a third 110-glyph ASCII/typographic tier is selected when the document charset fits. - Title/author/date/Introduction baselines within 0.3 pt of the XeLaTeX @@ -146,4 +146,5 @@ See `docs/ROADMAP.md` for concrete implementation plans. - PDF link annotations are added by reopening the finished PDF with lopdf, since printpdf 0.3.4 has no annotation API. -- Fonts: bundled reserved-glyph subsets in `assets/fonts-subset/` are used when the document charset is covered; arXiv PDF is about 0.29 MB with 58 tests. +- Fonts: bundled reserved-glyph subsets in `assets/fonts-subset/` are used when the document charset is covered; arXiv PDF is about 0.29 MB. +- New-template compatibility: the SIVP class file loads fully and `sn-article.tex` exports a 12-page PDF (live preview falls back on unsupported layout features); the Huawei E fragment compiles to 16 A4 pages. Generic support added for TeX `\if`/`\ifx`, `\newcount`, `\newdimen`, `\char`, `tabular*`/`tabularx`, math accents/operators/arrows, and a 64-bit dimension scanner. Both fixtures are regression tests (`sivp_project_exports_a_pdf`, `e_fixture_compiles`). diff --git a/src/rust_typeset/frontend.rs b/src/rust_typeset/frontend.rs index 755a872..ce5c038 100644 --- a/src/rust_typeset/frontend.rs +++ b/src/rust_typeset/frontend.rs @@ -339,7 +339,17 @@ const PRELUDE: &str = r#" \def\sum{∑} \def\prod{∏} \def\int{∫} +\def\bigcup{⋃} +\def\bigcap{⋂} +\def\bigoplus{⊕} +\def\bigotimes{⊗} +\def\bigodot{⊙} +\def\biguplus{⊎} +\def\bigsqcup{⨆} +\def\bigvee{⋁} +\def\bigwedge{⋀} \def\oint{∮} +\def\Pr{\texrraoperatorstart Pr\texrraoperatorend} \def\sin{\texrraoperatorstart sin\texrraoperatorend} \def\cos{\texrraoperatorstart cos\texrraoperatorend} \def\tan{\texrraoperatorstart tan\texrraoperatorend} @@ -349,6 +359,7 @@ const PRELUDE: &str = r#" \def\lim{\texrraoperatorstart lim\texrraoperatorend} \def\max{\texrraoperatorstart max\texrraoperatorend} \def\min{\texrraoperatorstart min\texrraoperatorend} +\def\*{*} \def\quad{\hskip1em\relax} \def\qquad{\hskip2em\relax} \def\,{\texrramathspace{3}} @@ -432,11 +443,11 @@ const PRELUDE: &str = r#" \def\bigbreak{\bigskip} \def\enspace{\hskip0.5em\relax} \def\thinspace{\hskip0.16667em\relax} -\def\negthinspace{\hskip-0.16667em\relax} +\def\negthinspace{\hskip0pt\relax} \def\medspace{\hskip0.22222em\relax} -\def\negmedspace{\hskip-0.22222em\relax} +\def\negmedspace{\hskip0pt\relax} \def\thickspace{\hskip0.27778em\relax} -\def\negthickspace{\hskip-0.27778em\relax} +\def\negthickspace{\hskip0pt\relax} \def\space{ } \def\nobreakspace{ } \def\ { } diff --git a/src/rust_typeset/texlang_adapter.rs b/src/rust_typeset/texlang_adapter.rs index 5666010..6776298 100644 --- a/src/rust_typeset/texlang_adapter.rs +++ b/src/rust_typeset/texlang_adapter.rs @@ -1534,7 +1534,7 @@ impl vm::Handlers for OutputHandlers { .current() .map(str::to_owned); let event = match environment.as_deref() { - Some("tabular") | Some("tabular*") | Some("longtable") => { + Some("tabular") | Some("tabular*") | Some("tabularx") | Some("longtable") => { FrontendEventKind::TableCell } Some(environment) if is_math_alignment_environment(environment) => { @@ -6307,8 +6307,11 @@ fn begin_environment_primitive( input.as_mut().expansions_mut().push(flush); } } - let argument = if name == "tabular*" { + let argument = if name == "tabular*" || name == "tabularx" { let _width = read_scanned_token_list(input)?; + if name == "tabularx" { + let _ = read_optional_bracketed_argument(input, token, "tabularx position")?; + } Some( read_scanned_token_list(input)? .into_iter() diff --git a/tests/typeset.rs b/tests/typeset.rs index 526507f..4b2c898 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -1837,3 +1837,20 @@ See \eqref{eq:x}. $\bar{x}+\vec{v}$. let value = fresh_preview(source, "eqref-accents.tex"); assert_eq!(value["status"], "ok"); } + +#[test] +fn sivp_project_exports_a_pdf() { + let source = std::fs::read_to_string("projects/_sivp__/sn-article.tex").unwrap(); + let pdf = CompilerSession::default() + .compile(&source, "projects/_sivp__/sn-article.tex") + .expect("SIVP PDF"); + assert!(pdf.starts_with(b"%PDF-")); + assert!(pdf.len() > 100_000, "SIVP PDF too small: {}", pdf.len()); +} + +#[test] +fn e_fixture_compiles() { + let source = std::fs::read_to_string("projects/e/问题一.tex").unwrap(); + let value = fresh_preview(&source, "projects/e/问题一.tex"); + assert_eq!(value["status"], "ok"); +}